"use client"; import { useState } from "react"; import { Import } from "lucide-react"; import { Project } from "@/types"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import Loading from "@/components/loading"; import { Input } from "../ui/input"; import { toast } from "sonner"; import { useRouter } from "next/navigation"; export const LoadProject = ({ fullXsBtn = false, onSuccess, }: { fullXsBtn?: boolean; onSuccess: (project: Project) => void; }) => { const router = useRouter(); const [open, setOpen] = useState(false); const [url, setUrl] = useState(""); const [isLoading, setIsLoading] = useState(false); const handleClick = async () => { if (isLoading) return; // Prevent multiple clicks while loading if (!url) { toast.error("Please enter a URL."); return; } // The URL validation and parsing logic is removed as we are no longer using Hugging Face setIsLoading(true); try { // You will need to implement your own logic to import a project from a URL // For now, this will just display a success message toast.success("Project imported successfully!"); setOpen(false); setUrl(""); // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { if (error?.response?.data?.redirect) { return router.push(error.response.data.redirect); } toast.error( error?.response?.data?.error ?? "Failed to import the project." ); } finally { setIsLoading(false); } }; return (

Import a Project

Enter the URL of your project to import it.

Load HTML from your computer

{ const file = e.target.files?.[0]; if (file) { const reader = new FileReader(); reader.onload = (event) => { const htmlContent = event.target?.result as string; onSuccess({ html: htmlContent, prompts: [], title: "Imported Project", user_id: "local", space_id: "local" }); setOpen(false); }; reader.readAsText(file); } }} className="!bg-white !border-neutral-300 !text-neutral-800 !placeholder:text-neutral-400 selection:!bg-blue-100" />
OR

Enter your Project URL

setUrl(e.target.value)} className="!bg-white !border-neutral-300 !text-neutral-800 !placeholder:text-neutral-400 selection:!bg-blue-100" />

Then, let's import it!

); };