"use client"; import { useQuery } from "@tanstack/react-query"; import { PageHeader, EmptyState, Badge, DataTable } from "@/components/ds"; import { beautyBusinessApi } from "@/modules/beauty/services/beauty-business-api"; import { useTenantId } from "@/hooks/useTenantId"; import { useBeautyLookups } from "@/modules/beauty/hooks/useBeautyLookups"; import { AppointmentCard } from "@/modules/beauty/design-system"; import { AggregateStatsRow, BeautyPageError, BeautyPageLoader, SettingsListPage, } from "./shared"; export function StaffPortalDashboard() { const { tenantId } = useTenantId(); const { staff, isLoading } = useBeautyLookups(); const schedulesQ = useQuery({ queryKey: ["beauty", tenantId, "staff-schedules"], queryFn: () => beautyBusinessApi.staffSchedules.list(tenantId!), enabled: !!tenantId, }); const apptsQ = useQuery({ queryKey: ["beauty", tenantId, "staff-appts"], queryFn: () => beautyBusinessApi.appointments.list(tenantId!), enabled: !!tenantId, }); if (!tenantId || isLoading || schedulesQ.isLoading) return ; return (
); } export function StaffPortalSchedule() { const { tenantId } = useTenantId(); const { staffName } = useBeautyLookups(); const q = useQuery({ queryKey: ["beauty", tenantId, "staff-portal-schedule"], queryFn: () => beautyBusinessApi.staffSchedules.list(tenantId!), enabled: !!tenantId, }); if (!tenantId || q.isLoading) return ; if (q.error) return q.refetch()} />; return (
staffName(String(r.staff_ref)), }, { key: "day_of_week", header: "روز" }, { key: "start_time", header: "شروع" }, { key: "end_time", header: "پایان" }, ]} rows={(q.data ?? []) as unknown as Record[]} empty={} />
); } export function StaffPortalCommission() { const { tenantId } = useTenantId(); const q = useQuery({ queryKey: ["beauty", tenantId, "staff-commission"], queryFn: () => beautyBusinessApi.commissionRules.list(tenantId!), enabled: !!tenantId, }); if (!tenantId || q.isLoading) return ; if (q.error) return q.refetch()} />; return (
(r.rate_percent != null ? `${r.rate_percent}%` : "—"), }, { key: "status", header: "وضعیت", render: (r) => {String(r.status)}, }, ]} rows={(q.data ?? []) as unknown as Record[]} empty={} />
); } export function StaffPortalAppointments() { const { tenantId } = useTenantId(); const { staffName, serviceName } = useBeautyLookups(); const q = useQuery({ queryKey: ["beauty", tenantId, "staff-portal-appts"], queryFn: () => beautyBusinessApi.appointments.list(tenantId!), enabled: !!tenantId, }); if (!tenantId || q.isLoading) return ; if (q.error) return q.refetch()} />; return (
{(q.data ?? []).map((a) => ( ))}
{(q.data ?? []).length === 0 ? : null}
); } export function StaffPortalNotifications() { return (
); } export function StaffPortalSettings() { return ; }