fix(rg): missing actionbutton context
Build and Push Image / build-backend (push) Successful in 31s
Build and Push Image / build-frontend (push) Successful in 2m21s
Build and Push Image / push (push) Successful in 1m1s

This commit is contained in:
2026-09-30 18:14:02 +07:00 Unverified
parent 9318d588f7
commit 754379d30d
+23 -7
View File
@@ -5,6 +5,11 @@ import { useRouter } from "next/navigation";
import posthog from "posthog-js"; import posthog from "posthog-js";
import { toast } from "sonner"; import { toast } from "sonner";
import { submitEndgame, submitEndgamePayment } from "./api"; import { submitEndgame, submitEndgamePayment } from "./api";
import { useRef } from "react";
import {
ActionSubmitContext,
ActionSubmitContextData,
} from "@/components/action-submit-provider";
export function EndgameFormWrapper({ export function EndgameFormWrapper({
type, type,
@@ -12,6 +17,13 @@ export function EndgameFormWrapper({
}: React.ComponentProps<"form"> & { type: "registration" | "payment" }) { }: React.ComponentProps<"form"> & { type: "registration" | "payment" }) {
const router = useRouter(); const router = useRouter();
const { start, stop } = useProgress(); const { start, stop } = useProgress();
const callback = useRef<() => void>(() => {});
const context: ActionSubmitContextData = {
listenForComplete(complete) {
callback.current = complete;
},
};
async function submit(data: FormData) { async function submit(data: FormData) {
start(); start();
posthog.capture( posthog.capture(
@@ -37,12 +49,16 @@ export function EndgameFormWrapper({
.finally(stop); .finally(stop);
} }
return ( return (
<form <ActionSubmitContext.Provider value={context}>
{...props} <form
onSubmit={(e) => { {...props}
e.preventDefault(); onSubmit={(e) => {
submit(new FormData(e.target as HTMLFormElement)); e.preventDefault();
}} submit(new FormData(e.target as HTMLFormElement)).finally(() =>
/> setTimeout(callback.current, 1000),
);
}}
/>
</ActionSubmitContext.Provider>
); );
} }