feat(admin): move work schedule from profile to appointment settings

Export ScheduleSection from DoctorDetailPage and render the full
weekly/overrides/holidays editor in AppointmentSettingsPage. Gate the
profile's schedule render on !isOwnProfile so it no longer appears in the
doctor's own profile while the admin doctor-detail view keeps it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-07-17 10:53:51 +03:30
co-authored by Claude Fable 5
parent fcd7a0596d
commit 3e5d61e280
2 changed files with 7 additions and 21 deletions
+5 -19
View File
@@ -1,30 +1,18 @@
import { useQuery } from '@tanstack/react-query';
import { api } from '../lib/api';
import type { ApiResponse } from '../lib/api';
import { useAuthStore } from '../stores/authStore';
import SettingsLayout from '../components/layout/SettingsLayout';
import FreeVisitPrice from '../components/FreeVisitPrice';
import { WeeklyScheduleTab, type AddressData } from './DoctorDetailPage';
import { ScheduleSection } from './DoctorDetailPage';
/**
* مدیریت نوبت دهی — the doctor's weekly booking schedule as a standalone
* settings section. Reuses the WeeklyScheduleTab editor (also shown in the
* doctor profile) with the current doctor's uuid and addresses.
* مدیریت نوبت دهی — the doctor's appointment settings: visit price and the full
* weekly/overrides/holidays schedule (moved here from the doctor profile). The
* schedule is now managed exclusively from this page.
*/
export default function AppointmentSettingsPage() {
const doctorUuid = useAuthStore((s) => s.doctorUuid);
const dbUuid = useAuthStore((s) => s.dbUuid);
const uuid = doctorUuid ?? dbUuid ?? undefined;
const { data, isLoading } = useQuery({
queryKey: ['doctor-detail', uuid, 'appointment-settings'],
queryFn: () => api.get<ApiResponse<any>>(`/api/v1/doctor/${uuid}`),
enabled: !!uuid,
});
const doctor = (data?.data as any)?.data ?? data?.data;
const addresses: AddressData[] = doctor?.address ?? [];
return (
<SettingsLayout active="appointment">
<div
@@ -39,10 +27,8 @@ export default function AppointmentSettingsPage() {
<div className="card" style={{ padding: 32, textAlign: 'center', color: 'var(--text-3)', fontSize: 14 }}>
این بخش فقط برای پزشک در دسترس است.
</div>
) : isLoading ? (
<div style={{ padding: 16, color: 'var(--text-3)', fontSize: 13 }}>در حال بارگذاری...</div>
) : (
<WeeklyScheduleTab doctorUuid={uuid} addresses={addresses} />
<ScheduleSection doctorUuid={uuid} />
)}
</div>
</SettingsLayout>
+2 -2
View File
@@ -2055,7 +2055,7 @@ const SCHEDULE_TABS = [
{ id: 'holidays' as const, label: 'تعطیلات' },
];
function ScheduleSection({ doctorUuid, readOnly = false }: { doctorUuid: string; readOnly?: boolean }) {
export function ScheduleSection({ doctorUuid, readOnly = false }: { doctorUuid: string; readOnly?: boolean }) {
const [tab, setTab] = useState<'weekly' | 'overrides' | 'holidays'>('weekly');
const locationsQ = useQuery({
@@ -2896,7 +2896,7 @@ export default function DoctorDetailPage({ isOwnProfile = false }: { isOwnProfil
)}
</div>
{uuid && <ScheduleSection doctorUuid={uuid} readOnly={isReadOnly} />}
{uuid && !isOwnProfile && <ScheduleSection doctorUuid={uuid} readOnly={isReadOnly} />}
{isOwnProfile && <ClinicInvitationsSection />}