diff --git a/src/app/_components/UI/Checkbox.tsx b/src/app/_components/UI/Checkbox.tsx index 4ad1b151d..b38791b05 100644 --- a/src/app/_components/UI/Checkbox.tsx +++ b/src/app/_components/UI/Checkbox.tsx @@ -1,35 +1,39 @@ import styles from './Checkbox.module.scss' -import { v4 as uuid } from 'uuid' import type { InputHTMLAttributes, ReactNode } from 'react' -type PropTypes = Omit, 'type'> & { +type PropTypes = Omit, 'type' | 'name' | 'id'> & { label?: string children?: ReactNode -} +} & ({ + id: string + name?: string | undefined +} | { + name: string + id?: string | undefined +}) /** - * * @param label - The label shown to user (optional) * @param children - If given, the children will be clickable as part of checkbox * @returns */ function Checkbox({ label, children, ...props }: PropTypes) { - props.id ??= `id_input_${uuid()}` + const inputId = props.id ?? props.name return (
{ children ? ( ) : ( <> - - {label && } + + {label && } ) } diff --git a/src/app/_components/UI/FileInput.tsx b/src/app/_components/UI/FileInput.tsx index e5f8fa1c0..3d7e476fe 100644 --- a/src/app/_components/UI/FileInput.tsx +++ b/src/app/_components/UI/FileInput.tsx @@ -1,5 +1,4 @@ 'use client' - import styles from './FileInput.module.scss' import { useState } from 'react' import { v4 as uuid } from 'uuid' diff --git a/src/app/_components/UI/TextInput.tsx b/src/app/_components/UI/TextInput.tsx index 701b43ec4..28b6693b3 100644 --- a/src/app/_components/UI/TextInput.tsx +++ b/src/app/_components/UI/TextInput.tsx @@ -1,16 +1,21 @@ import styles from './TextInput.module.scss' -import { v4 as uuid } from 'uuid' import type { InputHTMLAttributes } from 'react' -export type PropTypes = Omit, 'type'> & { +export type PropTypes = Omit, 'type' | 'name' | 'id'> & { label: string, type?: 'text' | 'password', color?: 'primary' | 'secondary' | 'red' | 'black' | 'white', -} +} & ({ + id: string, + name?: string | undefined, +} | { + name: string, + id?: string | undefined, +}) export default function TextInput({ label = 'default', type = 'text', color = 'black', className, ...props }: PropTypes) { - props.id ??= `id_input_${uuid()}` + props.id ??= `id_input_${props.name}` return (