Mirrored from https://github.com/Camo67/OCIU-npo.git
Synced Nov 21, 06:00 UTC
fix/ociu-remove-placeholder-content
| 1 | import React, { useState } from 'react'; |
| 2 | import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; |
| 3 | import { Button } from "@/components/ui/button"; |
| 4 | import { Input } from "@/components/ui/input"; |
| 5 | import { Layout, Palette, Code, ExternalLink } from "lucide-react"; |
| 6 | import { toast } from "sonner"; |
| 7 | |
| 8 | export const WebsiteBuilder = () => { |
| 9 | const [description, setDescription] = useState(""); |
| 10 | const [isGenerating, setIsGenerating] = useState(false); |
| 11 | const [plan, setPlan] = useState<string | null>(null); |
| 12 | |
| 13 | const handleGenerate = async () => { |
| 14 | if (!description) { |
| 15 | toast.error("Please describe your website"); |
| 16 | return; |
| 17 | } |
| 18 | setIsGenerating(true); |
| 19 | try { |
| 20 | const response = await fetch('http://localhost:8000/api/agent/website', { |
| 21 | method: 'POST', |
| 22 | headers: { 'Content-Type': 'application/json' }, |
| 23 | body: JSON.stringify({ description }), |
| 24 | }); |
| 25 | const data = await response.json(); |
| 26 | setPlan(data.output); |
| 27 | toast.success("Website plan generated!"); |
| 28 | } catch (error) { |
| 29 | toast.error("Failed to generate plan"); |
| 30 | } finally { |
| 31 | setIsGenerating(false); |
| 32 | } |
| 33 | }; |
| 34 | |
| 35 | return ( |
| 36 | <Card className="border-accent/50 bg-accent/5"> |
| 37 | <CardHeader> |
| 38 | <CardTitle className="flex items-center gap-2"> |
| 39 | <Layout className="text-accent" /> |
| 40 | Community Website Builder |
| 41 | </CardTitle> |
| 42 | <p className="text-sm text-muted-foreground">Describe your vision, and I'll generate the structure and copy.</p> |
| 43 | </CardHeader> |
| 44 | <CardContent className="space-y-4"> |
| 45 | <div className="space-y-2"> |
| 46 | <Input |
| 47 | placeholder="e.g. A portfolio for a local artist or a page for a community garden" |
| 48 | value={description} |
| 49 | onChange={(e) => setDescription(e.target.value)} |
| 50 | /> |
| 51 | <Button |
| 52 | onClick={handleGenerate} |
| 53 | disabled={isGenerating} |
| 54 | className="w-full bg-accent hover:bg-accent/80 text-accent-foreground" |
| 55 | > |
| 56 | {isGenerating ? "Generating..." : "Generate Website Plan"} |
| 57 | </Button> |
| 58 | </div> |
| 59 | |
| 60 | {plan && ( |
| 61 | <div className="mt-4 p-4 bg-background border rounded-md space-y-4"> |
| 62 | <div className="flex items-center justify-between"> |
| 63 | <h4 className="font-bold text-sm flex items-center gap-2"> |
| 64 | <Palette size={14} /> Generated Vision |
| 65 | </h4> |
| 66 | <Button size="sm" variant="ghost" className="h-7 text-xs"> |
| 67 | <ExternalLink size={12} className="mr-1" /> Export to Webflow |
| 68 | </Button> |
| 69 | </div> |
| 70 | <div className="text-xs font-mono whitespace-pre-wrap max-h-48 overflow-y-auto p-2 bg-muted rounded"> |
| 71 | {plan} |
| 72 | </div> |
| 73 | </div> |
| 74 | )} |
| 75 | </CardContent> |
| 76 | </Card> |
| 77 | ); |
| 78 | }; |