@opexa/portal-components 0.0.40 → 0.0.42

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 (115) hide show
  1. package/dist/client/hooks/useCreateOnlineBankDepositMutation.js +4 -1
  2. package/dist/client/hooks/useCreateQRPHDepositMutation.js +4 -1
  3. package/dist/client/hooks/useGlobalStore.d.ts +1 -2
  4. package/dist/client/hooks/useGlobalStore.js +19 -36
  5. package/dist/client/hooks/useIsMayaSessionValidQuery.js +5 -1
  6. package/dist/components/Account/Account.d.ts +1 -7
  7. package/dist/components/Account/Account.js +15 -40
  8. package/dist/components/AccountInfo/AccountInfo.js +20 -3
  9. package/dist/components/AccountSecurity/AccountSecurity.js +14 -6
  10. package/dist/components/AccountVerification/VerificationDetails.js +6 -6
  11. package/dist/components/DepositWithdrawal/AmountChoices.js +1 -1
  12. package/dist/components/DepositWithdrawal/Deposit/AvailablePromos.js +21 -16
  13. package/dist/components/DepositWithdrawal/Deposit/Deposit.js +15 -4
  14. package/dist/components/DepositWithdrawal/Deposit/GCashDeposit/GCashDeposit.js +20 -32
  15. package/dist/components/DepositWithdrawal/Deposit/MayaAppDeposit/MayaAppDeposit.js +20 -41
  16. package/dist/components/DepositWithdrawal/Deposit/MayaDeposit/MayaDeposit.js +20 -32
  17. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDeposit.js +3 -4
  18. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositAlert.d.ts +1 -0
  19. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositAlert.js +96 -0
  20. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.d.ts +16 -16
  21. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositDetails.d.ts +1 -0
  22. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositDetails.js +16 -0
  23. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositForm.d.ts +1 -1
  24. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositForm.js +7 -34
  25. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/useOnlineBankDeposit.d.ts +9 -10
  26. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/useOnlineBankDeposit.js +38 -51
  27. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDeposit.js +3 -4
  28. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositAlert.d.ts +1 -0
  29. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositAlert.js +96 -0
  30. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositContext.d.ts +14 -16
  31. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositDetails.d.ts +1 -0
  32. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositDetails.js +16 -0
  33. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositForm.d.ts +1 -1
  34. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositForm.js +7 -34
  35. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.d.ts +8 -10
  36. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.js +37 -54
  37. package/dist/components/DepositWithdrawal/DepositWithdrawal.js +3 -3
  38. package/dist/components/DepositWithdrawal/PaymentMethods.js +4 -3
  39. package/dist/components/DepositWithdrawal/Withdrawal/GCashWithdrawal/GCashWithdrawal.js +23 -19
  40. package/dist/components/DepositWithdrawal/Withdrawal/InstapayWithdrawal/InstapayWithdrawal.js +23 -20
  41. package/dist/components/DepositWithdrawal/Withdrawal/MayaAppWithdrawal/MayaAppWithdrawal.js +23 -25
  42. package/dist/components/DepositWithdrawal/Withdrawal/MayaWithdrawal/MayaWithdrawal.js +23 -19
  43. package/dist/components/DepositWithdrawal/Withdrawal/Withdrawal.js +36 -20
  44. package/dist/components/GameLaunch/GameLaunch.js +33 -57
  45. package/dist/components/KYC/KYC.d.ts +1 -0
  46. package/dist/components/KYC/KYC.js +3 -0
  47. package/dist/components/KYC/index.d.ts +1 -0
  48. package/dist/components/KYC/index.js +1 -0
  49. package/dist/components/Messages/MessageItem.js +12 -7
  50. package/dist/components/Messages/MessagePopup.js +8 -7
  51. package/dist/components/PortalProvider/PortalProvider.d.ts +2 -2
  52. package/dist/components/PortalProvider/PortalProvider.js +8 -5
  53. package/dist/components/PortalProvider/Providers.d.ts +4 -0
  54. package/dist/components/PortalProvider/Providers.js +12 -0
  55. package/dist/components/PortalProvider/Snackbar.d.ts +1 -0
  56. package/dist/components/PortalProvider/Snackbar.js +21 -0
  57. package/dist/components/PortalProvider/WebVitals.d.ts +1 -0
  58. package/dist/components/PortalProvider/WebVitals.js +8 -0
  59. package/dist/components/index.d.ts +1 -0
  60. package/dist/components/index.js +1 -0
  61. package/dist/icons/SpinnerIcon.js +1 -1
  62. package/dist/images/QRPH.png +0 -0
  63. package/dist/images/gcash.png +0 -0
  64. package/dist/images/gift.png +0 -0
  65. package/dist/styles/theme.css +28 -1
  66. package/dist/tsconfig.build.tsbuildinfo +1 -1
  67. package/dist/ui/AlertDialog/alertDialog.recipe.js +4 -4
  68. package/dist/ui/Badge/Badge.d.ts +12 -12
  69. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  70. package/dist/ui/Button/button.recipe.js +1 -1
  71. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  72. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  73. package/dist/ui/Checkbox/checkbox.recipe.js +2 -2
  74. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  75. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  76. package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
  77. package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
  78. package/dist/ui/Combobox/Combobox.d.ts +196 -196
  79. package/dist/ui/Combobox/combobox.recipe.d.ts +14 -14
  80. package/dist/ui/DatePicker/DatePicker.d.ts +192 -192
  81. package/dist/ui/DatePicker/datePicker.recipe.d.ts +8 -8
  82. package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
  83. package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
  84. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  85. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  86. package/dist/ui/Popover/Popover.d.ts +55 -55
  87. package/dist/ui/Popover/popover.recipe.d.ts +5 -5
  88. package/dist/ui/Progress/Progress.d.ts +27 -27
  89. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  90. package/dist/ui/Select/Select.d.ts +45 -45
  91. package/dist/ui/Select/select.recipe.d.ts +3 -3
  92. package/dist/ui/Table/Table.d.ts +21 -21
  93. package/dist/ui/Table/table.recipe.d.ts +3 -3
  94. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  95. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  96. package/package.json +11 -5
  97. package/dist/components/AccountVerification/selfie.png +0 -0
  98. package/dist/components/AccountVerification/upload-id.png +0 -0
  99. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositLoading.d.ts +0 -1
  100. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositLoading.js +0 -5
  101. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositSuccess.d.ts +0 -1
  102. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositSuccess.js +0 -5
  103. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositVCA.d.ts +0 -1
  104. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositVCA.js +0 -14
  105. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositLoading.d.ts +0 -1
  106. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositLoading.js +0 -5
  107. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositQrCode.d.ts +0 -1
  108. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositQrCode.js +0 -18
  109. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositSuccess.d.ts +0 -1
  110. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositSuccess.js +0 -8
  111. package/dist/components/DepositWithdrawal/MayaSessionExpired.d.ts +0 -1
  112. package/dist/components/DepositWithdrawal/MayaSessionExpired.js +0 -5
  113. package/dist/components/PortalProvider/PortalProvider.client.d.ts +0 -2
  114. package/dist/components/PortalProvider/PortalProvider.client.js +0 -38
  115. package/dist/images/QRPh.png +0 -0
