import { useWrStore } from "@/app/store"; import { pbnSttHeadList } from "@/app/store/ruseFcltMng/fcltSttn/pbnstSttn"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@common/business_components/ui"; import { Button, Checkbox } from "@common/components/ui"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import { z } from "zod"; export default function HeadChModal() { const { pbnStt } = useWrStore((state) => state); const items = pbnSttHeadList.map(item => ({id:item.id, label:item.title})); const FormSchema = z.object({ items: z.array(z.string()).refine((value) => value.some((item) => item), { message: "You have to select at least one item.", }), }) const form = useForm>({ resolver: zodResolver(FormSchema), }) const onSubmit = (val : z.infer) =>{ console.log(val) } return ( <>
(
Sidebar Select the items you want to display in the sidebar.
{items.map((item) => ( { return ( { return checked ? field.onChange([...field.value, item.id]) : field.onChange( field.value?.filter( (value) => value !== item.id ) ); }} /> {item.label} ); }} /> ))}
)} />
); }