"use client"; import Link from "next/link"; import { useQuery } from "@tanstack/react-query"; import { PageHeader, EmptyState, Badge, Button } 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, QueueRow } from "@/modules/beauty/design-system"; import { AggregateStatsRow, AnalyticsPage, BeautyPageError, BeautyPageLoader, } from "./shared"; export function ReceptionDashboard() { const { tenantId } = useTenantId(); const apptsQ = useQuery({ queryKey: ["beauty", tenantId, "reception-appts"], queryFn: () => beautyBusinessApi.appointments.list(tenantId!), enabled: !!tenantId, }); const waitQ = useQuery({ queryKey: ["beauty", tenantId, "reception-waiting"], queryFn: () => beautyBusinessApi.waitingList.list(tenantId!), enabled: !!tenantId, }); if (!tenantId || apptsQ.isLoading) return ; if (apptsQ.error) return apptsQ.refetch()} />; return ( a.status === "checked_in").length, }, ]} /> ); } export function ReceptionCalendar() { const { tenantId } = useTenantId(); const { staffName, serviceName } = useBeautyLookups(); const apptsQ = useQuery({ queryKey: ["beauty", tenantId, "reception-calendar"], queryFn: () => beautyBusinessApi.appointments.list(tenantId!), enabled: !!tenantId, }); if (!tenantId || apptsQ.isLoading) return ; if (apptsQ.error) return apptsQ.refetch()} />; return ( {(apptsQ.data ?? []).map((a) => ( ))} {(apptsQ.data ?? []).length === 0 ? : null} ); } export function ReceptionWalkIn() { const { tenantId } = useTenantId(); const { customers, services } = useBeautyLookups(); return ( مشتریان: {customers.length} · خدمات: {services.length} لیست انتظار ); } export function ReceptionCheckIn() { const { tenantId } = useTenantId(); const { staffName } = useBeautyLookups(); const apptsQ = useQuery({ queryKey: ["beauty", tenantId, "reception-checkin"], queryFn: () => beautyBusinessApi.appointments.list(tenantId!), enabled: !!tenantId, select: (rows) => rows.filter((a) => a.status === "confirmed" || a.status === "requested"), }); if (!tenantId || apptsQ.isLoading) return ; if (apptsQ.error) return apptsQ.refetch()} />; return ( {(apptsQ.data ?? []).map((a) => ( ))} {(apptsQ.data ?? []).length === 0 ? : null} ); } export function ReceptionCheckOut() { const { tenantId } = useTenantId(); const apptsQ = useQuery({ queryKey: ["beauty", tenantId, "reception-checkout"], queryFn: () => beautyBusinessApi.appointments.list(tenantId!), enabled: !!tenantId, select: (rows) => rows.filter((a) => a.status === "in_progress" || a.status === "checked_in"), }); if (!tenantId || apptsQ.isLoading) return ; if (apptsQ.error) return apptsQ.refetch()} />; return ( {(apptsQ.data ?? []).map((a) => ( ))} {(apptsQ.data ?? []).length === 0 ? : null} ); } export function ReceptionQueue() { const { tenantId } = useTenantId(); const { customerName, serviceName } = useBeautyLookups(); const waitQ = useQuery({ queryKey: ["beauty", tenantId, "reception-queue"], queryFn: () => beautyBusinessApi.waitingList.list(tenantId!), enabled: !!tenantId, }); if (!tenantId || waitQ.isLoading) return ; if (waitQ.error) return waitQ.refetch()} />; return ( {(waitQ.data ?? []).map((w, i) => ( ))} {(waitQ.data ?? []).length === 0 ? : null} ); } export function ReceptionPayments() { return ( رفتن به حسابداری } /> ); } export function ReceptionReports() { return ; }
مشتریان: {customers.length} · خدمات: {services.length}