fix(registration): simplify successful receipt details
This commit is contained in:
@@ -272,6 +272,12 @@ export default function EventRegistrationHub({ slug, registrationId, paymentId }
|
|||||||
const eventHref = event ? getEventPath({ id: event.id, slug: event.slug }) : "/events";
|
const eventHref = event ? getEventPath({ id: event.id, slug: event.slug }) : "/events";
|
||||||
const money = (amount?: number | null) => typeof amount === "number" ? formatToman(amount) : "—";
|
const money = (amount?: number | null) => typeof amount === "number" ? formatToman(amount) : "—";
|
||||||
const hasSettledRegistration = state === "paid_success" || state === "free_success";
|
const hasSettledRegistration = state === "paid_success" || state === "free_success";
|
||||||
|
const discountAmount = Math.max(data?.payment?.discount_amount ?? 0, data?.registration?.discount_amount ?? 0);
|
||||||
|
const hasDiscount = discountAmount > 0;
|
||||||
|
const hideSuccessSummaryRows = hasSettledRegistration && !hasDiscount;
|
||||||
|
const paidAmount = data?.payment?.amount
|
||||||
|
?? data?.registration?.final_price
|
||||||
|
?? Math.max((data?.event.price ?? 0) - discountAmount, 0);
|
||||||
const refreshNow = () => setRefreshToken((value) => value + 1);
|
const refreshNow = () => setRefreshToken((value) => value + 1);
|
||||||
|
|
||||||
const startCheckout = async (coupon?: string) => {
|
const startCheckout = async (coupon?: string) => {
|
||||||
@@ -437,16 +443,19 @@ export default function EventRegistrationHub({ slug, registrationId, paymentId }
|
|||||||
? [
|
? [
|
||||||
{ label: "رویداد", value: data.event.title },
|
{ label: "رویداد", value: data.event.title },
|
||||||
{ label: "زمان برگزاری", value: formatEventDateTimeRange(data.event.start_time, data.event.end_time) },
|
{ label: "زمان برگزاری", value: formatEventDateTimeRange(data.event.start_time, data.event.end_time) },
|
||||||
{ label: "هزینهٔ رویداد", value: data.event.price <= 0 ? "رایگان" : money(data.event.price) },
|
...(!hideSuccessSummaryRows ? [{ label: "هزینهٔ رویداد", value: data.event.price <= 0 ? "رایگان" : money(data.event.price) }] : []),
|
||||||
...(data.registration ? [{ label: "وضعیت ثبتنام", value: data.registration.status === "confirmed" || data.registration.status === "attended" ? "تأییدشده" : data.registration.status === "pending" ? "در انتظار" : "لغوشده" }] : []),
|
...(hasDiscount ? [{ label: "تخفیف اعمالشده", value: money(discountAmount) }] : []),
|
||||||
|
...(data.payment || (hasSettledRegistration && hasDiscount)
|
||||||
|
? [{ label: "مبلغ پرداختشده", value: money(data.payment?.amount ?? paidAmount) }]
|
||||||
|
: []),
|
||||||
|
...(data.registration && !hideSuccessSummaryRows ? [{ label: "وضعیت ثبتنام", value: data.registration.status === "confirmed" || data.registration.status === "attended" ? "تأییدشده" : data.registration.status === "pending" ? "در انتظار" : "لغوشده" }] : []),
|
||||||
...(data.registration?.checkout_expires_at && state === "active_checkout" ? [{ label: "زمان باقیماندهٔ رزرو", value: checkoutTimeRemaining(data.registration.checkout_expires_at) }] : []),
|
...(data.registration?.checkout_expires_at && state === "active_checkout" ? [{ label: "زمان باقیماندهٔ رزرو", value: checkoutTimeRemaining(data.registration.checkout_expires_at) }] : []),
|
||||||
...(data.payment ? [
|
...(data.payment ? [
|
||||||
{ label: "وضعیت پرداخت", value: data.payment.status === "paid" ? "پرداخت تأییدشده" : data.payment.status === "failed" ? "ناموفق" : data.payment.status === "canceled" ? "لغوشده" : "در انتظار تأیید" },
|
...(!hideSuccessSummaryRows ? [{ label: "وضعیت پرداخت", value: data.payment.status === "paid" ? "پرداخت تأییدشده" : data.payment.status === "failed" ? "ناموفق" : data.payment.status === "canceled" ? "لغوشده" : "در انتظار تأیید" }] : []),
|
||||||
{ label: "مبلغ پرداخت", value: money(data.payment.amount) },
|
...(data.payment.ref_id ? [{ label: "شناسه پرداخت", value: <code dir="ltr" className="font-mono">{data.payment.ref_id}</code> }] : []),
|
||||||
...(data.payment.ref_id ? [{ label: "کد پیگیری درگاه", value: <code dir="ltr" className="font-mono">{data.payment.ref_id}</code> }] : []),
|
|
||||||
] : []),
|
] : []),
|
||||||
...(data.registration ? [{ label: "کد ثبتنام", value: <code dir="ltr" className="font-mono">{displayIdentifier(data.registration.ticket_id)}</code> }] : []),
|
...(data.registration ? [{ label: "شماره ثبتنام", value: <code dir="ltr" className="font-mono">{displayIdentifier(data.registration.ticket_id)}</code> }] : []),
|
||||||
...(data.registration?.registered_at ? [{ label: "تاریخ درخواست", value: formatJalali(data.registration.registered_at) }] : []),
|
...(data.registration?.registered_at ? [{ label: "تاریخ ثبتنام", value: formatJalali(data.registration.registered_at) }] : []),
|
||||||
]
|
]
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
@@ -480,7 +489,7 @@ export default function EventRegistrationHub({ slug, registrationId, paymentId }
|
|||||||
} : undefined}
|
} : undefined}
|
||||||
details={details}
|
details={details}
|
||||||
reference={data?.payment?.ref_id || data?.registration?.ticket_id || null}
|
reference={data?.payment?.ref_id || data?.registration?.ticket_id || null}
|
||||||
referenceLabel={data?.payment?.ref_id ? "کد پیگیری درگاه" : "کد ثبتنام"}
|
referenceLabel={data?.payment?.ref_id ? "شناسه پرداخت" : "شماره ثبتنام"}
|
||||||
support={presentationState === "verification_pending" || presentationState === "manual_review" || presentationState === "refund_manual_review" || loadState === "error" || loadState === "not_found"}
|
support={presentationState === "verification_pending" || presentationState === "manual_review" || presentationState === "refund_manual_review" || loadState === "error" || loadState === "not_found"}
|
||||||
supportDescription={presentationState === "verification_pending"
|
supportDescription={presentationState === "verification_pending"
|
||||||
? "اگر هزینهٔ رویداد از حساب شما کسر شده است، رسید پرداخت و کد پیگیری را برای بررسی وضعیت با انجمن در میان بگذارید. تا دریافت نتیجهٔ قطعی، پرداخت دیگری آغاز نکنید."
|
? "اگر هزینهٔ رویداد از حساب شما کسر شده است، رسید پرداخت و کد پیگیری را برای بررسی وضعیت با انجمن در میان بگذارید. تا دریافت نتیجهٔ قطعی، پرداخت دیگری آغاز نکنید."
|
||||||
|
|||||||
Reference in New Issue
Block a user