"use client"; import { useState } from "react"; import { MediaPicker } from "./media-picker"; import { RichText } from "./rich-text"; export function ArticleForm({ action, defaultValues, }: { action: (formData: FormData) => Promise; defaultValues?: { title?: string; image?: string; shortStory?: string; fullStory?: string }; }) { const [image, setImage] = useState(defaultValues?.image ?? ""); const [imageError, setImageError] = useState(false); return (
{ setImage(e.target.value); setImageError(false); }} placeholder="Image URL" style={{ flex: 1 }} /> { setImage(url); setImageError(false); }} current={image} />
{image && !imageError ? ( // eslint-disable-next-line @next/next/no-img-element preview setImageError(true)} style={{ marginTop: "0.4rem", maxHeight: 120, borderRadius: 6, objectFit: "cover" }} /> ) : null} {imageError ? (

Image not found — enter a valid URL or browse.

) : null}