Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/components/AppBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function ButtonAppBar() {
}

return (
<Box sx={{ flexGrow: 1, width: '30%' }}>
<Box sx={{ flexGrow: 1, width: '100%' }}>
<AppBar position="static">
<Toolbar>

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/TransactionChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const TransactionChart = ({chartData}) => {
}

return (
<Paper style={{ marginTop: 20, width: '20%' }}>
<Paper style={{ marginTop: 20, width: '100%' }}>
<Chart
data={chartData}
>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/TransactionList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function BasicTable() {
<IconButton
color='primary'
sx={{ marginLeft: 1, cursor: 'pointer' }}
onClick={()=>handleEdit()}
onClick={()=>handleEdit(row)}
>
<EditIcon/>
</IconButton>
Expand Down
6 changes: 4 additions & 2 deletions client/src/pages/Category.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
4 changes: 2 additions & 2 deletions server/routes/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand Down