import React, {FC} from 'react'; import {EnterCodeStyle as S} from './styles/enter-code.style'; import {useEnterCode} from './hooks/use-enter-code'; import {IEnterCode} from './enter-code.type'; import {useTheme} from '@mui/material'; export const EnterCodeComponent: FC = ({ onComplete, fields, label, hint, size, error, ...rest }) => { const {processInput, onKeyUp, code, inputs} = useEnterCode({ onComplete, fields, }); const theme = useTheme(); return ( {label && {label}} {code.map((num, idx) => { return ( processInput(e, idx)} onKeyUp={(e) => onKeyUp(e, idx)} ref={(ref) => inputs.current.push(ref)} {...rest} /> ); })} {hint && {hint}} ); };