File size: 892 Bytes
aa2e6af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { useRecoilState } from 'recoil';
import HoverCardSettings from '../HoverCardSettings';
import { Switch } from '~/components/ui';
import { useLocalize } from '~/hooks';
import store from '~/store';

export default function ShowCodeSwitch({
  onCheckedChange,
}: {
  onCheckedChange?: (value: boolean) => void;
}) {
  const [showCode, setShowCode] = useRecoilState<boolean>(store.showCode);
  const localize = useLocalize();

  const handleCheckedChange = (value: boolean) => {
    setShowCode(value);
    if (onCheckedChange) {
      onCheckedChange(value);
    }
  };

  return (
    <div className="flex items-center justify-between">
      <div> {localize('com_nav_show_code')} </div>
      <Switch
        id="showCode"
        checked={showCode}
        onCheckedChange={handleCheckedChange}
        className="ml-4 mt-2"
        data-testid="showCode"
      />
    </div>
  );
}