Skip to content

Commit

Permalink
Merge pull request #83 from Goldenrash-lab/feature/balance
Browse files Browse the repository at this point in the history
fix balance
  • Loading branch information
Goldenrash-lab authored Jan 13, 2024
2 parents de0a988 + f5bb373 commit 0672c71
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 0672c71

Please sign in to comment.