import { HStack, PinInput, PinInputField, PinInputProps, StackProps, } from '@chakra-ui/react'; import { useField, useFormikContext } from 'formik'; import React, { FC } from 'react'; import { BaseProps, FormControl } from '../form-control'; export type PinInputControlProps = BaseProps & { pinAmount: number; stackProps?: StackProps; pinInputProps?: Omit; }; export const PinInputControl: FC = ( props: PinInputControlProps ) => { const { name, label, pinAmount, stackProps, pinInputProps, ...rest } = props; const [field, , { setValue }] = useField(name); const { isSubmitting } = useFormikContext(); const renderedPinInputFields = Array(pinAmount) .fill(null) .map((_noop, i) => ); function handleChange(value: string) { setValue(value); } return ( {renderedPinInputFields} ); }; export default PinInputControl;