@opexa/portal-components 0.0.802 → 0.0.804
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/client/hooks/useCreateDigitainGameSessionMutatio.js +0 -1
- 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/Deposit/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.d.ts +1 -1
- package/dist/components/DigitainLauncher/DigitainLauncher.js +2 -1
- package/dist/components/DigitainLauncher/DigitianContainter.js +1 -0
- package/dist/components/KYC/KYCDefault/KYCVerificationStatus.lazy.js +0 -1
- package/dist/styles/theme.css +4 -1
- package/dist/ui/AlertDialog/AlertDialog.d.ts +154 -154
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +14 -14
- package/dist/ui/Badge/Badge.d.ts +12 -12
- package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
- package/dist/ui/Badge/badge.recipe.d.ts +3 -3
- package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
- package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
- package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
- package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
- package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
- package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
- package/dist/ui/Combobox/Combobox.d.ts +42 -42
- package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
- package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
- package/dist/ui/Dialog/Dialog.d.ts +33 -33
- package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
- package/dist/ui/Drawer/Drawer.d.ts +33 -33
- package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
- package/dist/ui/Field/Field.d.ts +21 -21
- package/dist/ui/Field/field.recipe.d.ts +3 -3
- package/dist/ui/Menu/Menu.d.ts +198 -198
- package/dist/ui/Menu/menu.recipe.d.ts +11 -11
- package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
- package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
- package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
- package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
- package/dist/ui/PinInput/PinInput.d.ts +12 -12
- package/dist/ui/PinInput/pinInput.recipe.d.ts +3 -3
- package/dist/ui/Popover/Popover.d.ts +121 -121
- package/dist/ui/Popover/popover.recipe.d.ts +11 -11
- package/dist/ui/Progress/Progress.d.ts +27 -27
- package/dist/ui/Progress/progress.recipe.d.ts +3 -3
- package/dist/ui/QrCode/QrCode.d.ts +40 -40
- package/dist/ui/QrCode/qrCode.recipe.d.ts +8 -8
- package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
- package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
- package/dist/ui/Select/Select.d.ts +45 -45
- package/dist/ui/Select/select.recipe.d.ts +3 -3
- package/dist/ui/Table/Table.d.ts +21 -21
- package/dist/ui/Table/table.anatomy.d.ts +1 -1
- package/dist/ui/Table/table.recipe.d.ts +3 -3
- package/dist/ui/Tabs/Tabs.d.ts +15 -15
- package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
- package/dist/ui/Tooltip/Tooltip.d.ts +30 -30
- package/dist/ui/Tooltip/tooltip.recipe.d.ts +5 -5
- package/package.json +1 -1
- package/dist/assets/providers/alize.png +0 -0
- package/dist/assets/providers/bigtime-gaming.png +0 -0
- package/dist/assets/providers/bng.png +0 -0
- package/dist/assets/providers/boongo.png +0 -0
- package/dist/assets/providers/btg.png +0 -0
- package/dist/assets/providers/cq9.png +0 -0
- package/dist/assets/providers/darwin.png +0 -0
- package/dist/assets/providers/digitain.png +0 -0
- package/dist/assets/providers/evolution.png +0 -0
- package/dist/assets/providers/fantasma-games.png +0 -0
- package/dist/assets/providers/fc.png +0 -0
- package/dist/assets/providers/fp.png +0 -0
- package/dist/assets/providers/habanero.png +0 -0
- package/dist/assets/providers/hacksaw.png +0 -0
- package/dist/assets/providers/jdb.png +0 -0
- package/dist/assets/providers/jili.png +0 -0
- package/dist/assets/providers/leap.png +0 -0
- package/dist/assets/providers/live-22-metaverse.png +0 -0
- package/dist/assets/providers/netent.png +0 -0
- package/dist/assets/providers/no-limit.png +0 -0
- package/dist/assets/providers/pg.png +0 -0
- package/dist/assets/providers/pgsoft.png +0 -0
- package/dist/assets/providers/pragmatic-play.png +0 -0
- package/dist/assets/providers/realtime-gaming.png +0 -0
- package/dist/assets/providers/redtiger.png +0 -0
- package/dist/assets/providers/rtg.png +0 -0
- package/dist/assets/providers/sagaming.png +0 -0
- package/dist/components/DepositWithdrawal/AiOPaymentMethods.d.ts +0 -11
- package/dist/components/DepositWithdrawal/AiOPaymentMethods.js +0 -55
- package/dist/components/KYCNotRequired/KYCNotRequired.d.ts +0 -0
- package/dist/components/KYCNotRequired/KYCNotRequired.js +0 -1
- package/dist/components/Quests/MultiWageringQuest.d.ts +0 -1
- package/dist/components/Quests/MultiWageringQuest.js +0 -111
- package/dist/images/game-providers/ALPHACHINKO.png +0 -0
- package/dist/tsconfig.build.tsbuildinfo +0 -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 { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
|
|
10
11
|
import { useCreateGCashWebpayDepositMutation } from '../../../../client/hooks/useCreateGCashWebpayDepositMutation.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 GCashWebpayDeposit() {
|
|
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 GCashWebpayDeposit() {
|
|
|
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();
|
|
@@ -153,13 +182,29 @@ export function GCashWebpayDeposit() {
|
|
|
153
182
|
globalStore.depositWithdrawal.setPromo(null);
|
|
154
183
|
}, 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) => {
|
|
155
184
|
disclosure.setOpen(details.open);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
|
|
185
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
|
|
186
|
+
setStatus('waiting');
|
|
187
|
+
form.reset();
|
|
188
|
+
warn.setFalse();
|
|
189
|
+
}, 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: () => {
|
|
190
|
+
if (status === 'success' && !warn.value) {
|
|
191
|
+
warn.setTrue();
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
163
194
|
api.setOpen(false);
|
|
164
|
-
}
|
|
195
|
+
}
|
|
196
|
+
}, 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' &&
|
|
197
|
+
!warn.value &&
|
|
198
|
+
'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' &&
|
|
199
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
200
|
+
!warn.value &&
|
|
201
|
+
'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' &&
|
|
202
|
+
warn.value &&
|
|
203
|
+
'Closing this window might cancel your current deposit. Do you want to continue?', status === 'confirmed' &&
|
|
204
|
+
'Your deposit has been successfully processed.', status === 'failed' &&
|
|
205
|
+
'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' ||
|
|
206
|
+
status === 'success' ||
|
|
207
|
+
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: () => {
|
|
208
|
+
warn.setFalse();
|
|
209
|
+
}, 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" })) }))] }))] }) })] }) })] }));
|
|
165
210
|
}
|
|
@@ -4,6 +4,7 @@ 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';
|
|
@@ -17,6 +18,7 @@ import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSett
|
|
|
17
18
|
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
18
19
|
import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
|
|
19
20
|
import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
|
|
21
|
+
import { RefreshCcw01Icon } from '../../../../icons/RefreshCcw01Icon.js';
|
|
20
22
|
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
21
23
|
import { XIcon } from '../../../../icons/XIcon.js';
|
|
22
24
|
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
@@ -30,7 +32,13 @@ import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext
|
|
|
30
32
|
import { AvailablePromos } from '../AvailablePromos.js';
|
|
31
33
|
export function LibanganDeposit() {
|
|
32
34
|
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
33
|
-
const disclosure = useDisclosure(
|
|
35
|
+
const disclosure = useDisclosure({
|
|
36
|
+
onOpenChange(open) {
|
|
37
|
+
if (!open) {
|
|
38
|
+
form.reset();
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
});
|
|
34
42
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
35
43
|
depositWithdrawal: ctx.depositWithdrawal,
|
|
36
44
|
kycVerificationStatus: ctx.kycVerificationStatus,
|
|
@@ -46,36 +54,32 @@ export function LibanganDeposit() {
|
|
|
46
54
|
onSuccess(data) {
|
|
47
55
|
invariant(data.checkoutUrl);
|
|
48
56
|
window.open(data.checkoutUrl, '_blank', 'noopener,noreferrer');
|
|
49
|
-
|
|
50
|
-
disclosure.setOpen(false);
|
|
57
|
+
setStatus('success');
|
|
51
58
|
},
|
|
52
59
|
onError() {
|
|
53
|
-
disclosure.setOpen(true);
|
|
54
60
|
setStatus('failed');
|
|
55
61
|
},
|
|
56
62
|
});
|
|
63
|
+
const warn = useBoolean();
|
|
57
64
|
const depositQuery = useDepositQuery(createDepositMutation.data?.id, {
|
|
58
|
-
enabled:
|
|
59
|
-
refetchInterval(ctx)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
else {
|
|
65
|
-
return 2500;
|
|
66
|
-
}
|
|
67
|
-
},
|
|
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,
|
|
68
71
|
});
|
|
69
72
|
useEffect(() => {
|
|
70
|
-
if (depositQuery.data?.status === '
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
if (depositQuery.data?.status === 'CONFIRMED') {
|
|
74
|
+
setStatus('confirmed');
|
|
75
|
+
return;
|
|
73
76
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
setStatus('
|
|
77
|
+
if (depositQuery.data?.status === 'REJECTED' ||
|
|
78
|
+
depositQuery.data?.status === 'CANCELLED') {
|
|
79
|
+
setStatus('failed');
|
|
80
|
+
return;
|
|
77
81
|
}
|
|
78
|
-
}, [depositQuery.data?.status
|
|
82
|
+
}, [depositQuery.data?.status]);
|
|
79
83
|
const depositsCountQuery = useDepositsCountQuery();
|
|
80
84
|
const depositsCount = depositsCountQuery.data ?? 0;
|
|
81
85
|
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
@@ -178,9 +182,29 @@ export function LibanganDeposit() {
|
|
|
178
182
|
globalStore.depositWithdrawal.setPromo(null);
|
|
179
183
|
}, 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) => {
|
|
180
184
|
disclosure.setOpen(details.open);
|
|
181
|
-
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false,
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
|
|
186
|
+
setStatus('waiting');
|
|
187
|
+
form.reset();
|
|
188
|
+
warn.setFalse();
|
|
189
|
+
}, 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: () => {
|
|
190
|
+
if (status === 'success' && !warn.value) {
|
|
191
|
+
warn.setTrue();
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
184
194
|
api.setOpen(false);
|
|
185
|
-
}
|
|
195
|
+
}
|
|
196
|
+
}, 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' &&
|
|
197
|
+
!warn.value &&
|
|
198
|
+
'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' &&
|
|
199
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
200
|
+
!warn.value &&
|
|
201
|
+
'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' &&
|
|
202
|
+
warn.value &&
|
|
203
|
+
'Closing this window might cancel your current deposit. Do you want to continue?', status === 'confirmed' &&
|
|
204
|
+
'Your deposit has been successfully processed.', status === 'failed' &&
|
|
205
|
+
'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' ||
|
|
206
|
+
status === 'success' ||
|
|
207
|
+
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: () => {
|
|
208
|
+
warn.setFalse();
|
|
209
|
+
}, 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" })) }))] }))] }) })] }) })] }));
|
|
186
210
|
}
|
|
@@ -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 { useCreateMayaDepositMutation } from '../../../../client/hooks/useCreateMayaDepositMutation.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 MayaDeposit() {
|
|
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 MayaDeposit() {
|
|
|
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 MayaDeposit() {
|
|
|
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
|
}
|
|
@@ -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 { useCreateMayaWebpayDepositMutation } from '../../../../client/hooks/useCreateMayaWebpayDepositMutation.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 MayaWebpayDeposit() {
|
|
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 MayaWebpayDeposit() {
|
|
|
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();
|
|
@@ -154,13 +183,29 @@ export function MayaWebpayDeposit() {
|
|
|
154
183
|
globalStore.depositWithdrawal.setPromo(null);
|
|
155
184
|
}, 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) => {
|
|
156
185
|
disclosure.setOpen(details.open);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
|
|
186
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
|
|
187
|
+
setStatus('waiting');
|
|
188
|
+
form.reset();
|
|
189
|
+
warn.setFalse();
|
|
190
|
+
}, 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: () => {
|
|
191
|
+
if (status === 'success' && !warn.value) {
|
|
192
|
+
warn.setTrue();
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
164
195
|
api.setOpen(false);
|
|
165
|
-
}
|
|
196
|
+
}
|
|
197
|
+
}, 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' &&
|
|
198
|
+
!warn.value &&
|
|
199
|
+
'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' &&
|
|
200
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
201
|
+
!warn.value &&
|
|
202
|
+
'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' &&
|
|
203
|
+
warn.value &&
|
|
204
|
+
'Closing this window might cancel your current deposit. Do you want to continue?', status === 'confirmed' &&
|
|
205
|
+
'Your deposit has been successfully processed.', status === 'failed' &&
|
|
206
|
+
'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' ||
|
|
207
|
+
status === 'success' ||
|
|
208
|
+
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: () => {
|
|
209
|
+
warn.setFalse();
|
|
210
|
+
}, 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" })) }))] }))] }) })] }) })] }));
|
|
166
211
|
}
|
|
@@ -5,16 +5,19 @@ import Link from 'next/link';
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
import { Controller, useForm } from 'react-hook-form';
|
|
7
7
|
import invariant from 'tiny-invariant';
|
|
8
|
+
import { useBoolean } from 'usehooks-ts';
|
|
8
9
|
import { z } from 'zod';
|
|
9
10
|
import { useShallow } from 'zustand/shallow';
|
|
10
11
|
import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
|
|
11
12
|
import { useCreatePisoPayDepositMutation } from '../../../../client/hooks/useCreatePisoPayDepositMutation.js';
|
|
13
|
+
import { useDepositQuery } from '../../../../client/hooks/useDepositQuery.js';
|
|
12
14
|
import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
|
|
13
15
|
import { useDisclosure } from '../../../../client/hooks/useDisclosure.js';
|
|
14
16
|
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
15
17
|
import { useMemberVerificationQuery } from '../../../../client/hooks/useMemberVerificationQuery.js';
|
|
16
18
|
import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
|
|
17
19
|
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
20
|
+
import { RefreshCcw01Icon } from '../../../../icons/RefreshCcw01Icon.js';
|
|
18
21
|
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
19
22
|
import { XIcon } from '../../../../icons/XIcon.js';
|
|
20
23
|
import { ObjectType } from '../../../../services/ObjectType.js';
|
|
@@ -27,11 +30,16 @@ import { parseDecimal } from '../../../../utils/parseDecimal.js';
|
|
|
27
30
|
import { getDepositsCountQueryKey } from '../../../../utils/queryKeys.js';
|
|
28
31
|
import { AmountChoices } from '../../AmountChoices.js';
|
|
29
32
|
import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
|
|
30
|
-
import { explainError } from '../../utils.js';
|
|
31
33
|
import { AvailablePromos } from '../AvailablePromos.js';
|
|
32
34
|
export function PisoPayDeposit() {
|
|
33
35
|
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
34
|
-
const disclosure = useDisclosure(
|
|
36
|
+
const disclosure = useDisclosure({
|
|
37
|
+
onOpenChange(open) {
|
|
38
|
+
if (!open) {
|
|
39
|
+
form.reset();
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
});
|
|
35
43
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
36
44
|
depositWithdrawal: ctx.depositWithdrawal,
|
|
37
45
|
kycVerificationStatus: ctx.kycVerificationStatus,
|
|
@@ -55,6 +63,26 @@ export function PisoPayDeposit() {
|
|
|
55
63
|
setStatus('failed');
|
|
56
64
|
},
|
|
57
65
|
});
|
|
66
|
+
const warn = useBoolean();
|
|
67
|
+
const depositQuery = useDepositQuery(createDepositMutation.data?.id, {
|
|
68
|
+
enabled: !warn.value && status === 'success',
|
|
69
|
+
refetchInterval: (ctx) => ctx.state.data?.status === 'CONFIRMED' ||
|
|
70
|
+
ctx.state.data?.status === 'REJECTED' ||
|
|
71
|
+
ctx.state.data?.status === 'CANCELLED'
|
|
72
|
+
? false
|
|
73
|
+
: 1000,
|
|
74
|
+
});
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (depositQuery.data?.status === 'CONFIRMED') {
|
|
77
|
+
setStatus('confirmed');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (depositQuery.data?.status === 'REJECTED' ||
|
|
81
|
+
depositQuery.data?.status === 'CANCELLED') {
|
|
82
|
+
setStatus('failed');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}, [depositQuery.data?.status]);
|
|
58
86
|
const depositsCountQuery = useDepositsCountQuery();
|
|
59
87
|
const depositsCount = depositsCountQuery.data ?? 0;
|
|
60
88
|
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
@@ -168,13 +196,29 @@ export function PisoPayDeposit() {
|
|
|
168
196
|
globalStore.depositWithdrawal.setPromo(null);
|
|
169
197
|
}, 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) => {
|
|
170
198
|
disclosure.setOpen(details.open);
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
|
|
199
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
|
|
200
|
+
setStatus('waiting');
|
|
201
|
+
form.reset();
|
|
202
|
+
warn.setFalse();
|
|
203
|
+
}, 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: () => {
|
|
204
|
+
if (status === 'success' && !warn.value) {
|
|
205
|
+
warn.setTrue();
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
178
208
|
api.setOpen(false);
|
|
179
|
-
}
|
|
209
|
+
}
|
|
210
|
+
}, 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' &&
|
|
211
|
+
!warn.value &&
|
|
212
|
+
'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' &&
|
|
213
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
214
|
+
!warn.value &&
|
|
215
|
+
'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' &&
|
|
216
|
+
warn.value &&
|
|
217
|
+
'Closing this window might cancel your current deposit. Do you want to continue?', status === 'confirmed' &&
|
|
218
|
+
'Your deposit has been successfully processed.', status === 'failed' &&
|
|
219
|
+
'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' ||
|
|
220
|
+
status === 'success' ||
|
|
221
|
+
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: () => {
|
|
222
|
+
warn.setFalse();
|
|
223
|
+
}, 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" })) }))] }))] }) })] }) })] }));
|
|
180
224
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const QRPHDepositContext: (props: {
|
|
2
2
|
value: {
|
|
3
|
-
view: "
|
|
3
|
+
view: "form" | "qrCode";
|
|
4
4
|
status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
|
|
5
5
|
verify: () => void;
|
|
6
6
|
reset: () => void;
|
|
@@ -13,7 +13,7 @@ export declare const QRPHDepositContext: (props: {
|
|
|
13
13
|
} & {
|
|
14
14
|
children?: import("react").ReactNode | undefined;
|
|
15
15
|
}) => React.ReactNode, useQRPHDepositContext: () => {
|
|
16
|
-
view: "
|
|
16
|
+
view: "form" | "qrCode";
|
|
17
17
|
status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
|
|
18
18
|
verify: () => void;
|
|
19
19
|
reset: () => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Deposit } from '../../../../types';
|
|
2
2
|
export type UseQRPHDepositReturn = ReturnType<typeof useQRPHDeposit>;
|
|
3
3
|
export declare function useQRPHDeposit(): {
|
|
4
|
-
view: "
|
|
4
|
+
view: "form" | "qrCode";
|
|
5
5
|
status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
|
|
6
6
|
verify: () => void;
|
|
7
7
|
reset: () => void;
|