32 lines
832 B
TypeScript
32 lines
832 B
TypeScript
// * Other
|
|
import InputError from "@/back/Components/InputError";
|
|
import { usePage } from "@inertiajs/react";
|
|
import { Switch } from "@/components/ui/switch";
|
|
|
|
export default function SimpleSwitch({
|
|
name,
|
|
checked,
|
|
required = false,
|
|
disabled = false,
|
|
setData,
|
|
}: {
|
|
name: string;
|
|
checked?: boolean;
|
|
required?: boolean;
|
|
disabled?: boolean;
|
|
setData: Function;
|
|
}) {
|
|
const errors = usePage().props.errors;
|
|
return (
|
|
<div className="flex flex-col items-start w-fit gap-1.5">
|
|
<Switch
|
|
name={name}
|
|
onCheckedChange={(value) => setData(name, value)}
|
|
required={required}
|
|
checked={checked}
|
|
disabled={disabled}
|
|
/>
|
|
<InputError message={errors[name]} />
|
|
</div>
|
|
);
|
|
}
|