-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fc7aff
commit 132b2f3
Showing
7 changed files
with
50 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
frontend/src/Component/App/EditMovieForm/deletePersonButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import PersonType from "../../../Type/PersonType.tsx"; | ||
import axios from "axios"; | ||
type RelationType = { | ||
personId: string; | ||
movieId: string; | ||
} | ||
export default function DeletePersonButton({person, setStaff, staff, deleteUrl, movieId}: { | ||
person: PersonType, | ||
setStaff: (staffList: PersonType[]) => void, | ||
staff: PersonType[], | ||
deleteUrl: string, | ||
movieId: string | ||
}) { | ||
|
||
const handleDelete = function (){ | ||
setStaff(staff.filter((filteredPerson) => filteredPerson !== person)); | ||
|
||
if (!movieId) return; | ||
const relation : RelationType = { | ||
personId: person.id, | ||
movieId: movieId | ||
} | ||
axios.delete(`${deleteUrl}`, { | ||
data: relation | ||
}); | ||
} | ||
return <button onClick={handleDelete}>delete</button> | ||
} |