@opexa/portal-components 0.0.803 → 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 (136) hide show
  1. package/dist/components/DepositWithdrawal/Deposit/AiOGCashDeposit/AiOGCashDeposit.js +54 -10
  2. package/dist/components/DepositWithdrawal/Deposit/AiOGrabPayDeposit/AiOGrabPayDeposit.js +54 -10
  3. package/dist/components/DepositWithdrawal/Deposit/AiOPalawanPayDeposit/AiOPalawanPayDeposit.js +54 -10
  4. package/dist/components/DepositWithdrawal/Deposit/AiOPayMayaDeposit/AiOPayMayaDeposit.js +54 -10
  5. package/dist/components/DepositWithdrawal/Deposit/GCashDeposit/GCashDeposit.js +54 -9
  6. package/dist/components/DepositWithdrawal/Deposit/GCashWebpayDeposit/GCashWebpayDeposit.js +54 -9
  7. package/dist/components/DepositWithdrawal/Deposit/LibanganDeposit/LibanganDeposit.js +49 -25
  8. package/dist/components/DepositWithdrawal/Deposit/MayaDeposit/MayaDeposit.js +54 -9
  9. package/dist/components/DepositWithdrawal/Deposit/MayaWebpayDeposit/MayaWebpayDeposit.js +54 -9
  10. package/dist/components/DepositWithdrawal/Deposit/PisoPayDeposit/PisoPayDeposit.js +54 -10
  11. package/dist/styles/theme.css +4 -1
  12. package/dist/ui/AlertDialog/AlertDialog.d.ts +88 -88
  13. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +8 -8
  14. package/dist/ui/Avatar/Avatar.d.ts +9 -9
  15. package/dist/ui/Avatar/avatar.recipe.d.ts +3 -3
  16. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  17. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  18. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  19. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  20. package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
  21. package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
  22. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  23. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  24. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  25. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  26. package/dist/ui/Dialog/Dialog.d.ts +33 -33
  27. package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
  28. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  29. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  30. package/dist/ui/Menu/Menu.d.ts +144 -144
  31. package/dist/ui/Menu/menu.recipe.d.ts +8 -8
  32. package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
  33. package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
  34. package/dist/ui/Popover/Popover.d.ts +154 -154
  35. package/dist/ui/Popover/popover.recipe.d.ts +14 -14
  36. package/dist/ui/QrCode/QrCode.d.ts +25 -25
  37. package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
  38. package/dist/ui/Select/Select.d.ts +45 -45
  39. package/dist/ui/Select/select.recipe.d.ts +3 -3
  40. package/dist/ui/Table/Table.d.ts +21 -21
  41. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  42. package/dist/ui/Table/table.recipe.d.ts +3 -3
  43. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  44. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  45. package/dist/ui/Tooltip/Tooltip.d.ts +30 -30
  46. package/dist/ui/Tooltip/tooltip.recipe.d.ts +5 -5
  47. package/package.json +1 -1
  48. package/dist/assets/providers/alize.png +0 -0
  49. package/dist/assets/providers/bigtime-gaming.png +0 -0
  50. package/dist/assets/providers/bng.png +0 -0
  51. package/dist/assets/providers/boongo.png +0 -0
  52. package/dist/assets/providers/btg.png +0 -0
  53. package/dist/assets/providers/cq9.png +0 -0
  54. package/dist/assets/providers/darwin.png +0 -0
  55. package/dist/assets/providers/digitain.png +0 -0
  56. package/dist/assets/providers/evolution.png +0 -0
  57. package/dist/assets/providers/fantasma-games.png +0 -0
  58. package/dist/assets/providers/fc.png +0 -0
  59. package/dist/assets/providers/fp.png +0 -0
  60. package/dist/assets/providers/habanero.png +0 -0
  61. package/dist/assets/providers/hacksaw.png +0 -0
  62. package/dist/assets/providers/jdb.png +0 -0
  63. package/dist/assets/providers/jili.png +0 -0
  64. package/dist/assets/providers/leap.png +0 -0
  65. package/dist/assets/providers/live-22-metaverse.png +0 -0
  66. package/dist/assets/providers/netent.png +0 -0
  67. package/dist/assets/providers/no-limit.png +0 -0
  68. package/dist/assets/providers/pg.png +0 -0
  69. package/dist/assets/providers/pgsoft.png +0 -0
  70. package/dist/assets/providers/pragmatic-play.png +0 -0
  71. package/dist/assets/providers/realtime-gaming.png +0 -0
  72. package/dist/assets/providers/redtiger.png +0 -0
  73. package/dist/assets/providers/rtg.png +0 -0
  74. package/dist/assets/providers/sagaming.png +0 -0
  75. package/dist/components/Banner/Banner.client.d.ts +0 -12
  76. package/dist/components/Banner/Banner.client.js +0 -49
  77. package/dist/components/DepositWithdrawal/AiOPaymentMethods.d.ts +0 -11
  78. package/dist/components/DepositWithdrawal/AiOPaymentMethods.js +0 -55
  79. package/dist/components/DigitainLauncher/Loading.d.ts +0 -1
  80. package/dist/components/DigitainLauncher/Loading.js +0 -5
  81. package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +0 -184
  82. package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +0 -184
  83. package/dist/components/KYC/BasicInformation.d.ts +0 -1
  84. package/dist/components/KYC/BasicInformation.js +0 -101
  85. package/dist/components/KYC/IdentityVerification.d.ts +0 -1
  86. package/dist/components/KYC/IdentityVerification.js +0 -120
  87. package/dist/components/KYC/Indicator.d.ts +0 -1
  88. package/dist/components/KYC/Indicator.js +0 -8
  89. package/dist/components/KYC/KYC.lazy.d.ts +0 -6
  90. package/dist/components/KYC/KYC.lazy.js +0 -45
  91. package/dist/components/KYC/KYCContext.d.ts +0 -6
  92. package/dist/components/KYC/KYCContext.js +0 -2
  93. package/dist/components/KYC/KYCDefault/BasicInformation.d.ts +0 -1
  94. package/dist/components/KYC/KYCDefault/BasicInformation.js +0 -101
  95. package/dist/components/KYC/KYCVerificationStatus.d.ts +0 -1
  96. package/dist/components/KYC/KYCVerificationStatus.js +0 -10
  97. package/dist/components/KYC/KYCVerificationStatus.lazy.d.ts +0 -1
  98. package/dist/components/KYC/KYCVerificationStatus.lazy.js +0 -36
  99. package/dist/components/KYC/PersonalInformation.d.ts +0 -1
  100. package/dist/components/KYC/PersonalInformation.js +0 -122
  101. package/dist/components/KYC/useKYC.d.ts +0 -25
  102. package/dist/components/KYC/useKYC.js +0 -38
  103. package/dist/components/KYCNotRequired/KYCNotRequired.d.ts +0 -0
  104. package/dist/components/KYCNotRequired/KYCNotRequired.js +0 -1
  105. package/dist/components/PortalProvider/AndroidOnlyComponents.d.ts +0 -1
  106. package/dist/components/PortalProvider/AndroidOnlyComponents.js +0 -12
  107. package/dist/components/PortalProvider/CXDTokenObserver.d.ts +0 -1
  108. package/dist/components/PortalProvider/CXDTokenObserver.js +0 -30
  109. package/dist/components/PortalProvider/LinkGoogleAccountObserver.d.ts +0 -1
  110. package/dist/components/PortalProvider/LinkGoogleAccountObserver.js +0 -29
  111. package/dist/components/Quests/MultiWageringQuest.d.ts +0 -1
  112. package/dist/components/Quests/MultiWageringQuest.js +0 -111
  113. package/dist/components/SessionWatcher/SessionWatcher.d.ts +0 -1
  114. package/dist/components/SessionWatcher/SessionWatcher.js +0 -20
  115. package/dist/components/SessionWatcher/index.d.ts +0 -1
  116. package/dist/components/SessionWatcher/index.js +0 -1
  117. package/dist/components/SignIn/utils.d.ts +0 -8
  118. package/dist/components/SignIn/utils.js +0 -26
  119. package/dist/constants/Branches.d.ts +0 -2
  120. package/dist/constants/Branches.js +0 -42
  121. package/dist/images/game-providers/ALPHACHINKO.png +0 -0
  122. package/dist/images/responsible-gaming-yellow.png +0 -0
  123. package/dist/third-parties/FacebookPixel/FacebookPixel.d.ts +0 -4
  124. package/dist/third-parties/FacebookPixel/FacebookPixel.js +0 -4
  125. package/dist/third-parties/FacebookPixel/api.d.ts +0 -0
  126. package/dist/third-parties/FacebookPixel/api.js +0 -1
  127. package/dist/third-parties/FacebookPixel/index.d.ts +0 -1
  128. package/dist/third-parties/FacebookPixel/index.js +0 -1
  129. package/dist/third-parties/GoogleRecaptcha/GoogleRecaptcha.d.ts +0 -4
  130. package/dist/third-parties/GoogleRecaptcha/GoogleRecaptcha.js +0 -4
  131. package/dist/third-parties/GoogleRecaptcha/api.d.ts +0 -0
  132. package/dist/third-parties/GoogleRecaptcha/api.js +0 -1
  133. package/dist/third-parties/GoogleRecaptcha/index.d.ts +0 -1
  134. package/dist/third-parties/GoogleRecaptcha/index.js +0 -1
  135. package/dist/third-parties/index.d.ts +0 -2
  136. package/dist/third-parties/index.js +0 -2
