toggle-setting.tsx 713 B

1234567891011121314151617181920212223242526272829303132333435
  1. import React from 'react'
  2. import Setting from './setting'
  3. import OLFormSwitch from '@/shared/components/ol/ol-form-switch'
  4. export default function ToggleSetting({
  5. id,
  6. label,
  7. description,
  8. checked,
  9. onChange,
  10. disabled,
  11. }: {
  12. id: string
  13. label: React.ReactNode
  14. description: React.ReactNode
  15. checked: boolean | undefined
  16. onChange: (newValue: boolean) => void
  17. disabled?: boolean
  18. }) {
  19. const handleChange = () => {
  20. onChange(!checked)
  21. }
  22. return (
  23. <Setting controlId={id} label={label} description={description}>
  24. <OLFormSwitch
  25. id={id}
  26. onChange={handleChange}
  27. checked={checked}
  28. label={label}
  29. disabled={disabled}
  30. />
  31. </Setting>
  32. )
  33. }