@@ -1,34 +1,30 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Portal } from '@ark-ui/react';
3
3
  import { zodResolver } from '@hookform/resolvers/zod';
4
- import { useEffect } from 'react';
4
+ import { useEffect, useState } from 'react';
5
5
  import { Controller, useForm } from 'react-hook-form';
6
6
  import invariant from 'tiny-invariant';
7
7
  import { z } from 'zod';
8
- import { useShallow } from 'zustand/shallow';
9
- import { useAvailablePromosQuery, useCreateGCashDepositMutation, useDepositsCountQuery, useDisclosure, useGlobalStore, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
10
- import { toaster } from '../../../../client/utils/index.js';
8
+ import { useAvailablePromosQuery, useCreateGCashDepositMutation, useDepositsCountQuery, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
11
9
  import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, SpinnerIcon, XIcon, } from '../../../../icons/index.js';
12
10
  import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
13
11
  import { parseDecimal } from '../../../../utils/index.js';
14
12
  import { AmountChoices } from '../../AmountChoices.js';
15
13
  import { AvailablePromos } from '../AvailablePromos.js';
16
14
  export function GCashDeposit() {
17
- const disclosure = useDisclosure();
18
- const globalStore = useGlobalStore(useShallow((ctx) => ({
19
- depositWithdrawal: ctx.depositWithdrawal,
20
- })));
15
+ const [status, setStatus] = useState('waiting');
21
16
  const createDepositMutation = useCreateGCashDepositMutation({
17
+ onMutate() {
18
+ setStatus('processing');
19
+ },
22
20
  onSuccess(data) {
23
21
  invariant(data.checkoutUrl);
24
22
  window.open(data.checkoutUrl, '_blank', 'noopener,noreferrer');
25
23
  form.reset();
26
- globalStore.depositWithdrawal.setOpen(false);
24
+ setStatus('success');
27
25
  },
28
- onError(error) {
29
- toaster.error({
30
- description: error.message,
31
- });
26
+ onError() {
27
+ setStatus('failed');
32
28
  },
33
29
  });
34
30
  const depositsCountQuery = useDepositsCountQuery();
@@ -120,22 +116,14 @@ export function GCashDeposit() {
120
116
  shouldDirty: true,
121
117
  shouldValidate: true,
122
118
  });
123
- }, min: minimumAmount, max: maximumAmount, className: "mt-xl" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-4xl", value: o.field.value, onChange: o.field.onChange })) }), _jsxs("p", { className: "mt-4xl text-xs", children: ["Upon clicking the deposit button, you agree to the", ' ', _jsx("button", { type: "button", className: "underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(Button, { type: "submit", className: "mt-4.5", disabled: createDepositMutation.isPending, onClick: async (e) => {
124
- const ok = await form.trigger('amount');
125
- if (!ok)
126
- return;
127
- if (promos.length <= 0)
128
- return;
129
- if (form.getValues('promo'))
130
- return;
131
- e.preventDefault();
132
- disclosure.setOpen(true);
133
- }, children: createDepositMutation.isPending ? (_jsxs(_Fragment, { children: [_jsx(SpinnerIcon, {}), "Processing..."] })) : ('Deposit') }), _jsx(AlertDialog.Root, { role: "alertdialog", open: disclosure.open, onOpenChange: (details) => {
134
- disclosure.setOpen(details.open);
135
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+10)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+25)]", children: _jsxs(AlertDialog.Content, { children: [_jsxs(AlertDialog.Header, { children: [_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-[#FEE4E2] text-[#D92D20]", children: _jsx(AlertCircleIcon, {}) }), _jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) })] }), _jsxs(AlertDialog.Body, { children: [_jsx(AlertDialog.Title, { children: "Submit deposit request without promo?" }), _jsx(AlertDialog.Description, { children: "You haven\u2019t selected a promo. Are you sure you want to proceed without one?" })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
136
- disclosure.setOpen(false);
137
- }, children: "Cancel" }), _jsx(Button, { onClick: () => {
138
- handleSubmit();
139
- disclosure.setOpen(false);
140
- }, children: "Proceed" })] })] }) })] }) })] }));
119
+ }, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: o.field.onChange, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: status !== 'waiting', onOpenChange: (details) => {
120
+ if (!details.open) {
121
+ setStatus('waiting');
122
+ }
123
+ }, lazyMount: true, unmountOnExit: true, 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, { disabled: status === 'processing', children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "text-text-brand-primary-600 size-12" })), status === 'success' && (_jsx("div", { className: "bg-bg-success-secondary text-text-featured-icon-light-success flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "bg-bg-error-secondary text-text-featured-icon-light-error flex size-12 items-center justify-center rounded-full", 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' &&
124
+ "We're verifying your account and amount. Please hold a moment.", status === 'success' &&
125
+ 'Your deposit has been successfully processed.', status === 'failed' &&
126
+ '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: () => {
127
+ api.setOpen(false);
128
+ }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
141
129
  }
@@ -1,39 +1,29 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Portal } from '@ark-ui/react';
3
3
  import { zodResolver } from '@hookform/resolvers/zod';
