From 73e46ad0d6395b9dc376b29c1bab1551fe8cfd5c Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Sat, 20 Apr 2024 00:25:08 +0600 Subject: [PATCH] feat: add ai roadmap slug --- src/api/ai-roadmap.ts | 1 + src/components/GenerateRoadmap/GenerateRoadmap.tsx | 8 ++++++-- src/pages/ai/[aiRoadmapSlug].astro | 6 +++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/api/ai-roadmap.ts b/src/api/ai-roadmap.ts index 89610ec8d..944b120ed 100644 --- a/src/api/ai-roadmap.ts +++ b/src/api/ai-roadmap.ts @@ -6,6 +6,7 @@ export type GetAIRoadmapBySlugResponse = { term: string; title: string; data: string; + isAuthenticatedUser: boolean; }; export function aiRoadmapApi(context: APIContext) { diff --git a/src/components/GenerateRoadmap/GenerateRoadmap.tsx b/src/components/GenerateRoadmap/GenerateRoadmap.tsx index d7a36236e..e675fa2a1 100644 --- a/src/components/GenerateRoadmap/GenerateRoadmap.tsx +++ b/src/components/GenerateRoadmap/GenerateRoadmap.tsx @@ -91,10 +91,15 @@ type GetAIRoadmapResponse = { type GenerateRoadmapProps = { roadmapId?: string; slug?: string; + isAuthenticatedUser?: boolean; }; export function GenerateRoadmap(props: GenerateRoadmapProps) { - const { roadmapId: defaultRoadmapId, slug: defaultRoadmapSlug } = props; + const { + roadmapId: defaultRoadmapId, + slug: defaultRoadmapSlug, + isAuthenticatedUser = isLoggedIn(), + } = props; const roadmapContainerRef = useRef(null); @@ -130,7 +135,6 @@ export function GenerateRoadmap(props: GenerateRoadmapProps) { getOpenAIKey(), ); const isKeyOnly = IS_KEY_ONLY_ROADMAP_GENERATION; - const isAuthenticatedUser = isLoggedIn(); const renderRoadmap = async (roadmap: string) => { const { nodes, edges } = generateAIRoadmapFromText(roadmap); diff --git a/src/pages/ai/[aiRoadmapSlug].astro b/src/pages/ai/[aiRoadmapSlug].astro index faf8464b7..d37723669 100644 --- a/src/pages/ai/[aiRoadmapSlug].astro +++ b/src/pages/ai/[aiRoadmapSlug].astro @@ -26,5 +26,9 @@ const title = roadmap?.title || 'Roadmap AI'; --- - +