Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modals await network requests #253

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion frontend/src/components/common/DeleteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ const DeleteModal = ({
<Button mr={3} onClick={onClose}>
<Text>Cancel</Text>
</Button>
<Button colorScheme="red" onClick={onDelete}>
<Button
colorScheme="red"
onClick={() => {
onClose();
onDelete();
}}
>
{buttonLabel}
</Button>
</HStack>
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/components/pages/AccessControl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ const AccessControlPage = (): JSX.Element => {
duration: 3000,
});
}
onClose();
setUserToChangeStatus(null);
};

Expand Down Expand Up @@ -217,9 +216,13 @@ const AccessControlPage = (): JSX.Element => {
buttonColor={userToChangeStatus?.active ? "red" : "green"}
isOpen={isOpen}
onClose={onClose}
onChangeStatus={() =>
userToChangeStatus && handleStatusChange(userToChangeStatus)
}
onChangeStatus={() => {
if (userToChangeStatus) {
handleStatusChange(userToChangeStatus);
}

onClose();
}}
/>
<Text mb="35px" textStyle="displayXLarge">
FON Staff Access Control
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ const WaitlistedCampersTable = ({
waitlistedCamper.id,
);

onClose();
if (deletedWaitlistedCamperResponse) {
toast({
description: `${camperToDeleteName} has been removed from the waitlist for this camp session.`,
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/pages/CampsList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const CampsListPage = (): React.ReactElement => {
duration: 3000,
});
}
onDeleteModalClose();
setCampToDelete(null);
};

Expand All @@ -89,7 +88,7 @@ const CampsListPage = (): React.ReactElement => {
buttonLabel="Remove"
isOpen={isDeleteModalOpen}
onClose={onDeleteModalClose}
onDelete={() => handleConfirmDelete()}
onDelete={handleConfirmDelete}
/>
<Flex
width={isDrawerOpen ? "calc(100% - 500px)" : "100%"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ const CamperCard = ({
isClosable: false,
variant: "subtle",
});
onClose();
},
});

Expand Down