4
- import { useEffect } from 'react';
4
+ import { useEffect, useState } from 'react';
5
5
  import { Controller, useForm } from 'react-hook-form';
6
6
  import { z } from 'zod';
7
- import { useShallow } from 'zustand/shallow';
8
- import { useAvailablePromosQuery, useCreateMayaAppDepositMutation, useDepositsCountQuery, useDisclosure, useGlobalStore, useIsMayaSessionValidQuery, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
9
- import { toaster } from '../../../../client/utils/index.js';
7
+ import { useAvailablePromosQuery, useCreateMayaAppDepositMutation, useDepositsCountQuery, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
10
8
  import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, SpinnerIcon, XIcon, } from '../../../../icons/index.js';
11
9
  import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
12
10
  import { parseDecimal } from '../../../../utils/index.js';
13
11
  import { AmountChoices } from '../../AmountChoices.js';
14
- import { MayaSessionExpired } from '../../MayaSessionExpired.js';
15
12
  import { AvailablePromos } from '../AvailablePromos.js';
16
13
  export function MayaAppDeposit() {
17
- const disclosure = useDisclosure();
18
- const globalStore = useGlobalStore(useShallow((ctx) => ({
19
- depositWithdrawal: ctx.depositWithdrawal,
20
- })));
14
+ const [status, setStatus] = useState('waiting');
21
15
  const createDepositMutation = useCreateMayaAppDepositMutation({
16
+ onMutate() {
17
+ setStatus('processing');
18
+ },
22
19
  onSuccess() {
20
+ setStatus('success');
23
21
  form.reset();
24
- globalStore.depositWithdrawal.setOpen(false);
25
- toaster.success({
26
- description: 'Deposit success!',
27
- });
28
22
  },
29
- onError(error) {
30
- toaster.error({
31
- description: error.message,
32
- });
23
+ onError() {
24
+ setStatus('failed');
33
25
  },
34
26
  });
35
- const isMayaSessionValidQuery = useIsMayaSessionValidQuery();
36
- const isMayaSessionValid = isMayaSessionValidQuery.data ?? true;
37
27
  const depositsCountQuery = useDepositsCountQuery();
38
28
  const depositsCount = depositsCountQuery.data ?? 0;
39
29
  const paymentSettingsQuery = usePaymentSettingsQuery();
@@ -112,9 +102,6 @@ export function MayaAppDeposit() {
112
102
  promo: data.promo ?? undefined,
113
103
  });
114
104
  });
