import { Checkbox, FormControl, FormField, FormItem, FormLabel, FormMessage, ScrollArea, } from "@marzneshin/components"; import { useServicesQuery, type ServiceType, } from "@marzneshin/features/services"; import { ServiceCard } from "@marzneshin/features/users"; import { cn } from "@marzneshin/utils"; import type { FC } from "react"; import { useFormContext, type FieldValues, type ControllerRenderProps, } from "react-hook-form"; import { useTranslation } from "react-i18next"; interface ServiceCheckboxCardProps { service: ServiceType; field: ControllerRenderProps; } const ServiceCheckboxCard: FC = ({ service, field, }) => { return (
{ return checked ? field.onChange([...field.value, service.id]) : field.onChange( field.value?.filter((value: number) => value !== service.id), ); }} />
); }; export const ServicesField: FC = () => { const form = useFormContext(); const { data } = useServicesQuery({ page: 1, size: 100 }); const { t } = useTranslation(); return ( ( {t("services")} {data.entity.map((service) => ( ( )} /> ))} )} /> ); };