@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,73 +1,60 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import invariant from 'tiny-invariant';
3
3
  import { useCreateOnlineBankDepositMutation, useDepositQuery, } from '../../../../client/hooks/index.js';
4
- import { toaster } from '../../../../client/utils/index.js';
5
4
  export function useOnlineBankDeposit() {
6
- const [view, setView] = useState('FORM');
7
- const [id, setId] = useState(null);
8
- const [vca, setVca] = useState(null);
9
- const [promo, setPromo] = useState(null);
10
- const [amount, setAmount] = useState(null);
5
+ const [deposit, setDeposit] = useState(null);
6
+ const [status, setStatus] = useState('waiting');
7
+ const view = status === 'verification-failed' ||
8
+ status === 'verification-waiting' ||
9
+ status === 'verification-success' ||
10
+ status === 'verification-processing'
11
+ ? 'vca'
12
+ : 'form';
11
13
  const mutation = useCreateOnlineBankDepositMutation({
14
+ onMutate() {
15
+ setStatus('processing');
16
+ },
12
17
  onSuccess(data) {
13
18
  invariant(data.vca);
14
- setId(data.id);
15
- setVca(data.vca);
16
- setView('VCA');
17
- },
18
- onError(error) {
19
- setView('FORM');
20
- toaster.error({
21
- description: error.message,
22
- });
19
+ setStatus('verification-waiting');
20
+ setDeposit(data);
23
21
  },
24
- onMutate(data) {
25
- setId(null);
26
- setVca(null);
27
- setPromo(data.promo ?? null);
28
- setAmount(data.amount);
29
- setView('LOADING');
22
+ onError() {
23
+ setStatus('failed');
30
24
  },
31
25
  });
32
- const query = useDepositQuery(id ?? undefined, {
33
- enabled: !!id,
26
+ const generateVCA = (input) => mutation.mutate({
27
+ amount: input.amount,
28
+ promo: input.promo ?? undefined,
29
+ });
30
+ const query = useDepositQuery(deposit?.id, {
31
+ enabled: !!deposit,
34
32
  refetchInterval: 5000,
35
33
  });
36
34
  useEffect(() => {
37
- if (query.data?.status === 'CONFIRMED' ||
38
- query.data?.status === 'APPROVED') {
39
- setView('SUCCESS');
35
+ if (query.data?.status === 'APPROVED' ||
36
+ query.data?.status === 'CONFIRMED') {
37
+ setStatus('verification-success');
38
+ }
39
+ if (query.data?.status === 'CANCELLED' ||
40
+ query.data?.status === 'REJECTED' ||
41
+ query.data?.status === 'FAILED') {
42
+ setStatus('verification-failed');
40
43
  }
41
44
  }, [query.data?.status]);
42
- const generateVca = mutation.mutate;
43
- const regenerateVca = () => {
44
- invariant(amount);
45
- mutation.mutate({
46
- amount: amount.toString(),
47
- promo: promo ?? undefined,
48
- });
49
- };
50
45
  const reset = () => {
51
- setId(null);
52
- setVca(null);
53
- setPromo(null);
54
- setAmount(null);
55
- setView('FORM');
46
+ setDeposit(null);
47
+ setStatus('waiting');
48
+ };
49
+ const verify = () => {
50
+ setStatus('verification-processing');
56
51
  };
57
- useEffect(() => {
58
- return () => {
59
- setId(null);
60
- setVca(null);
61
- setPromo(null);
62
- setAmount(null);
63
- setView('FORM');
64
- };
65
- }, []);
66
52
  return {
67
- vca,
68
53
  view,
69
- generateVca,
70
- regenerateVca,
54
+ status,
55
+ verify,
71
56
  reset,
57
+ deposit,
58
+ generateVCA,
72
59
  };
73
60
  }
@@ -1,11 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { QRPHDepositAlert } from './QRPHDepositAlert.js';
2
3
  import { QRPHDepositContext } from './QRPHDepositContext.js';
4
+ import { QRPHDepositDetails } from './QRPHDepositDetails.js';
3
5
  import { QRPHDepositForm } from './QRPHDepositForm.js';
4
- import { QRPHDepositLoading } from './QRPHDepositLoading.js';
5
- import { QRPHDepositQrCode } from './QRPHDepositQrCode.js';
6
- import { QRPHDepositSuccess } from './QRPHDepositSuccess.js';
7
6
  import { useQRPHDeposit } from './useQRPHDeposit.js';
8
7
  export function QRPHDeposit() {
9
8
  const context = useQRPHDeposit();
10
- return (_jsxs(QRPHDepositContext, { value: context, children: [context.view === 'FORM' && _jsx(QRPHDepositForm, {}), context.view === 'LOADING' && _jsx(QRPHDepositLoading, {}), context.view === 'SUCCESS' && _jsx(QRPHDepositSuccess, {}), (context.view === 'QR_CODE' || context.view === 'VERIFYING') && (_jsx(QRPHDepositQrCode, {}))] }));
9
+ return (_jsxs(QRPHDepositContext, { value: context, children: [_jsx(QRPHDepositForm, {}), _jsx(QRPHDepositDetails, {}), _jsx(QRPHDepositAlert, {})] }));
11
10
  }
@@ -0,0 +1 @@
1
+ export declare function QRPHDepositAlert(): 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 { useQRPHDepositContext } from './QRPHDepositContext.js';
6
+ export function QRPHDepositAlert() {
7
+ const context = useQRPHDepositContext();
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 = useQRPHDepositContext();
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,24 +1,22 @@
1
1
  export declare const QRPHDepositContext: import("react").Context<{
2
- view: "LOADING" | "FORM" | "SUCCESS" | "QR_CODE" | "VERIFYING";
3
- qrCode: string | null;
2
+ view: "form" | "qrCode";
3
+ status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
4
4
  verify: () => void;
5
- generateQrCode: import("@tanstack/react-query").UseMutateFunction<import("@opexa/portal-sdk-core").Deposit, Error, {
6
- amount: string;
7
- promo?: string | undefined;
8
- id?: string | undefined;
9
- }, unknown>;
10
- regenerateQrCode: () => void;
11
5
  reset: () => void;
6
+ deposit: import("@opexa/portal-sdk-core").Deposit | null;
7
+ generateQRCode: (input: {
8
+ amount: string;
9
+ promo?: string | null;
10
+ }) => void;
12
11
  } | null>;
13
12
  export declare const useQRPHDepositContext: () => {
14
- view: "LOADING" | "FORM" | "SUCCESS" | "QR_CODE" | "VERIFYING";
15
- qrCode: string | null;
13
+ view: "form" | "qrCode";
14
+ status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
16
15
  verify: () => void;
17
- generateQrCode: import("@tanstack/react-query").UseMutateFunction<import("@opexa/portal-sdk-core").Deposit, Error, {
18
- amount: string;
19
- promo?: string | undefined;
20
- id?: string | undefined;
21
- }, unknown>;
22
- regenerateQrCode: () => void;
23
16
  reset: () => void;
17
+ deposit: import("@opexa/portal-sdk-core").Deposit | null;
18
+ generateQRCode: (input: {
19
+ amount: string;
20
+ promo?: string | null;
21
+ }) => void;
24
22
  };
@@ -0,0 +1 @@
1
+ export declare function QRPHDepositDetails(): 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, QrCode } from '@ark-ui/react';
3
+ import Image from 'next/image';
4
+ import { QrCode02Icon, XIcon } from '../../../../icons/index.js';
5
+ import qrphIcon from '../../../../images/qrph-icon.png';
6
+ import { Button, Dialog } from '../../../../ui/index.js';
7
+ import { useQRPHDepositContext } from './QRPHDepositContext.js';
8
+ export function QRPHDepositDetails() {
9
+ const context = useQRPHDepositContext();
10
+ if (context.view !== 'qrCode')
11
+ return null;
12
+ return (_jsxs("div", { className: "bg-bg-primary-alt rounded-lg p-2xl", children: [_jsx("p", { className: "text-center text-lg font-semibold lg:text-xl", children: "QR Code" }), _jsx("p", { className: "text-text-secondary-700 mt-3 text-center text-sm lg:text-base", children: "Scan the QR code below with your banking app, or upload it to complete your deposit." }), _jsxs(QrCode.Root, { value: context.deposit?.qrCode ?? '', className: "border-border-primary bg-bg-brand-secondary-alt mx-auto mt-6 w-[12.5rem] rounded-lg border p-5 lg:w-[13rem] lg:p-6", children: [_jsxs("div", { className: "relative", children: [_jsx(QrCode.Frame, { className: "border-border-primary mx-auto size-[10rem] rounded-[0.25rem] border bg-white", children: _jsx(QrCode.Pattern, {}) }), _jsx(QrCode.Overlay, { className: "bg-white p-0.5", children: _jsx(Image, { src: qrphIcon, alt: "", className: "size-8", width: 40, height: 40 }) })] }), _jsx(QrCode.DownloadTrigger, { fileName: `qrcode-${new Date().getTime()}`, mimeType: "image/png", className: "text-text-secondary-700 mt-5 block w-full text-center text-sm font-semibold", children: "Download QR Code" })] }), _jsxs("div", { className: "mt-6 flex flex-col gap-4 lg:flex-row", children: [_jsx(Button, { size: "sm", variant: "outline", colorScheme: "gray", onClick: context.reset, children: "Generate New QR Code" }), _jsx(Button, { size: "sm", onClick: context.verify, children: "Confirm Deposit" })] }), _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 QR Code?", ' ', _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(QrCode02Icon, { className: "size-6" }) }), _jsx(Dialog.Title, { className: "text-lg font-semibold", children: "How to Use the QR Code 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: "Open your preferred banking or EMI mobile app and select 'Transfer Money' or 'Pay via QR'" }), _jsx("li", { children: "Scan or upload the generated QR Ph code. If prompted by the app, enter the amount to be sent." }), _jsx("li", { children: "Proceed with the transfer or payment." })] })] })] }) })] })] })] }));
16
+ }
@@ -1 +1 @@
1
- export declare function QRPHDepositForm(): import("react/jsx-runtime").JSX.Element;
1
+ export declare function QRPHDepositForm(): import("react/jsx-runtime").JSX.Element | null;
@@ -1,19 +1,17 @@
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 { useEffect } from 'react';
5
4
  import { Controller, useForm } from 'react-hook-form';
