Skip to content

Commit bf6055f

Browse files
committed
Added the delete member feature updated the component Members with the new function which takes up the email and the send the email in the body to the internal api for further processing next add the route.ts for this function to work.
1 parent 830702a commit bf6055f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/components/Members.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@ const getMembers = async() => {
5656
showAlert("Error Fetching the members!","error");
5757
}
5858
}
59+
60+
//Function to delete a member from the list
61+
const deleteMember = async(email:string) => {
62+
try {
63+
const res = await fetch('/api/deleteMember', {
64+
method: "DELETE",
65+
headers :
66+
{ "Content-Type": "application/json",},
67+
body: JSON.stringify({email})
68+
});
69+
if (res.ok) {
70+
await getMembers();
71+
console.log("Member deletion successfuly!")
72+
showAlert("Member deleted successfully!", "success");
73+
}
74+
} catch {
75+
console.log("Error deleting the member");
76+
showAlert("Error deleting member","error");
77+
}
78+
}
5979
//Refreshes at page refresh and mount
6080
useEffect(() => {
6181
if(token)

0 commit comments

Comments
 (0)