Skip to content

Commit 10e9889

Browse files
committed
Implemented onboarding page
1 parent 7979fd2 commit 10e9889

File tree

8 files changed

+59
-6
lines changed

8 files changed

+59
-6
lines changed

app/(auth)/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function AuthLayout({
1212
children: React.ReactNode;
1313
}) {
1414
return (
15-
<main className="flex min-h-screen w-full items-center justify-center">
15+
<main className="flex min-h-screen w-full items-center justify-center bg-auth-light bg-cover bg-center bg-no-repeat dark:bg-auth-dark">
1616
{children}
1717
</main>
1818
);

app/(auth)/onboarding/page.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { auth } from "@clerk/nextjs";
2+
import { redirect } from "next/navigation";
3+
4+
import Profile from "@/components/forms/Profile";
5+
6+
import { getUserById } from "@/lib/actions/user.action";
7+
8+
const Page = async () => {
9+
const { userId } = auth();
10+
if (!userId) return null;
11+
12+
const mongoUser = await getUserById({ userId });
13+
if (mongoUser?.onboarded) redirect("/");
14+
15+
return (
16+
<>
17+
<main className="mx-auto flex max-w-3xl flex-col justify-start px-10 py-20">
18+
<h1 className="h1-bold text-dark100_light900">Onboarding</h1>
19+
<p className="base-medium text-dark100_light900 mt-3">
20+
Complete your profile now to use DevOverflow
21+
</p>
22+
23+
<div className="background-light850_dark100 mt-9 p-10">
24+
<Profile clerkId={userId} user={JSON.stringify(mongoUser)} />
25+
</div>
26+
</main>
27+
</>
28+
);
29+
};
30+
31+
export default Page;

app/(root)/ask-question/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { auth } from "@clerk/nextjs";
2+
import { redirect } from "next/navigation";
23

34
import Question from "@/components/forms/Question";
45

@@ -17,6 +18,7 @@ const Page = async (props: Props) => {
1718
if (!userId) return null;
1819

1920
const mongoUser = await getUserById({ userId });
21+
if (!mongoUser?.onboarded) redirect("/onboarding");
2022

2123
return (
2224
<div>

app/(root)/collection/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { auth } from "@clerk/nextjs";
2+
import { redirect } from "next/navigation";
23

34
import LocalSearchbar from "@/components/shared/search/LocalSearchbar";
45
import Filter from "@/components/shared/Filter";
56
import NoResult from "@/components/shared/NoResult";
67
import Pagination from "@/components/shared/Pagination";
78
import QuestionCard from "@/components/cards/QuestionCard";
89

9-
import { getSavedQuestions } from "@/lib/actions/user.action";
10+
import { getSavedQuestions, getUserById } from "@/lib/actions/user.action";
1011

1112
import { QuestionFilters } from "@/constants/filters";
1213

@@ -22,6 +23,9 @@ export default async function Collection({ searchParams }: SearchParamsProps) {
2223

2324
if (!clerkId) return null;
2425

26+
const mongoUser = await getUserById({ userId: clerkId });
27+
if (!mongoUser?.onboarded) redirect("/onboarding");
28+
2529
const result = await getSavedQuestions({
2630
clerkId,
2731
searchQuery: searchParams.q,

app/(root)/edit-answer/[id]/page.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { redirect } from "next/navigation";
2-
31
import { auth } from "@clerk/nextjs";
2+
import { redirect } from "next/navigation";
43

54
import Answer from "@/components/forms/Answer";
65

6+
import { getUserById } from "@/lib/actions/user.action";
77
import { getAnswerById } from "@/lib/actions/answer.action";
88

99
import type { ParamsProps } from "@/types";
@@ -18,6 +18,9 @@ const Page = async ({ params }: ParamsProps) => {
1818

1919
if (!userId) return null;
2020

21+
const mongoUser = await getUserById({ userId });
22+
if (!mongoUser?.onboarded) redirect("/onboarding");
23+
2124
const result = await getAnswerById({ answerId: params.id });
2225

2326
if (userId !== result.author.clerkId) redirect("/");

app/(root)/profile/edit/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { auth } from "@clerk/nextjs";
2+
import { redirect } from "next/navigation";
23

34
import Profile from "@/components/forms/Profile";
45

@@ -17,6 +18,7 @@ const Page = async ({ params }: ParamsProps) => {
1718
if (!userId) return null;
1819

1920
const mongoUser = await getUserById({ userId });
21+
if (!mongoUser?.onboarded) redirect("/onboarding");
2022

2123
return (
2224
<>

app/(root)/question/edit/[id]/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { auth } from "@clerk/nextjs";
2+
import { redirect } from "next/navigation";
23

34
import Question from "@/components/forms/Question";
45

@@ -18,6 +19,7 @@ const Page = async ({ params }: ParamsProps) => {
1819
if (!userId) return null;
1920

2021
const mongoUser = await getUserById({ userId });
22+
if (!mongoUser?.onboarded) redirect("/onboarding");
2123

2224
const result = await getQuestionById({ questionId: params.id });
2325

middleware.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@ import { authMiddleware } from "@clerk/nextjs";
44
// Please edit this to allow other routes to be public as needed.
55
// See https://clerk.com/docs/references/nextjs/auth-middleware for more information about configuring your Middleware
66
export default authMiddleware({
7-
publicRoutes: ["/", "/api/webhook/clerk"],
8-
ignoredRoutes: ["/api/webhook/clerk"],
7+
publicRoutes: [
8+
"/",
9+
"/api/webhook/clerk",
10+
"/question/:id",
11+
"/tags",
12+
"/tags/:id",
13+
"/profile/:id",
14+
"/community",
15+
"/jobs",
16+
],
17+
ignoredRoutes: ["/api/webhook/clerk", "/api/openai"],
918
});
1019

1120
export const config = {

0 commit comments

Comments
 (0)