@@ -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
- if (!details.open) {
157
- setStatus('waiting');
158
- form.reset();
159
- }
160
- }, 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' &&
161
- "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' &&
162
- '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: () => {
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
- }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
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
- form.reset();
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: createDepositMutation.data != null,
59
- refetchInterval(ctx) {
60
- if (ctx.state.data?.status === 'CANCELLED' ||
61
- ctx.state.data?.status === 'CONFIRMED') {
62
- return false;
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 === 'CANCELLED') {
71
- disclosure.setOpen(true);
72
- setStatus('failed');
73
+ if (depositQuery.data?.status === 'CONFIRMED') {
74
+ setStatus('confirmed');
75
+ return;
73
76
  }
74
- else if (depositQuery.data?.status === 'CONFIRMED') {
75
- disclosure.setOpen(true);
76
- setStatus('success');
77
+ if (depositQuery.data?.status === 'REJECTED' ||
78
+ depositQuery.data?.status === 'CANCELLED') {
79
+ setStatus('failed');
80
+ return;
77
81
  }
78
- }, [depositQuery.data?.status, disclosure]);
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, 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' &&
182
- "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' &&
183
- '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: () => {
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
- }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
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
- 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
  }
@@ -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
- if (!details.open) {
158
- setStatus('waiting');
159
- form.reset();
160
- }
161
- }, 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' &&
162
- "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' &&
163
- '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: () => {
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
- }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
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
- if (!details.open) {
172
- setStatus('waiting');
173
- form.reset();
174
- }
175
- }, 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' &&
176
- "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' &&
177
- explainError(createDepositMutation?.error?.name)] })] }), (status === 'failed' || status === 'success') && (_jsx(AlertDialog.Footer, { children: _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => {
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
- }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
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
  }
@@ -264,10 +264,13 @@
264
264
  --color-text-warning-primary: #f79009;
265
265
  --color-text-warning-primary-600: #fdb022;
266
266
  --color-text-error-primary: #f04438;
267
+ --color-dark-text: #cccccc;
268
+
267
269
  --color-text-featured-icon-light-success: #abefc6;
268
270
  --color-text-featured-icon-light-error: #fecdca;
269
271
  --color-text-featured-icon-light-warning: #fedf89;
270
- --color-dark-text: #cccccc;
272
+ --color-text-featured-icon-light-warning: #fedf89;
273
+ --color-text-featured-icon-light-brand: #E4D5A4;
271
274
 
272
275
  --color-border-primary: #373a41;
273
276
  --color-border-secondary: #22262f;