diff --git a/src/core/state.jsx b/src/core/state.jsx index 209dd12..5dd6fdb 100644 --- a/src/core/state.jsx +++ b/src/core/state.jsx @@ -21,6 +21,7 @@ const state = () => ({ categories: atom({ key: 'categories', default: [] }), date: atom({ key: 'date', default: dayjs.utc().startOf('day') }), visibleTransactionId: atom({ key: 'visibleTransactionId', default: undefined }), + currency: atom({ key: 'currency', default: 'SGD' }), }); export default state(); diff --git a/src/transactions/add-transaction-dialog.jsx b/src/transactions/add-transaction-dialog.jsx index 5786be7..3c40f90 100644 --- a/src/transactions/add-transaction-dialog.jsx +++ b/src/transactions/add-transaction-dialog.jsx @@ -40,8 +40,8 @@ const AddTransactionDialog = ({ const [ side, setSide ] = useState(-1); const [ date, setDate ] = state.useState(state.date); const [ month, setMonth ] = useState(dayjs.utc().startOf('day')); - const [ inputCurrency, setInputCurrency ] = useState(transactionToEdit?.currency || ''); - const [ currency, setCurrency ] = useState(transactionToEdit?.currency || 'SGD'); + const [ inputCurrency, setInputCurrency ] = useState(transactionToEdit?.currency || 'SGD'); + const [ currency, setCurrency ] = state.useState(state.currency); const [ code, setCode ] = useState(transactionToEdit?.code || ''); const [ amountValue, setAmountValue ] = useState(Math.abs(transactionToEdit?.amount) || 0); const [ originalAmount, setOriginalAmount ] = useState(Math.abs(transactionToEdit?.originalAmount) || 0); @@ -88,6 +88,9 @@ const AddTransactionDialog = ({ if (transactionToEdit.category) { setCategory(transactionToEdit.category); } + if (transactionToEdit.currency) { + setCurrency(transactionToEdit.currency); + } }, [ selectedAccount, transactionToEdit ]); useEffect(() => {