diff --git a/src/app/private/volunteers/page.tsx b/src/app/private/volunteers/page.tsx index 12beced..66c5385 100644 --- a/src/app/private/volunteers/page.tsx +++ b/src/app/private/volunteers/page.tsx @@ -14,6 +14,7 @@ export default function VolunteersPage() { const [users, setUsers] = React.useState(); const [selected, setSelected] = React.useState([]); const [searchText, setSearchText] = React.useState(""); + const [isModalOpen, setIsModalOpen] = React.useState(false); React.useEffect(() => { const fetchUsers = async () => { @@ -36,9 +37,9 @@ export default function VolunteersPage() { user.email.toLowerCase().includes(searchText.toLowerCase()) ); - const deleteUsers = async (selectedIds: string[]) => { + const deleteUsers = async () => { try { - const deletePromises = selectedIds.map((id) => deleteUser(id)); + const deletePromises = selected.map((id) => deleteUser(id)); const responses = await Promise.all(deletePromises); const allDeleted = responses.every( (response) => response.code === "SUCCESS" @@ -47,7 +48,7 @@ export default function VolunteersPage() { if (allDeleted) { setUsers((prevUsers) => prevUsers - ? prevUsers.filter((user) => !selectedIds.includes(user.id)) + ? prevUsers.filter((user) => !selected.includes(user.id)) : [] ); setSelected([]); @@ -55,6 +56,7 @@ export default function VolunteersPage() { } else { console.error("Not all deletions succeeded"); } + setIsModalOpen(false); } catch (error) { console.error("Error deleting users:", error); } @@ -87,7 +89,7 @@ export default function VolunteersPage() { backgroundColor: "var(--Rose-700, #C11429)", }, }} - onClick={() => deleteUsers(selected)} + onClick={() => setIsModalOpen(true)} >
Delete
@@ -126,6 +128,54 @@ export default function VolunteersPage() { )} + {isModalOpen && ( +
+
+
+
+ Are you sure you want to delete {selected.length}{" "} + {selected.length === 1 ? "user" : "users"}? +
+
+ You will not be able to recover {selected.length === 1 ? "a" : ""}{" "} + deleted {selected.length === 1 ? "profile" : "profiles"}. +
+
+ + +
+
+
+ )} ); } diff --git a/src/components/createUserForm.tsx b/src/components/createUserForm.tsx index 31957b2..b63aa7a 100644 --- a/src/components/createUserForm.tsx +++ b/src/components/createUserForm.tsx @@ -61,7 +61,7 @@ const CreateUserForm = ({ setUserID }: CreateUserForm) => { address: formData.address, city: formData.city, state: formData.state, - zipCode: formData.zipCode ? parseInt(formData.zipCode) : null, + zipCode: formData.zipCode, hasLicense: formData.hasLicense, speaksEsp: formData.speaksEsp, volunteerType: formData.volunteerType,