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 ( - + 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/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..ac4d6de 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) })