115
- if (!isMayaSessionValid) {
116
- return _jsx(MayaSessionExpired, {});
117
- }
118
105
  return (_jsxs("form", { onSubmit: handleSubmit, noValidate: true, children: [_jsx(Controller, { control: form.control, name: "amount", render: (o) => (_jsxs(Field.Root, { invalid: !!form.formState.errors.amount, children: [_jsxs(NumberInput.Root, { min: 0, step: 1, value: o.field.value, onValueChange: (details) => {
119
106
  o.field.onChange(details.value);
120
107
  }, formatOptions: {
@@ -126,22 +113,14 @@ export function MayaAppDeposit() {
126
113
  shouldDirty: true,
127
114
  shouldValidate: true,
128
115
  });
129
- }, min: minimumAmount, max: maximumAmount, className: "mt-xl" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-4xl", value: o.field.value, onChange: o.field.onChange })) }), _jsxs("p", { className: "mt-4xl text-xs", children: ["Upon clicking the deposit button, you agree to the", ' ', _jsx("button", { type: "button", className: "underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(Button, { type: "submit", className: "mt-4.5", disabled: createDepositMutation.isPending, onClick: async (e) => {
130
- const ok = await form.trigger('amount');
131
- if (!ok)
132
- return;
133
- if (promos.length <= 0)
134
- return;
135
- if (form.getValues('promo'))
136
- return;
137
- e.preventDefault();
138
- disclosure.setOpen(true);
139
- }, children: createDepositMutation.isPending ? (_jsxs(_Fragment, { children: [_jsx(SpinnerIcon, {}), "Processing..."] })) : ('Deposit') }), _jsx(AlertDialog.Root, { role: "alertdialog", open: disclosure.open, onOpenChange: (details) => {
140
- disclosure.setOpen(details.open);
141
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+10)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+25)]", children: _jsxs(AlertDialog.Content, { children: [_jsxs(AlertDialog.Header, { children: [_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-[#FEE4E2] text-[#D92D20]", children: _jsx(AlertCircleIcon, {}) }), _jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) })] }), _jsxs(AlertDialog.Body, { children: [_jsx(AlertDialog.Title, { children: "Submit deposit request without promo?" }), _jsx(AlertDialog.Description, { children: "You haven\u2019t selected a promo. Are you sure you want to proceed without one?" })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
142
- disclosure.setOpen(false);
143
- }, children: "Cancel" }), _jsx(Button, { onClick: () => {
144
- handleSubmit();
145
- disclosure.setOpen(false);
146
- }, children: "Proceed" })] })] }) })] }) })] }));
116
+ }, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: o.field.onChange, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: status !== 'waiting', onOpenChange: (details) => {
117
+ if (!details.open) {
118
+ setStatus('waiting');
119
+ }
120
+ }, lazyMount: true, unmountOnExit: true, 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, { disabled: status === 'processing', children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "text-text-brand-primary-600 size-12" })), status === 'success' && (_jsx("div", { className: "bg-bg-success-secondary text-text-featured-icon-light-success flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "bg-bg-error-secondary text-text-featured-icon-light-error flex size-12 items-center justify-center rounded-full", 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' &&
121
+ "We're verifying your account and amount. Please hold a moment.", status === 'success' &&
122
+ 'Your deposit has been successfully processed.', status === 'failed' &&
123
+ '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: () => {
124
+ api.setOpen(false);
125
+ }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
147
126
  }
@@ -1,34 +1,30 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Portal } from '@ark-ui/react';
3
3
  import { zodResolver } from '@hookform/resolvers/zod';
4
- import { useEffect } from 'react';
4
+ import { useEffect, useState } from 'react';
5
5
  import { Controller, useForm } from 'react-hook-form';
6
6
  import invariant from 'tiny-invariant';
7
7
  import { z } from 'zod';
