"use client"; import Link from "next/link"; import { useQuery } from "@tanstack/react-query"; import { PageHeader, Badge, EmptyState, 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, AnalyticsPage, BeautyPageError, BeautyPageLoader, ExternalProvidersByKind, ServiceMetaBadges, } from "./shared"; export function OwnerDashboard() { const { tenantId } = useTenantId(); const { organizations, branches, customers, staff, services, isLoading } = useBeautyLookups(); const apptsQ = useQuery({ queryKey: ["beauty", tenantId, "owner-appts"], queryFn: () => beautyBusinessApi.appointments.list(tenantId!), enabled: !!tenantId, }); if (!tenantId || isLoading || apptsQ.isLoading) return ; if (apptsQ.error) return apptsQ.refetch()} />; return (
} />

آخرین نوبت‌ها

{(apptsQ.data ?? []).slice(0, 5).map((a) => ( ))} {(apptsQ.data ?? []).length === 0 ? : null}
); } export function OwnerAnalytics() { return ; } export function OwnerCalendar() { const { tenantId } = useTenantId(); const { staffName, serviceName } = useBeautyLookups(); const apptsQ = useQuery({ queryKey: ["beauty", tenantId, "owner-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 OwnerCrmIntegration() { return ( ); } export function OwnerAccountingIntegration() { return ( ); } export function OwnerMarketing() { const { tenantId } = useTenantId(); const q = useQuery({ queryKey: ["beauty", tenantId, "owner-marketing"], queryFn: () => beautyBusinessApi.marketingCampaigns.list(tenantId!), enabled: !!tenantId, }); if (!tenantId || q.isLoading) return ; if (q.error) return q.refetch()} />; return (
مدیریت کمپین } /> String(r.channel ?? "—") }, { key: "status", header: "وضعیت", render: (r) => {String(r.status)}, }, ]} rows={(q.data ?? []) as unknown as Record[]} empty={} />
); } export function OwnerCoupons() { const { tenantId } = useTenantId(); const q = useQuery({ queryKey: ["beauty", tenantId, "owner-coupons"], queryFn: () => beautyBusinessApi.marketingCampaigns.list(tenantId!), enabled: !!tenantId, }); if (!tenantId || q.isLoading) return ; if (q.error) return q.refetch()} />; return (
String(r.external_campaign_ref ?? "—") }, ]} rows={(q.data ?? []) as unknown as Record[]} empty={} />
); }