-
-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/complete onboarding form #1216
base: develop
Are you sure you want to change the base?
Changes from 9 commits
c3319dc
9e7d0d2
133d182
a98c1ce
eda596b
cb5fed7
2028ef8
f87c10d
1267ea8
b1aed86
aed148f
1d1eeca
5d05a0b
724c155
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
"use client"; | ||
import { SessionProvider } from "next-auth/react"; | ||
import { SessionProvider, useSession } from "next-auth/react"; | ||
import { useRouter } from "next/navigation"; | ||
import { useEffect } from "react"; | ||
|
||
export default function AuthProvider({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return <SessionProvider>{children}</SessionProvider>; | ||
return ( | ||
<SessionProvider> | ||
<OnboardingCheck>{children}</OnboardingCheck> | ||
</SessionProvider> | ||
); | ||
} | ||
|
||
function OnboardingCheck({ children }: { children: React.ReactNode }) { | ||
const { data: session, status } = useSession(); | ||
const router = useRouter(); | ||
|
||
console.log("-------------"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log |
||
|
||
useEffect(() => { | ||
if (status === "authenticated" && !session?.user?.isOnboardingComplete) { | ||
router.push("/onboarding"); | ||
} | ||
}, [status, session, router]); | ||
John-Paul-Larkin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return <>{children}</>; | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,3 @@ | ||||||||||
ALTER TABLE "session" ADD PRIMARY KEY ("sessionToken");--> statement-breakpoint | ||||||||||
ALTER TABLE "user" ADD COLUMN "yearsOfExperience" text;--> statement-breakpoint | ||||||||||
ALTER TABLE "user" ADD COLUMN "onboardingComplete" timestamp with time zone; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider strengthening column definitions The current column definitions could be improved:
Consider this alternative implementation: -ALTER TABLE "user" ADD COLUMN "yearsOfExperience" text;
-ALTER TABLE "user" ADD COLUMN "onboardingComplete" timestamp with time zone;
+ALTER TABLE "user" ADD COLUMN "yearsOfExperience" integer CHECK ("yearsOfExperience" >= 0 AND "yearsOfExperience" <= 50);
+ALTER TABLE "user" ADD COLUMN "onboardingComplete" timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP; 📝 Committable suggestion
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider moving timestamp generation to database level
Instead of generating the timestamp in the application code, consider letting the database handle it for better consistency and reliability across all onboarding completions.