Skip to content

Commit

Permalink
fix balance
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldenrash-lab committed Jan 13, 2024
1 parent de0a988 commit f5bb373
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/components/Currency/Currency.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const Currency = () => {
const [currency, setCurrency] = useState([]);
const dispatch = useDispatch();
const selectedCurrency = useSelector(currencySelector);
console.log('here', selectedCurrency, currency);
// const isLoading = useSelector(isLoadingSelector);
const token = useSelector(state => state.auth.token);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ const TransactionsItem = ({ transaction }) => {

const transType = transaction.type === 'EXPENSE' ? '-' : '+';

function correctBalance(amount) {
if (amount < 0) {
return Math.abs(amount);
} else {
return (amount = -amount);
}
}

return (
<StyledTransaction $normalFont={true}>
<StyledTh $width={true}>{formattedDateStr}</StyledTh>
Expand Down Expand Up @@ -65,7 +73,7 @@ const TransactionsItem = ({ transaction }) => {
dispatch(deleteTransactionThunk(transaction.id))
.unwrap()
.then(() => {
dispatch(changeBalance(transaction.amount));
dispatch(changeBalance(correctBalance(transaction.amount)));
dispatch(deleteTransaction(transaction.id));
toast.success('Transaction is deleted!');
})
Expand Down

0 comments on commit f5bb373

Please sign in to comment.