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

add case when no fields exists #711

Merged
merged 1 commit into from
Aug 1, 2024
Merged
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
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
Loading