/* eslint-disable @typescript-eslint/no-explicit-any */ import { useState } from "react"; import { toast } from "sonner"; import SpaceIcon from "@/assets/space.svg"; import Loading from "../loading/loading"; import Login from "../login/login"; import { Auth } from "./../../../utils/types"; import LoadButton from "../load-button/load-button"; import { Button } from "../ui/button"; import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover"; const MsgToast = ({ url }: { url: string }) => (
Your space is live!
); function DeployButton({ html, auth, setHtml, prompts, }: { html: string; auth?: Auth; setHtml: (html: string) => void; prompts: string[]; }) { const [loading, setLoading] = useState(false); const [path, setPath] = useState(undefined); const [config, setConfig] = useState({ title: "", }); const createSpace = async () => { setLoading(true); try { const request = await fetch("/api/deploy", { method: "POST", body: JSON.stringify({ title: config.title, path, html, prompts, }), headers: { "Content-Type": "application/json", }, }); const response = await request.json(); if (response.ok) { toast.success( ); setPath(response.path); } else { toast.error(response.message); } } catch (err: any) { toast.error(err.message); } finally { setLoading(false); } }; return (
{!auth ? (

Host this project for free and share it with your friends.

) : ( <>
Space Icon Space Configure Deployment

{path ? ( Your space is live at{" "} huggingface.co/{path} . You can update it by deploying again. ) : ( "Deploy your project to a space on the Hub. Spaces are a way to share your project with the world." )}

{!path && ( )}
)}
); } export default DeployButton;