(value: string, index: number)
| 30 | ); |
| 31 | |
| 32 | const updateCode = (value: string, index: number) => { |
| 33 | const newCode = [...code]; |
| 34 | newCode[index] = value; |
| 35 | setCode(newCode); |
| 36 | onChange?.(newCode.join('')); |
| 37 | |
| 38 | const finalCode = newCode.join(''); |
| 39 | |
| 40 | if (finalCode.length === length && index === length - 1) { |
| 41 | onSubmit(finalCode); |
| 42 | } |
| 43 | }; |
| 44 | |
| 45 | const onSlice = (text: string) => { |
| 46 | const sliced = text.slice(0, length); |