From b592f520aba10e72e5461d711bac9c0b3c7b608e Mon Sep 17 00:00:00 2001 From: sajjadtalkhabi <97734061+sajjadtalkhabi@users.noreply.github.com> Date: Sun, 12 Jul 2026 12:03:26 +0330 Subject: [PATCH] fix: dashboard --- .../dashboard/DashboardActivityCard.vue | 143 ++++++++++ .../dashboard/DashboardActivityGroup.vue | 65 +++++ .../dashboard/DashboardCalendar.vue | 99 +++++++ .../dashboard/DashboardProfileCard.vue | 134 +++++++++ .../dashboard/DashboardStatCard.vue | 108 +++++++ src/composables/useTehranCalendar.js | 50 ++++ src/enums/index.js | 4 +- .../admin/pages/AdminDashboardPage.vue | 269 +++++++++++++++--- .../pages/CounselorDashboardPage.vue | 212 ++++++++++++++ src/features/counselor/router.js | 11 + .../pages/MissionaryDashboardPage.vue | 231 +++++++++++++++ src/features/missionary/router.js | 11 + .../student/pages/StudentDashboardPage.vue | 206 +++++++++----- src/layouts/CounselorLayout.vue | 6 + src/layouts/MissionaryLayout.vue | 6 + src/services/api/admin-dashboard.js | 4 + src/services/api/counselor-dashboard.js | 4 + src/services/api/endpoints.js | 7 + src/services/api/missionary-dashboard.js | 4 + src/services/api/student-dashboard.js | 4 + src/services/mock/fixtures/admin-dashboard.js | 45 +++ .../mock/fixtures/counselor-dashboard.js | 28 ++ .../mock/fixtures/missionary-dashboard.js | 37 +++ .../mock/fixtures/student-dashboard.js | 39 +++ src/services/mock/routes/admin-dashboard.js | 5 + .../mock/routes/counselor-dashboard.js | 5 + .../mock/routes/missionary-dashboard.js | 5 + src/services/mock/routes/student-dashboard.js | 5 + src/services/query/admin-dashboard.js | 13 + src/services/query/counselor-dashboard.js | 13 + src/services/query/missionary-dashboard.js | 13 + src/services/query/student-dashboard.js | 13 + src/utils/persian.js | 17 ++ 33 files changed, 1714 insertions(+), 102 deletions(-) create mode 100644 src/components/dashboard/DashboardActivityCard.vue create mode 100644 src/components/dashboard/DashboardActivityGroup.vue create mode 100644 src/components/dashboard/DashboardCalendar.vue create mode 100644 src/components/dashboard/DashboardProfileCard.vue create mode 100644 src/components/dashboard/DashboardStatCard.vue create mode 100644 src/composables/useTehranCalendar.js create mode 100644 src/features/counselor/pages/CounselorDashboardPage.vue create mode 100644 src/features/missionary/pages/MissionaryDashboardPage.vue create mode 100644 src/services/api/admin-dashboard.js create mode 100644 src/services/api/counselor-dashboard.js create mode 100644 src/services/api/missionary-dashboard.js create mode 100644 src/services/api/student-dashboard.js create mode 100644 src/services/mock/fixtures/admin-dashboard.js create mode 100644 src/services/mock/fixtures/counselor-dashboard.js create mode 100644 src/services/mock/fixtures/missionary-dashboard.js create mode 100644 src/services/mock/fixtures/student-dashboard.js create mode 100644 src/services/mock/routes/admin-dashboard.js create mode 100644 src/services/mock/routes/counselor-dashboard.js create mode 100644 src/services/mock/routes/missionary-dashboard.js create mode 100644 src/services/mock/routes/student-dashboard.js create mode 100644 src/services/query/admin-dashboard.js create mode 100644 src/services/query/counselor-dashboard.js create mode 100644 src/services/query/missionary-dashboard.js create mode 100644 src/services/query/student-dashboard.js create mode 100644 src/utils/persian.js diff --git a/src/components/dashboard/DashboardActivityCard.vue b/src/components/dashboard/DashboardActivityCard.vue new file mode 100644 index 0000000..246d715 --- /dev/null +++ b/src/components/dashboard/DashboardActivityCard.vue @@ -0,0 +1,143 @@ + + + + + diff --git a/src/components/dashboard/DashboardActivityGroup.vue b/src/components/dashboard/DashboardActivityGroup.vue new file mode 100644 index 0000000..5fc032d --- /dev/null +++ b/src/components/dashboard/DashboardActivityGroup.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/components/dashboard/DashboardCalendar.vue b/src/components/dashboard/DashboardCalendar.vue new file mode 100644 index 0000000..0a1de64 --- /dev/null +++ b/src/components/dashboard/DashboardCalendar.vue @@ -0,0 +1,99 @@ + + + + + diff --git a/src/components/dashboard/DashboardProfileCard.vue b/src/components/dashboard/DashboardProfileCard.vue new file mode 100644 index 0000000..5c015ea --- /dev/null +++ b/src/components/dashboard/DashboardProfileCard.vue @@ -0,0 +1,134 @@ + + + + + diff --git a/src/components/dashboard/DashboardStatCard.vue b/src/components/dashboard/DashboardStatCard.vue new file mode 100644 index 0000000..02ce94b --- /dev/null +++ b/src/components/dashboard/DashboardStatCard.vue @@ -0,0 +1,108 @@ + + + + + diff --git a/src/composables/useTehranCalendar.js b/src/composables/useTehranCalendar.js new file mode 100644 index 0000000..75fbe7c --- /dev/null +++ b/src/composables/useTehranCalendar.js @@ -0,0 +1,50 @@ +import { toFaDigits } from '@/utils/persian' +import { toJalaali } from '@/utils/date-utils' + +const WEEKDAY_NAMES = ['شنبه', 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه'] +const MONTH_NAMES = [ + 'فروردین', + 'اردیبهشت', + 'خرداد', + 'تیر', + 'مرداد', + 'شهریور', + 'مهر', + 'آبان', + 'آذر', + 'دی', + 'بهمن', + 'اسفند', +] +const GREGORIAN_WEEKDAYS = ['Sat', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri'] +const DAY_MS = 24 * 60 * 60 * 1000 + +/** + * Builds the current Jalaali week (Saturday → Friday) anchored to the Asia/Tehran + * timezone, independent of the viewer's local clock. The day matching Tehran's + * "today" is flagged `selected`. Returns `{ month, days }` for DashboardCalendar. + */ +export const useTehranCalendar = () => { + const parts = new Intl.DateTimeFormat('en-US', { + timeZone: 'Asia/Tehran', + year: 'numeric', + month: 'numeric', + day: 'numeric', + weekday: 'short', + }).formatToParts(new Date()) + const part = (type) => parts.find((p) => p.type === type)?.value + const todayIndex = GREGORIAN_WEEKDAYS.indexOf(part('weekday')) + const todayUtc = Date.UTC(Number(part('year')), Number(part('month')) - 1, Number(part('day'))) + const weekStartUtc = todayUtc - todayIndex * DAY_MS + + const today = new Date(todayUtc) + const { jm } = toJalaali(today.getUTCFullYear(), today.getUTCMonth() + 1, today.getUTCDate()) + + const days = WEEKDAY_NAMES.map((weekday, i) => { + const date = new Date(weekStartUtc + i * DAY_MS) + const { jd } = toJalaali(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()) + return { weekday, day: toFaDigits(jd), selected: i === todayIndex } + }) + + return { month: `${MONTH_NAMES[jm - 1]} ماه`, days } +} diff --git a/src/enums/index.js b/src/enums/index.js index 3453321..a6b33b9 100644 --- a/src/enums/index.js +++ b/src/enums/index.js @@ -220,6 +220,6 @@ export const MISSIONARY_REQUEST_STATUS = Object.freeze({ // page. Roles not listed here fall back to the student dashboard. export const ROLE_HOME_ROUTES = Object.freeze({ admin: 'admin-dashboard', - counselor: 'counselor-consultations', - missionary: 'missionary-requests', + counselor: 'counselor-dashboard', + missionary: 'missionary-dashboard', }) diff --git a/src/features/admin/pages/AdminDashboardPage.vue b/src/features/admin/pages/AdminDashboardPage.vue index 7506380..d27d0ee 100644 --- a/src/features/admin/pages/AdminDashboardPage.vue +++ b/src/features/admin/pages/AdminDashboardPage.vue @@ -1,53 +1,256 @@ - + diff --git a/src/features/counselor/pages/CounselorDashboardPage.vue b/src/features/counselor/pages/CounselorDashboardPage.vue new file mode 100644 index 0000000..72ed559 --- /dev/null +++ b/src/features/counselor/pages/CounselorDashboardPage.vue @@ -0,0 +1,212 @@ + + + + + diff --git a/src/features/counselor/router.js b/src/features/counselor/router.js index c00f272..66bf8f2 100644 --- a/src/features/counselor/router.js +++ b/src/features/counselor/router.js @@ -1,4 +1,15 @@ export default [ + { + path: '/counselor/dashboard', + name: 'counselor-dashboard', + component: () => import('@/features/counselor/pages/CounselorDashboardPage.vue'), + meta: { + layout: 'counselor', + role: 'counselor', + title: 'سلام بر شما', + subtitle: 'به پنل مشاوره بانو خوش آمدید.', + }, + }, { path: '/counselor/consultations', name: 'counselor-consultations', diff --git a/src/features/missionary/pages/MissionaryDashboardPage.vue b/src/features/missionary/pages/MissionaryDashboardPage.vue new file mode 100644 index 0000000..c2d1613 --- /dev/null +++ b/src/features/missionary/pages/MissionaryDashboardPage.vue @@ -0,0 +1,231 @@ + + + + + diff --git a/src/features/missionary/router.js b/src/features/missionary/router.js index c9a7ed5..4a1b7dc 100644 --- a/src/features/missionary/router.js +++ b/src/features/missionary/router.js @@ -1,4 +1,15 @@ export default [ + { + path: '/missionary-panel/dashboard', + name: 'missionary-dashboard', + component: () => import('@/features/missionary/pages/MissionaryDashboardPage.vue'), + meta: { + layout: 'missionary', + role: 'missionary', + title: 'سلام بر شما', + subtitle: 'به پنل اعزام بانو خوش آمدید.', + }, + }, { path: '/missionary-panel/requests', name: 'missionary-requests', diff --git a/src/features/student/pages/StudentDashboardPage.vue b/src/features/student/pages/StudentDashboardPage.vue index 9801ed7..71a1d14 100644 --- a/src/features/student/pages/StudentDashboardPage.vue +++ b/src/features/student/pages/StudentDashboardPage.vue @@ -9,7 +9,8 @@ -
+ +
-
+ +
@@ -46,9 +48,12 @@