6
5
  import { z } from 'zod';
7
- import { useAvailablePromosQuery, useDepositsCountQuery, useDisclosure, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
8
- import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, XIcon, } from '../../../../icons/index.js';
9
- import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
6
+ import { useAvailablePromosQuery, useDepositsCountQuery, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
7
+ import { ChevronDownIcon, ChevronUpIcon } from '../../../../icons/index.js';
8
+ import { Button, Field, NumberInput } from '../../../../ui/index.js';
10
9
  import { parseDecimal } from '../../../../utils/index.js';
11
10
  import { AmountChoices } from '../../AmountChoices.js';
12
11
  import { AvailablePromos } from '../AvailablePromos.js';
13
12
  import { useQRPHDepositContext } from './QRPHDepositContext.js';
14
13
  export function QRPHDepositForm() {
15
14
  const context = useQRPHDepositContext();
16
- const disclosure = useDisclosure();
17
15
  const depositsCountQuery = useDepositsCountQuery();
18
16
  const depositsCount = depositsCountQuery.data ?? 0;
19
17
  const paymentSettingsQuery = usePaymentSettingsQuery();
@@ -86,17 +84,9 @@ export function QRPHDepositForm() {
86
84
  });
87
85
  }
88
86
  }, [form, minimumAmount]);
