import { PropsWithChildren, useState } from 'react'; import { IoCheckmark } from 'react-icons/io5'; import { cx } from '../../utils/styleUtils'; import IconButton from '../buttons/IconButton'; import Input from '../input/input/Input'; import style from './PinPage.module.scss'; interface PinPageProps { permission: 'editor' | 'operator'; handleValidation: (pin: string) => boolean; } export default function PinPage({ permission, handleValidation }: PropsWithChildren) { const [pin, setPin] = useState(''); const [failed, setFailed] = useState(false); const validate = () => { const isValid = handleValidation(pin); if (!isValid) { setFailed(true); setPin(''); } }; const handleInputChange = (value: string) => { setPin(value); if (failed) setFailed(false); }; return (
{`Ontime ${permission}`}
{ event.preventDefault(); validate(); }} className={cx([style.pin, failed && style.pinFailed])} > handleInputChange(e.target.value)} />
); }