From 8543acc9b3366d5e2131879edfd730084eaff026 Mon Sep 17 00:00:00 2001 From: Devyash Saini Date: Sun, 17 Nov 2024 17:01:40 +0530 Subject: [PATCH 1/3] Fix navbar and chart width --- client/src/components/AppBar.jsx | 2 +- client/src/components/TransactionChart.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/components/AppBar.jsx b/client/src/components/AppBar.jsx index 76134ac..7934543 100644 --- a/client/src/components/AppBar.jsx +++ b/client/src/components/AppBar.jsx @@ -24,7 +24,7 @@ export default function ButtonAppBar() { } return ( - + diff --git a/client/src/components/TransactionChart.jsx b/client/src/components/TransactionChart.jsx index 6166305..46127aa 100644 --- a/client/src/components/TransactionChart.jsx +++ b/client/src/components/TransactionChart.jsx @@ -23,7 +23,7 @@ const TransactionChart = ({chartData}) => { } return ( - + From 5952f27cb5dd3f89f0a6f42e09db308506a883a0 Mon Sep 17 00:00:00 2001 From: Devyash Saini Date: Sun, 17 Nov 2024 17:35:23 +0530 Subject: [PATCH 2/3] Fixed category delete --- client/src/pages/Category.jsx | 6 ++++-- server/routes/category.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/client/src/pages/Category.jsx b/client/src/pages/Category.jsx index 7897de1..fd04534 100644 --- a/client/src/pages/Category.jsx +++ b/client/src/pages/Category.jsx @@ -12,16 +12,18 @@ import {setUser} from '../reducers/authReducer' import CategoryService from '../requests/Category.js' import CategoryForm from '../components/CategoryForm.jsx' import { setMessage } from '../reducers/messageReducer'; +import { setTransactions } from "../reducers/transactionReducer.js" export default function Category() { const dispatch = useDispatch() - + const transactions = useSelector(state => state.transactions) const categories = useSelector(state=>state.auth.user.categories) const handleDelete = async (name) => { if (confirm("Are you sure you want to delete the category?")){ const res = await CategoryService.remove(name) - // setTransactions(transactions.filter(trans => trans.id != id)) + console.log(res) + setTransactions(transactions.filter(trans => trans.id != id)) if(res.status===200){ dispatch(setUser(res.data)) dispatch(setMessage(['Category deleted successfully',true])) diff --git a/server/routes/category.js b/server/routes/category.js index 0186b6e..db6f92f 100644 --- a/server/routes/category.js +++ b/server/routes/category.js @@ -3,8 +3,8 @@ const router = Router() import User from '../models/User.js' router.delete('/:name',async (req,res)=>{ - req.user.categories.filter(n=>n!==req.params.name) - const user = await User.findByIdAndUpdate(req.user.id,{categories:req.user.categories},{new:true}) + const newCategories= req.user.categories.filter(n=>n!==req.params.name) + const user = await User.findByIdAndUpdate(req.user.id,{categories:newCategories},{new:true}) res.status(200).json(user) }) From 577d27324a55f330a774ad07c7736e5b771e82d6 Mon Sep 17 00:00:00 2001 From: Devyash Saini Date: Sun, 17 Nov 2024 17:43:07 +0530 Subject: [PATCH 3/3] Fixed edit transactions --- client/src/components/TransactionList.jsx | 2 +- server/routes/category.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/components/TransactionList.jsx b/client/src/components/TransactionList.jsx index 669e06c..8bca772 100644 --- a/client/src/components/TransactionList.jsx +++ b/client/src/components/TransactionList.jsx @@ -80,7 +80,7 @@ export default function BasicTable() { handleEdit()} + onClick={()=>handleEdit(row)} > diff --git a/server/routes/category.js b/server/routes/category.js index db6f92f..ac4d6de 100644 --- a/server/routes/category.js +++ b/server/routes/category.js @@ -3,7 +3,7 @@ const router = Router() import User from '../models/User.js' router.delete('/:name',async (req,res)=>{ - const newCategories= req.user.categories.filter(n=>n!==req.params.name) + const newCategories = req.user.categories.filter(n=>n!==req.params.name) const user = await User.findByIdAndUpdate(req.user.id,{categories:newCategories},{new:true}) res.status(200).json(user) })