89
- const handleSubmit = form.handleSubmit(async (data) => {
90
- context.generateQrCode({
91
- amount: data.amount.toString(),
92
- promo: data.promo ?? undefined,
93
- }, {
94
- onSuccess() {
95
- form.reset();
96
- },
97
- });
98
- });
99
- 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) => {
87
+ if (context.view !== 'form')
88
+ return null;
89
+ return (_jsxs("form", { onSubmit: form.handleSubmit(context.generateQRCode), 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) => {
100
90
  o.field.onChange(details.value);
101
91
  }, formatOptions: {
102
92
  maximumFractionDigits: 2,
@@ -107,22 +97,5 @@ export function QRPHDepositForm() {
107
97
  shouldDirty: true,
108
98
  shouldValidate: true,
109
99
  });
110
- }, 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", onClick: async (e) => {
111
- const ok = await form.trigger('amount');
112
- if (!ok)
113
- return;
114
- if (promos.length <= 0)
115
- return;
116
- if (form.getValues('promo'))
117
- return;
118
- e.preventDefault();
119
- disclosure.setOpen(true);
120
- }, children: "Deposit" }), _jsx(AlertDialog.Root, { role: "alertdialog", open: disclosure.open, onOpenChange: (details) => {
121
- disclosure.setOpen(details.open);
122
- }, 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: () => {
123
- disclosure.setOpen(false);
124
- }, children: "Cancel" }), _jsx(Button, { onClick: () => {
125
- handleSubmit();
126
- disclosure.setOpen(false);
127
- }, children: "Proceed" })] })] }) })] }) })] }));
100
+ }, 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", 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" }), "."] })] }));
128
101
  }