8
- import { useShallow } from 'zustand/shallow';
9
- import { useAvailablePromosQuery, useCreateMayaDepositMutation, useDepositsCountQuery, useDisclosure, useGlobalStore, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
10
- import { toaster } from '../../../../client/utils/index.js';
8
+ import { useAvailablePromosQuery, useCreateMayaDepositMutation, useDepositsCountQuery, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
11
9
  import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, SpinnerIcon, XIcon, } from '../../../../icons/index.js';
12
10
  import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
13
11
  import { parseDecimal } from '../../../../utils/index.js';
14
12
  import { AmountChoices } from '../../AmountChoices.js';
15
13
  import { AvailablePromos } from '../AvailablePromos.js';
16
14
  export function MayaDeposit() {
17
- const disclosure = useDisclosure();
18
- const globalStore = useGlobalStore(useShallow((ctx) => ({
19
- depositWithdrawal: ctx.depositWithdrawal,
20
- })));
15
+ const [status, setStatus] = useState('waiting');
21
16
  const createDepositMutation = useCreateMayaDepositMutation({
17
+ onMutate() {
18
+ setStatus('processing');
19
+ },
22
20
  onSuccess(data) {
23
21
  invariant(data.checkoutUrl);
24
22
  window.open(data.checkoutUrl, '_blank', 'noopener,noreferrer');
25
23
  form.reset();
26
- globalStore.depositWithdrawal.setOpen(false);
24
+ setStatus('success');
27
25
  },
28
- onError(error) {
29
- toaster.error({
30
- description: error.message,
31
- });
26
+ onError() {
27
+ setStatus('failed');
32
28
  },
33
29
  });
34
30
  const depositsCountQuery = useDepositsCountQuery();
@@ -120,22 +116,14 @@ export function MayaDeposit() {
120
116
  shouldDirty: true,
121
117
  shouldValidate: true,
122
118
  });
123
- }, min: minimumAmount, max: maximumAmount, className: "mt-xl" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-4xl", value: o.field.value, onChange: o.field.onChange })) }), _jsxs("p", { className: "mt-4xl text-xs", children: ["Upon clicking the deposit button, you agree to the", ' ', _jsx("button", { type: "button", className: "underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(Button, { type: "submit", className: "mt-4.5", disabled: createDepositMutation.isPending, onClick: async (e) => {
124
- const ok = await form.trigger('amount');
125
- if (!ok)
126
- return;
127
- if (promos.length <= 0)
128
- return;
129
- if (form.getValues('promo'))
130
- return;
131
- e.preventDefault();
132
- disclosure.setOpen(true);
133
- }, children: createDepositMutation.isPending ? (_jsxs(_Fragment, { children: [_jsx(SpinnerIcon, {}), "Processing..."] })) : ('Deposit') }), _jsx(AlertDialog.Root, { role: "alertdialog", open: disclosure.open, onOpenChange: (details) => {
134
- disclosure.setOpen(details.open);
135
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+10)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+25)]", children: _jsxs(AlertDialog.Content, { children: [_jsxs(AlertDialog.Header, { children: [_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-[#FEE4E2] text-[#D92D20]", children: _jsx(AlertCircleIcon, {}) }), _jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) })] }), _jsxs(AlertDialog.Body, { children: [_jsx(AlertDialog.Title, { children: "Submit deposit request without promo?" }), _jsx(AlertDialog.Description, { children: "You haven\u2019t selected a promo. Are you sure you want to proceed without one?" })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
136
- disclosure.setOpen(false);
137
- }, children: "Cancel" }), _jsx(Button, { onClick: () => {
138
- handleSubmit();
139
- disclosure.setOpen(false);
140
- }, children: "Proceed" })] })] }) })] }) })] }));
119
+ }, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: o.field.onChange, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: status !== 'waiting', onOpenChange: (details) => {
120
+ if (!details.open) {
121
+ setStatus('waiting');
122
+ }
123
+ }, lazyMount: true, unmountOnExit: true, 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, { disabled: status === 'processing', children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "text-text-brand-primary-600 size-12" })), status === 'success' && (_jsx("div", { className: "bg-bg-success-secondary text-text-featured-icon-light-success flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "bg-bg-error-secondary text-text-featured-icon-light-error flex size-12 items-center justify-center rounded-full", 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' &&
124
+ "We're verifying your account and amount. Please hold a moment.", status === 'success' &&
125
+ 'Your deposit has been successfully processed.', status === 'failed' &&
126
+ '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: () => {
127
+ api.setOpen(false);
128
+ }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
141
129
  }
@@ -1,11 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { OnlineBankDepositAlert } from './OnlineBankDepositAlert.js';
2
3
  import { OnlineBankDepositContext } from './OnlineBankDepositContext.js';
4
+ import { OnlineBankDepositDetails } from './OnlineBankDepositDetails.js';
3
5
  import { OnlineBankDepositForm } from './OnlineBankDepositForm.js';
4
- import { OnlineBankDepositLoading } from './OnlineBankDepositLoading.js';
5
- import { OnlineBankDepositSuccess } from './OnlineBankDepositSuccess.js';
6
- import { OnlineBankDepositVCA } from './OnlineBankDepositVCA.js';
7
6
  import { useOnlineBankDeposit } from './useOnlineBankDeposit.js';
8
7
  export function OnlineBankDeposit() {
9
8
  const context = useOnlineBankDeposit();
10
- return (_jsxs(OnlineBankDepositContext, { value: context, children: [context.view === 'FORM' && _jsx(OnlineBankDepositForm, {}), context.view === 'LOADING' && _jsx(OnlineBankDepositLoading, {}), context.view === 'SUCCESS' && _jsx(OnlineBankDepositSuccess, {}), context.view === 'VCA' && _jsx(OnlineBankDepositVCA, {})] }));
9
+ return (_jsxs(OnlineBankDepositContext, { value: context, children: [_jsx(OnlineBankDepositForm, {}), _jsx(OnlineBankDepositDetails, {}), _jsx(OnlineBankDepositAlert, {})] }));
11
10
  }
@@ -0,0 +1 @@
1
+ export declare function OnlineBankDepositAlert(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,96 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Portal } from '@ark-ui/react';
3
+ import { AlertCircleIcon, SpinnerIcon, XIcon } from '../../../../icons/index.js';
4
+ import { AlertDialog, Button } from '../../../../ui/index.js';
5
+ import { useOnlineBankDepositContext } from './OnlineBankDepositContext.js';
6
+ export function OnlineBankDepositAlert() {
7
+ const context = useOnlineBankDepositContext();
8
+ const details = useDetails();
9
+ return (_jsx(AlertDialog.Root, { open: context.status !== 'waiting' &&
10
+ context.status !== 'verification-waiting', onOpenChange: (details) => {
11
+ if (!details.open) {
12
+ context.reset();
13
+ }
14
+ }, lazyMount: true, unmountOnExit: true, 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, { disabled: details.type === 'loading', children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [details.type === 'loading' && (_jsx(SpinnerIcon, { className: "text-text-brand-primary-600 size-12" })), details.type === 'success' && (_jsx("div", { className: "bg-bg-success-secondary text-text-featured-icon-light-success flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, {}) })), details.type === 'erorr' && (_jsx("div", { className: "bg-bg-error-secondary text-text-featured-icon-light-error flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, {}) }))] }), _jsxs(AlertDialog.Body, { children: [_jsx(AlertDialog.Title, { children: details.title }), _jsx(AlertDialog.Description, { children: details.description })] }), (details.type === 'erorr' || details.type === 'success') && (_jsx(AlertDialog.Footer, { children: _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => {
15
+ api.setOpen(false);
16
+ }, children: details.type === 'success' ? 'Ok' : 'Try Again' })) }) }))] }) })] }) }));
17
+ }
18
+ function useDetails() {
19
+ const context = useOnlineBankDepositContext();
20
+ const title = (() => {
21
+ let s = '';
22
+ if (context.status === 'processing') {
23
+ s = 'Processing Deposit';
24
+ }
25
+ else if (context.status === 'failed') {
26
+ s = 'Deposit Failed';
27
+ }
28
+ else if (context.status === 'verification-success') {
29
+ s = 'Deposit Successful';
30
+ }
31
+ else if (context.status === 'verification-processing') {
32
+ s = 'Verifying Deposit';
33
+ }
34
+ else if (context.status === 'verification-failed') {
35
+ if (context.deposit?.status === 'CANCELLED') {
36
+ s = 'Deposit Cancelled';
37
+ }
38
+ else if (context.deposit?.status === 'REJECTED') {
39
+ s = 'Deposit Rejected';
40
+ }
41
+ else {
42
+ s = 'Deposit Failed';
43
+ }
44
+ }
45
+ return s;
46
+ })();
47
+ const description = (() => {
48
+ let d = '';
49
+ if (context.status === 'processing') {
50
+ d = "We're verifying your account and amount. Please hold a moment.";
51
+ }
52
+ else if (context.status === 'failed') {
53
+ d =
54
+ 'Something went wrong while processing your deposit. ' +
55
+ 'Please try again or contact support.';
56
+ }
57
+ else if (context.status === 'verification-success') {
58
+ d = 'Your deposit has been successfully processed.';
59
+ }
60
+ else if (context.status === 'verification-processing') {
61
+ d = 'Your deposit is being processed.';
62
+ }
63
+ else if (context.status === 'verification-failed') {
64
+ if (context.deposit?.status === 'CANCELLED') {
65
+ d = 'Your deposit has been cancelled.';
66
+ }
67
+ else if (context.deposit?.status === 'REJECTED') {
68
+ d = 'Your deposit has been rejected.';
69
+ }
70
+ else if (context.deposit?.status === 'FAILED') {
71
+ d = context.deposit.error ?? 'Your deposit has failed.';
72
+ }
73
+ else {
74
+ d =
75
+ 'Something went wrong while processing your deposit. ' +
76
+ 'Please try again or contact support.';
77
+ }
78
+ }
79
+ return d;
80
+ })();
81
+ const type = (() => {
82
+ if (context.status === 'failed' ||
83
+ context.status === 'verification-failed') {
84
+ return 'erorr';
85
+ }
86
+ if (context.status === 'verification-success') {
87
+ return 'success';
88
+ }
89
+ return 'loading';
90
+ })();
91
+ return {
92
+ type,
93
+ title,
94
+ description,
95
+ };
96
+ }
@@ -1,22 +1,22 @@
1
1
  export declare const OnlineBankDepositContext: import("react").Context<{
2
- vca: string | null;
3
- view: "LOADING" | "FORM" | "SUCCESS" | "VCA";
4
- generateVca: import("@tanstack/react-query").UseMutateFunction<import("@opexa/portal-sdk-core").Deposit, Error, {
5
- amount: string;
6
- promo?: string | undefined;
7
- id?: string | undefined;
8
- }, unknown>;
9
- regenerateVca: () => void;
2
+ view: "form" | "vca";
3
+ status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
4
+ verify: () => void;
10
5
  reset: () => void;
6
+ deposit: import("@opexa/portal-sdk-core").Deposit | null;
7
+ generateVCA: (input: {
8
+ amount: string;
9
+ promo?: string | null;
10
+ }) => void;
11
11
  } | null>;
