Skip to content

Commit

Permalink
Remember currency in add transaction dialog for fx accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
ystxn committed Mar 9, 2024
1 parent de6839b commit 0a75232
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/core/state.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
7 changes: 5 additions & 2 deletions src/transactions/add-transaction-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -88,6 +88,9 @@ const AddTransactionDialog = ({
if (transactionToEdit.category) {
setCategory(transactionToEdit.category);
}
if (transactionToEdit.currency) {
setCurrency(transactionToEdit.currency);
}
}, [ selectedAccount, transactionToEdit ]);

useEffect(() => {
Expand Down

0 comments on commit 0a75232

Please sign in to comment.