"use client";
import { Select } from "@/components/ds";
import { useBeautyLookups } from "@/modules/beauty/hooks/useBeautyLookups";
import { useQuery } from "@tanstack/react-query";
import { beautyBusinessApi } from "@/modules/beauty/services/beauty-business-api";
import { useTenantId } from "@/hooks/useTenantId";
type SelectProps = {
value: string;
onChange: (v: string) => void;
required?: boolean;
label?: string;
organizationId?: string;
};
function FieldShell({
label,
required,
children,
}: {
label?: string;
required?: boolean;
children: React.ReactNode;
}) {
return (
);
}
export function OrganizationSelect({ value, onChange, required, label = "سازمان" }: SelectProps) {
const { organizations } = useBeautyLookups();
return (
);
}
export function BranchSelect({ value, onChange, required, label = "شعبه", organizationId }: SelectProps) {
const { branches } = useBeautyLookups();
const filtered = organizationId
? branches.filter((b) => b.organization_id === organizationId)
: branches;
return (
);
}
export function StaffSelect({ value, onChange, required, label = "پرسنل" }: SelectProps) {
const { staff } = useBeautyLookups();
return (
);
}
export function CustomerSelect({ value, onChange, required, label = "مشتری" }: SelectProps) {
const { customers } = useBeautyLookups();
return (
);
}
export function ServiceSelect({ value, onChange, required, label = "خدمت" }: SelectProps) {
const { services } = useBeautyLookups();
return (
);
}
export function CategorySelect({ value, onChange, required, label = "دستهبندی" }: SelectProps) {
const { tenantId } = useTenantId();
const q = useQuery({
queryKey: ["beauty", tenantId, "lookups", "categories"],
queryFn: () => beautyBusinessApi.serviceCategories.list(tenantId!),
enabled: !!tenantId,
});
return (
);
}
export function RoomSelect({
value,
onChange,
required,
label = "اتاق",
organizationId,
}: SelectProps) {
const { tenantId } = useTenantId();
const q = useQuery({
queryKey: ["beauty", tenantId, "lookups", "rooms"],
queryFn: () => beautyBusinessApi.treatmentRooms.list(tenantId!),
enabled: !!tenantId,
});
const rooms = (q.data ?? []).filter(
(r) => !organizationId || r.organization_id === organizationId
);
return (
);
}