Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 167
Feature/complete onboarding form#1216
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
c3319dc9e7d0d2133d182a98c1ceeda596bcb5fed72028ef8f87c10d1267ea8b1aed86aed148f1d1eeca5d05a0b724c155File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,29 @@ | ||
| "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(); | ||
| useEffect(() => { | ||
| if (status === "authenticated" && !session?.user?.isOnboardingComplete) { | ||
| router.push("/onboarding"); | ||
| } | ||
| }, [status, session, router]); | ||
John-Paul-Larkin marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return <>{children}</>; | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||||
| DO $$ BEGIN | ||||||||||
| CREATE TYPE "public"."experience_range" AS ENUM('0-1', '1-3', '3-5', '5-8', '12+'); | ||||||||||
| EXCEPTION | ||||||||||
| WHEN duplicate_object THEN null; | ||||||||||
| END $$; | ||||||||||
| --> statement-breakpoint | ||||||||||
| ALTER TABLE "session" ADD PRIMARY KEY ("sessionToken");--> statement-breakpoint | ||||||||||
| ALTER TABLE "user" ADD COLUMN "yearsOfExperience" "experience_range";--> statement-breakpoint | ||||||||||
| ALTER TABLE "user" ADD COLUMN "onboardingComplete" timestamp with time zone; | ||||||||||
Comment on lines
+8
to
+9
Contributor 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 Strengthen column definitions for data integrity The current column definitions could be improved to ensure data consistency:
Consider this alternative implementation: -ALTER TABLE "user" ADD COLUMN "yearsOfExperience" "experience_range";-ALTER TABLE "user" ADD COLUMN "onboardingComplete" timestamp with time zone;+ALTER TABLE "user" ADD COLUMN "yearsOfExperience" "experience_range" NOT NULL DEFAULT '0-1';+ALTER TABLE "user" ADD COLUMN "onboardingComplete" timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP;Note: The default value for 📝 Committable suggestion
Suggested change
| ||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.