'use client'; import { useDebouncedOnChangeCallback } from './hooks'; import { Checkbox, type CheckboxProps } from '@repo/ui/components/ui/checkbox'; import { useState } from 'react'; type Props = Pick & { readonly description?: string; readonly onChange?: (value: boolean) => Promise | void; readonly text: string; }; export function CheckboxWithText({ checked: initialValue, description, onChange, text }: Props) { const [checked, setChecked] = useState(initialValue); const { debouncedCallback, isPending } = useDebouncedOnChangeCallback(onChange); const handleChange = () => { const newValue = !checked; setChecked(newValue); debouncedCallback(newValue); }; return (
{description ?

{description}

: false}
); }