feat: add ai roadmap slug

feat/ai-rdm-slug
Arik Chakma 7 months ago
parent 5d82c1080f
commit 73e46ad0d6
  1. 1
      src/api/ai-roadmap.ts
  2. 8
      src/components/GenerateRoadmap/GenerateRoadmap.tsx
  3. 6
      src/pages/ai/[aiRoadmapSlug].astro

@ -6,6 +6,7 @@ export type GetAIRoadmapBySlugResponse = {
term: string; term: string;
title: string; title: string;
data: string; data: string;
isAuthenticatedUser: boolean;
}; };
export function aiRoadmapApi(context: APIContext) { export function aiRoadmapApi(context: APIContext) {

@ -91,10 +91,15 @@ type GetAIRoadmapResponse = {
type GenerateRoadmapProps = { type GenerateRoadmapProps = {
roadmapId?: string; roadmapId?: string;
slug?: string; slug?: string;
isAuthenticatedUser?: boolean;
}; };
export function GenerateRoadmap(props: GenerateRoadmapProps) { export function GenerateRoadmap(props: GenerateRoadmapProps) {
const { roadmapId: defaultRoadmapId, slug: defaultRoadmapSlug } = props; const {
roadmapId: defaultRoadmapId,
slug: defaultRoadmapSlug,
isAuthenticatedUser = isLoggedIn(),
} = props;
const roadmapContainerRef = useRef<HTMLDivElement>(null); const roadmapContainerRef = useRef<HTMLDivElement>(null);
@ -130,7 +135,6 @@ export function GenerateRoadmap(props: GenerateRoadmapProps) {
getOpenAIKey(), getOpenAIKey(),
); );
const isKeyOnly = IS_KEY_ONLY_ROADMAP_GENERATION; const isKeyOnly = IS_KEY_ONLY_ROADMAP_GENERATION;
const isAuthenticatedUser = isLoggedIn();
const renderRoadmap = async (roadmap: string) => { const renderRoadmap = async (roadmap: string) => {
const { nodes, edges } = generateAIRoadmapFromText(roadmap); const { nodes, edges } = generateAIRoadmapFromText(roadmap);

@ -26,5 +26,9 @@ const title = roadmap?.title || 'Roadmap AI';
--- ---
<BaseLayout title={title}> <BaseLayout title={title}>
<GenerateRoadmap roadmapId={roadmap?.id} client:load /> <GenerateRoadmap
roadmapId={roadmap?.id}
isAuthenticatedUser={roadmap?.isAuthenticatedUser}
client:load
/>
</BaseLayout> </BaseLayout>

Loading…
Cancel
Save