-
-
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 all 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,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.
Show resolved
Hide resolved
|
||
|
||
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
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
|
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.