import { updateMbzId } from "api/api"; import { useState } from "react"; import { AsyncButton } from "~/components/AsyncButton"; interface Props { type: string; id: number; } export default function UpdateMbzID({ type, id }: Props) { const [err, setError] = useState(); const [input, setInput] = useState(""); const [loading, setLoading] = useState(false); const [mbzid, setMbzid] = useState<"">(); const [success, setSuccess] = useState(""); const handleUpdateMbzID = () => { setError(undefined); if (input === "") { setError("no input"); return; } setLoading(true); updateMbzId(type, id, input).then((r) => { if (r.ok) { setSuccess("successfully updated MusicBrainz ID"); } else { r.json().then((r) => setError(r.error)); } }); setLoading(false); }; return (

Update MusicBrainz ID

setInput(e.target.value)} /> Submit
{err &&

{err}

} {success &&

{success}

}
); }