@opexa/portal-components 0.0.808 → 0.0.809
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DepositWithdrawal/Deposit/AiOGCashDeposit/AiOGCashDeposit.js +54 -10
- package/dist/components/DepositWithdrawal/Deposit/AiOGrabPayDeposit/AiOGrabPayDeposit.js +54 -10
- package/dist/components/DepositWithdrawal/Deposit/AiOPalawanPayDeposit/AiOPalawanPayDeposit.js +54 -10
- package/dist/components/DepositWithdrawal/Deposit/AiOPayMayaDeposit/AiOPayMayaDeposit.js +54 -10
- package/dist/components/DepositWithdrawal/Deposit/GCashDeposit/GCashDeposit.js +54 -9
- package/dist/components/DepositWithdrawal/Deposit/GCashWebpayDeposit/GCashWebpayDeposit.js +54 -9
- package/dist/components/DepositWithdrawal/Deposit/LibanganDeposit/LibanganDeposit.js +49 -25
- package/dist/components/DepositWithdrawal/Deposit/MayaDeposit/MayaDeposit.js +54 -9
- package/dist/components/DepositWithdrawal/Deposit/MayaWebpayDeposit/MayaWebpayDeposit.js +54 -9
- package/dist/components/DepositWithdrawal/Deposit/PisoPayDeposit/PisoPayDeposit.js +54 -10
- package/dist/components/DepositWithdrawal/DepositWithdrawal.lazy.js +2 -5
- package/dist/components/DepositWithdrawal/Deposit__legacy/AiOGCashDeposit/AiOGCashDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/AiOGCashDeposit/AiOGCashDeposit.js +173 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/AiOGrabPayDeposit/AiOGrabPayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/AiOGrabPayDeposit/AiOGrabPayDeposit.js +171 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/AiOPalawanPayDeposit/AiOPalawanPayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/AiOPalawanPayDeposit/AiOPalawanPayDeposit.js +171 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/AiOPayMayaDeposit/AiOPayMayaDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/AiOPayMayaDeposit/AiOPayMayaDeposit.js +171 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/AvailablePromos.d.ts +8 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/AvailablePromos.js +33 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/Deposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/Deposit.js +120 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/GCashDeposit/GCashDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/GCashDeposit/GCashDeposit.js +163 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/GCashWebpayDeposit/GCashWebpayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/GCashWebpayDeposit/GCashWebpayDeposit.js +165 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/LibanganDeposit/LibanganDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/LibanganDeposit/LibanganDeposit.js +186 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/MayaAppDeposit/MayaAppDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/MayaAppDeposit/MayaAppDeposit.js +157 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/MayaDeposit/MayaDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/MayaDeposit/MayaDeposit.js +163 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/MayaWebpayDeposit/MayaWebpayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/MayaWebpayDeposit/MayaWebpayDeposit.js +166 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDeposit.js +10 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDepositAlert.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDepositAlert.js +99 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDepositContext.d.ts +25 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDepositContext.js +2 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDepositDetails.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDepositDetails.js +19 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDepositForm.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDepositForm.js +115 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/useOnlineBankDeposit.d.ts +13 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/useOnlineBankDeposit.js +81 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/PisoPayDeposit/PisoPayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/PisoPayDeposit/PisoPayDeposit.js +180 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDeposit.js +10 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositAlert.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositAlert.js +99 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositContext.d.ts +25 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositContext.js +2 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositDetails.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositDetails.js +17 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositForm.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositForm.js +116 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHQRCode.d.ts +3 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHQRCode.js +69 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/useQRPHDeposit.d.ts +13 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/useQRPHDeposit.js +85 -0
- package/dist/components/DepositWithdrawal/HasPendingBonuses.d.ts +2 -2
- package/dist/components/DepositWithdrawal/HasPendingBonuses.js +1 -2
- package/package.json +1 -1
|
@@ -4,10 +4,12 @@ import Link from 'next/link';
|
|
|
4
4
|
import { useEffect, useState } from 'react';
|
|
5
5
|
import { Controller, useForm } from 'react-hook-form';
|
|
6
6
|
import invariant from 'tiny-invariant';
|
|
7
|
+
import { useBoolean } from 'usehooks-ts';
|
|
7
8
|
import { z } from 'zod';
|
|
8
9
|
import { useShallow } from 'zustand/shallow';
|
|
9
10
|
import { useCreateAiOGCashDepositMutation } from '../../../../client/hooks/useAiOGCashDepositMutation.js';
|
|
10
11
|
import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
|
|
12
|
+
import { useDepositQuery } from '../../../../client/hooks/useDepositQuery.js';
|
|
11
13
|
import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
|
|
12
14
|
import { useDisclosure } from '../../../../client/hooks/useDisclosure.js';
|
|
13
15
|
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
@@ -16,6 +18,7 @@ import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSett
|
|
|
16
18
|
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
17
19
|
import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
|
|
18
20
|
import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
|
|
21
|
+
import { RefreshCcw01Icon } from '../../../../icons/RefreshCcw01Icon.js';
|
|
19
22
|
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
20
23
|
import { XIcon } from '../../../../icons/XIcon.js';
|
|
21
24
|
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
@@ -28,11 +31,16 @@ import { parseDecimal } from '../../../../utils/parseDecimal.js';
|
|
|
28
31
|
import { getDepositsCountQueryKey } from '../../../../utils/queryKeys.js';
|
|
29
32
|
import { AmountChoices } from '../../AmountChoices.js';
|
|
30
33
|
import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
|
|
31
|
-
import { explainError } from '../../utils.js';
|
|
32
34
|
import { AvailablePromos } from '../AvailablePromos.js';
|
|
33
35
|
export function AiOGCashDeposit() {
|
|
34
36
|
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
35
|
-
const disclosure = useDisclosure(
|
|
37
|
+
const disclosure = useDisclosure({
|
|
38
|
+
onOpenChange(open) {
|
|
39
|
+
if (!open) {
|
|
40
|
+
form.reset();
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
36
44
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
37
45
|
depositWithdrawal: ctx.depositWithdrawal,
|
|
38
46
|
kycVerificationStatus: ctx.kycVerificationStatus,
|
|
@@ -58,6 +66,26 @@ export function AiOGCashDeposit() {
|
|
|
58
66
|
setStatus('failed');
|
|
59
67
|
},
|
|
60
68
|
});
|
|
69
|
+
const warn = useBoolean();
|
|
70
|
+
const depositQuery = useDepositQuery(createDepositMutation.data?.id, {
|
|
71
|
+
enabled: !warn.value && status === 'success',
|
|
72
|
+
refetchInterval: (ctx) => ctx.state.data?.status === 'CONFIRMED' ||
|
|
73
|
+
ctx.state.data?.status === 'REJECTED' ||
|
|
74
|
+
ctx.state.data?.status === 'CANCELLED'
|
|
75
|
+
? false
|
|
76
|
+
: 1000,
|
|
77
|
+
});
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (depositQuery.data?.status === 'CONFIRMED') {
|
|
80
|
+
setStatus('confirmed');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (depositQuery.data?.status === 'REJECTED' ||
|
|
84
|
+
depositQuery.data?.status === 'CANCELLED') {
|
|
85
|
+
setStatus('failed');
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}, [depositQuery.data?.status]);
|
|
61
89
|
const depositsCountQuery = useDepositsCountQuery();
|
|
62
90
|
const depositsCount = depositsCountQuery.data ?? 0;
|
|
63
91
|
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
@@ -161,13 +189,29 @@ export function AiOGCashDeposit() {
|
|
|
161
189
|
globalStore.depositWithdrawal.setPromo(null);
|
|
162
190
|
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "mt-lg text-text-tertiary-600 text-xs", children: ["By depositing, you agree to our", ' ', _jsx(Link, { href: depositWithdrawalProps.termsOfUseUrl ?? '/terms-of-use', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use" }), ' ', "and", ' ', _jsx(Link, { href: depositWithdrawalProps.privacyPolicyUrl ?? '/privacy-policy', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: disclosure.open, onOpenChange: (details) => {
|
|
163
191
|
disclosure.setOpen(details.open);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
|
|
192
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
|
|
193
|
+
setStatus('waiting');
|
|
194
|
+
form.reset();
|
|
195
|
+
warn.setFalse();
|
|
196
|
+
}, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.Context, { children: (api) => (_jsx("button", { type: "button", className: "absolute top-2.5 right-2.5 flex icon:size-6 size-11 items-center justify-center text-text-quinary", onClick: () => {
|
|
197
|
+
if (status === 'success' && !warn.value) {
|
|
198
|
+
warn.setTrue();
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
171
201
|
api.setOpen(false);
|
|
172
|
-
}
|
|
202
|
+
}
|
|
203
|
+
}, children: _jsx(XIcon, {}) })) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && !warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary text-text-featured-icon-light-brand", children: _jsx(RefreshCcw01Icon, {}) })), status === 'success' && warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) })), status === 'confirmed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-success-secondary text-text-featured-icon-light-success", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) }))] }), _jsxs(AlertDialog.Body, { children: [_jsxs(AlertDialog.Title, { children: [status === 'processing' && 'Processing Deposit', status === 'success' &&
|
|
204
|
+
!warn.value &&
|
|
205
|
+
'Didn’t see the payment window?', status === 'success' && warn.value && (_jsx(_Fragment, { children: "Are you sure you want to close this\u00A0window?" })), status === 'confirmed' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
|
|
206
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
207
|
+
!warn.value &&
|
|
208
|
+
'Sometimes the payment pop up doesn’t appear right away. Don’t worry, just click the button below to reopen it and continue your deposit.', status === 'success' &&
|
|
209
|
+
warn.value &&
|
|
210
|
+
'Closing this window might cancel your current deposit. Do you want to continue?', status === 'confirmed' &&
|
|
211
|
+
'Your deposit has been successfully processed.', status === 'failed' &&
|
|
212
|
+
'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' ||
|
|
213
|
+
status === 'success' ||
|
|
214
|
+
status === 'confirmed') && (_jsxs(AlertDialog.Footer, { children: [status === 'success' && !warn.value && (_jsx(Button, { asChild: true, children: _jsx("a", { href: createDepositMutation.data?.checkoutUrl ?? '', target: "_blank", rel: "noopener noreferrer", children: "Try Again" }) })), status === 'success' && warn.value && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", onClick: () => {
|
|
215
|
+
warn.setFalse();
|
|
216
|
+
}, children: "Go back" }), _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Continue" })) })] })), status !== 'success' && (_jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Ok" })) }))] }))] }) })] }) })] }));
|
|
173
217
|
}
|
|
@@ -4,10 +4,12 @@ import Link from 'next/link';
|
|
|
4
4
|
import { useEffect, useState } from 'react';
|
|
5
5
|
import { Controller, useForm } from 'react-hook-form';
|
|
6
6
|
import invariant from 'tiny-invariant';
|
|
7
|
+
import { useBoolean } from 'usehooks-ts';
|
|
7
8
|
import { z } from 'zod';
|
|
8
9
|
import { useShallow } from 'zustand/shallow';
|
|
9
10
|
import { useCreateAiOGrabPayDepositMutation } from '../../../../client/hooks/useAiOGrabPayDepositMutation.js';
|
|
10
11
|
import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
|
|
12
|
+
import { useDepositQuery } from '../../../../client/hooks/useDepositQuery.js';
|
|
11
13
|
import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
|
|
12
14
|
import { useDisclosure } from '../../../../client/hooks/useDisclosure.js';
|
|
13
15
|
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
@@ -16,6 +18,7 @@ import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSett
|
|
|
16
18
|
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
17
19
|
import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
|
|
18
20
|
import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
|
|
21
|
+
import { RefreshCcw01Icon } from '../../../../icons/RefreshCcw01Icon.js';
|
|
19
22
|
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
20
23
|
import { XIcon } from '../../../../icons/XIcon.js';
|
|
21
24
|
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
@@ -28,11 +31,16 @@ import { parseDecimal } from '../../../../utils/parseDecimal.js';
|
|
|
28
31
|
import { getDepositsCountQueryKey } from '../../../../utils/queryKeys.js';
|
|
29
32
|
import { AmountChoices } from '../../AmountChoices.js';
|
|
30
33
|
import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
|
|
31
|
-
import { explainError } from '../../utils.js';
|
|
32
34
|
import { AvailablePromos } from '../AvailablePromos.js';
|
|
33
35
|
export function AiOGrabPayDeposit() {
|
|
34
36
|
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
35
|
-
const disclosure = useDisclosure(
|
|
37
|
+
const disclosure = useDisclosure({
|
|
38
|
+
onOpenChange(open) {
|
|
39
|
+
if (!open) {
|
|
40
|
+
form.reset();
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
36
44
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
37
45
|
depositWithdrawal: ctx.depositWithdrawal,
|
|
38
46
|
kycVerificationStatus: ctx.kycVerificationStatus,
|
|
@@ -56,6 +64,26 @@ export function AiOGrabPayDeposit() {
|
|
|
56
64
|
setStatus('failed');
|
|
57
65
|
},
|
|
58
66
|
});
|
|
67
|
+
const warn = useBoolean();
|
|
68
|
+
const depositQuery = useDepositQuery(createDepositMutation.data?.id, {
|
|
69
|
+
enabled: !warn.value && status === 'success',
|
|
70
|
+
refetchInterval: (ctx) => ctx.state.data?.status === 'CONFIRMED' ||
|
|
71
|
+
ctx.state.data?.status === 'REJECTED' ||
|
|
72
|
+
ctx.state.data?.status === 'CANCELLED'
|
|
73
|
+
? false
|
|
74
|
+
: 1000,
|
|
75
|
+
});
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (depositQuery.data?.status === 'CONFIRMED') {
|
|
78
|
+
setStatus('confirmed');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (depositQuery.data?.status === 'REJECTED' ||
|
|
82
|
+
depositQuery.data?.status === 'CANCELLED') {
|
|
83
|
+
setStatus('failed');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}, [depositQuery.data?.status]);
|
|
59
87
|
const depositsCountQuery = useDepositsCountQuery();
|
|
60
88
|
const depositsCount = depositsCountQuery.data ?? 0;
|
|
61
89
|
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
@@ -159,13 +187,29 @@ export function AiOGrabPayDeposit() {
|
|
|
159
187
|
globalStore.depositWithdrawal.setPromo(null);
|
|
160
188
|
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "mt-lg text-text-tertiary-600 text-xs", children: ["By depositing, you agree to our", ' ', _jsx(Link, { href: depositWithdrawalProps.termsOfUseUrl ?? '/terms-of-use', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use" }), ' ', "and", ' ', _jsx(Link, { href: depositWithdrawalProps.privacyPolicyUrl ?? '/privacy-policy', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: disclosure.open, onOpenChange: (details) => {
|
|
161
189
|
disclosure.setOpen(details.open);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
|
|
190
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
|
|
191
|
+
setStatus('waiting');
|
|
192
|
+
form.reset();
|
|
193
|
+
warn.setFalse();
|
|
194
|
+
}, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.Context, { children: (api) => (_jsx("button", { type: "button", className: "absolute top-2.5 right-2.5 flex icon:size-6 size-11 items-center justify-center text-text-quinary", onClick: () => {
|
|
195
|
+
if (status === 'success' && !warn.value) {
|
|
196
|
+
warn.setTrue();
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
169
199
|
api.setOpen(false);
|
|
170
|
-
}
|
|
200
|
+
}
|
|
201
|
+
}, children: _jsx(XIcon, {}) })) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && !warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary text-text-featured-icon-light-brand", children: _jsx(RefreshCcw01Icon, {}) })), status === 'success' && warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) })), status === 'confirmed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-success-secondary text-text-featured-icon-light-success", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) }))] }), _jsxs(AlertDialog.Body, { children: [_jsxs(AlertDialog.Title, { children: [status === 'processing' && 'Processing Deposit', status === 'success' &&
|
|
202
|
+
!warn.value &&
|
|
203
|
+
'Didn’t see the payment window?', status === 'success' && warn.value && (_jsx(_Fragment, { children: "Are you sure you want to close this\u00A0window?" })), status === 'confirmed' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
|
|
204
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
205
|
+
!warn.value &&
|
|
206
|
+
'Sometimes the payment pop up doesn’t appear right away. Don’t worry, just click the button below to reopen it and continue your deposit.', status === 'success' &&
|
|
207
|
+
warn.value &&
|
|
208
|
+
'Closing this window might cancel your current deposit. Do you want to continue?', status === 'confirmed' &&
|
|
209
|
+
'Your deposit has been successfully processed.', status === 'failed' &&
|
|
210
|
+
'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' ||
|
|
211
|
+
status === 'success' ||
|
|
212
|
+
status === 'confirmed') && (_jsxs(AlertDialog.Footer, { children: [status === 'success' && !warn.value && (_jsx(Button, { asChild: true, children: _jsx("a", { href: createDepositMutation.data?.checkoutUrl ?? '', target: "_blank", rel: "noopener noreferrer", children: "Try Again" }) })), status === 'success' && warn.value && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", onClick: () => {
|
|
213
|
+
warn.setFalse();
|
|
214
|
+
}, children: "Go back" }), _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Continue" })) })] })), status !== 'success' && (_jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Ok" })) }))] }))] }) })] }) })] }));
|
|
171
215
|
}
|
package/dist/components/DepositWithdrawal/Deposit/AiOPalawanPayDeposit/AiOPalawanPayDeposit.js
CHANGED
|
@@ -4,10 +4,12 @@ import Link from 'next/link';
|
|
|
4
4
|
import { useEffect, useState } from 'react';
|
|
5
5
|
import { Controller, useForm } from 'react-hook-form';
|
|
6
6
|
import invariant from 'tiny-invariant';
|
|
7
|
+
import { useBoolean } from 'usehooks-ts';
|
|
7
8
|
import { z } from 'zod';
|
|
8
9
|
import { useShallow } from 'zustand/shallow';
|
|
9
10
|
import { useCreateAiOPalawanPayDepositMutation } from '../../../../client/hooks/useAiOPalawanPayDepositMutation.js';
|
|
10
11
|
import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
|
|
12
|
+
import { useDepositQuery } from '../../../../client/hooks/useDepositQuery.js';
|
|
11
13
|
import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
|
|
12
14
|
import { useDisclosure } from '../../../../client/hooks/useDisclosure.js';
|
|
13
15
|
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
@@ -16,6 +18,7 @@ import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSett
|
|
|
16
18
|
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
17
19
|
import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
|
|
18
20
|
import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
|
|
21
|
+
import { RefreshCcw01Icon } from '../../../../icons/RefreshCcw01Icon.js';
|
|
19
22
|
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
20
23
|
import { XIcon } from '../../../../icons/XIcon.js';
|
|
21
24
|
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
@@ -28,11 +31,16 @@ import { parseDecimal } from '../../../../utils/parseDecimal.js';
|
|
|
28
31
|
import { getDepositsCountQueryKey } from '../../../../utils/queryKeys.js';
|
|
29
32
|
import { AmountChoices } from '../../AmountChoices.js';
|
|
30
33
|
import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
|
|
31
|
-
import { explainError } from '../../utils.js';
|
|
32
34
|
import { AvailablePromos } from '../AvailablePromos.js';
|
|
33
35
|
export function AiOPalawanPayDeposit() {
|
|
34
36
|
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
35
|
-
const disclosure = useDisclosure(
|
|
37
|
+
const disclosure = useDisclosure({
|
|
38
|
+
onOpenChange(open) {
|
|
39
|
+
if (!open) {
|
|
40
|
+
form.reset();
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
36
44
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
37
45
|
depositWithdrawal: ctx.depositWithdrawal,
|
|
38
46
|
kycVerificationStatus: ctx.kycVerificationStatus,
|
|
@@ -56,6 +64,26 @@ export function AiOPalawanPayDeposit() {
|
|
|
56
64
|
setStatus('failed');
|
|
57
65
|
},
|
|
58
66
|
});
|
|
67
|
+
const warn = useBoolean();
|
|
68
|
+
const depositQuery = useDepositQuery(createDepositMutation.data?.id, {
|
|
69
|
+
enabled: !warn.value && status === 'success',
|
|
70
|
+
refetchInterval: (ctx) => ctx.state.data?.status === 'CONFIRMED' ||
|
|
71
|
+
ctx.state.data?.status === 'REJECTED' ||
|
|
72
|
+
ctx.state.data?.status === 'CANCELLED'
|
|
73
|
+
? false
|
|
74
|
+
: 1000,
|
|
75
|
+
});
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (depositQuery.data?.status === 'CONFIRMED') {
|
|
78
|
+
setStatus('confirmed');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (depositQuery.data?.status === 'REJECTED' ||
|
|
82
|
+
depositQuery.data?.status === 'CANCELLED') {
|
|
83
|
+
setStatus('failed');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}, [depositQuery.data?.status]);
|
|
59
87
|
const depositsCountQuery = useDepositsCountQuery();
|
|
60
88
|
const depositsCount = depositsCountQuery.data ?? 0;
|
|
61
89
|
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
@@ -159,13 +187,29 @@ export function AiOPalawanPayDeposit() {
|
|
|
159
187
|
globalStore.depositWithdrawal.setPromo(null);
|
|
160
188
|
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "mt-lg text-text-tertiary-600 text-xs", children: ["By depositing, you agree to our", ' ', _jsx(Link, { href: depositWithdrawalProps.termsOfUseUrl ?? '/terms-of-use', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use" }), ' ', "and", ' ', _jsx(Link, { href: depositWithdrawalProps.privacyPolicyUrl ?? '/privacy-policy', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: disclosure.open, onOpenChange: (details) => {
|
|
161
189
|
disclosure.setOpen(details.open);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
|
|
190
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
|
|
191
|
+
setStatus('waiting');
|
|
192
|
+
form.reset();
|
|
193
|
+
warn.setFalse();
|
|
194
|
+
}, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.Context, { children: (api) => (_jsx("button", { type: "button", className: "absolute top-2.5 right-2.5 flex icon:size-6 size-11 items-center justify-center text-text-quinary", onClick: () => {
|
|
195
|
+
if (status === 'success' && !warn.value) {
|
|
196
|
+
warn.setTrue();
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
169
199
|
api.setOpen(false);
|
|
170
|
-
}
|
|
200
|
+
}
|
|
201
|
+
}, children: _jsx(XIcon, {}) })) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && !warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary text-text-featured-icon-light-brand", children: _jsx(RefreshCcw01Icon, {}) })), status === 'success' && warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) })), status === 'confirmed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-success-secondary text-text-featured-icon-light-success", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) }))] }), _jsxs(AlertDialog.Body, { children: [_jsxs(AlertDialog.Title, { children: [status === 'processing' && 'Processing Deposit', status === 'success' &&
|
|
202
|
+
!warn.value &&
|
|
203
|
+
'Didn’t see the payment window?', status === 'success' && warn.value && (_jsx(_Fragment, { children: "Are you sure you want to close this\u00A0window?" })), status === 'confirmed' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
|
|
204
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
205
|
+
!warn.value &&
|
|
206
|
+
'Sometimes the payment pop up doesn’t appear right away. Don’t worry, just click the button below to reopen it and continue your deposit.', status === 'success' &&
|
|
207
|
+
warn.value &&
|
|
208
|
+
'Closing this window might cancel your current deposit. Do you want to continue?', status === 'confirmed' &&
|
|
209
|
+
'Your deposit has been successfully processed.', status === 'failed' &&
|
|
210
|
+
'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' ||
|
|
211
|
+
status === 'success' ||
|
|
212
|
+
status === 'confirmed') && (_jsxs(AlertDialog.Footer, { children: [status === 'success' && !warn.value && (_jsx(Button, { asChild: true, children: _jsx("a", { href: createDepositMutation.data?.checkoutUrl ?? '', target: "_blank", rel: "noopener noreferrer", children: "Try Again" }) })), status === 'success' && warn.value && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", onClick: () => {
|
|
213
|
+
warn.setFalse();
|
|
214
|
+
}, children: "Go back" }), _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Continue" })) })] })), status !== 'success' && (_jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Ok" })) }))] }))] }) })] }) })] }));
|
|
171
215
|
}
|
|
@@ -4,10 +4,12 @@ import Link from 'next/link';
|
|
|
4
4
|
import { useEffect, useState } from 'react';
|
|
5
5
|
import { Controller, useForm } from 'react-hook-form';
|
|
6
6
|
import invariant from 'tiny-invariant';
|
|
7
|
+
import { useBoolean } from 'usehooks-ts';
|
|
7
8
|
import { z } from 'zod';
|
|
8
9
|
import { useShallow } from 'zustand/shallow';
|
|
9
10
|
import { useCreateAiOPayMayaDepositMutation } from '../../../../client/hooks/useAiOPayMayaDepositMutation.js';
|
|
10
11
|
import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
|
|
12
|
+
import { useDepositQuery } from '../../../../client/hooks/useDepositQuery.js';
|
|
11
13
|
import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
|
|
12
14
|
import { useDisclosure } from '../../../../client/hooks/useDisclosure.js';
|
|
13
15
|
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
@@ -16,6 +18,7 @@ import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSett
|
|
|
16
18
|
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
17
19
|
import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
|
|
18
20
|
import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
|
|
21
|
+
import { RefreshCcw01Icon } from '../../../../icons/RefreshCcw01Icon.js';
|
|
19
22
|
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
20
23
|
import { XIcon } from '../../../../icons/XIcon.js';
|
|
21
24
|
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
@@ -28,11 +31,16 @@ import { parseDecimal } from '../../../../utils/parseDecimal.js';
|
|
|
28
31
|
import { getDepositsCountQueryKey } from '../../../../utils/queryKeys.js';
|
|
29
32
|
import { AmountChoices } from '../../AmountChoices.js';
|
|
30
33
|
import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
|
|
31
|
-
import { explainError } from '../../utils.js';
|
|
32
34
|
import { AvailablePromos } from '../AvailablePromos.js';
|
|
33
35
|
export function AiOPayMayaDeposit() {
|
|
34
36
|
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
35
|
-
const disclosure = useDisclosure(
|
|
37
|
+
const disclosure = useDisclosure({
|
|
38
|
+
onOpenChange(open) {
|
|
39
|
+
if (!open) {
|
|
40
|
+
form.reset();
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
36
44
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
37
45
|
depositWithdrawal: ctx.depositWithdrawal,
|
|
38
46
|
kycVerificationStatus: ctx.kycVerificationStatus,
|
|
@@ -56,6 +64,26 @@ export function AiOPayMayaDeposit() {
|
|
|
56
64
|
setStatus('failed');
|
|
57
65
|
},
|
|
58
66
|
});
|
|
67
|
+
const warn = useBoolean();
|
|
68
|
+
const depositQuery = useDepositQuery(createDepositMutation.data?.id, {
|
|
69
|
+
enabled: !warn.value && status === 'success',
|
|
70
|
+
refetchInterval: (ctx) => ctx.state.data?.status === 'CONFIRMED' ||
|
|
71
|
+
ctx.state.data?.status === 'REJECTED' ||
|
|
72
|
+
ctx.state.data?.status === 'CANCELLED'
|
|
73
|
+
? false
|
|
74
|
+
: 1000,
|
|
75
|
+
});
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (depositQuery.data?.status === 'CONFIRMED') {
|
|
78
|
+
setStatus('confirmed');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (depositQuery.data?.status === 'REJECTED' ||
|
|
82
|
+
depositQuery.data?.status === 'CANCELLED') {
|
|
83
|
+
setStatus('failed');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}, [depositQuery.data?.status]);
|
|
59
87
|
const depositsCountQuery = useDepositsCountQuery();
|
|
60
88
|
const depositsCount = depositsCountQuery.data ?? 0;
|
|
61
89
|
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
@@ -159,13 +187,29 @@ export function AiOPayMayaDeposit() {
|
|
|
159
187
|
globalStore.depositWithdrawal.setPromo(null);
|
|
160
188
|
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "mt-lg text-text-tertiary-600 text-xs", children: ["By depositing, you agree to our", ' ', _jsx(Link, { href: depositWithdrawalProps.termsOfUseUrl ?? '/terms-of-use', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use" }), ' ', "and", ' ', _jsx(Link, { href: depositWithdrawalProps.privacyPolicyUrl ?? '/privacy-policy', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: disclosure.open, onOpenChange: (details) => {
|
|
161
189
|
disclosure.setOpen(details.open);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
|
|
190
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
|
|
191
|
+
setStatus('waiting');
|
|
192
|
+
form.reset();
|
|
193
|
+
warn.setFalse();
|
|
194
|
+
}, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.Context, { children: (api) => (_jsx("button", { type: "button", className: "absolute top-2.5 right-2.5 flex icon:size-6 size-11 items-center justify-center text-text-quinary", onClick: () => {
|
|
195
|
+
if (status === 'success' && !warn.value) {
|
|
196
|
+
warn.setTrue();
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
169
199
|
api.setOpen(false);
|
|
170
|
-
}
|
|
200
|
+
}
|
|
201
|
+
}, children: _jsx(XIcon, {}) })) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && !warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary text-text-featured-icon-light-brand", children: _jsx(RefreshCcw01Icon, {}) })), status === 'success' && warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) })), status === 'confirmed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-success-secondary text-text-featured-icon-light-success", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) }))] }), _jsxs(AlertDialog.Body, { children: [_jsxs(AlertDialog.Title, { children: [status === 'processing' && 'Processing Deposit', status === 'success' &&
|
|
202
|
+
!warn.value &&
|
|
203
|
+
'Didn’t see the payment window?', status === 'success' && warn.value && (_jsx(_Fragment, { children: "Are you sure you want to close this\u00A0window?" })), status === 'confirmed' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
|
|
204
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
205
|
+
!warn.value &&
|
|
206
|
+
'Sometimes the payment pop up doesn’t appear right away. Don’t worry, just click the button below to reopen it and continue your deposit.', status === 'success' &&
|
|
207
|
+
warn.value &&
|
|
208
|
+
'Closing this window might cancel your current deposit. Do you want to continue?', status === 'confirmed' &&
|
|
209
|
+
'Your deposit has been successfully processed.', status === 'failed' &&
|
|
210
|
+
'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' ||
|
|
211
|
+
status === 'success' ||
|
|
212
|
+
status === 'confirmed') && (_jsxs(AlertDialog.Footer, { children: [status === 'success' && !warn.value && (_jsx(Button, { asChild: true, children: _jsx("a", { href: createDepositMutation.data?.checkoutUrl ?? '', target: "_blank", rel: "noopener noreferrer", children: "Try Again" }) })), status === 'success' && warn.value && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", onClick: () => {
|
|
213
|
+
warn.setFalse();
|
|
214
|
+
}, children: "Go back" }), _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Continue" })) })] })), status !== 'success' && (_jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Ok" })) }))] }))] }) })] }) })] }));
|
|
171
215
|
}
|
|
@@ -4,10 +4,12 @@ import Link from 'next/link';
|
|
|
4
4
|
import { useEffect, useState } from 'react';
|
|
5
5
|
import { Controller, useForm } from 'react-hook-form';
|
|
6
6
|
import invariant from 'tiny-invariant';
|
|
7
|
+
import { useBoolean } from 'usehooks-ts';
|
|
7
8
|
import { z } from 'zod';
|
|
8
9
|
import { useShallow } from 'zustand/shallow';
|
|
9
10
|
import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
|
|
10
11
|
import { useCreateGCashDepositMutation } from '../../../../client/hooks/useCreateGCashDepositMutation.js';
|
|
12
|
+
import { useDepositQuery } from '../../../../client/hooks/useDepositQuery.js';
|
|
11
13
|
import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
|
|
12
14
|
import { useDisclosure } from '../../../../client/hooks/useDisclosure.js';
|
|
13
15
|
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
@@ -16,6 +18,7 @@ import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSett
|
|
|
16
18
|
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
17
19
|
import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
|
|
18
20
|
import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
|
|
21
|
+
import { RefreshCcw01Icon } from '../../../../icons/RefreshCcw01Icon.js';
|
|
19
22
|
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
20
23
|
import { XIcon } from '../../../../icons/XIcon.js';
|
|
21
24
|
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
@@ -29,7 +32,13 @@ import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext
|
|
|
29
32
|
import { AvailablePromos } from '../AvailablePromos.js';
|
|
30
33
|
export function GCashDeposit() {
|
|
31
34
|
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
32
|
-
const disclosure = useDisclosure(
|
|
35
|
+
const disclosure = useDisclosure({
|
|
36
|
+
onOpenChange(open) {
|
|
37
|
+
if (!open) {
|
|
38
|
+
form.reset();
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
});
|
|
33
42
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
34
43
|
depositWithdrawal: ctx.depositWithdrawal,
|
|
35
44
|
kycVerificationStatus: ctx.kycVerificationStatus,
|
|
@@ -51,6 +60,26 @@ export function GCashDeposit() {
|
|
|
51
60
|
setStatus('failed');
|
|
52
61
|
},
|
|
53
62
|
});
|
|
63
|
+
const warn = useBoolean();
|
|
64
|
+
const depositQuery = useDepositQuery(createDepositMutation.data?.id, {
|
|
65
|
+
enabled: !warn.value && status === 'success',
|
|
66
|
+
refetchInterval: (ctx) => ctx.state.data?.status === 'CONFIRMED' ||
|
|
67
|
+
ctx.state.data?.status === 'REJECTED' ||
|
|
68
|
+
ctx.state.data?.status === 'CANCELLED'
|
|
69
|
+
? false
|
|
70
|
+
: 1000,
|
|
71
|
+
});
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (depositQuery.data?.status === 'CONFIRMED') {
|
|
74
|
+
setStatus('confirmed');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (depositQuery.data?.status === 'REJECTED' ||
|
|
78
|
+
depositQuery.data?.status === 'CANCELLED') {
|
|
79
|
+
setStatus('failed');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}, [depositQuery.data?.status]);
|
|
54
83
|
const depositsCountQuery = useDepositsCountQuery();
|
|
55
84
|
const depositsCount = depositsCountQuery.data ?? 0;
|
|
56
85
|
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
@@ -151,13 +180,29 @@ export function GCashDeposit() {
|
|
|
151
180
|
globalStore.depositWithdrawal.setPromo(null);
|
|
152
181
|
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), depositWithdrawalProps.hasPrivacyPolicyAndTermsOfUse && (_jsxs("p", { className: "mt-lg text-text-tertiary-600 text-xs", children: ["By depositing, you agree to our", ' ', _jsx(Link, { href: depositWithdrawalProps.termsOfUseUrl ?? '/terms-of-use', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use" }), ' ', "and", ' ', _jsx(Link, { href: depositWithdrawalProps.privacyPolicyUrl ?? '/privacy-policy', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Privacy Policy" }), "."] })), _jsx(AlertDialog.Root, { open: disclosure.open, onOpenChange: (details) => {
|
|
153
182
|
disclosure.setOpen(details.open);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
|
|
183
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
|
|
184
|
+
setStatus('waiting');
|
|
185
|
+
form.reset();
|
|
186
|
+
warn.setFalse();
|
|
187
|
+
}, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.Context, { children: (api) => (_jsx("button", { type: "button", className: "absolute top-2.5 right-2.5 flex icon:size-6 size-11 items-center justify-center text-text-quinary", onClick: () => {
|
|
188
|
+
if (status === 'success' && !warn.value) {
|
|
189
|
+
warn.setTrue();
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
161
192
|
api.setOpen(false);
|
|
162
|
-
}
|
|
193
|
+
}
|
|
194
|
+
}, children: _jsx(XIcon, {}) })) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && !warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary text-text-featured-icon-light-brand", children: _jsx(RefreshCcw01Icon, {}) })), status === 'success' && warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) })), status === 'confirmed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-success-secondary text-text-featured-icon-light-success", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) }))] }), _jsxs(AlertDialog.Body, { children: [_jsxs(AlertDialog.Title, { children: [status === 'processing' && 'Processing Deposit', status === 'success' &&
|
|
195
|
+
!warn.value &&
|
|
196
|
+
'Didn’t see the payment window?', status === 'success' && warn.value && (_jsx(_Fragment, { children: "Are you sure you want to close this\u00A0window?" })), status === 'confirmed' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
|
|
197
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
198
|
+
!warn.value &&
|
|
199
|
+
'Sometimes the payment pop up doesn’t appear right away. Don’t worry, just click the button below to reopen it and continue your deposit.', status === 'success' &&
|
|
200
|
+
warn.value &&
|
|
201
|
+
'Closing this window might cancel your current deposit. Do you want to continue?', status === 'confirmed' &&
|
|
202
|
+
'Your deposit has been successfully processed.', status === 'failed' &&
|
|
203
|
+
'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' ||
|
|
204
|
+
status === 'success' ||
|
|
205
|
+
status === 'confirmed') && (_jsxs(AlertDialog.Footer, { children: [status === 'success' && !warn.value && (_jsx(Button, { asChild: true, children: _jsx("a", { href: createDepositMutation.data?.checkoutUrl ?? '', target: "_blank", rel: "noopener noreferrer", children: "Try Again" }) })), status === 'success' && warn.value && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", onClick: () => {
|
|
206
|
+
warn.setFalse();
|
|
207
|
+
}, children: "Go back" }), _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Continue" })) })] })), status !== 'success' && (_jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Ok" })) }))] }))] }) })] }) })] }));
|
|
163
208
|
}
|