Files
Gildas Garcia 0facd341a6 chore: remove UI form components _Shadcn_ suffix (#45212)
## Problem

We used to have a `_Shadcn_` suffix for all the shadcn form components
because we also had `formik` form components.
This is not needed anymore.

## Solution

- Remove the suffix
- Update all usages
2026-04-24 12:14:15 +02:00

45 lines
1.2 KiB
TypeScript

import type { ReactNode } from 'react'
import type { FieldValues, Path, UseFormReturn } from 'react-hook-form'
import { CardContent, FormControl, FormField, Switch } from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
interface DashboardToggleProps<T extends FieldValues> {
form: UseFormReturn<T>
name: Path<T>
label: string
description: ReactNode
onToggle: (value: boolean) => void
isLast?: boolean
}
export function DashboardToggle<T extends FieldValues>({
form,
name,
label,
description,
onToggle,
isLast,
}: DashboardToggleProps<T>) {
return (
<CardContent className={isLast ? undefined : 'border-b'}>
<FormField
control={form.control}
name={name}
render={({ field }) => (
<FormItemLayout layout="flex-row-reverse" label={label} description={description}>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={(value) => {
field.onChange(value)
onToggle(value)
}}
/>
</FormControl>
</FormItemLayout>
)}
/>
</CardContent>
)
}