12
12
  export declare const useOnlineBankDepositContext: () => {
13
- vca: string | null;
14
- view: "LOADING" | "FORM" | "SUCCESS" | "VCA";
15
- generateVca: import("@tanstack/react-query").UseMutateFunction<import("@opexa/portal-sdk-core").Deposit, Error, {
16
- amount: string;
17
- promo?: string | undefined;
18
- id?: string | undefined;
19
- }, unknown>;
20
- regenerateVca: () => void;
13
+ view: "form" | "vca";
14
+ status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
15
+ verify: () => void;
21
16
  reset: () => void;
17
+ deposit: import("@opexa/portal-sdk-core").Deposit | null;
18
+ generateVCA: (input: {
19
+ amount: string;
20
+ promo?: string | null;
21
+ }) => void;
22
22
  };
@@ -0,0 +1 @@
1
+ export declare function OnlineBankDepositDetails(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Portal } from '@ark-ui/react';
3
+ import Image from 'next/image';
4
+ import { BankIcon, XIcon } from '../../../../icons/index.js';
5
+ import bankIcon from '../../../../images/bank-icon.png';
6
+ import { Button, Clipboard, Dialog } from '../../../../ui/index.js';
7
+ import { useOnlineBankDepositContext } from './OnlineBankDepositContext.js';
8
+ export function OnlineBankDepositDetails() {
9
+ const context = useOnlineBankDepositContext();
10
+ if (context.view !== 'vca')
11
+ return null;
12
+ return (_jsxs("div", { className: "bg-bg-primary-alt rounded-lg p-2xl", children: [_jsx(Image, { src: bankIcon, alt: "", width: 52, height: 44.2, className: "mx-auto h-auto w-[3.25rem]" }), _jsx("p", { className: "mt-8 text-center font-semibold", children: "Your unique Virtual Collection Account (VCA) is:" }), _jsx(Clipboard.Root, { value: context.deposit?.vca ?? '', className: "mx-auto mt-6 max-w-[22.5rem]", children: _jsxs(Clipboard.Control, { className: "flex flex-col gap-4 lg:flex-row", children: [_jsx(Clipboard.Input, { className: "lg:grow" }), _jsx(Clipboard.Context, { children: (ctx) => (_jsx(Clipboard.Trigger, { asChild: true, children: _jsx(Button, { fullWidth: false, className: "w-full shrink-0 lg:w-28", children: ctx.copied ? 'Copied' : 'Copy VCA' }) })) })] }) }), _jsx(Instruction, {})] }));
13
+ }
14
+ function Instruction() {
15
+ return (_jsxs("p", { className: "text-text-tertiary-600 mt-6 text-center text-xs", children: ["Need help using the online bank for payment?", ' ', _jsxs(Dialog.Root, { lazyMount: true, unmountOnExit: true, children: [_jsx(Dialog.Trigger, { className: "text-text-warning-primary-600", children: "See instructions" }), _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "mx-auto w-[calc(100%-2rem)] rounded-lg p-4xl lg:w-[33.625rem]", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(Dialog.Body, { children: [_jsxs("div", { className: "flex items-center gap-xl", children: [_jsx("div", { className: "border-border-primary shadow-xs text-gray-700 text-text-secondary-700 flex size-11 items-center justify-center rounded-lg border", children: _jsx(BankIcon, { className: "size-6" }) }), _jsx(Dialog.Title, { className: "text-lg font-semibold", children: "How to Use Online Bank for Payment" })] }), _jsx(Dialog.Description, { className: "mt-5", children: "Follow these simple steps to complete your transaction:" }), _jsxs("ol", { className: "mt-3 list-inside list-decimal space-y-3", children: [_jsx("li", { children: "Click the 'Copy VCA' button to save your unique account number." }), _jsx("li", { children: "Log in to your Online Banking: Open your bank's app or website." }), _jsx("li", { children: "Initiate a Deposit: Choose the option to make a deposit." }), _jsx("li", { children: "Enter VCA: Paste your VCA in the designated field." }), _jsx("li", { children: "Complete Transaction: Follow your bank's prompts to finalize the deposit." })] }), _jsx("p", { className: "mt-3", children: "Note: Please ensure that the deposit amount you enter matches exactly." })] })] }) })] })] })] }));
16
+ }
@@ -1 +1 @@
1
- export declare function OnlineBankDepositForm(): import("react/jsx-runtime").JSX.Element;
1
+ export declare function OnlineBankDepositForm(): import("react/jsx-runtime").JSX.Element | null;
@@ -1,20 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Portal } from '@ark-ui/react';
3
2
  import { zodResolver } from '@hookform/resolvers/zod';
