diff --git a/web/src/app/submit/page.tsx b/web/src/app/submit/page.tsx index e098741..9125add 100644 --- a/web/src/app/submit/page.tsx +++ b/web/src/app/submit/page.tsx @@ -17,6 +17,9 @@ interface SubmissionPayload { AssetVersion: number; SubmissionType: number; } +interface IdResponse { + ID: number; +} export default function SubmissionInfoPage() { const [game, setGame] = useState(1); @@ -24,10 +27,10 @@ export default function SubmissionInfoPage() { const handleSubmit = async (event: React.FormEvent) => { event.preventDefault(); - + const form = event.currentTarget; const formData = new FormData(form); - + const payload: SubmissionPayload = { DisplayName: (formData.get("display-name") as string) ?? "unknown", // TEMPORARY! TODO: Change Creator: (formData.get("creator") as string) ?? "unknown", // TEMPORARY! TODO: Change @@ -39,7 +42,7 @@ export default function SubmissionInfoPage() { console.log(payload) console.log(JSON.stringify(payload)) - + try { // Send the POST request const response = await fetch("/api/submissions", { @@ -47,16 +50,18 @@ export default function SubmissionInfoPage() { headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload), }); - + // Allow any HTTP status - const responseText = await response.text(); - - console.log("Response Text:", responseText); + const id_response:IdResponse = await response.json(); + + // navigate to newly created submission + window.location.assign(`/submissions/${id_response.ID}`) + } catch (error) { console.error("Error submitting data:", error); } }; - + return (
@@ -90,4 +95,4 @@ export default function SubmissionInfoPage() {
) -} \ No newline at end of file +}