import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Checkbox } from "@/components/ui/checkbox"; interface TrackMetadata { title: string; description?: string; genre: string[]; bpm?: number; license_type: "ecosystem" | "commercial_sample"; is_published: boolean; } interface TrackMetadataFormProps { onSubmit: (metadata: TrackMetadata) => void; initialData?: Partial; isLoading?: boolean; } const GENRES = [ "Synthwave", "Orchestral", "SFX", "Ambient", "Electronic", "Cinematic", "Jazz", "Hip-Hop", "Folk", ]; export default function TrackMetadataForm({ onSubmit, initialData, isLoading, }: TrackMetadataFormProps) { const [title, setTitle] = useState(initialData?.title || ""); const [description, setDescription] = useState(initialData?.description || ""); const [selectedGenres, setSelectedGenres] = useState( initialData?.genre || [], ); const [bpm, setBpm] = useState(initialData?.bpm || ""); const [licenseType, setLicenseType] = useState<"ecosystem" | "commercial_sample">( initialData?.license_type || "ecosystem", ); const [isPublished, setIsPublished] = useState( initialData?.is_published !== false, ); const toggleGenre = (genre: string) => { setSelectedGenres((prev) => prev.includes(genre) ? prev.filter((g) => g !== genre) : [...prev, genre], ); }; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!title || selectedGenres.length === 0) { alert("Title and at least one genre are required"); return; } onSubmit({ title, description: description || undefined, genre: selectedGenres, bpm: bpm ? Number(bpm) : undefined, license_type: licenseType, is_published: isPublished, }); }; return (
setTitle(e.target.value)} placeholder="e.g., Synthwave Dream" className="bg-slate-800 border-slate-700" required />