-
Notifications
You must be signed in to change notification settings - Fork 353
Expand file tree
/
Copy pathencoding-format-toggle-switch.tsx
More file actions
42 lines (37 loc) · 1.54 KB
/
encoding-format-toggle-switch.tsx
File metadata and controls
42 lines (37 loc) · 1.54 KB
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
36
37
38
39
40
41
42
import React, { ChangeEvent, useEffect, useState } from "react";
import styles from "./encoding-format-toggle-switch.module.scss";
import { EncodingValues } from "@/features/common/values/encoding.values";
import { useDecoderStore } from "@/features/decoder/services/decoder.store";
import { getPickersUiDictionary } from "@/features/localization/services/ui-language-dictionary.service";
import { Switch } from "react-aria-components";
import clsx from "clsx";
interface EncodingFormatToggleSwitchComponentProps {
languageCode: string;
}
export const EncodingFormatToggleSwitchComponent: React.FC<
EncodingFormatToggleSwitchComponentProps
> = ({ languageCode }) => {
const dictionary = getPickersUiDictionary(languageCode);
const handleSymmetricSecretKeyEncodingChange = useDecoderStore(
(state) => state.handleSymmetricSecretKeyEncodingChange
);
const onSecretEncodingFormatChange = (event: ChangeEvent<HTMLInputElement>) => {
handleSymmetricSecretKeyEncodingChange(event.target.checked ? EncodingValues.BASE64URL : EncodingValues.UTF8);
};
return (
<div className={styles.container}>
<div className={styles.label}>
<span className={styles.fullLabel}>Base64URL Encoded?</span>
</div>
<label className={styles.switch__container}>
<input type="checkbox" role="switch" className={styles.input} onChange={onSecretEncodingFormatChange}/>
<span
className={clsx(
styles.picker__round,
styles.picker__slider
)}
></span>
</label>
</div>
);
};