feat(panel): connect turns/user-account/add-doctor to real data

- انتقال adapterهای نماینده به lib/representationAdapters (server-safe،
  بدون وابستگی client مثل js-cookie/react-toastify)
- turns: لیست از daily[] داشبورد ماهانه (ستون نام/تخصص خالی، بدون داده ساختگی)
- user-account: حساب بانکی واقعی از bank_account نماینده (map به آرایه تک‌کارته)
- add-doctor: حذف import mock مرده (کامپوننت data مصرف نمی‌کرد)
- رفع dead import اشتباه از turns/page در clinic/doctors که build را می‌شکست

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-15 00:06:01 +03:30
co-authored by Claude Opus 4.8
parent 1599098b6d
commit 5067824f28
8 changed files with 137 additions and 48 deletions
+66
View File
@@ -0,0 +1,66 @@
import moment from "moment-jalaali";
const DEFAULT_AVATAR = "/assets/images/doctor.png";
function toJalali(date) {
if (!date) return "--";
return moment(date).format("jYYYY/jM/jD");
}
export function adaptRepresentationInfo(representationInfo) {
const data = representationInfo?.data ?? representationInfo ?? {};
return {
name: data.full_name ?? "",
src: data.avatar ?? DEFAULT_AVATAR,
detail: data.city_name ? `نماینده شهر ${data.city_name}` : "نماینده",
mobile_number: data.mobile_number ?? "",
commission_percent: data.commission_percent ?? null,
bank_account: data.bank_account ?? null,
city: { label: data.city_name ?? "" },
all_patients: null,
total_turns: null,
number_of_patients: null,
today_turns: null,
payments: null,
todays_activities: [],
list_of_doctors_appointments: [],
chart_amount_income: [],
};
}
export function adaptRepresentationDashboard(dashboard) {
const stats = dashboard?.data?.stats ?? dashboard?.stats ?? {};
const daily = Array.isArray(stats.daily) ? stats.daily : [];
return {
number_of_patients: stats.total_appointments ?? 0,
today_turns: daily.length ? daily[daily.length - 1].appointments ?? 0 : 0,
payments: stats.total_revenue_rials ?? 0,
commission_rials: stats.commission_rials ?? 0,
chart_amount_income: daily.map((d) => d.revenue ?? 0),
list_of_doctors_appointments: daily.map((d) => ({
name: "",
expertise: "",
image: DEFAULT_AVATAR,
date: toJalali(d.date),
hour: "",
number_of_turns: d.appointments ?? 0,
})),
todays_activities: [],
};
}
export function adaptBankAccount(bankAccount) {
if (!bankAccount) return [];
return [
{
id: 1,
card_number: bankAccount.account_number ?? "",
shaba_number: bankAccount.iban ?? "",
bank: bankAccount.bank_name ?? "",
owner_name: bankAccount.owner_name ?? "",
status: true,
},
];
}