presenton/servers/nextjs/components/Home.tsx
sudipnext 4c271170b5 feat: Add chat history management and asset generation features
- Introduced a new `ChatHistoryMessageModel` to persist chat messages in the database.
- Implemented a migration script to create the `chat_history_messages` table.
- Enhanced chat services to support storing and retrieving chat history.
- Added functionality for generating multiple media assets in a single API call.
- Updated the chat UI to display assistant activities and tool usage more effectively.
- Refactored API calls to use absolute URLs for better reliability.
2026-04-26 13:12:50 +05:45

76 lines
2.6 KiB
TypeScript

"use client";
import { useState, useEffect, useMemo } from "react";
import { useRouter } from "next/navigation";
import { toast } from "sonner";
import { useSelector } from "react-redux";
import { RootState } from "@/store/store";
import { handleSaveLLMConfig } from "@/utils/storeHelpers";
import {
checkIfSelectedOllamaModelIsPulled,
pullOllamaModel,
} from "@/utils/providerUtils";
import { LLMConfig } from "@/types/llm_config";
import { trackEvent, MixpanelEvent } from "@/utils/mixpanel";
import { usePathname } from "next/navigation";
import OnBoardingSlidebar from "./OnBoarding/OnBoardingSlidebar";
import OnBoardingHeader from "./OnBoarding/OnBoardingHeader";
import ModeSelectStep from "./OnBoarding/ModeSelectStep";
import PresentonMode from "./OnBoarding/PresentonMode";
import GenerationWithImage from "./OnBoarding/GenerationWithImage";
import FinalStep from "./OnBoarding/FinalStep";
// Button state interface
interface ButtonState {
isLoading: boolean;
isDisabled: boolean;
text: string;
showProgress: boolean;
progressPercentage?: number;
status?: string;
}
export default function Home() {
const router = useRouter();
const [step, setStep] = useState<number>(1)
const [selectedMode, setSelectedMode] = useState<string>("presenton")
const config = useSelector((state: RootState) => state.userConfig);
const canChangeKeys = config.can_change_keys;
useEffect(() => {
if (!canChangeKeys) {
router.push("/upload");
}
}, [canChangeKeys, router]);
if (!canChangeKeys) {
return null;
}
return (
<div className="flex min-h-screen relative">
<div
className="fixed z-0 -bottom-[14.5rem] left-0 w-full h-full pointer-events-none"
aria-hidden
style={{
height: "341px",
borderRadius: '1440px',
background: 'radial-gradient(5.92% 104.69% at 50% 100%, rgba(122, 90, 248, 0.00) 0%, rgba(255, 255, 255, 0.00) 100%), radial-gradient(50% 50% at 50% 50%, rgba(122, 90, 248, 0.80) 0%, rgba(122, 90, 248, 0.00) 100%)',
}}
/>
<OnBoardingSlidebar step={step} />
<main className="w-full pl-20 pr-8 max-w-[1440px] mx-auto relative z-10">
<OnBoardingHeader currentStep={step} setStep={setStep} />
{step === 1 && <ModeSelectStep selectedMode={selectedMode} setStep={setStep} setSelectedMode={setSelectedMode} />}
{step === 2 && selectedMode === "presenton" && <PresentonMode currentStep={step} setStep={setStep} />}
{step === 2 && selectedMode === "image" && <GenerationWithImage />}
{step === 3 && <FinalStep />}
</main>
</div>
);
}