4
3
  import { noop } from 'lodash-es';
5
4
  import { useEffect } from 'react';
6
5
  import { Controller, useForm } from 'react-hook-form';
7
6
  import { z } from 'zod';
8
- import { useAvailablePromosQuery, useDepositsCountQuery, useDisclosure, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
9
- import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, XIcon, } from '../../../../icons/index.js';
10
- import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
7
+ import { useAvailablePromosQuery, useDepositsCountQuery, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
8
+ import { ChevronDownIcon, ChevronUpIcon } from '../../../../icons/index.js';
9
+ import { Button, Field, NumberInput } from '../../../../ui/index.js';
11
10
  import { parseDecimal } from '../../../../utils/index.js';
12
11
  import { AmountChoices } from '../../AmountChoices.js';
13
12
  import { AvailablePromos } from '../AvailablePromos.js';
14
13
  import { useOnlineBankDepositContext } from './OnlineBankDepositContext.js';
15
14
  export function OnlineBankDepositForm() {
16
15
  const context = useOnlineBankDepositContext();
17
- const disclosure = useDisclosure();
18
16
  const depositsCountQuery = useDepositsCountQuery();
19
17
  const depositsCount = depositsCountQuery.data ?? 0;
20
18
  const paymentSettingsQuery = usePaymentSettingsQuery();
@@ -87,17 +85,9 @@ export function OnlineBankDepositForm() {
87
85
  });
88
86
  }
