);
}
/** Upload form: a photo and what it shows (alt text is required, §3 "Every image needs alt text"). */
export function Uploader({ onUploaded, disabled }: { onUploaded: (m: MediaItem) => void; disabled?: boolean }) {
const file = useRef(null);
const [alt, setAlt] = useState("");
const { busy, message, run } = useAction();
const go = () => run(async () => {
const f = file.current?.files?.[0];
if (!f) throw new Error("Choose a photo first.");
if (!alt.trim()) throw new Error("Say what the photo shows (for people who can't see it).");
const m = await api(`/media?alt=${encodeURIComponent(alt.trim())}`, { raw: f });
setAlt("");
if (file.current) file.current.value = "";
onUploaded(m);
}, "Uploaded.");
return (
{data?.storage.full && Your storage is full, so uploads have stopped. To get more (5 GB at a time), contact Cross Code.}
{ reload(); onChange(m.id); setOpen(false); }} />