"use client"; import { useState } from "react"; import { Film, Sparkles, RefreshCw } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Label } from "@/components/ui/label"; import { toast } from "sonner"; import { apiFetch, getStatusColor, type Story } from "./types"; interface Props { stories: Story[]; onCreated: () => void; } export default function StorytellingTab({ stories, onCreated }: Props) { const [storyPrompt, setStoryPrompt] = useState(""); const [storyGenre, setStoryGenre] = useState("lifestyle"); const [storyEpisodes, setStoryEpisodes] = useState(7); const [storyLoading, setStoryLoading] = useState(false); const handleCreateStory = async () => { if (!storyPrompt.trim()) { toast.error("Describe tu historia"); return; } setStoryLoading(true); try { const result = await apiFetch("/storytelling", { method: "POST", body: JSON.stringify({ prompt: storyPrompt, genre: storyGenre, totalEpisodes: storyEpisodes }), }); if (result.success) { toast.success(`Historia "${result.story?.title}" creada`); setStoryPrompt(""); onCreated(); } else toast.error(result.error); } catch { toast.error("Error"); } finally { setStoryLoading(false); } }; return (
Crear Historia