Skip to content

Commit

Permalink
feat: added loader for registration
Browse files Browse the repository at this point in the history
  • Loading branch information
akshatmittal61 committed Sep 22, 2023
1 parent 22fe653 commit 1e1b636
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
17 changes: 13 additions & 4 deletions components/Event/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,16 @@ const EventPopup: React.FC<EventPopupProps> = ({ event, onClose }) => {
try {
setRegistering(true);
const res = await participateInEventApi(event._id);
toast.success(`You have registered in ${res.data.event.name}`);
onClose();
setRegistering(false);
return Promise.resolve(
res.message ?? `You have registered in ${res.data.event.name}`
);
} catch (error: any) {
console.error(error);
toast.error(error?.message ?? "Something went wrong");
setIsInputDisabled(false);
setRegistering(false);
return Promise.reject(error?.message ?? "Something went wrong");
} finally {
setRegistering(false);
}
Expand Down Expand Up @@ -165,7 +169,7 @@ const EventPopup: React.FC<EventPopupProps> = ({ event, onClose }) => {
variant="subtitle"
style={{
textAlign: "center",
margin: "12px auto",
margin: "24px auto",
}}
>
You have already registered for this event
Expand All @@ -183,7 +187,12 @@ const EventPopup: React.FC<EventPopupProps> = ({ event, onClose }) => {
title="Register"
body={`Participate in ${event.name} as ${user?.name}?`}
onConfirm={() => {
participateAsIndividual();
// participateAsIndividual();
toast.promise(participateAsIndividual(), {
loading: "Registering...",
success: "Registered successfully!",
error: "Something went wrong",
});
}}
onCancel={onClose}
/>
Expand Down
4 changes: 2 additions & 2 deletions pages/admin/events/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ const AdminEventPage: React.FC = () => {
}
exportAsCSV(
parsedData,
`${eventDetails.name}-${
`${eventDetails.name}-registrations-${
eventDetails._id
}-${Date.now()} Registrations`
}-${Date.now()}`
);
};

Expand Down
5 changes: 1 addition & 4 deletions styles/pages/Event.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
display: flex;
justify-content: flex-start;
align-items: center;
flex-flow: row wrap;
gap: 20px;

@include responsive(phone) {
Expand All @@ -89,10 +90,6 @@
}
}

&-chips {
flex-flow: row wrap;
}

&-btn {
@include init-button();
}
Expand Down

0 comments on commit 1e1b636

Please sign in to comment.