fix(events): bound registration status loading

This commit is contained in:
2026-10-01 13:35:22 +03:30
parent 57c8da1326
commit 4d17066939
2 changed files with 23 additions and 4 deletions

View File

@@ -1087,10 +1087,26 @@ class ApiClient {
if (identifiers.registration_id) query.set("registration_id", identifiers.registration_id); if (identifiers.registration_id) query.set("registration_id", identifiers.registration_id);
if (identifiers.payment_id) query.set("payment_id", String(identifiers.payment_id)); if (identifiers.payment_id) query.set("payment_id", String(identifiers.payment_id));
const suffix = query.size ? `?${query.toString()}` : ""; const suffix = query.size ? `?${query.toString()}` : "";
return this.request<Types.RegistrationHubSchema>( const controller = new AbortController();
`/api/events/${encodeURIComponent(eventSlug)}/registration/status${suffix}`, const timeout = window.setTimeout(() => controller.abort(), 15_000);
{ method: "GET" }, try {
); return await Promise.race([
this.request<Types.RegistrationHubSchema>(
`/api/events/${encodeURIComponent(eventSlug)}/registration/status${suffix}`,
{ method: "GET", signal: controller.signal },
),
new Promise<never>((_, reject) => {
controller.signal.addEventListener("abort", () => reject(new DOMException("Timed out", "AbortError")), { once: true });
}),
]);
} catch (error) {
if (error instanceof DOMException && error.name === "AbortError") {
throw new Error("دریافت وضعیت ثبت‌نام بیش از حد طول کشید. دوباره تلاش کنید.");
}
throw error;
} finally {
window.clearTimeout(timeout);
}
} }
// ============= Payment Endpoints ============= // ============= Payment Endpoints =============

View File

@@ -371,6 +371,9 @@ export default function EventRegistrationHub({ slug, registrationId, paymentId }
}; };
const primaryAction: OutcomeAction | undefined = (() => { const primaryAction: OutcomeAction | undefined = (() => {
if (loadState === "error") {
return { label: "بررسی دوباره", onClick: refreshNow, disabled: refreshing };
}
if (!data || !state) return undefined; if (!data || !state) return undefined;
if (state === "ready" && data.can_register) { if (state === "ready" && data.can_register) {
return data.event.price > 0 return data.event.price > 0