89
87
  }, [form, minimumAmount]);
90
- const handleSubmit = form.handleSubmit(async (data) => {
91
- context.generateVca({
92
- amount: data.amount.toString(),
93
- promo: data.promo ?? undefined,
94
- }, {
95
- onSuccess() {
96
- form.reset();
97
- },
98
- });
99
- });
100
- return (_jsxs("form", { onSubmit: handleSubmit, noValidate: true, children: [_jsxs(Field.Root, { children: [_jsx(Field.Label, { children: "Bank" }), _jsx(Field.Input, { value: "BANKNET", onChange: noop, readOnly: true })] }), _jsx(Controller, { control: form.control, name: "amount", render: (o) => (_jsxs(Field.Root, { invalid: !!form.formState.errors.amount, className: "mt-4", children: [_jsxs(NumberInput.Root, { min: 0, step: 1, value: o.field.value, onValueChange: (details) => {
88
+ if (context.view !== 'form')
89
+ return null;
90
+ return (_jsxs("form", { onSubmit: form.handleSubmit(context.generateVCA), noValidate: true, children: [_jsxs(Field.Root, { children: [_jsx(Field.Label, { children: "Bank" }), _jsx(Field.Input, { value: "BANKNET", onChange: noop, readOnly: true })] }), _jsx(Controller, { control: form.control, name: "amount", render: (o) => (_jsxs(Field.Root, { invalid: !!form.formState.errors.amount, className: "mt-3xl", children: [_jsxs(NumberInput.Root, { min: 0, step: 1, value: o.field.value, onValueChange: (details) => {
101
91
  o.field.onChange(details.value);
102
92
  }, formatOptions: {
103
93
  maximumFractionDigits: 2,
@@ -108,22 +98,5 @@ export function OnlineBankDepositForm() {
108
98
  shouldDirty: true,
109
99
  shouldValidate: true,
110
100
  });
111
- }, min: minimumAmount, max: maximumAmount, className: "mt-xl" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-3xl", value: o.field.value, onChange: o.field.onChange })) }), _jsxs("p", { className: "mt-4xl text-xs", children: ["Upon clicking the deposit button, you agree to the", ' ', _jsx("button", { type: "button", className: "underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(Button, { type: "submit", className: "mt-4.5", onClick: async (e) => {
112
- const ok = await form.trigger('amount');
113
- if (!ok)
114
- return;
115
- if (promos.length <= 0)
116
- return;
117
- if (form.getValues('promo'))
118
- return;
119
- e.preventDefault();
120
- disclosure.setOpen(true);
121
- }, children: "Deposit" }), _jsx(AlertDialog.Root, { role: "alertdialog", open: disclosure.open, onOpenChange: (details) => {
122
- disclosure.setOpen(details.open);
123
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+10)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+25)]", children: _jsxs(AlertDialog.Content, { children: [_jsxs(AlertDialog.Header, { children: [_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-[#FEE4E2] text-[#D92D20]", children: _jsx(AlertCircleIcon, {}) }), _jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) })] }), _jsxs(AlertDialog.Body, { children: [_jsx(AlertDialog.Title, { children: "Submit deposit request without promo?" }), _jsx(AlertDialog.Description, { children: "You haven\u2019t selected a promo. Are you sure you want to proceed without one?" })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
124
- disclosure.setOpen(false);
125
- }, children: "Cancel" }), _jsx(Button, { onClick: () => {
126
- handleSubmit();
127
- disclosure.setOpen(false);
128
- }, children: "Proceed" })] })] }) })] }) })] }));
101
+ }, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-3xl", value: o.field.value, onChange: o.field.onChange })) }), _jsx(Button, { type: "submit", className: "mt-3xl", children: "Deposit" }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] })] }));
129
102
  }
@@ -1,14 +1,13 @@
1
- type View = 'FORM' | 'LOADING' | 'SUCCESS' | 'VCA';
1
+ import type { Deposit } from '@opexa/portal-sdk-core';
2
2
  export type UseOnlineBankDepositReturn = ReturnType<typeof useOnlineBankDeposit>;
3
3
  export declare function useOnlineBankDeposit(): {
4
- vca: string | null;
5
- view: View;
6
- generateVca: import("@tanstack/react-query").UseMutateFunction<import("@opexa/portal-sdk-core").Deposit, Error, {
7
- amount: string;
8
- promo?: string | undefined;
9
- id?: string | undefined;
10
- }, unknown>;
11
- regenerateVca: () => void;
4
+ view: "form" | "vca";
5
+ status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
6
+ verify: () => void;
12
7
  reset: () => void;
8
+ deposit: Deposit | null;
9
+ generateVCA: (input: {
10
+ amount: string;
11
+ promo?: string | null;
12
+ }) => void;
13
13
  };
14
- export {};