From df14d4e2f9a3752fda241cf0bac1de54abbfa49e Mon Sep 17 00:00:00 2001 From: Kariamos Date: Mon, 25 Aug 2025 11:14:44 +0200 Subject: [PATCH 1/4] fix: include templateId in the basicInfo object during form submission --- src/pages/JoinPage/useJoinSubmit.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/JoinPage/useJoinSubmit.tsx b/src/pages/JoinPage/useJoinSubmit.tsx index c173e3a20..027696ee0 100644 --- a/src/pages/JoinPage/useJoinSubmit.tsx +++ b/src/pages/JoinPage/useJoinSubmit.tsx @@ -28,6 +28,7 @@ export function useJoinSubmit(isInvited: boolean) { surname: values.surname, roleId: values.roleId, companySizeId: values.companySizeId, + templateId: searchParams.get('template'), }; sendGTMevent({ event: 'sign-up-flow', From d986cf3fb733c791994aa10e27c5509b8d06a5f9 Mon Sep 17 00:00:00 2001 From: Kariamos Date: Mon, 25 Aug 2025 11:54:39 +0200 Subject: [PATCH 2/4] fix: ensure templateId is converted to a number during form submission --- src/pages/JoinPage/useJoinSubmit.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/JoinPage/useJoinSubmit.tsx b/src/pages/JoinPage/useJoinSubmit.tsx index 027696ee0..46383b686 100644 --- a/src/pages/JoinPage/useJoinSubmit.tsx +++ b/src/pages/JoinPage/useJoinSubmit.tsx @@ -15,6 +15,12 @@ export function useJoinSubmit(isInvited: boolean) { const { token, profile } = useParams(); const sendGTMevent = useSendGTMevent({ loggedUser: false }); + const templateId = Number(searchParams.get('template')); + + if (!Number.isInteger(templateId)) { + throw new Error('Template must be an integer'); + } + const onSubmit = useCallback( async ( values: JoinFormValues, @@ -28,7 +34,7 @@ export function useJoinSubmit(isInvited: boolean) { surname: values.surname, roleId: values.roleId, companySizeId: values.companySizeId, - templateId: searchParams.get('template'), + templateId, }; sendGTMevent({ event: 'sign-up-flow', From cb6d36f931092ef702afe8692c562b4953296bb8 Mon Sep 17 00:00:00 2001 From: Kariamos Date: Mon, 25 Aug 2025 12:04:17 +0200 Subject: [PATCH 3/4] fix: refactor templateId handling to ensure proper validation and assignment --- src/pages/JoinPage/useJoinSubmit.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pages/JoinPage/useJoinSubmit.tsx b/src/pages/JoinPage/useJoinSubmit.tsx index 46383b686..8c620c2eb 100644 --- a/src/pages/JoinPage/useJoinSubmit.tsx +++ b/src/pages/JoinPage/useJoinSubmit.tsx @@ -15,10 +15,15 @@ export function useJoinSubmit(isInvited: boolean) { const { token, profile } = useParams(); const sendGTMevent = useSendGTMevent({ loggedUser: false }); - const templateId = Number(searchParams.get('template')); + const templateParam = searchParams.get('template'); + let templateId: number | undefined; - if (!Number.isInteger(templateId)) { - throw new Error('Template must be an integer'); + if (templateParam !== null) { + const parsed = Number(templateParam); + if (!Number.isInteger(parsed)) { + throw new Error('Template must be an integer'); + } + templateId = parsed; } const onSubmit = useCallback( @@ -34,8 +39,9 @@ export function useJoinSubmit(isInvited: boolean) { surname: values.surname, roleId: values.roleId, companySizeId: values.companySizeId, - templateId, + ...(templateId !== undefined && { templateId }), }; + sendGTMevent({ event: 'sign-up-flow', category: `is invited: ${isInvited}`, From 6c735664925f7984c8096314d9b0eecf44446941 Mon Sep 17 00:00:00 2001 From: Kariamos Date: Mon, 25 Aug 2025 13:06:36 +0200 Subject: [PATCH 4/4] fix: handle non-integer templateId by removing it from search params and reloading the page --- src/pages/JoinPage/useJoinSubmit.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/JoinPage/useJoinSubmit.tsx b/src/pages/JoinPage/useJoinSubmit.tsx index 8c620c2eb..675c8f012 100644 --- a/src/pages/JoinPage/useJoinSubmit.tsx +++ b/src/pages/JoinPage/useJoinSubmit.tsx @@ -21,7 +21,10 @@ export function useJoinSubmit(isInvited: boolean) { if (templateParam !== null) { const parsed = Number(templateParam); if (!Number.isInteger(parsed)) { - throw new Error('Template must be an integer'); + searchParams.delete('template'); + const url = window.location.origin + window.location.pathname; + window.history.replaceState({}, '', url); + window.location.reload(); } templateId = parsed; }