mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 04:13:47 +00:00
1849b4d39f
* chore: migrate eslint to oxlint * chore: migrate prettier to oxfmt * chore: migrate typescript * chore: toThrow should have a expected value * chore: cast test value as Day * chore: small title fix * chore: mocks should be hoisted * chore: incorrect async useage * chore: test should be inside description * chore: test sohuld include an expeced * chore: oxfmt --------- Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { Settings } from 'ontime-types';
|
|
import { PropsWithChildren, useState } from 'react';
|
|
import { UseFormRegister } from 'react-hook-form';
|
|
import { IoEyeOutline } from 'react-icons/io5';
|
|
|
|
import IconButton from '../../../../../common/components/buttons/IconButton';
|
|
import Input from '../../../../../common/components/input/input/Input';
|
|
import { isAlphanumeric } from '../../../../../common/utils/regex';
|
|
|
|
import style from './GeneralPinInput.module.scss';
|
|
|
|
interface GeneralPinInputProps {
|
|
register: UseFormRegister<Settings>;
|
|
formName: keyof Settings;
|
|
disabled?: boolean;
|
|
}
|
|
|
|
export default function GeneralPinInput({ register, formName, disabled }: PropsWithChildren<GeneralPinInputProps>) {
|
|
const [isVisible, setVisible] = useState(false);
|
|
|
|
return (
|
|
<div className={style.container}>
|
|
<Input
|
|
type={isVisible ? 'text' : 'password'}
|
|
maxLength={4}
|
|
{...register(formName, {
|
|
pattern: {
|
|
value: isAlphanumeric,
|
|
message: 'Only alphanumeric characters are allowed',
|
|
},
|
|
})}
|
|
placeholder='-'
|
|
disabled={disabled}
|
|
/>
|
|
<IconButton
|
|
onMouseDown={() => setVisible(true)}
|
|
onMouseUp={() => setVisible(false)}
|
|
variant='ghosted'
|
|
aria-label='Show pin code'
|
|
>
|
|
<IoEyeOutline />
|
|
</IconButton>
|
|
</div>
|
|
);
|
|
}
|