"use client" import { Switch as AriaSwitch } from "react-aria-components" import { useController, useFormContext } from "react-hook-form" import Caption from "@scandic-hotels/design-system/Caption" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import styles from "./switch.module.css" import type { SwitchProps } from "@/types/components/switch" export default function Switch({ className, name, children, registerOptions, }: React.PropsWithChildren) { const { control } = useFormContext() const { field, fieldState } = useController({ control, name, rules: registerOptions, }) return ( {children} {fieldState.error ? ( {fieldState.error.message} ) : null} ) }