gitscope
← marzneshin / v0.4.1 / dashboard/src/components/form-fields/checkbox.tsx
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/components/form-fields/checkbox.tsx · TypeScript
Blame Raw
 1import {
 2    FormField,
 3    FormItem,
 4    FormLabel,
 5    Checkbox,
 6    FormControl,
 7} from "@marzneshin/components";
 8import { useFormContext } from "react-hook-form";
 9
10export const CheckboxField = ({ name, label }: { name: string, label: string }) => {
11    const form = useFormContext();
12    return (
13        <FormField
14            control={form.control}
15            name={name}
16            render={({ field }) => (
17                <FormItem className="flex flex-row items-start space-x-3 space-y-0 rounded-md py-2">
18                    <FormControl>
19                        <Checkbox
20                            checked={field.value}
21                            onCheckedChange={field.onChange}
22                        />
23                    </FormControl>
24                    <div className="space-y-1 leading-none">
25                        <FormLabel>
26                            {label}
27                        </FormLabel>
28                    </div>
29                </FormItem>
30            )}
31        />
32    )
33}