@@ -1,15 +1,13 @@
1
- type View = 'FORM' | 'LOADING' | 'SUCCESS' | 'QR_CODE' | 'VERIFYING';
1
+ import type { Deposit } from '@opexa/portal-sdk-core';
2
2
  export type UseQRPHDepositReturn = ReturnType<typeof useQRPHDeposit>;
3
3
  export declare function useQRPHDeposit(): {
4
- view: View;
5
- qrCode: string | null;
4
+ view: "form" | "qrCode";
5
+ status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
6
6
  verify: () => void;
7
- generateQrCode: import("@tanstack/react-query").UseMutateFunction<import("@opexa/portal-sdk-core").Deposit, Error, {
8
- amount: string;
9
- promo?: string | undefined;
10
- id?: string | undefined;
11
- }, unknown>;
12
- regenerateQrCode: () => void;
13
7
  reset: () => void;
8
+ deposit: Deposit | null;
9
+ generateQRCode: (input: {
10
+ amount: string;
11
+ promo?: string | null;
12
+ }) => void;
14
13
  };
15
- export {};
@@ -1,77 +1,60 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import invariant from 'tiny-invariant';
3
3
  import { useCreateQRPHDepositMutation, useDepositQuery, } from '../../../../client/hooks/index.js';
4
- import { toaster } from '../../../../client/utils/index.js';
5
4
  export function useQRPHDeposit() {
6
- const [view, setView] = useState('FORM');
7
- const [id, setId] = useState(null);
8
- const [promo, setPromo] = useState(null);
9
- const [amount, setAmount] = useState(null);
10
- const [qrCode, setQrCode] = useState(null);
5
+ const [deposit, setDeposit] = useState(null);
6
+ const [status, setStatus] = useState('waiting');
7
+ const view = status === 'verification-failed' ||
8
+ status === 'verification-waiting' ||
9
+ status === 'verification-success' ||
10
+ status === 'verification-processing'
11
+ ? 'qrCode'
12
+ : 'form';
11
13
  const mutation = useCreateQRPHDepositMutation({
14
+ onMutate() {
15
+ setStatus('processing');
16
+ },
12
17
  onSuccess(data) {
13
18
  invariant(data.qrCode);
14
- setId(data.id);
15
- setQrCode(data.qrCode);
16
- setView('QR_CODE');
17
- },
18
- onError(error) {
19
- setView('FORM');
20
- toaster.error({
21
- description: error.message,
22
- });
19
+ setStatus('verification-waiting');
20
+ setDeposit(data);
23
21
  },
24
- onMutate(data) {
25
- setId(null);
26
- setPromo(data.promo ?? null);
27
- setAmount(data.amount);
28
- setQrCode(null);
29
- setView('LOADING');
22
+ onError() {
23
+ setStatus('failed');
30
24
  },
31
25
  });
32
- const query = useDepositQuery(id ?? undefined, {
33
- enabled: !!id,
34
- refetchInterval: view === 'VERIFYING' ? 2500 : 5000,
26
+ const generateQRCode = (input) => mutation.mutate({
27
+ amount: input.amount,
28
+ promo: input.promo ?? undefined,
29
+ });
30
+ const query = useDepositQuery(deposit?.id, {
31
+ enabled: !!deposit,
32
+ refetchInterval: 5000,
35
33
  });
36
34
  useEffect(() => {
37
- if (query.data?.status === 'CONFIRMED' ||
38
- query.data?.status === 'APPROVED') {
39
- setView('SUCCESS');
35
+ if (query.data?.status === 'APPROVED' ||
36
+ query.data?.status === 'CONFIRMED') {
37
+ setStatus('verification-success');
38
+ }
39
+ if (query.data?.status === 'CANCELLED' ||
40
+ query.data?.status === 'REJECTED' ||
41
+ query.data?.status === 'FAILED') {
42
+ setStatus('verification-failed');
40
43
  }
41
44
  }, [query.data?.status]);
42
- const generateQrCode = mutation.mutate;
43
- const regenerateQrCode = () => {
44
- invariant(amount);
45
- mutation.mutate({
46
- amount: amount.toString(),
47
- promo: promo ?? undefined,
48
- });
45
+ const reset = () => {
46
+ setDeposit(null);
47
+ setStatus('waiting');
49
48
  };
50
49
  const verify = () => {
51
- setView('VERIFYING');
52
- };
53
- const reset = () => {
54
- setId(null);
55
- setPromo(null);
56
- setAmount(null);
57
- setQrCode(null);
58
- setView('FORM');
50
+ setStatus('verification-processing');
59
51
  };
60
- useEffect(() => {
61
- return () => {
62
- setId(null);
63
- setPromo(null);
64
- setAmount(null);
65
- setQrCode(null);
66
- setView('FORM');
67
- };
68
- }, []);
69
52
  return {
70
53
  view,
71
- qrCode,
54
+ status,
72
55
  verify,
73
- generateQrCode,
74
- regenerateQrCode,
75
56
  reset,
57
+ deposit,
58
+ generateQRCode,
76
59
  };
77
60
  }
@@ -6,7 +6,7 @@ import { z } from 'zod';
6
6
  import { useShallow } from 'zustand/shallow';
7
7
  import { useGlobalStore, useLocaleInfo, useWalletQuery, } from '../../client/hooks/index.js';
8
8
  import { Wallet02Icon, XIcon } from '../../icons/index.js';
9
- import { Dialog, Tabs } from '../../ui/index.js';
9
+ import { Dialog, IconButton, Tabs } from '../../ui/index.js';
10
10
  import { formatNumber } from '../../utils/index.js';
11
11
  import { Deposit } from './Deposit/Deposit.js';
12
12
  import { Withdrawal } from './Withdrawal/Withdrawal.js';
@@ -20,12 +20,12 @@ export function DepositWithdrawal(props) {
20
20
  });
21
21
  return (_jsxs(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: globalStore.depositWithdrawal.open, onOpenChange: (details) => {
22
22
  globalStore.depositWithdrawal.setOpen(details.open);
23
- }, closeOnEscape: false, closeOnInteractOutside: false, children: [_jsx(Dialog.Trigger, { asChild: true, children: props.children ?? _jsx(DefaulTrigger, {}) }), _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)]", children: _jsxs(Dialog.Content, { className: "lg:min-h-auto mx-auto min-h-full w-full p-2xl lg:w-[640px] lg:rounded-xl lg:p-3xl", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(Dialog.Header, { className: "flex items-center gap-xl", children: [_jsx("div", { className: "border-border-secondary shadow-xs text-gray-700 flex size-12 items-center justify-center rounded-lg border", children: _jsx(Wallet02Icon, {}) }), _jsx(Dialog.Title, { className: "grow text-lg font-semibold", children: "Wallet" })] }), _jsxs(Dialog.Body, { className: "mt-5", children: [_jsx("p", { className: "text-gray-500 text-center text-sm font-medium leading-tight", children: "Available Balance" }), _jsx("p", { className: "mt-lg text-center text-4xl font-semibold leading-tight tracking-tight", children: formatNumber(walletQuery.data?.balance, {
23
+ }, closeOnEscape: false, closeOnInteractOutside: false, children: [_jsx(Dialog.Trigger, { asChild: true, children: props.children ?? _jsx(DefaulTrigger, {}) }), _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)]", children: _jsxs(Dialog.Content, { className: "lg:min-h-auto mx-auto min-h-full w-full px-4 py-3xl lg:w-[480px] lg:rounded-xl", children: [_jsxs(Dialog.Header, { className: "flex items-center gap-xl", children: [_jsx("div", { className: "border-border-primary shadow-xs text-gray-700 text-text-secondary-700 flex size-10 items-center justify-center rounded-md border", children: _jsx(Wallet02Icon, { className: "size-5" }) }), _jsx(Dialog.Title, { className: "grow text-lg font-semibold", children: "Wallet" }), _jsx(Dialog.Context, { children: (api) => (_jsx(IconButton, { size: "sm", variant: "outline", colorScheme: "gray", onClick: () => api.setOpen(false), children: _jsx(XIcon, {}) })) })] }), _jsxs(Dialog.Body, { className: "mt-3xl", children: [_jsx("p", { className: "text-text-secondary-700 text-center text-sm", children: "Deposit Balance" }), _jsx("p", { className: "text-center text-3xl font-bold leading-tight tracking-tight", children: formatNumber(walletQuery.data?.balance, {
24
24
  currency: localeInfo.currency.code,
25
25
  minDecimalPlaces: 2,
26
26
  }) }), _jsxs(Tabs.Root, { value: globalStore.depositWithdrawal.tab, onValueChange: (details) => {
27
27
  globalStore.depositWithdrawal.setTab(z.enum(['DEPOSIT', 'WITHDRAWAL']).parse(details.value));
28
- }, lazyMount: true, unmountOnExit: true, className: "mt-4xl space-y-4xl", children: [_jsxs(Tabs.List, { className: "w-full", children: [_jsx(Tabs.Trigger, { value: "DEPOSIT", className: "grow", children: "Deposit" }), _jsx(Tabs.Trigger, { value: "WITHDRAWAL", className: "grow", children: "Withdrawal" }), _jsx(Tabs.Indicator, {})] }), _jsx(Tabs.Content, { value: "DEPOSIT", className: "space-y-4xl", children: _jsx(Deposit, {}) }), _jsx(Tabs.Content, { value: "WITHDRAWAL", className: "space-y-4xl", children: _jsx(Withdrawal, {}) })] })] })] }) })] })] }));
28
+ }, lazyMount: true, unmountOnExit: true, className: "mt-3xl space-y-4xl", children: [_jsxs(Tabs.List, { className: "w-full", children: [_jsx(Tabs.Trigger, { value: "DEPOSIT", className: "grow", children: "Deposit" }), _jsx(Tabs.Trigger, { value: "WITHDRAWAL", className: "grow", children: "Withdrawal" }), _jsx(Tabs.Indicator, {})] }), _jsx(Tabs.Content, { value: "DEPOSIT", className: "space-y-3xl", children: _jsx(Deposit, {}) }), _jsx(Tabs.Content, { value: "WITHDRAWAL", className: "space-y-3xl", children: _jsx(Withdrawal, {}) })] })] })] }) })] })] }));
29
29
  }
