fix(appointments): detail page back/breadcrumb return to the appointment day
AppointmentDetailPage now derives the appointment's local day from slot_start and points both the «بازگشت» button and the «نوبتها» breadcrumb to /admin/appointments?date=<that day>, so viewing/acting on an appointment from any day returns to that day instead of today. Test: the «نوبتها» breadcrumb links back to the appointment's date. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,13 @@ const ALL_STATUSES: { value: AppointmentStatus; label: string }[] = [
|
||||
{ value: 'expired', label: 'منقضی' },
|
||||
];
|
||||
|
||||
// روزِ محلیِ نوبت (YYYY-MM-DD) برای بازگشت به همان تاریخ در لیست.
|
||||
const isoDay = (ts?: number | null) => {
|
||||
if (!ts) return '';
|
||||
const d = new Date(ts * 1000);
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
||||
};
|
||||
|
||||
const timeOf = (ts?: number | null) => {
|
||||
const d = toDate(ts ?? null);
|
||||
return d
|
||||
@@ -73,6 +80,9 @@ export default function AppointmentDetailPage() {
|
||||
|
||||
// پاسخ single تودرتو است: { data: { data: {...} } }
|
||||
const appt: any = (data?.data as any)?.data ?? data?.data;
|
||||
// بازگشت به همان روزِ نوبت (نه امروز).
|
||||
const day = isoDay(appt?.slot_start);
|
||||
const backTo = day ? `/admin/appointments?date=${day}` : '/admin/appointments';
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -80,11 +90,11 @@ export default function AppointmentDetailPage() {
|
||||
title="جزئیات نوبت"
|
||||
breadcrumbs={[
|
||||
{ label: 'داشبورد', to: '/admin/dashboard' },
|
||||
{ label: 'نوبتها', to: '/admin/appointments' },
|
||||
{ label: 'نوبتها', to: backTo },
|
||||
{ label: 'جزئیات' },
|
||||
]}
|
||||
action={
|
||||
<button onClick={() => navigate('/admin/appointments')}
|
||||
<button onClick={() => navigate(backTo)}
|
||||
className="flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400 hover:text-slate-800 dark:hover:text-slate-100 transition-colors">
|
||||
<ArrowRightIcon className="w-4 h-4" />
|
||||
بازگشت
|
||||
|
||||
Reference in New Issue
Block a user