"use client"; import React from 'react'; import { useForm, Controller } from 'react-hook-form'; import { z } from 'zod'; import { zodResolver } from '@hookform/resolvers/zod'; const items = [ { id: 'recents', label: 'Recents' }, { id: 'home', label: 'Home' }, { id: 'applications', label: 'Applications' }, { id: 'desktop', label: 'Desktop' }, { id: 'downloads', label: 'Downloads' }, { id: 'documents', label: 'Documents' }, ]; const displayFormSchema = z.object({ items: z.array(z.string()).refine((value) => value.some((item) => item), { message: "You have to select at least one item.", }), }); type DisplayFormValues = z.infer; const defaultValues: Partial = { items: ['recents', 'home'], }; export function DisplayForm() { const { control, handleSubmit } = useForm({ resolver: zodResolver(displayFormSchema), defaultValues, }); const onSubmit = (data: DisplayFormValues) => { console.log(JSON.stringify(data, null, 2)); }; return (

Sidebar

Select the items you want to display in the sidebar.

{items.map((item) => ( (
{ const updatedValue = e.target.checked ? [...field.value, item.id] : field.value?.filter((value) => value !== item.id); field.onChange(updatedValue); }} className="h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" />
)} /> ))}
); }