mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
feat: read gift warning from status response, soften poll error state
- Add warning field to GiftPurchaseStatus type - Read warning from status response with URL param fallback - Show PollErrorState for all poll errors (softer UX for gateway payments)
This commit is contained in:
@@ -74,6 +74,7 @@ export interface GiftPurchaseStatus {
|
|||||||
gift_message: string | null;
|
gift_message: string | null;
|
||||||
tariff_name: string | null;
|
tariff_name: string | null;
|
||||||
period_days: number | null;
|
period_days: number | null;
|
||||||
|
warning: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PendingGift {
|
export interface PendingGift {
|
||||||
|
|||||||
@@ -355,8 +355,8 @@ export default function GiftResult() {
|
|||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const token = searchParams.get('token');
|
const token = searchParams.get('token');
|
||||||
const mode = searchParams.get('mode');
|
const mode = searchParams.get('mode');
|
||||||
const rawWarning = searchParams.get('warning');
|
const rawUrlWarning = searchParams.get('warning');
|
||||||
const warning = rawWarning && KNOWN_WARNINGS.has(rawWarning) ? rawWarning : null;
|
const urlWarning = rawUrlWarning && KNOWN_WARNINGS.has(rawUrlWarning) ? rawUrlWarning : null;
|
||||||
|
|
||||||
const pollStart = useRef(Date.now());
|
const pollStart = useRef(Date.now());
|
||||||
const [pollTimedOut, setPollTimedOut] = useState(false);
|
const [pollTimedOut, setPollTimedOut] = useState(false);
|
||||||
@@ -415,6 +415,11 @@ export default function GiftResult() {
|
|||||||
const isPendingActivation = status?.status === 'pending_activation';
|
const isPendingActivation = status?.status === 'pending_activation';
|
||||||
const isFailed = status?.status === 'failed' || status?.status === 'expired';
|
const isFailed = status?.status === 'failed' || status?.status === 'expired';
|
||||||
|
|
||||||
|
// Warning from status response (persisted on purchase) takes priority over URL param
|
||||||
|
const statusWarning =
|
||||||
|
status?.warning && KNOWN_WARNINGS.has(status.warning) ? status.warning : null;
|
||||||
|
const warning = statusWarning ?? urlWarning;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-dvh items-center justify-center px-4">
|
<div className="flex min-h-dvh items-center justify-center px-4">
|
||||||
<div
|
<div
|
||||||
@@ -422,10 +427,8 @@ export default function GiftResult() {
|
|||||||
aria-live="polite"
|
aria-live="polite"
|
||||||
aria-atomic="true"
|
aria-atomic="true"
|
||||||
>
|
>
|
||||||
{isError && isBalanceMode ? (
|
{isError ? (
|
||||||
<PollErrorState />
|
<PollErrorState />
|
||||||
) : isError ? (
|
|
||||||
<FailedState />
|
|
||||||
) : isDelivered ? (
|
) : isDelivered ? (
|
||||||
<DeliveredState
|
<DeliveredState
|
||||||
recipientContact={status.recipient_contact_value}
|
recipientContact={status.recipient_contact_value}
|
||||||
|
|||||||
Reference in New Issue
Block a user