"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; const REASON_TAGS = [ "Too dark", "Bad composition", "Stock photo feel", "Wrong colors", "Too busy", "Off brand", ]; interface ThumbsDownModalProps { assetId: string; onClose: () => void; onSubmitted: (vote: "down") => void; } export function ThumbsDownModal({ assetId, onClose, onSubmitted }: ThumbsDownModalProps) { const [selectedTags, setSelectedTags] = useState>(new Set()); const [freeform, setFreeform] = useState(""); const [loading, setLoading] = useState(false); function toggleTag(tag: string) { setSelectedTags((prev) => { const next = new Set(prev); if (next.has(tag)) next.delete(tag); else next.add(tag); return next; }); } async function handleSubmit() { setLoading(true); const parts = [...selectedTags]; if (freeform.trim()) parts.push(freeform.trim()); const reason = parts.join("; ") || "Not preferred"; // Optimistic update — show disliked immediately onSubmitted("down"); try { const res = await fetch(`/api/assets/${assetId}/preference`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ vote: "down", reason }), }); if (!res.ok) { console.error("Preference API error:", res.status, await res.text()); } } catch (err) { console.error("Preference API failed:", err); } setLoading(false); onClose(); } return ( What didn't you like? Your feedback helps the AI avoid this style in future generations.
{REASON_TAGS.map((tag) => ( ))}