CreateProfile modal is rendered during the onboarding on the twenty.com. platform, we will review the onSubmit method:
const onSubmit: SubmitHandler<Form> = useCallback( async (data) => { try { if (!currentWorkspaceMember?.id) { throw new Error('User is not logged in'); } if (!data.firstName || !data.lastName) { throw new Error('First name or last name is missing'); } await updateWorkspaceMemberSettings({ ... }); setCurrentWorkspaceMembers((members) => ... ); setCurrentUser((current) => { ... }); setNextOnboardingStatus(); } catch (error: any) { enqueueErrorSnackBar({ apolloError: CombinedGraphQLErrors.is(error) ? error : undefined, }); } }, [ ... ], );
This function is wrapped in a try/catch block and the error in the catch block is used in the enqueuErrorSnackBar. What’s this function for? let’s find out.