diff --git a/src/components/Form/DynamicForm.tsx b/src/components/Form/DynamicForm.tsx index d70a0ee5..470f36e7 100644 --- a/src/components/Form/DynamicForm.tsx +++ b/src/components/Form/DynamicForm.tsx @@ -101,7 +101,10 @@ export function DynamicForm({ key={field.label} label={field.label} description={field.description} - valid={field.validationText == undefined || field.validationText == ""} + valid={ + field.validationText === undefined || + field.validationText === "" + } validationText={field.validationText} > extends BaseFormBuilderProps { @@ -22,7 +22,7 @@ export function PasswordGenerator({ ( + render={({ field: { value, ...rest } }) => (

{description}

- +
{children}
diff --git a/src/components/PageComponents/Channel.tsx b/src/components/PageComponents/Channel.tsx index 85a6866c..fd425995 100644 --- a/src/components/PageComponents/Channel.tsx +++ b/src/components/PageComponents/Channel.tsx @@ -59,48 +59,40 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => { }; const validatePass = (input: string, count: number) => { - if (count == 32) { - if (input.length != 44) { + if (count === 32) { + if (input.length !== 44) { setValidationText("Please enter a valid 256 bit PSK."); - } - else { + } else { setValidationText(undefined); } - } - else if (count == 16) - { - if (input.length != 24) { + } else if (count === 16) { + if (input.length !== 24) { setValidationText("Please enter a valid 128 bit PSK."); - } - else { + } else { setValidationText(undefined); } - } - else if (count == 1) - { - if (input.length != 4) { + } else if (count === 1) { + if (input.length !== 4) { setValidationText("Please enter a valid 1 bit PSK"); - } - else { + } else { setValidationText(undefined); } - } - else { + } else { setValidationText("Unkown PSK length."); } - } + }; const inputChangeEvent = (e) => { - let psk = e.currentTarget?.value; + const psk = e.currentTarget?.value; setPass(psk); validatePass(psk, bitCount); }; const selectChangeEvent = (e: string) => { - let count = Number.parseInt(e); + const count = Number.parseInt(e); setBits(count); validatePass(pass, count); - } + }; return ( @@ -152,7 +144,7 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => { selectChange: selectChangeEvent, buttonClick: clickEvent, properties: { - value: pass + value: pass, }, }, { diff --git a/src/components/UI/Generator.tsx b/src/components/UI/Generator.tsx index bdf0c3b8..344e89bb 100644 --- a/src/components/UI/Generator.tsx +++ b/src/components/UI/Generator.tsx @@ -10,8 +10,7 @@ import { SelectValue, } from "@components/UI/Select.js"; -export interface GeneratorProps - extends React.BaseHTMLAttributes { +export interface GeneratorProps extends React.BaseHTMLAttributes { devicePSKBitCount?: number; value: string; variant: "default" | "invalid"; @@ -21,17 +20,25 @@ export interface GeneratorProps buttonClick: React.MouseEventHandler; } - const Generator = React.forwardRef( ( - { devicePSKBitCount, variant, value, buttonText, selectChange, inputChange, buttonClick, ...props }, + { + devicePSKBitCount, + variant, + value, + buttonText, + selectChange, + inputChange, + buttonClick, + ...props + }, ref, ) => { return ( <> - ( - diff --git a/src/components/UI/Input.tsx b/src/components/UI/Input.tsx index c7ac3217..2c3080fb 100644 --- a/src/components/UI/Input.tsx +++ b/src/components/UI/Input.tsx @@ -1,18 +1,16 @@ import * as React from "react"; import { cn } from "@core/utils/cn.js"; +import { type VariantProps, cva } from "class-variance-authority"; import type { LucideIcon } from "lucide-react"; -import { cva, VariantProps } from "class-variance-authority"; const inputVariants = cva( "flex h-10 w-full rounded-md border bg-transparent py-2 px-3 text-sm placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-50 dark:focus:ring-slate-400 dark:focus:ring-offset-slate-900", { variants: { variant: { - default: - "border-slate-300 dark:border-slate-700", - invalid: - "border-red-500 dark:border-red-500", + default: "border-slate-300 dark:border-slate-700", + invalid: "border-red-500 dark:border-red-500", }, }, defaultVariants: { @@ -42,7 +40,11 @@ const Input = React.forwardRef( )}