fix(events): bound registration status loading
This commit is contained in:
@@ -1087,10 +1087,26 @@ class ApiClient {
|
||||
if (identifiers.registration_id) query.set("registration_id", identifiers.registration_id);
|
||||
if (identifiers.payment_id) query.set("payment_id", String(identifiers.payment_id));
|
||||
const suffix = query.size ? `?${query.toString()}` : "";
|
||||
return this.request<Types.RegistrationHubSchema>(
|
||||
`/api/events/${encodeURIComponent(eventSlug)}/registration/status${suffix}`,
|
||||
{ method: "GET" },
|
||||
);
|
||||
const controller = new AbortController();
|
||||
const timeout = window.setTimeout(() => controller.abort(), 15_000);
|
||||
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 =============
|
||||
|
||||
@@ -371,6 +371,9 @@ export default function EventRegistrationHub({ slug, registrationId, paymentId }
|
||||
};
|
||||
|
||||
const primaryAction: OutcomeAction | undefined = (() => {
|
||||
if (loadState === "error") {
|
||||
return { label: "بررسی دوباره", onClick: refreshNow, disabled: refreshing };
|
||||
}
|
||||
if (!data || !state) return undefined;
|
||||
if (state === "ready" && data.can_register) {
|
||||
return data.event.price > 0
|
||||
|
||||
Reference in New Issue
Block a user