diff --git a/public/images/icons8-wand.gif b/public/images/icons8-wand.gif new file mode 100644 index 000000000..621b405e3 Binary files /dev/null and b/public/images/icons8-wand.gif differ diff --git a/src/components/GenerateRoadmap/GenerateRoadmap.tsx b/src/components/GenerateRoadmap/GenerateRoadmap.tsx index 6147d3eaf..d2b0b7313 100644 --- a/src/components/GenerateRoadmap/GenerateRoadmap.tsx +++ b/src/components/GenerateRoadmap/GenerateRoadmap.tsx @@ -7,18 +7,24 @@ import { renderFlowJSON } from '../../../editor/renderer/renderer'; import { replaceChildren } from '../../lib/dom'; import { readAIRoadmapStream } from '../../helper/read-stream'; import { removeAuthToken } from '../../lib/jwt'; +import { RoadmapSearch } from './RoadmapSearch.tsx'; +import { Spinner } from '../ReactIcons/Spinner.tsx'; +import { Download, PenSquare, Wand } from 'lucide-react'; +import { ShareRoadmapButton } from '../ShareRoadmapButton.tsx'; export function GenerateRoadmap() { const roadmapContainerRef = useRef(null); const toast = useToast(); + const [hasSubmitted, setHasSubmitted] = useState(false); const [isLoading, setIsLoading] = useState(false); - const [roadmapName, setRoadmapName] = useState(''); + const [roadmapTopic, setRoadmapTopic] = useState(''); const handleSubmit = async (e: FormEvent) => { e.preventDefault(); setIsLoading(true); + setHasSubmitted(true); const response = await fetch( `${import.meta.env.PUBLIC_API_URL}/v1-generate-ai-roadmap`, @@ -28,7 +34,7 @@ export function GenerateRoadmap() { 'Content-Type': 'application/json', }, credentials: 'include', - body: JSON.stringify({ title: roadmapName }), + body: JSON.stringify({ title: roadmapTopic }), }, ); @@ -64,42 +70,77 @@ export function GenerateRoadmap() { setIsLoading(false); }; - return ( -
-
-
- - - setRoadmapName((e.target as HTMLInputElement).value) - } - /> -
- -
+ if (!hasSubmitted) { + return ( + + ); + } -
+ return ( +
+
+ {isLoading && ( + + + Generating roadmap .. + + )} + {!isLoading && ( +
+
+ + 0 of 5 roadmaps generated + +
+
+ + setRoadmapTopic((e.target as HTMLInputElement).value) + } + /> + +
+
+
+ + +
+ +
+
+ )} +
+
); } diff --git a/src/components/GenerateRoadmap/RoadmapSearch.tsx b/src/components/GenerateRoadmap/RoadmapSearch.tsx new file mode 100644 index 000000000..f0be53819 --- /dev/null +++ b/src/components/GenerateRoadmap/RoadmapSearch.tsx @@ -0,0 +1,51 @@ +import { Wand } from 'lucide-react'; +import type { FormEvent } from 'react'; + +type RoadmapSearchProps = { + roadmapTopic: string; + setRoadmapTopic: (topic: string) => void; + handleSubmit: (e: FormEvent) => void; +}; + +export function RoadmapSearch(props: RoadmapSearchProps) { + const { roadmapTopic, setRoadmapTopic, handleSubmit } = props; + + return ( +
+
+

+ Generate roadmaps with AI +

+

+ Enter a topic and let the AI generate a roadmap for you +

+
+
+ setRoadmapTopic((e.target as HTMLInputElement).value)} + /> + +
+
+

+ You have generated 0 of 5{' '} + roadmaps today.{' '} + +

+
+
+ ); +} diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 5baa80f82..ae3adfc96 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -149,7 +149,7 @@ const gaPageIdentifier = Astro.url.pathname ) } - +