From c62d84e34e7dab71638859e280ce7765fa3a8faf Mon Sep 17 00:00:00 2001 From: psiddharthdesign <107192927+psiddharthdesign@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:36:23 +0530 Subject: [PATCH] testing/logging onboarding pages --- .../(authenticated-pages)/onboarding/OnboardingFlow.tsx | 6 +++++- .../onboarding/OrganizationCreation.tsx | 5 +++-- .../(authenticated-pages)/onboarding/ProfileUpdate.tsx | 4 ++++ .../(authenticated-pages)/onboarding/TermsAcceptance.tsx | 2 ++ src/middleware.ts | 5 +++++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/OnboardingFlow.tsx b/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/OnboardingFlow.tsx index 369c6baf..da096288 100644 --- a/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/OnboardingFlow.tsx +++ b/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/OnboardingFlow.tsx @@ -41,9 +41,13 @@ export function UserOnboardingFlow({ setCurrentStep(flowStates[currentIndex + 1]); } }, [currentStep, flowStates]); + console.log('flowStates : ', flowStates); useEffect(() => { if (currentStep === "COMPLETE") { + console.log('currentStep is COMPLETE', currentStep); + console.log('onboardingStatus : ', onboardingStatus); + console.log('now redirecting to /dashboard'); replace("/dashboard"); } }, [currentStep, replace]); @@ -54,7 +58,7 @@ export function UserOnboardingFlow({ exit: { opacity: 0, y: -50 }, }; - console.log(currentStep) + console.log('currentStep in OnboardingFlow : ', currentStep) return ( diff --git a/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/OrganizationCreation.tsx b/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/OrganizationCreation.tsx index 75876368..1627fd84 100644 --- a/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/OrganizationCreation.tsx +++ b/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/OrganizationCreation.tsx @@ -34,13 +34,14 @@ export function OrganizationCreation({ onSuccess }: OrganizationCreationProps) { toast({ title: "Organization created!", description: "Your new organization is ready." }); onSuccess(); }, - onError: () => { + onError: (error) => { + console.log('Failed to create organization. reason : ', error); toast({ title: "Failed to create organization", description: "Please try again.", variant: "destructive" }); }, }); const onSubmit = (data: CreateOrganizationSchema) => { - console.log('submitting'); + console.log('submitting data : ', data); createOrgMutation.mutate(data); }; diff --git a/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/ProfileUpdate.tsx b/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/ProfileUpdate.tsx index c6a1d832..8784a6e8 100644 --- a/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/ProfileUpdate.tsx +++ b/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/ProfileUpdate.tsx @@ -33,10 +33,12 @@ export function ProfileUpdate({ const updateProfileMutation = useMutation({ mutationFn: () => updateUserProfileNameAndAvatar({ fullName, avatarUrl }, { isOnboardingFlow: true }), onSuccess: () => { + console.log('Profile updated!'); toast({ title: "Profile updated!", description: "Your profile has been successfully updated." }); onSuccess(); }, onError: () => { + console.log('Failed to update profile'); toast({ title: "Failed to update profile", description: "Please try again.", variant: "destructive" }); }, }); @@ -50,10 +52,12 @@ export function ProfileUpdate({ onSuccess: (response) => { if (response.status === 'success') { setAvatarUrl(response.data); + console.log('Avatar uploaded!'); toast({ title: "Avatar uploaded!", description: "Your new avatar has been set." }); } }, onError: () => { + console.log('Failed to upload avatar'); toast({ title: "Error uploading avatar", description: "Please try again.", variant: "destructive" }); }, }); diff --git a/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/TermsAcceptance.tsx b/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/TermsAcceptance.tsx index a7c5a6ab..8c291528 100644 --- a/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/TermsAcceptance.tsx +++ b/src/app/(dynamic-pages)/(authenticated-pages)/onboarding/TermsAcceptance.tsx @@ -14,10 +14,12 @@ export function TermsAcceptance({ onSuccess }: TermsAcceptanceProps) { const acceptTermsMutation = useMutation({ mutationFn: () => acceptTermsOfService(true), onSuccess: () => { + console.log('Terms accepted!'); toast({ title: "Terms accepted!", description: "Welcome aboard!" }); onSuccess(); }, onError: () => { + console.log('Failed to accept terms'); toast({ title: "Failed to accept terms", description: "Please try again.", variant: "destructive" }); }, }); diff --git a/src/middleware.ts b/src/middleware.ts index b764838e..5596ee5b 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -85,10 +85,15 @@ export async function middleware(req: NextRequest) { // user is possibly logged in, but lets validate session const user = await supabase.auth.getUser(); if (user.error) { + console.log('user is not logged in. reason : ', user.error); return NextResponse.redirect(toSiteURL('/login')); } } if (!isUnprotectedPage(req.nextUrl.pathname) && !maybeUser) { + console.log( + 'protected page but user is not logged in. reason : ', + maybeUser, + ); return NextResponse.redirect(toSiteURL('/login')); } if (