Skip to content

Commit c5effe6

Browse files
committed
feat(challenges): implement GatedAIAssistant
1 parent 05e574c commit c5effe6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use server";
2+
3+
import { getAuthorizedUserInfo } from "@/lib/auth.rsc";
4+
import { AIAssistant, type AIAssistantProps } from "./ai-assistant";
5+
6+
export async function GatedAIAssistant({ questionId }: AIAssistantProps) {
7+
const userInfo = await getAuthorizedUserInfo(["*", "ai"]);
8+
if (!userInfo) {
9+
return null;
10+
}
11+
12+
return <AIAssistant questionId={questionId} />;
13+
}

app/(app)/challenges/[id]/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Metadata } from "next";
22
import { Suspense } from "react";
3-
import { AIAssistant } from "./_components/ai-assistant";
3+
import { GatedAIAssistant } from "./_components/gated-ai-assistant";
44
import Header from "./_components/header";
55
import HeaderSkeleton from "./_components/header/skeleton";
66
import PracticeIDE from "./_components/ide";
@@ -26,7 +26,9 @@ export default async function ChallengePage({
2626
<PracticeIDE id={id} />
2727
</Suspense>
2828

29-
<AIAssistant questionId={id} />
29+
<Suspense>
30+
<GatedAIAssistant questionId={id} />
31+
</Suspense>
3032
</div>
3133
);
3234
}

0 commit comments

Comments
 (0)