/* eslint-disable consistent-return */ /* eslint-disable no-return-assign */ /* eslint-disable react/no-array-index-key */ import React from 'react'; import { staticMessages } from '~/driven/utils/constants/staticMessages'; export interface IOtpCodeView { otpChar: React.MutableRefObject; eventHandlers: { handleFocusInput: (e: React.FocusEvent) => void; handleKeyPressInput: (e: React.KeyboardEvent) => void; }; } export default function OtpCodeView(props: IOtpCodeView) { const { eventHandlers, otpChar } = props; const { handleFocusInput, handleKeyPressInput } = eventHandlers; const otpInputs = Array.from({ length: 6 }).map((digit, i) => ( (otpChar.current[i] = el)} key={`otp_char_${i}`} className='font-bold text-base inline-block w-5 md:w-10 bg-transparent text-center focus:outline-none' maxLength={1} defaultValue='_' placeholder='_' onClick={(e) => e.stopPropagation()} onFocus={handleFocusInput} onKeyDown={handleKeyPressInput} /> )); return (
{staticMessages.global.enterOtpCode}
{otpInputs}
); }