diff --git a/servers/nextjs/app/(presentation-generator)/presentation/components/Header.tsx b/servers/nextjs/app/(presentation-generator)/presentation/components/Header.tsx index 63e0daaa..06c68e8c 100644 --- a/servers/nextjs/app/(presentation-generator)/presentation/components/Header.tsx +++ b/servers/nextjs/app/(presentation-generator)/presentation/components/Header.tsx @@ -231,7 +231,7 @@ const Header = ({ }; const downloadLink = (url: string) => { const link = document.createElement("a"); - link.href = url; + link.href = `file://${url}`; // Append to document, trigger click and remove document.body.appendChild(link); link.click(); @@ -248,6 +248,11 @@ const Header = ({ const data = await PresentationGenerationApi.exportAsPDF(apiBody); if (data.url) { + toast({ + title: "Presentation exported successfully", + description: `Please check this path ${data.url}`, + variant: "default", + }); downloadLink(data.url); } setShowLoader(false); @@ -329,7 +334,7 @@ const Header = ({ /> - + Presentation logo {
{pathname !== '/upload' && } - + Presentation logo {
- {/* {pathname !== '/dashboard' && - Dashboard - } */} -
diff --git a/servers/nextjs/app/page.tsx b/servers/nextjs/app/page.tsx index 30cc3dd6..25390701 100644 --- a/servers/nextjs/app/page.tsx +++ b/servers/nextjs/app/page.tsx @@ -1,10 +1,16 @@ "use client"; -import { useState } from "react"; +import { useState, useEffect } from "react"; import { useRouter } from "next/navigation"; import { toast } from "@/hooks/use-toast"; -import { Info, ExternalLink, PlayCircle } from "lucide-react"; +import { Info, ExternalLink, PlayCircle, Loader2 } from "lucide-react"; import Link from "next/link"; import { getEnv } from "@/utils/constant"; +import { + Accordion, + AccordionContent, + AccordionItem, + AccordionTrigger, +} from "@/components/ui/accordion"; interface ModelOption { value: string; @@ -89,10 +95,9 @@ interface ConfigState { imageModel: string; } - export default function Home() { - const urls = getEnv(); const router = useRouter(); + const [isLoading, setIsLoading] = useState(true); const [config, setConfig] = useState({ provider: "openai", apiKey: "", @@ -100,6 +105,51 @@ export default function Home() { imageModel: PROVIDER_CONFIGS.openai.imageModels[0].value, }); + useEffect(() => { + const checkExistingConfig = async () => { + try { + const urls = getEnv(); + const userConfigPath = urls.USER_CONFIG_PATH; + + if (!userConfigPath) { + console.error("User config path not found"); + setIsLoading(false); + return; + } + + const response = await fetch(`/api/read-config?path=${encodeURIComponent(userConfigPath)}`); + if (!response.ok) { + throw new Error('Failed to load configuration'); + } + + const { config: savedConfig } = await response.json(); + + // If either API key exists, redirect to upload + if (savedConfig?.OPENAI_API_KEY || savedConfig?.GOOGLE_API_KEY) { + router.push('/upload'); + } else { + setIsLoading(false); + } + } catch (error) { + console.error("Error checking config:", error); + setIsLoading(false); + } + }; + + checkExistingConfig(); + }, [router]); + + if (isLoading) { + return ( +
+
+ +

Loading configuration...

+
+
+ ); + } + const handleProviderChange = (provider: string) => { setConfig((prev) => ({ ...prev, @@ -130,7 +180,7 @@ export default function Home() { } try { - const userConfigPath = urls.USER_CONFIG_PATH; + const userConfigPath = getEnv().USER_CONFIG_PATH; if (!userConfigPath) { toast({ @@ -172,7 +222,7 @@ export default function Home() { }; return ( -
+
{/* Branding Header */}
@@ -259,46 +309,51 @@ export default function Home() {
{/* API Guide Section */} -
-
- -

- {currentProvider.apiGuide.title} -

-
+ + + +
+ +

+ {currentProvider.apiGuide.title} +

+
+
+ +
+
    + {currentProvider.apiGuide.steps.map((step, index) => ( +
  1. + {step} +
  2. + ))} +
-
-
    - {currentProvider.apiGuide.steps.map((step, index) => ( -
  1. - {step} -
  2. - ))} -
- -
- {currentProvider.apiGuide.videoUrl && ( - - - Watch Video Tutorial - - - )} - - Official Documentation - - -
-
-
+
+ {currentProvider.apiGuide.videoUrl && ( + + + Watch Video Tutorial + + + )} + + Official Documentation + + +
+
+ + + {/* Save Button */}