feat(art): switch submit button to ActionButton
Build and Push Image / push (push) Has been cancelled
Build and Push Image / build-backend (push) Has been cancelled
Build and Push Image / build-frontend (push) Has been cancelled

This commit is contained in:
2026-09-13 18:05:36 +07:00 Unverified
parent d8e7c29c51
commit 4c6106b99e
3 changed files with 40 additions and 12 deletions
+20 -9
View File
@@ -2,10 +2,12 @@
import { useRouter } from "next/navigation";
import posthog from "posthog-js";
import { useState } from "react";
import { useRef, useState } from "react";
import { toast } from "sonner";
import { checkEnkaStatus, submitArtifact } from "@/lib/api";
import { shared } from "@/lib/comms";
import type { ActionSubmitContextData } from "@/components/action-submit-provider";
import { ActionSubmitContext } from "@/components/action-submit-provider";
export function ArtifactFormWrapper({
edit,
@@ -20,6 +22,12 @@ export function ArtifactFormWrapper({
const [, setWarningUid] = shared.state("warning.uid");
const [warningSrc, setWarningSrc] = shared.state("warning.src");
const [dataHold, setDataHold] = useState<FormData>();
const callback = useRef<() => void>(() => {});
const context: ActionSubmitContextData = {
listenForComplete(complete) {
callback.current = complete;
},
};
// Disable warning for 60 seconds
shared.signal(
@@ -53,15 +61,18 @@ export function ArtifactFormWrapper({
} catch {}
router.refresh();
})
.catch((e) => toast.error(`${e.message || e}`));
.catch((e) => toast.error(`${e.message || e}`))
.finally(callback.current);
}
return (
<form
{...props}
onSubmit={(e) => {
e.preventDefault();
submit(new FormData(e.target as HTMLFormElement));
}}
/>
<ActionSubmitContext.Provider value={context}>
<form
{...props}
onSubmit={(e) => {
e.preventDefault();
submit(new FormData(e.target as HTMLFormElement));
}}
/>
</ActionSubmitContext.Provider>
);
}