Skip to content

Commit

Permalink
add case when no fields exists
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoalzate committed Aug 1, 2024
1 parent 9ecf1b9 commit 769ac09
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/berlin/src/pages/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ function Register() {
});

const defaultStep = useMemo(() => {
const fields = fieldsSchema.safeParse(event?.fields);

if (!fields.success) {
return 0;
}

// if no fields exists then stay on group categories page
if (Object.values(fields).length === 0) {
return 0;
}

// check if the user is already in all required groups for the event
const requiredCategories = groupCategories?.filter((category) => category.required);
const userGroups = usersToGroups?.map((userToGroup) => userToGroup.group.groupCategoryId);
Expand All @@ -88,7 +99,7 @@ function Register() {
}

return 0;
}, [groupCategories, usersToGroups]);
}, [groupCategories, usersToGroups, event]);

if (isLoading) {
return <Subtitle>Loading...</Subtitle>;
Expand Down

0 comments on commit 769ac09

Please sign in to comment.