"use client"; import { LIMITS } from "@/lib/limits"; interface ImageUrlInputProps { value: string[]; onChange: (urls: string[]) => void; } export function ImageUrlInput({ value, onChange }: ImageUrlInputProps) { const urls = value.length > 0 ? value : [""]; const max = LIMITS.MAX_IMAGE_URLS; function addField() { if (urls.length < max) { onChange([...urls, ""]); } } function removeField(index: number) { const next = urls.filter((_, i) => i !== index); onChange(next.length > 0 ? next : [""]); } function updateField(index: number, next: string) { const updated = [...urls]; updated[index] = next; onChange(updated); } return (
{urls.map((url, i) => (
updateField(i, e.target.value)} className="flex-1 rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-2.5 text-sm text-neutral-800 placeholder:text-neutral-400 focus:bg-white" placeholder={ i === 0 ? "URL foto utama (cover)" : `URL foto ${i + 1} (opsional)` } /> {urls.length > 1 && ( )}
))}
{urls.length < max && ( )}

Upload foto ke hosting (imgur, imgbb, dll) lalu paste URL-nya di sini.

); }