biome
This commit is contained in:
@@ -21,12 +21,13 @@ export function PasswordGenerator<T extends FieldValues>({
|
||||
render={({ field: { value, onChange, ...rest } }) => (
|
||||
<Generator
|
||||
devicePSKBitCount={field.devicePSKBitCount}
|
||||
changeEvent={onChange}
|
||||
changeEvent={onChange}
|
||||
value={value}
|
||||
variant={"success"}
|
||||
buttonText="Generate"
|
||||
{...field.properties}
|
||||
{...rest} />
|
||||
{...rest}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -15,8 +15,12 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
|
||||
const { config, connection, addChannel } = useDevice();
|
||||
const { toast } = useToast();
|
||||
|
||||
const [pass, setPass] = useState<string>(fromByteArray(channel?.settings?.psk ?? new Uint8Array(0)));
|
||||
const [bitCount, setBits] = useState<number>(channel?.settings?.psk.length ?? 16);
|
||||
const [pass, setPass] = useState<string>(
|
||||
fromByteArray(channel?.settings?.psk ?? new Uint8Array(0)),
|
||||
);
|
||||
const [bitCount, setBits] = useState<number>(
|
||||
channel?.settings?.psk.length ?? 16,
|
||||
);
|
||||
|
||||
const onSubmit = (data: ChannelValidation) => {
|
||||
const channel = new Protobuf.Channel.Channel({
|
||||
@@ -41,7 +45,6 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const clickEventCb = (e) => {
|
||||
setPass(
|
||||
btoa(
|
||||
@@ -51,7 +54,7 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<ChannelValidation>
|
||||
@@ -101,7 +104,7 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
|
||||
properties: {
|
||||
value: pass,
|
||||
onClick: clickEventCb,
|
||||
changeEvent: (e: string) => setBits(parseInt(e)),
|
||||
changeEvent: (e: string) => setBits(Number.parseInt(e)),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -10,9 +10,9 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@components/UI/Select.js";
|
||||
import { fromByteArray, toByteArray } from "base64-js";
|
||||
import cryptoRandomString from "crypto-random-string";
|
||||
import { useState } from "react";
|
||||
import { fromByteArray, toByteArray } from "base64-js";
|
||||
|
||||
const generatorVariants = cva(
|
||||
"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus:outline-none focus:ring-2",
|
||||
@@ -51,33 +51,24 @@ export interface GeneratorProps
|
||||
devicePSKBitCount?: number;
|
||||
value: string;
|
||||
buttonText?: string;
|
||||
changeEvent: Function;
|
||||
|
||||
changeEvent: (event: string) => void;
|
||||
}
|
||||
|
||||
const getBitString = (bitcount?: number) => {
|
||||
if (bitcount == 32) {
|
||||
return "32"
|
||||
if (bitcount === 32) {
|
||||
return "32";
|
||||
}
|
||||
if (bitcount == 1) {
|
||||
return "1"
|
||||
if (bitcount === 1) {
|
||||
return "1";
|
||||
}
|
||||
return "16"
|
||||
}
|
||||
return "16";
|
||||
};
|
||||
|
||||
const Generator = React.forwardRef<HTMLInputElement, GeneratorProps>(
|
||||
(
|
||||
{
|
||||
devicePSKBitCount,
|
||||
value,
|
||||
buttonText,
|
||||
variant,
|
||||
changeEvent,
|
||||
...props
|
||||
},
|
||||
{ devicePSKBitCount, value, buttonText, variant, changeEvent, ...props },
|
||||
ref,
|
||||
) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Input type="text" id="pskInput" value={value} />
|
||||
@@ -100,11 +91,7 @@ const Generator = React.forwardRef<HTMLInputElement, GeneratorProps>(
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Button
|
||||
type="button"
|
||||
variant="success"
|
||||
{...props}
|
||||
>
|
||||
<Button type="button" variant="success" {...props}>
|
||||
{buttonText}
|
||||
</Button>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user