Skip to content

Commit

Permalink
Merge pull request #329 from SELab-2/last_last_bugs
Browse files Browse the repository at this point in the history
remove project
  • Loading branch information
Bendemeurichy authored May 23, 2024
2 parents a21ab44 + c80eb44 commit 6bb8f8a
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 6bb8f8a

Please sign in to comment.