diff --git a/frontend/src/components/dashboard/AddTransactionForm.js b/frontend/src/components/dashboard/AddTransactionForm.js index 3d67759..a7cbc32 100644 --- a/frontend/src/components/dashboard/AddTransactionForm.js +++ b/frontend/src/components/dashboard/AddTransactionForm.js @@ -1,15 +1,39 @@ import React from "react"; import { useDash } from "../../contexts/DashBoardContext"; +import { useState } from "react"; +import { useRef } from "react"; const AddTransactionForm = () => { const { setTransactionType, handleDateChange, handleTransaction } = useDash(); const { expenseCategories, incomeCategories, transactionType, dateValue } = useDash(); + // const [formState, setFormState] = useState({ + // title: '', + // amount: '', + // type: '', + // label: '', + // // date: dateValue, + // }); + + const formRef = useRef(null); + + const cleanAfterSubmit = async (ev) => { + try { + await handleTransaction(ev); + formRef.current.reset(); + formRef.current.querySelector('select[name="type"]').value = ''; + formRef.current.querySelector('select[name="label"]').value = ''; + } catch (err) { + console.error(err); + } + + }; + return (