30
30
  function DefaulTrigger(props) {
31
31
  const localeInfo = useLocaleInfo();
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import Image from 'next/image';
3
+ import { twMerge } from 'tailwind-merge';
3
4
  import { useControllableState } from '../../client/hooks/index.js';
4
5
  import { CheckIcon } from '../../icons/index.js';
5
- import qrph from '../../images/QRPh.png';
6
+ import qrph from '../../images/QRPH.png';
6
7
  import gcash from '../../images/gcash.png';
7
8
  import instapay from '../../images/instapay.png';
8
9
  import maya from '../../images/maya.png';
@@ -50,10 +51,10 @@ export function PaymentMethods(props) {
50
51
  defaultValue: props.defaultValue ?? options[0].value,
51
52
  onChange: props.onChange,
52
53
  });
53
- return (_jsxs("div", { className: props.className, children: [_jsx(Field.Label, { asChild: true, children: _jsx("div", { children: "Select your payment method" }) }), _jsx(Checkbox.Group, { value: [value], onValueChange: (newValue) => {
54
+ return (_jsxs("div", { className: props.className, children: [_jsx(Field.Label, { asChild: true, children: _jsx("div", { children: "Available payment methods" }) }), _jsx(Checkbox.Group, { value: [value], onValueChange: (newValue) => {
54
55
  const lastValue = newValue.at(-1);
55
56
  if (!lastValue)
56
57
  return;
57
58
  setValue(PaymentMethodDefinition.parse(lastValue));
58
- }, className: "grid grid-cols-2 gap-x-4 gap-y-3", children: options.map((option) => (_jsxs(Checkbox.Root, { value: option.value, className: "border-border-secondary ui-checked:border-gray-900 ui-checked:outline-solid ui-checked:outline-border-secondary flex cursor-pointer rounded-xl border p-xl ui-checked:outline", children: [_jsx("div", { className: "grow", children: _jsx(Image, { src: option.image, alt: "", width: 200, height: 40, className: "h-5 w-auto lg:h-8", draggable: false }) }), _jsx(Checkbox.Control, { className: "shrink-0", children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsx(Checkbox.HiddenInput, {})] }, option.value))) })] }));
59
+ }, className: "grid grid-cols-2 gap-x-4 gap-y-3", children: options.map((option) => (_jsxs(Checkbox.Root, { value: option.value, className: "border-border-secondary ui-checked:border-border-brand-solid flex cursor-pointer items-center justify-between rounded-xl border p-lg", children: [_jsx("div", { className: twMerge('rounded-xs bg-white px-sm py-[0.688rem]', option.value === 'GCASH' && 'bg-[#017EFF]'), children: _jsx(Image, { src: option.image, alt: "", width: 200, height: 40, className: "h-[1.063rem] w-auto", draggable: false }) }), _jsx(Checkbox.Control, { className: "shrink-0", children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsx(Checkbox.HiddenInput, {})] }, option.value))) })] }));
59
60
  }