import { useState } from "react"; import { Paintbrush } from "lucide-react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { Input } from "@/components/ui/input"; import Loading from "@/components/loading"; import { api } from "@/lib/api"; export function ReImagine({ onRedesign, }: { onRedesign: (md: string) => void; }) { const [url, setUrl] = useState(""); const [open, setOpen] = useState(false); const [isLoading, setIsLoading] = useState(false); const checkIfUrlIsValid = (url: string) => { const urlPattern = new RegExp( /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/, "i" ); return urlPattern.test(url); }; const handleClick = async () => { if (isLoading) return; // Prevent multiple clicks while loading if (!url) { toast.error("Please enter a URL."); return; } if (!checkIfUrlIsValid(url)) { toast.error("Please enter a valid URL."); return; } // TODO implement the API call to redesign the site // Here you would typically handle the re-design logic setIsLoading(true); // const request = await api.post("/api/re-design", { // method: "POST", // body: JSON.stringify({ url }), // headers: { // "Content-Type": "application/json", // }, // }); // const response = await request.json(); // if (response.ok) { // setOpen(false); // setUrl(""); // onRedesign(response.markdown); // toast.success("DeepSite is redesigning your site! Let him cook... 🔥"); // } else { // toast.error(response.message || "Failed to redesign the site."); // } setIsLoading(false); }; return (
🎨
🥳
💎

Redesign your Site!

Try our new Redesign feature to give your site a fresh look.

Enter your website URL to get started:

setUrl(e.target.value)} onBlur={(e) => { const inputUrl = e.target.value.trim(); if (!inputUrl) { setUrl(""); return; } if (!checkIfUrlIsValid(inputUrl)) { toast.error("Please enter a valid URL."); return; } setUrl(inputUrl); }} className="!bg-white !border-neutral-300 !text-neutral-800 !placeholder:text-neutral-400 selection:!bg-blue-100" />

Then, let's redesign it!

); }