import { Check } from '@mui/icons-material'
import clsx from 'clsx'
import { FieldValues, UseFormSetValue } from 'react-hook-form'
import { BooleanFieldNames } from '@dao-dao/types'
export interface CheckboxProps {
checked: boolean
onClick?: () => void
className?: string
readOnly?: boolean
size?: 'sm' | 'default'
}
export const Checkbox = ({
checked,
onClick,
className,
readOnly,
size = 'default',
}: CheckboxProps) => (
)
export type FormCheckboxWrapperProps<
Props,
FV extends FieldValues,
BooleanFieldName extends BooleanFieldNames,
> = Omit & {
fieldName: BooleanFieldName
value: boolean | undefined
setValue: UseFormSetValue
onToggle?: (newValue: boolean) => void
}
export const FormCheckbox = <
FV extends FieldValues,
BooleanFieldName extends BooleanFieldNames,
>({
fieldName,
value,
setValue,
onToggle,
...props
}: FormCheckboxWrapperProps) => (
{
const newValue = !value
setValue(fieldName, newValue as any)
onToggle?.(newValue)
}}
{...props}
/>
)