Skip to content

Commit

Permalink
remove project
Browse files Browse the repository at this point in the history
  • Loading branch information
Bendemeurichy committed May 23, 2024
1 parent f7041f2 commit c80eb44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion frontend/frontend/src/pages/subjectsPage/ProjectsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ export function ProjectsView({
}
deleteEvent={() =>
deleteAssignment(
project.index
project.assignment
.project_id
)
}
archiveEvent={() =>
Expand Down
13 changes: 7 additions & 6 deletions frontend/frontend/src/pages/subjectsPage/SubjectsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,20 @@ export function SubjectsPage() {
}

const [openDeletePopup, setOpenDeletePopup] = useState(false)
const [deleteIndex, setDeleteIndex] = useState(0)
const [deleteId, setDeleteId] = useState(0)
const [openArchivePopup, setOpenArchivePopup] = useState(false)
const [archiveIndex, setArchiveIndex] = useState(0)

const deleteAssignment = (index: number) => {
setDeleteIndex(index)
const deleteAssignment = (id: number) => {
setDeleteId(id)
setOpenDeletePopup(true)
}
const doDelete = async () => {
setAssignments(assignments.filter((_, i) => i !== deleteIndex))
setAssignments(
assignments.filter((project) => project.project_id !== deleteId)
)
try {
const deletedAssignment = assignments[deleteIndex]
await instance.delete(`/projecten/${deletedAssignment.project_id}/`)
await instance.delete(`/projecten/${deleteId}/`)
} catch (error) {
console.error('Error deleting data:', error)
}
Expand Down

0 comments on commit c80eb44

Please sign in to comment.