@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.
Files changed (99) hide show
  1. package/dist/client/hooks/useCreateDigitainGameSessionMutatio.js +0 -1
  2. package/dist/components/DepositWithdrawal/Deposit/AiOGCashDeposit/AiOGCashDeposit.js +54 -10
  3. package/dist/components/DepositWithdrawal/Deposit/AiOGrabPayDeposit/AiOGrabPayDeposit.js +54 -10
  4. package/dist/components/DepositWithdrawal/Deposit/AiOPalawanPayDeposit/AiOPalawanPayDeposit.js +54 -10
  5. package/dist/components/DepositWithdrawal/Deposit/AiOPayMayaDeposit/AiOPayMayaDeposit.js +54 -10
  6. package/dist/components/DepositWithdrawal/Deposit/GCashDeposit/GCashDeposit.js +54 -9
  7. package/dist/components/DepositWithdrawal/Deposit/GCashWebpayDeposit/GCashWebpayDeposit.js +54 -9
  8. package/dist/components/DepositWithdrawal/Deposit/LibanganDeposit/LibanganDeposit.js +49 -25
  9. package/dist/components/DepositWithdrawal/Deposit/MayaDeposit/MayaDeposit.js +54 -9
  10. package/dist/components/DepositWithdrawal/Deposit/MayaWebpayDeposit/MayaWebpayDeposit.js +54 -9
  11. package/dist/components/DepositWithdrawal/Deposit/PisoPayDeposit/PisoPayDeposit.js +54 -10
  12. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
  13. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.d.ts +1 -1
  14. package/dist/components/DigitainLauncher/DigitainLauncher.js +2 -1
  15. package/dist/components/DigitainLauncher/DigitianContainter.js +1 -0
  16. package/dist/components/KYC/KYCDefault/KYCVerificationStatus.lazy.js +0 -1
  17. package/dist/styles/theme.css +4 -1
  18. package/dist/ui/AlertDialog/AlertDialog.d.ts +154 -154
  19. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +14 -14
  20. package/dist/ui/Badge/Badge.d.ts +12 -12
  21. package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
  22. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  23. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  24. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  25. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  26. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  27. package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
  28. package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
  29. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  30. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  31. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  32. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  33. package/dist/ui/Dialog/Dialog.d.ts +33 -33
  34. package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
  35. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  36. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  37. package/dist/ui/Field/Field.d.ts +21 -21
  38. package/dist/ui/Field/field.recipe.d.ts +3 -3
  39. package/dist/ui/Menu/Menu.d.ts +198 -198
  40. package/dist/ui/Menu/menu.recipe.d.ts +11 -11
  41. package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
  42. package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
  43. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  44. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  45. package/dist/ui/PinInput/PinInput.d.ts +12 -12
  46. package/dist/ui/PinInput/pinInput.recipe.d.ts +3 -3
  47. package/dist/ui/Popover/Popover.d.ts +121 -121
  48. package/dist/ui/Popover/popover.recipe.d.ts +11 -11
  49. package/dist/ui/Progress/Progress.d.ts +27 -27
  50. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  51. package/dist/ui/QrCode/QrCode.d.ts +40 -40
  52. package/dist/ui/QrCode/qrCode.recipe.d.ts +8 -8
  53. package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
  54. package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
  55. package/dist/ui/Select/Select.d.ts +45 -45
  56. package/dist/ui/Select/select.recipe.d.ts +3 -3
  57. package/dist/ui/Table/Table.d.ts +21 -21
  58. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  59. package/dist/ui/Table/table.recipe.d.ts +3 -3
  60. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  61. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  62. package/dist/ui/Tooltip/Tooltip.d.ts +30 -30
  63. package/dist/ui/Tooltip/tooltip.recipe.d.ts +5 -5
  64. package/package.json +1 -1
  65. package/dist/assets/providers/alize.png +0 -0
  66. package/dist/assets/providers/bigtime-gaming.png +0 -0
  67. package/dist/assets/providers/bng.png +0 -0
  68. package/dist/assets/providers/boongo.png +0 -0
  69. package/dist/assets/providers/btg.png +0 -0
  70. package/dist/assets/providers/cq9.png +0 -0
  71. package/dist/assets/providers/darwin.png +0 -0
  72. package/dist/assets/providers/digitain.png +0 -0
  73. package/dist/assets/providers/evolution.png +0 -0
  74. package/dist/assets/providers/fantasma-games.png +0 -0
  75. package/dist/assets/providers/fc.png +0 -0
  76. package/dist/assets/providers/fp.png +0 -0
  77. package/dist/assets/providers/habanero.png +0 -0
  78. package/dist/assets/providers/hacksaw.png +0 -0
  79. package/dist/assets/providers/jdb.png +0 -0
  80. package/dist/assets/providers/jili.png +0 -0
  81. package/dist/assets/providers/leap.png +0 -0
  82. package/dist/assets/providers/live-22-metaverse.png +0 -0
  83. package/dist/assets/providers/netent.png +0 -0
  84. package/dist/assets/providers/no-limit.png +0 -0
  85. package/dist/assets/providers/pg.png +0 -0
  86. package/dist/assets/providers/pgsoft.png +0 -0
  87. package/dist/assets/providers/pragmatic-play.png +0 -0
  88. package/dist/assets/providers/realtime-gaming.png +0 -0
  89. package/dist/assets/providers/redtiger.png +0 -0
  90. package/dist/assets/providers/rtg.png +0 -0
  91. package/dist/assets/providers/sagaming.png +0 -0
  92. package/dist/components/DepositWithdrawal/AiOPaymentMethods.d.ts +0 -11
  93. package/dist/components/DepositWithdrawal/AiOPaymentMethods.js +0 -55
  94. package/dist/components/KYCNotRequired/KYCNotRequired.d.ts +0 -0
  95. package/dist/components/KYCNotRequired/KYCNotRequired.js +0 -1
  96. package/dist/components/Quests/MultiWageringQuest.d.ts +0 -1
  97. package/dist/components/Quests/MultiWageringQuest.js +0 -111
  98. package/dist/images/game-providers/ALPHACHINKO.png +0 -0
  99. package/dist/tsconfig.build.tsbuildinfo +0 -1
