diff --git a/src/app/page.tsx b/src/app/page.tsx index 1bd894b..e4b35ab 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -17,6 +17,8 @@ export default function Page() { const [transcription, setTranscription] = useState(''); const [isTranscribing, setIsTranscribing] = useState(false); const [extractedTransaction, setExtractedTransaction] = useState(''); + const [receiverAddress, setReceiverAddress] = useState<`0x${string}` | undefined>(); + const [amountValue, setAmountValue] = useState(BigInt(0)); const [isExtracting, setIsExtracting] = useState(false); const startRecording = async () => { @@ -150,6 +152,22 @@ export default function Page() { } }, [transcription]); + useEffect(() => { + if (extractedTransaction) { + try { + const parsedTransaction = JSON.parse(extractedTransaction); + if (parsedTransaction.receiver_address && parsedTransaction.amount_usdc) { + setReceiverAddress(parsedTransaction.receiver_address); + setAmountValue(BigInt(Math.round(parseFloat(parsedTransaction.amount_usdc) * 1e6))); + console.log('Receiver address:', receiverAddress); + console.log('Amount value:', amountValue); + } + } catch (error) { + console.error('Error parsing extracted transaction:', error); + } + } + }, [extractedTransaction]); // Added extractedTransaction as a dependency + return (