import React, { useEffect, useState } from "react"; import styles from "../styles/stylesheet"; import { Dialog, DialogActions, DialogContent, DialogTitle, TextField, Grid, Button, Typography, } from "@mui/material"; const ImportWalletDialog = ({ visible, hideDialog, importWalletHandler, }: { visible: boolean; hideDialog: () => void; importWalletHandler: (recoveryPhrase: string) => Promise; }) => { const [words, setWords] = useState(Array(12).fill("")); const handleWordChange = (index: number, value: string) => { const newWords = [...words]; newWords[index] = value; setWords(newWords); }; const handlePaste = (event: React.ClipboardEvent) => { const pastedText = event.clipboardData.getData("Text"); const splitWords = pastedText.trim().split(/\s+/); if (splitWords.length === 12) { setWords(splitWords); event.preventDefault(); } }; useEffect(() => { setWords(Array(12).fill("")); }, [visible]); return ( Import your wallet from your mnemonic (You can paste your entire mnemonic into the first textbox) {words.map((word, index) => ( handleWordChange(index, e.target.value)} onPaste={index === 0 ? handlePaste : undefined} placeholder={`Word ${index + 1}`} fullWidth margin="normal" /> ))} ); }; export default ImportWalletDialog;