2026-09-01 16:05:29 +03:30
|
|
|
|
<script setup lang="ts">
|
2026-09-02 16:06:17 +03:30
|
|
|
|
import { computed } from 'vue';
|
2026-09-01 16:05:29 +03:30
|
|
|
|
import { RouterLink } from 'vue-router';
|
|
|
|
|
|
import UiIcon from '@/components/UiIcon.vue';
|
2026-09-21 17:55:05 +03:30
|
|
|
|
import HomePanelEmpty from '@/components/dashboard/HomePanelEmpty.vue';
|
2026-09-01 16:05:29 +03:30
|
|
|
|
import type { ActivityDto } from '@mento/shared';
|
|
|
|
|
|
|
2026-09-02 16:06:17 +03:30
|
|
|
|
const props = defineProps<{
|
2026-09-01 16:05:29 +03:30
|
|
|
|
activities: ActivityDto[];
|
|
|
|
|
|
formatWhen: (value: string | null) => string;
|
|
|
|
|
|
}>();
|
|
|
|
|
|
|
2026-09-02 16:06:17 +03:30
|
|
|
|
type Row = {
|
|
|
|
|
|
id: string;
|
|
|
|
|
|
title: string;
|
|
|
|
|
|
when: string;
|
|
|
|
|
|
type: string;
|
|
|
|
|
|
tone: 'done' | 'pending' | 'held' | 'late';
|
|
|
|
|
|
label: string;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-09-01 16:05:29 +03:30
|
|
|
|
const typeLabel: Record<string, string> = {
|
|
|
|
|
|
call: 'تماس',
|
|
|
|
|
|
meeting: 'جلسه',
|
|
|
|
|
|
task: 'وظیفه',
|
|
|
|
|
|
note: 'یادداشت',
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function activityStatus(act: ActivityDto) {
|
2026-09-02 16:06:17 +03:30
|
|
|
|
if (act.status === 'done') return { label: 'انجام شد', tone: 'done' as const };
|
2026-09-01 16:05:29 +03:30
|
|
|
|
if (act.dueAt && new Date(act.dueAt) < new Date()) {
|
2026-09-02 16:06:17 +03:30
|
|
|
|
return { label: 'عقبافتاده', tone: 'late' as const };
|
2026-09-01 16:05:29 +03:30
|
|
|
|
}
|
2026-09-02 16:06:17 +03:30
|
|
|
|
return { label: 'در انتظار پاسخ', tone: 'pending' as const };
|
2026-09-01 16:05:29 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function activityIcon(type: string) {
|
|
|
|
|
|
if (type === 'call') return 'phone' as const;
|
|
|
|
|
|
if (type === 'meeting') return 'calendar' as const;
|
|
|
|
|
|
if (type === 'task') return 'check' as const;
|
|
|
|
|
|
return 'mail' as const;
|
|
|
|
|
|
}
|
2026-09-02 16:06:17 +03:30
|
|
|
|
|
2026-09-21 17:55:05 +03:30
|
|
|
|
const rows = computed<Row[]>(() =>
|
|
|
|
|
|
props.activities.slice(0, 3).map((act) => {
|
2026-09-02 16:06:17 +03:30
|
|
|
|
const st = activityStatus(act);
|
|
|
|
|
|
return {
|
|
|
|
|
|
id: act.id,
|
|
|
|
|
|
title: act.title,
|
|
|
|
|
|
when: `${typeLabel[act.type] ?? act.type} · ${props.formatWhen(act.dueAt || act.createdAt)}`,
|
|
|
|
|
|
type: act.type,
|
|
|
|
|
|
tone: st.tone,
|
|
|
|
|
|
label: st.label,
|
|
|
|
|
|
};
|
2026-09-21 17:55:05 +03:30
|
|
|
|
}),
|
|
|
|
|
|
);
|
2026-09-01 16:05:29 +03:30
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<article class="panel">
|
|
|
|
|
|
<header class="panel-head">
|
|
|
|
|
|
<h2>فعالیتهای اخیر</h2>
|
|
|
|
|
|
<RouterLink :to="{ name: 'activities' }">مشاهده همه</RouterLink>
|
|
|
|
|
|
</header>
|
|
|
|
|
|
|
2026-09-21 17:55:05 +03:30
|
|
|
|
<HomePanelEmpty
|
|
|
|
|
|
v-if="!rows.length"
|
|
|
|
|
|
title="فعالیتی در این فهرست نیست"
|
|
|
|
|
|
description="فیلتر را عوض کنید، یا یک فعالیت جدید بسازید."
|
|
|
|
|
|
action-label="فعالیت جدید"
|
|
|
|
|
|
:action-to="{ name: 'activity-new' }"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<ul v-else class="activity-list">
|
2026-09-02 16:06:17 +03:30
|
|
|
|
<li v-for="act in rows" :key="act.id">
|
2026-09-01 16:05:29 +03:30
|
|
|
|
<span class="act-icon">
|
|
|
|
|
|
<UiIcon :name="activityIcon(act.type)" :size="16" />
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<div class="act-body">
|
|
|
|
|
|
<strong>{{ act.title }}</strong>
|
2026-09-02 16:06:17 +03:30
|
|
|
|
<span>{{ act.when }}</span>
|
2026-09-01 16:05:29 +03:30
|
|
|
|
</div>
|
2026-09-02 16:06:17 +03:30
|
|
|
|
<span class="status-pill" :class="act.tone">{{ act.label }}</span>
|
2026-09-01 16:05:29 +03:30
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</article>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.panel {
|
|
|
|
|
|
background: #fff;
|
2026-09-12 01:33:07 +03:30
|
|
|
|
border-radius: var(--radius);
|
2026-09-02 16:06:17 +03:30
|
|
|
|
padding: 1rem 1.05rem;
|
2026-09-01 16:05:29 +03:30
|
|
|
|
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
|
|
|
|
|
|
border: 1px solid #eef2f7;
|
|
|
|
|
|
min-width: 0;
|
2026-09-21 17:55:05 +03:30
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2026-09-01 16:05:29 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.panel-head {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
gap: 0.75rem;
|
|
|
|
|
|
margin-bottom: 0.85rem;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
h2 {
|
|
|
|
|
|
margin: 0;
|
2026-09-02 16:06:17 +03:30
|
|
|
|
font-size: 0.95rem;
|
2026-09-01 16:05:29 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
a {
|
|
|
|
|
|
color: #14b8a6;
|
2026-09-02 16:06:17 +03:30
|
|
|
|
font-size: 0.8rem;
|
2026-09-01 16:05:29 +03:30
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.activity-list {
|
|
|
|
|
|
list-style: none;
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
display: grid;
|
2026-09-02 16:06:17 +03:30
|
|
|
|
gap: 0.7rem;
|
2026-09-01 16:05:29 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.activity-list li {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2026-09-02 16:06:17 +03:30
|
|
|
|
gap: 0.65rem;
|
2026-09-01 16:05:29 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.act-icon {
|
2026-09-02 16:06:17 +03:30
|
|
|
|
width: 38px;
|
|
|
|
|
|
height: 38px;
|
2026-09-12 01:33:07 +03:30
|
|
|
|
border-radius: var(--radius);
|
2026-09-01 16:05:29 +03:30
|
|
|
|
background: #ecfdf8;
|
|
|
|
|
|
color: #14b8a6;
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
place-items: center;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.act-body {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
display: grid;
|
2026-09-02 16:06:17 +03:30
|
|
|
|
gap: 0.12rem;
|
2026-09-01 16:05:29 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.act-body strong {
|
2026-09-02 16:06:17 +03:30
|
|
|
|
font-size: 0.84rem;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
2026-09-01 16:05:29 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.act-body span {
|
|
|
|
|
|
color: #94a3b8;
|
2026-09-02 16:06:17 +03:30
|
|
|
|
font-size: 0.72rem;
|
2026-09-01 16:05:29 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.status-pill {
|
2026-09-02 16:06:17 +03:30
|
|
|
|
font-size: 0.68rem;
|
2026-09-01 16:05:29 +03:30
|
|
|
|
font-weight: 700;
|
2026-09-02 16:06:17 +03:30
|
|
|
|
padding: 0.22rem 0.5rem;
|
2026-09-01 16:05:29 +03:30
|
|
|
|
border-radius: 999px;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-02 16:06:17 +03:30
|
|
|
|
.status-pill.done,
|
|
|
|
|
|
.status-pill.held {
|
2026-09-01 16:05:29 +03:30
|
|
|
|
background: #dcfce7;
|
|
|
|
|
|
color: #166534;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.status-pill.pending {
|
|
|
|
|
|
background: #dbeafe;
|
|
|
|
|
|
color: #1d4ed8;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.status-pill.late {
|
|
|
|
|
|
background: #fee2e2;
|
|
|
|
|
|
color: #b91c1c;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|