import type { ReactNode } from "react"; import FieldLabel from "./help/FieldLabel"; import { helpForFieldLabel } from "../utils/fieldHelp"; import { usePlatformLanguage } from "../i18n/LanguageContext"; type ToggleSwitchProps = { label: ReactNode; activeLabel?: ReactNode; inactiveLabel?: ReactNode; checked: boolean; onChange?: (checked: boolean) => void; disabled?: boolean; help?: ReactNode; }; export default function ToggleSwitch({ label, activeLabel, inactiveLabel, checked, onChange, disabled = false, help }: ToggleSwitchProps) { const { translateText } = usePlatformLanguage(); const hasStateLabels = activeLabel !== undefined || inactiveLabel !== undefined; const renderedLabel = typeof label === "string" ? translateText(label) : label; const renderedInactiveLabel = typeof inactiveLabel === "string" ? translateText(inactiveLabel) : inactiveLabel; const renderedActiveLabel = typeof activeLabel === "string" ? translateText(activeLabel) : activeLabel; const inputLabel = typeof renderedLabel === "string" ? renderedLabel : undefined; return ( ); }