From 769ac099bb0152d0cc32f4fee8bfee8d7e272e76 Mon Sep 17 00:00:00 2001 From: Diego Alzate Date: Thu, 1 Aug 2024 17:29:00 +0100 Subject: [PATCH] add case when no fields exists --- packages/berlin/src/pages/Register.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/berlin/src/pages/Register.tsx b/packages/berlin/src/pages/Register.tsx index 6ecd7b7b..62877670 100644 --- a/packages/berlin/src/pages/Register.tsx +++ b/packages/berlin/src/pages/Register.tsx @@ -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); @@ -88,7 +99,7 @@ function Register() { } return 0; - }, [groupCategories, usersToGroups]); + }, [groupCategories, usersToGroups, event]); if (isLoading) { return Loading...;