"use client";
import Link from "next/link";
import { useEffect, Suspense } from "react";
import { useRouter, useParams, useSearchParams } from "next/navigation";
import { AuthGuard } from "@/components/AuthGuard";
import { LoadingState, PageHeader, Card, CardContent, Button } from "@/components/ds";
import { BEAUTY_PORTALS, type BeautyPortalId } from "@/modules/beauty/constants/portals";
import { cn } from "@/lib/utils";
import { ChevronLeft } from "lucide-react";
import { useQuery } from "@tanstack/react-query";
import { beautyBusinessApi } from "@/modules/beauty/services/beauty-business-api";
import { useTenantId } from "@/hooks/useTenantId";
import { AggregateStatsRow, BeautyPageLoader } from "./shared";
export function BeautyHub() {
return (
);
}
function BeautyHubInner() {
const { tenantId } = useTenantId();
const healthQ = useQuery({
queryKey: ["beauty", "health"],
queryFn: () => beautyBusinessApi.health(),
});
return (
v{healthQ.data.version}
) : null
}
/>
{BEAUTY_PORTALS.map((portal) => {
const Icon = portal.icon;
return (
{portal.label}
{portal.description}
ورود ←
);
})}
{!tenantId ? (
tenant فعال لازم است.
) : null}
);
}
function AuthLoginRedirectInner() {
const sp = useSearchParams();
const router = useRouter();
const returnUrl = sp.get("returnUrl") ?? "/beauty/hub";
useEffect(() => {
router.replace(`/login?returnUrl=${encodeURIComponent(returnUrl)}`);
}, [router, returnUrl]);
return ;
}
export function BeautyAuthLogin() {
return (
}>
);
}
export function BeautyAuthRegister() {
return ;
}
export function BeautyAuthOtp() {
return ;
}
export function BeautyAuthForgotPassword() {
return ;
}
export function BeautyAuth2fa() {
return ;
}
export function BeautyAuthProfileCompletion() {
return ;
}
const PORTAL_IDS: BeautyPortalId[] = ["customer", "owner", "reception", "staff", "admin"];
export function BeautyMobilePortal() {
const params = useParams();
const portal = String(params.portal) as BeautyPortalId;
const meta = BEAUTY_PORTALS.find((p) => p.id === portal);
const { tenantId } = useTenantId();
const statsQ = useQuery({
queryKey: ["beauty", tenantId, "mobile-stats", portal],
queryFn: async () => {
const [orgs, branches, customers, appts] = await Promise.all([
beautyBusinessApi.organizations.list(tenantId!),
beautyBusinessApi.branches.list(tenantId!),
beautyBusinessApi.customers.list(tenantId!),
beautyBusinessApi.appointments.list(tenantId!),
]);
return {
organizations: orgs.length,
branches: branches.length,
customers: customers.length,
appointments: appts.length,
};
},
enabled: !!tenantId && !!meta,
});
if (!meta || !PORTAL_IDS.includes(portal)) {
return (
);
}
const Icon = meta.icon;
return (
{meta.label}
{meta.description}
{!tenantId || statsQ.isLoading ? (
) : (
)}
ورود به داشبورد کامل
);
}