import { ArrowRight } from "lucide-react"; import { type ReactNode, useEffect, useState } from "react"; import { App, Button, Image, Tag } from "antd"; import { useNavigate } from "react-router-dom"; import { Trans, useTranslation } from "react-i18next"; import { fetchPrompts, type Prompt } from "@/services/api/prompts"; import { navigationTools } from "@/constant/navigation-tools"; import i18n from "@/i18n"; import { cn } from "@/lib/utils"; function Highlighter({ action, color, children }: { action: "highlight" | "underline"; color: string; children?: ReactNode }) { return ( {action === "highlight" ? ( ) : ( )} {children} ); } export default function IndexPage() { const { message } = App.useApp(); const { t } = useTranslation(); const navigate = useNavigate(); const [primaryTool] = navigationTools; const [promptShowcase, setPromptShowcase] = useState([]); const [previewIndex, setPreviewIndex] = useState(0); const [previewOpen, setPreviewOpen] = useState(false); useEffect(() => { void fetchPrompts({ pageSize: 12 }) .then((data) => setPromptShowcase(data.items)) .catch((error) => message.error(error instanceof Error ? error.message : i18n.t("home.promptError"))); }, [message]); return ( {t("meta.title")} , content: }} /> navigate(`/${primaryTool.slug}`)} icon={} iconPlacement="end"> {t("home.start")} navigate("/canvas")}> {t("home.openCanvas")} {t("home.showcaseTitle")} {t("home.showcaseDescription")} navigate("/prompts")} className="justify-self-center md:justify-self-end" icon={} iconPlacement="end"> {t("home.viewPrompts")} {promptShowcase.map((item, index) => ( { setPreviewIndex(index); setPreviewOpen(true); }} className={cn( "group relative cursor-pointer overflow-hidden border border-stone-200 bg-stone-100 text-left dark:border-stone-800 dark:bg-stone-900", index === 0 && "md:col-span-2 md:row-span-2", index === 3 && "md:col-span-2", )} > {item.tags.slice(0, 2).map((tag) => ( {tag} ))} {item.title} {item.prompt} ))} {promptShowcase.map((item) => ( ))} ); }
, content: }} />
{t("home.showcaseDescription")}
{item.prompt}