Skip to content

Commit

Permalink
testing/logging onboarding pages
Browse files Browse the repository at this point in the history
  • Loading branch information
psiddharthdesign committed Jul 22, 2024
1 parent d7b2e13 commit c62d84e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -54,7 +58,7 @@ export function UserOnboardingFlow({
exit: { opacity: 0, y: -50 },
};

console.log(currentStep)
console.log('currentStep in OnboardingFlow : ', currentStep)

return (
<AnimatePresence mode="wait">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
},
});
Expand All @@ -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" });
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
},
});
Expand Down
5 changes: 5 additions & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit c62d84e

Please sign in to comment.