@@ -18,7 +18,6 @@ export const useCreateDigitainGameSessionMutation = (config) => {
18
18
  mutationFn: async (game) => {
19
19
  const id = ObjectId.generate(ObjectType.GameSession).toString();
20
20
  const session = await getSession();
21
- console.log('Creating Digitain game session');
22
21
  invariant(session.status === 'authenticated');
23
22
  await createGameSession({
24
23
  id,
@@ -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
- if (!details.open) {
165
- setStatus('waiting');
166
- form.reset();
167
- }
168
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, 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.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && (_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' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
169
- "We're verifying your account and amount. Please hold a moment.", status === 'success' && (_jsxs(_Fragment, { children: ["Your deposit has been successfully processed. ", _jsx("br", {}), " If you are not redirected automatically, click", ' ', !!createDepositMutation.data?.checkoutUrl && (_jsx("a", { href: createDepositMutation.data?.checkoutUrl, target: "_blank", rel: "noopener noreferrer", className: "text-text-brand underline underline-offset-2", children: "here" })), "."] })), status === 'failed' &&
170
- explainError(createDepositMutation?.error?.name)] })] }), (status === 'failed' || status === 'success') && (_jsx(AlertDialog.Footer, { children: _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => {
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
- }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
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
- if (!details.open) {
163
- setStatus('waiting');
164
- form.reset();
165
- }
166
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, 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.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && (_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' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
167
- "We're verifying your account and amount. Please hold a moment.", status === 'success' && (_jsxs(_Fragment, { children: ["Your deposit has been successfully processed. ", _jsx("br", {}), " If you are not redirected automatically, click", ' ', !!createDepositMutation.data?.checkoutUrl && (_jsx("a", { href: createDepositMutation.data?.checkoutUrl, target: "_blank", rel: "noopener noreferrer", className: "text-text-brand underline underline-offset-2", children: "here" })), "."] })), status === 'failed' &&
168
- explainError(createDepositMutation?.error?.name)] })] }), (status === 'failed' || status === 'success') && (_jsx(AlertDialog.Footer, { children: _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => {
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
- }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
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 { 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
- if (!details.open) {
163
- setStatus('waiting');
164
- form.reset();
165
- }
166
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, 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.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && (_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' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
167
- "We're verifying your account and amount. Please hold a moment.", status === 'success' && (_jsxs(_Fragment, { children: ["Your deposit has been successfully processed. ", _jsx("br", {}), " If you are not redirected automatically, click", ' ', !!createDepositMutation.data?.checkoutUrl && (_jsx("a", { href: createDepositMutation.data?.checkoutUrl, target: "_blank", rel: "noopener noreferrer", className: "text-text-brand underline underline-offset-2", children: "here" })), "."] })), status === 'failed' &&
168
- explainError(createDepositMutation?.error?.name)] })] }), (status === 'failed' || status === 'success') && (_jsx(AlertDialog.Footer, { children: _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => {
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
- }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
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
- if (!details.open) {
163
- setStatus('waiting');
164
- form.reset();
165
- }
166
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, 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.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && (_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' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
167
- "We're verifying your account and amount. Please hold a moment.", status === 'success' && (_jsxs(_Fragment, { children: ["Your deposit has been successfully processed. ", _jsx("br", {}), " If you are not redirected automatically, click", ' ', !!createDepositMutation.data?.checkoutUrl && (_jsx("a", { href: createDepositMutation.data?.checkoutUrl, target: "_blank", rel: "noopener noreferrer", className: "text-text-brand underline underline-offset-2", children: "here" })), "."] })), status === 'failed' &&
168
- explainError(createDepositMutation?.error?.name)] })] }), (status === 'failed' || status === 'success') && (_jsx(AlertDialog.Footer, { children: _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => {
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
- }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
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
- if (!details.open) {
155
- setStatus('waiting');
156
- form.reset();
157
- }
158
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, 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.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && (_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' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
159
- "We're verifying your account and amount. Please hold a moment.", status === 'success' && (_jsxs(_Fragment, { children: ["Your deposit has been successfully processed. ", _jsx("br", {}), " If you are not redirected automatically, click", ' ', !!createDepositMutation.data?.checkoutUrl && (_jsx("a", { href: createDepositMutation.data?.checkoutUrl, target: "_blank", rel: "noopener noreferrer", className: "text-text-brand underline underline-offset-2", children: "here" })), "."] })), status === 'failed' &&
160
- 'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' || status === 'success') && (_jsx(AlertDialog.Footer, { children: _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => {
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
- }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
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
  }