@opexa/portal-components 0.0.806 → 0.0.808
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DepositWithdrawal/DepositWithdrawal.lazy.js +4 -1
- package/dist/components/DepositWithdrawal/Deposit__next/AiOGCashDeposit/AiOGCashDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/AiOGCashDeposit/AiOGCashDeposit.js +217 -0
- package/dist/components/DepositWithdrawal/Deposit__next/AiOGrabPayDeposit/AiOGrabPayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/AiOGrabPayDeposit/AiOGrabPayDeposit.js +215 -0
- package/dist/components/DepositWithdrawal/Deposit__next/AiOPalawanPayDeposit/AiOPalawanPayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/AiOPalawanPayDeposit/AiOPalawanPayDeposit.js +215 -0
- package/dist/components/DepositWithdrawal/Deposit__next/AiOPayMayaDeposit/AiOPayMayaDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/AiOPayMayaDeposit/AiOPayMayaDeposit.js +215 -0
- package/dist/components/DepositWithdrawal/Deposit__next/AvailablePromos.d.ts +8 -0
- package/dist/components/DepositWithdrawal/Deposit__next/AvailablePromos.js +33 -0
- package/dist/components/DepositWithdrawal/Deposit__next/Deposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/Deposit.js +120 -0
- package/dist/components/DepositWithdrawal/Deposit__next/GCashDeposit/GCashDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/GCashDeposit/GCashDeposit.js +208 -0
- package/dist/components/DepositWithdrawal/Deposit__next/GCashWebpayDeposit/GCashWebpayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/GCashWebpayDeposit/GCashWebpayDeposit.js +210 -0
- package/dist/components/DepositWithdrawal/Deposit__next/LibanganDeposit/LibanganDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/LibanganDeposit/LibanganDeposit.js +210 -0
- package/dist/components/DepositWithdrawal/Deposit__next/MayaAppDeposit/MayaAppDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/MayaAppDeposit/MayaAppDeposit.js +157 -0
- package/dist/components/DepositWithdrawal/Deposit__next/MayaDeposit/MayaDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/MayaDeposit/MayaDeposit.js +208 -0
- package/dist/components/DepositWithdrawal/Deposit__next/MayaWebpayDeposit/MayaWebpayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/MayaWebpayDeposit/MayaWebpayDeposit.js +211 -0
- package/dist/components/DepositWithdrawal/Deposit__next/OnlineBankDeposit/OnlineBankDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/OnlineBankDeposit/OnlineBankDeposit.js +10 -0
- package/dist/components/DepositWithdrawal/Deposit__next/OnlineBankDeposit/OnlineBankDepositAlert.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/OnlineBankDeposit/OnlineBankDepositAlert.js +99 -0
- package/dist/components/DepositWithdrawal/Deposit__next/OnlineBankDeposit/OnlineBankDepositContext.d.ts +25 -0
- package/dist/components/DepositWithdrawal/Deposit__next/OnlineBankDeposit/OnlineBankDepositContext.js +2 -0
- package/dist/components/DepositWithdrawal/Deposit__next/OnlineBankDeposit/OnlineBankDepositDetails.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/OnlineBankDeposit/OnlineBankDepositDetails.js +19 -0
- package/dist/components/DepositWithdrawal/Deposit__next/OnlineBankDeposit/OnlineBankDepositForm.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/OnlineBankDeposit/OnlineBankDepositForm.js +115 -0
- package/dist/components/DepositWithdrawal/Deposit__next/OnlineBankDeposit/useOnlineBankDeposit.d.ts +13 -0
- package/dist/components/DepositWithdrawal/Deposit__next/OnlineBankDeposit/useOnlineBankDeposit.js +81 -0
- package/dist/components/DepositWithdrawal/Deposit__next/PisoPayDeposit/PisoPayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/PisoPayDeposit/PisoPayDeposit.js +224 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/QRPHDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/QRPHDeposit.js +10 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/QRPHDepositAlert.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/QRPHDepositAlert.js +99 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/QRPHDepositContext.d.ts +25 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/QRPHDepositContext.js +2 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/QRPHDepositDetails.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/QRPHDepositDetails.js +17 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/QRPHDepositForm.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/QRPHDepositForm.js +116 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/QRPHQRCode.d.ts +3 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/QRPHQRCode.js +69 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/useQRPHDeposit.d.ts +13 -0
- package/dist/components/DepositWithdrawal/Deposit__next/QRPHDeposit/useQRPHDeposit.js +85 -0
- package/dist/components/Disclaimer/DisclaimerV2.js +1 -1
- package/dist/styles/theme.css +4 -1
- package/package.json +1 -1
package/dist/components/DepositWithdrawal/Deposit__next/AiOPalawanPayDeposit/AiOPalawanPayDeposit.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
6
|
+
import invariant from 'tiny-invariant';
|
|
7
|
+
import { useBoolean } from 'usehooks-ts';
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { useShallow } from 'zustand/shallow';
|
|
10
|
+
import { useCreateAiOPalawanPayDepositMutation } from '../../../../client/hooks/useAiOPalawanPayDepositMutation.js';
|
|
11
|
+
import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
|
|
12
|
+
import { useDepositQuery } from '../../../../client/hooks/useDepositQuery.js';
|
|
13
|
+
import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
|
|
14
|
+
import { useDisclosure } from '../../../../client/hooks/useDisclosure.js';
|
|
15
|
+
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
16
|
+
import { useMemberVerificationQuery } from '../../../../client/hooks/useMemberVerificationQuery.js';
|
|
17
|
+
import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
|
|
18
|
+
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
19
|
+
import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
|
|
20
|
+
import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
|
|
21
|
+
import { RefreshCcw01Icon } from '../../../../icons/RefreshCcw01Icon.js';
|
|
22
|
+
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
23
|
+
import { XIcon } from '../../../../icons/XIcon.js';
|
|
24
|
+
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
25
|
+
import { Button } from '../../../../ui/Button/index.js';
|
|
26
|
+
import { Field } from '../../../../ui/Field/index.js';
|
|
27
|
+
import { NumberInput } from '../../../../ui/NumberInput/index.js';
|
|
28
|
+
import { Portal } from '../../../../ui/Portal/index.js';
|
|
29
|
+
import { getQueryClient } from '../../../../utils/getQueryClient.js';
|
|
30
|
+
import { parseDecimal } from '../../../../utils/parseDecimal.js';
|
|
31
|
+
import { getDepositsCountQueryKey } from '../../../../utils/queryKeys.js';
|
|
32
|
+
import { AmountChoices } from '../../AmountChoices.js';
|
|
33
|
+
import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
|
|
34
|
+
import { AvailablePromos } from '../AvailablePromos.js';
|
|
35
|
+
export function AiOPalawanPayDeposit() {
|
|
36
|
+
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
37
|
+
const disclosure = useDisclosure({
|
|
38
|
+
onOpenChange(open) {
|
|
39
|
+
if (!open) {
|
|
40
|
+
form.reset();
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
45
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
46
|
+
kycVerificationStatus: ctx.kycVerificationStatus,
|
|
47
|
+
})));
|
|
48
|
+
const verificationQuery = useMemberVerificationQuery();
|
|
49
|
+
const verificationStatus = verificationQuery.data?.status ?? 'UNVERIFIED';
|
|
50
|
+
const [status, setStatus] = useState('waiting');
|
|
51
|
+
const createDepositMutation = useCreateAiOPalawanPayDepositMutation({
|
|
52
|
+
onMutate() {
|
|
53
|
+
disclosure.setOpen(true);
|
|
54
|
+
setStatus('processing');
|
|
55
|
+
},
|
|
56
|
+
onSuccess(data) {
|
|
57
|
+
const queryClient = getQueryClient();
|
|
58
|
+
invariant(data.checkoutUrl);
|
|
59
|
+
window.open(data.checkoutUrl, '_blank', 'noopener,noreferrer');
|
|
60
|
+
queryClient.invalidateQueries({ queryKey: getDepositsCountQueryKey() });
|
|
61
|
+
setStatus('success');
|
|
62
|
+
},
|
|
63
|
+
onError() {
|
|
64
|
+
setStatus('failed');
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const warn = useBoolean();
|
|
68
|
+
const depositQuery = useDepositQuery(createDepositMutation.data?.id, {
|
|
69
|
+
enabled: !warn.value && status === 'success',
|
|
70
|
+
refetchInterval: (ctx) => ctx.state.data?.status === 'CONFIRMED' ||
|
|
71
|
+
ctx.state.data?.status === 'REJECTED' ||
|
|
72
|
+
ctx.state.data?.status === 'CANCELLED'
|
|
73
|
+
? false
|
|
74
|
+
: 1000,
|
|
75
|
+
});
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (depositQuery.data?.status === 'CONFIRMED') {
|
|
78
|
+
setStatus('confirmed');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (depositQuery.data?.status === 'REJECTED' ||
|
|
82
|
+
depositQuery.data?.status === 'CANCELLED') {
|
|
83
|
+
setStatus('failed');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}, [depositQuery.data?.status]);
|
|
87
|
+
const depositsCountQuery = useDepositsCountQuery();
|
|
88
|
+
const depositsCount = depositsCountQuery.data ?? 0;
|
|
89
|
+
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
90
|
+
const paymentSettings = paymentSettingsQuery.data;
|
|
91
|
+
const gatewaySettings = paymentSettings?.aioPalawanPayDepositGatewaySettings;
|
|
92
|
+
const maximumAmount = parseDecimal(gatewaySettings?.maximumAmount, 0);
|
|
93
|
+
const minimumAmount = depositsCount <= 0
|
|
94
|
+
? parseDecimal(paymentSettingsQuery.data?.minimumFirstDepositAmount, 0)
|
|
95
|
+
: parseDecimal(gatewaySettings?.minimumAmount, 0);
|
|
96
|
+
const promosQuery = useAvailablePromosQuery();
|
|
97
|
+
const promos = promosQuery.data ?? [];
|
|
98
|
+
const definition = z
|
|
99
|
+
.object({
|
|
100
|
+
amount: z.string().superRefine((val, ctx) => {
|
|
101
|
+
const n = parseDecimal(val, 0);
|
|
102
|
+
if (n < minimumAmount) {
|
|
103
|
+
ctx.addIssue({
|
|
104
|
+
type: 'number',
|
|
105
|
+
code: z.ZodIssueCode.too_small,
|
|
106
|
+
inclusive: true,
|
|
107
|
+
minimum: minimumAmount,
|
|
108
|
+
message: `Minimum amount is ${minimumAmount.toLocaleString()}`,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (n > maximumAmount) {
|
|
112
|
+
ctx.addIssue({
|
|
113
|
+
type: 'number',
|
|
114
|
+
code: z.ZodIssueCode.too_big,
|
|
115
|
+
inclusive: true,
|
|
116
|
+
maximum: maximumAmount,
|
|
117
|
+
message: `Maximum amount is ${maximumAmount.toLocaleString()}`,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}),
|
|
121
|
+
promo: z.string().optional().nullable(),
|
|
122
|
+
})
|
|
123
|
+
.superRefine((value, ctx) => {
|
|
124
|
+
const promo = promos.find((o) => o.id === value.promo);
|
|
125
|
+
const promoMinAmount = parseDecimal(promo?.minimumDepositAmount, 0);
|
|
126
|
+
const promoMaxAmount = parseDecimal(promo?.maximumDepositAmount, 0);
|
|
127
|
+
const amount = parseDecimal(value.amount, 0);
|
|
128
|
+
if (promo && amount < promoMinAmount) {
|
|
129
|
+
ctx.addIssue({
|
|
130
|
+
path: ['amount'],
|
|
131
|
+
code: z.ZodIssueCode.custom,
|
|
132
|
+
message: `Minimum amount for this promo is ${promoMinAmount.toLocaleString()}`,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (promo && amount > promoMaxAmount) {
|
|
136
|
+
ctx.addIssue({
|
|
137
|
+
path: ['amount'],
|
|
138
|
+
code: z.ZodIssueCode.custom,
|
|
139
|
+
message: `Maximum amount for this promo is ${promoMaxAmount}`,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const form = useForm({
|
|
144
|
+
mode: 'all',
|
|
145
|
+
resolver: zodResolver(definition),
|
|
146
|
+
defaultValues: {
|
|
147
|
+
amount: '0',
|
|
148
|
+
promo: globalStore.depositWithdrawal.promo ?? null,
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (minimumAmount) {
|
|
153
|
+
form.reset({
|
|
154
|
+
amount: minimumAmount.toString(),
|
|
155
|
+
promo: form.getValues('promo') ?? null,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}, [form, minimumAmount]);
|
|
159
|
+
return (_jsxs("form", { onSubmit: form.handleSubmit(async (data) => {
|
|
160
|
+
if (verificationStatus === 'PENDING' ||
|
|
161
|
+
verificationStatus === 'UNVERIFIED' ||
|
|
162
|
+
verificationStatus === 'REJECTED' ||
|
|
163
|
+
verificationStatus === 'CREATED') {
|
|
164
|
+
globalStore.kycVerificationStatus.setOpen(true);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
createDepositMutation.reset();
|
|
169
|
+
createDepositMutation.mutate({
|
|
170
|
+
amount: data.amount.toString(),
|
|
171
|
+
promo: data.promo ?? undefined,
|
|
172
|
+
redirectUrl: window.location.origin.includes('localhost')
|
|
173
|
+
? 'https://uat.powerplay.ph'
|
|
174
|
+
: window.location.origin,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}), 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) => {
|
|
178
|
+
o.field.onChange(details.value);
|
|
179
|
+
}, allowMouseWheel: true, children: [_jsx(NumberInput.Label, { children: "Enter amount you want to deposit" }), _jsxs(NumberInput.Control, { children: [_jsx(NumberInput.Input, {}), _jsx(NumberInput.IncrementTrigger, { children: _jsx(ChevronUpIcon, {}) }), _jsx(NumberInput.DecrementTrigger, { children: _jsx(ChevronDownIcon, {}) })] })] }), _jsx(Field.ErrorText, { children: form.formState.errors.amount?.message })] })) }), _jsx(AmountChoices, { value: parseDecimal(form.watch('amount'), 0), onChange: (value) => {
|
|
180
|
+
form.setValue('amount', value.toString(), {
|
|
181
|
+
shouldTouch: true,
|
|
182
|
+
shouldDirty: true,
|
|
183
|
+
shouldValidate: true,
|
|
184
|
+
});
|
|
185
|
+
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: (value) => {
|
|
186
|
+
o.field.onChange(value);
|
|
187
|
+
globalStore.depositWithdrawal.setPromo(null);
|
|
188
|
+
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "mt-lg text-text-tertiary-600 text-xs", children: ["By depositing, you agree to our", ' ', _jsx(Link, { href: depositWithdrawalProps.termsOfUseUrl ?? '/terms-of-use', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use" }), ' ', "and", ' ', _jsx(Link, { href: depositWithdrawalProps.privacyPolicyUrl ?? '/privacy-policy', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: disclosure.open, onOpenChange: (details) => {
|
|
189
|
+
disclosure.setOpen(details.open);
|
|
190
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
|
|
191
|
+
setStatus('waiting');
|
|
192
|
+
form.reset();
|
|
193
|
+
warn.setFalse();
|
|
194
|
+
}, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.Context, { children: (api) => (_jsx("button", { type: "button", className: "absolute top-2.5 right-2.5 flex icon:size-6 size-11 items-center justify-center text-text-quinary", onClick: () => {
|
|
195
|
+
if (status === 'success' && !warn.value) {
|
|
196
|
+
warn.setTrue();
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
api.setOpen(false);
|
|
200
|
+
}
|
|
201
|
+
}, children: _jsx(XIcon, {}) })) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && !warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary text-text-featured-icon-light-brand", children: _jsx(RefreshCcw01Icon, {}) })), status === 'success' && warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) })), status === 'confirmed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-success-secondary text-text-featured-icon-light-success", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) }))] }), _jsxs(AlertDialog.Body, { children: [_jsxs(AlertDialog.Title, { children: [status === 'processing' && 'Processing Deposit', status === 'success' &&
|
|
202
|
+
!warn.value &&
|
|
203
|
+
'Didn’t see the payment window?', status === 'success' && warn.value && (_jsx(_Fragment, { children: "Are you sure you want to close this\u00A0window?" })), status === 'confirmed' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
|
|
204
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
205
|
+
!warn.value &&
|
|
206
|
+
'Sometimes the payment pop up doesn’t appear right away. Don’t worry, just click the button below to reopen it and continue your deposit.', status === 'success' &&
|
|
207
|
+
warn.value &&
|
|
208
|
+
'Closing this window might cancel your current deposit. Do you want to continue?', status === 'confirmed' &&
|
|
209
|
+
'Your deposit has been successfully processed.', status === 'failed' &&
|
|
210
|
+
'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' ||
|
|
211
|
+
status === 'success' ||
|
|
212
|
+
status === 'confirmed') && (_jsxs(AlertDialog.Footer, { children: [status === 'success' && !warn.value && (_jsx(Button, { asChild: true, children: _jsx("a", { href: createDepositMutation.data?.checkoutUrl ?? '', target: "_blank", rel: "noopener noreferrer", children: "Try Again" }) })), status === 'success' && warn.value && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", onClick: () => {
|
|
213
|
+
warn.setFalse();
|
|
214
|
+
}, children: "Go back" }), _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Continue" })) })] })), status !== 'success' && (_jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Ok" })) }))] }))] }) })] }) })] }));
|
|
215
|
+
}
|
package/dist/components/DepositWithdrawal/Deposit__next/AiOPayMayaDeposit/AiOPayMayaDeposit.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AiOPayMayaDeposit(): import("react/jsx-runtime").JSX.Element;
|
package/dist/components/DepositWithdrawal/Deposit__next/AiOPayMayaDeposit/AiOPayMayaDeposit.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
6
|
+
import invariant from 'tiny-invariant';
|
|
7
|
+
import { useBoolean } from 'usehooks-ts';
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { useShallow } from 'zustand/shallow';
|
|
10
|
+
import { useCreateAiOPayMayaDepositMutation } from '../../../../client/hooks/useAiOPayMayaDepositMutation.js';
|
|
11
|
+
import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
|
|
12
|
+
import { useDepositQuery } from '../../../../client/hooks/useDepositQuery.js';
|
|
13
|
+
import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
|
|
14
|
+
import { useDisclosure } from '../../../../client/hooks/useDisclosure.js';
|
|
15
|
+
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
16
|
+
import { useMemberVerificationQuery } from '../../../../client/hooks/useMemberVerificationQuery.js';
|
|
17
|
+
import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
|
|
18
|
+
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
19
|
+
import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
|
|
20
|
+
import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
|
|
21
|
+
import { RefreshCcw01Icon } from '../../../../icons/RefreshCcw01Icon.js';
|
|
22
|
+
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
23
|
+
import { XIcon } from '../../../../icons/XIcon.js';
|
|
24
|
+
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
25
|
+
import { Button } from '../../../../ui/Button/index.js';
|
|
26
|
+
import { Field } from '../../../../ui/Field/index.js';
|
|
27
|
+
import { NumberInput } from '../../../../ui/NumberInput/index.js';
|
|
28
|
+
import { Portal } from '../../../../ui/Portal/index.js';
|
|
29
|
+
import { getQueryClient } from '../../../../utils/getQueryClient.js';
|
|
30
|
+
import { parseDecimal } from '../../../../utils/parseDecimal.js';
|
|
31
|
+
import { getDepositsCountQueryKey } from '../../../../utils/queryKeys.js';
|
|
32
|
+
import { AmountChoices } from '../../AmountChoices.js';
|
|
33
|
+
import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
|
|
34
|
+
import { AvailablePromos } from '../AvailablePromos.js';
|
|
35
|
+
export function AiOPayMayaDeposit() {
|
|
36
|
+
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
37
|
+
const disclosure = useDisclosure({
|
|
38
|
+
onOpenChange(open) {
|
|
39
|
+
if (!open) {
|
|
40
|
+
form.reset();
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
45
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
46
|
+
kycVerificationStatus: ctx.kycVerificationStatus,
|
|
47
|
+
})));
|
|
48
|
+
const verificationQuery = useMemberVerificationQuery();
|
|
49
|
+
const verificationStatus = verificationQuery.data?.status ?? 'UNVERIFIED';
|
|
50
|
+
const [status, setStatus] = useState('waiting');
|
|
51
|
+
const createDepositMutation = useCreateAiOPayMayaDepositMutation({
|
|
52
|
+
onMutate() {
|
|
53
|
+
disclosure.setOpen(true);
|
|
54
|
+
setStatus('processing');
|
|
55
|
+
},
|
|
56
|
+
onSuccess(data) {
|
|
57
|
+
const queryClient = getQueryClient();
|
|
58
|
+
invariant(data.checkoutUrl);
|
|
59
|
+
window.open(data.checkoutUrl, '_blank', 'noopener,noreferrer');
|
|
60
|
+
queryClient.invalidateQueries({ queryKey: getDepositsCountQueryKey() });
|
|
61
|
+
setStatus('success');
|
|
62
|
+
},
|
|
63
|
+
onError() {
|
|
64
|
+
setStatus('failed');
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const warn = useBoolean();
|
|
68
|
+
const depositQuery = useDepositQuery(createDepositMutation.data?.id, {
|
|
69
|
+
enabled: !warn.value && status === 'success',
|
|
70
|
+
refetchInterval: (ctx) => ctx.state.data?.status === 'CONFIRMED' ||
|
|
71
|
+
ctx.state.data?.status === 'REJECTED' ||
|
|
72
|
+
ctx.state.data?.status === 'CANCELLED'
|
|
73
|
+
? false
|
|
74
|
+
: 1000,
|
|
75
|
+
});
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (depositQuery.data?.status === 'CONFIRMED') {
|
|
78
|
+
setStatus('confirmed');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (depositQuery.data?.status === 'REJECTED' ||
|
|
82
|
+
depositQuery.data?.status === 'CANCELLED') {
|
|
83
|
+
setStatus('failed');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}, [depositQuery.data?.status]);
|
|
87
|
+
const depositsCountQuery = useDepositsCountQuery();
|
|
88
|
+
const depositsCount = depositsCountQuery.data ?? 0;
|
|
89
|
+
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
90
|
+
const paymentSettings = paymentSettingsQuery.data;
|
|
91
|
+
const gatewaySettings = paymentSettings?.aioPayMayaDepositGatewaySettings;
|
|
92
|
+
const maximumAmount = parseDecimal(gatewaySettings?.maximumAmount, 0);
|
|
93
|
+
const minimumAmount = depositsCount <= 0
|
|
94
|
+
? parseDecimal(paymentSettingsQuery.data?.minimumFirstDepositAmount, 0)
|
|
95
|
+
: parseDecimal(gatewaySettings?.minimumAmount, 0);
|
|
96
|
+
const promosQuery = useAvailablePromosQuery();
|
|
97
|
+
const promos = promosQuery.data ?? [];
|
|
98
|
+
const definition = z
|
|
99
|
+
.object({
|
|
100
|
+
amount: z.string().superRefine((val, ctx) => {
|
|
101
|
+
const n = parseDecimal(val, 0);
|
|
102
|
+
if (n < minimumAmount) {
|
|
103
|
+
ctx.addIssue({
|
|
104
|
+
type: 'number',
|
|
105
|
+
code: z.ZodIssueCode.too_small,
|
|
106
|
+
inclusive: true,
|
|
107
|
+
minimum: minimumAmount,
|
|
108
|
+
message: `Minimum amount is ${minimumAmount.toLocaleString()}`,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (n > maximumAmount) {
|
|
112
|
+
ctx.addIssue({
|
|
113
|
+
type: 'number',
|
|
114
|
+
code: z.ZodIssueCode.too_big,
|
|
115
|
+
inclusive: true,
|
|
116
|
+
maximum: maximumAmount,
|
|
117
|
+
message: `Maximum amount is ${maximumAmount.toLocaleString()}`,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}),
|
|
121
|
+
promo: z.string().optional().nullable(),
|
|
122
|
+
})
|
|
123
|
+
.superRefine((value, ctx) => {
|
|
124
|
+
const promo = promos.find((o) => o.id === value.promo);
|
|
125
|
+
const promoMinAmount = parseDecimal(promo?.minimumDepositAmount, 0);
|
|
126
|
+
const promoMaxAmount = parseDecimal(promo?.maximumDepositAmount, 0);
|
|
127
|
+
const amount = parseDecimal(value.amount, 0);
|
|
128
|
+
if (promo && amount < promoMinAmount) {
|
|
129
|
+
ctx.addIssue({
|
|
130
|
+
path: ['amount'],
|
|
131
|
+
code: z.ZodIssueCode.custom,
|
|
132
|
+
message: `Minimum amount for this promo is ${promoMinAmount.toLocaleString()}`,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (promo && amount > promoMaxAmount) {
|
|
136
|
+
ctx.addIssue({
|
|
137
|
+
path: ['amount'],
|
|
138
|
+
code: z.ZodIssueCode.custom,
|
|
139
|
+
message: `Maximum amount for this promo is ${promoMaxAmount}`,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const form = useForm({
|
|
144
|
+
mode: 'all',
|
|
145
|
+
resolver: zodResolver(definition),
|
|
146
|
+
defaultValues: {
|
|
147
|
+
amount: '0',
|
|
148
|
+
promo: globalStore.depositWithdrawal.promo ?? null,
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (minimumAmount) {
|
|
153
|
+
form.reset({
|
|
154
|
+
amount: minimumAmount.toString(),
|
|
155
|
+
promo: form.getValues('promo') ?? null,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}, [form, minimumAmount]);
|
|
159
|
+
return (_jsxs("form", { onSubmit: form.handleSubmit(async (data) => {
|
|
160
|
+
if (verificationStatus === 'PENDING' ||
|
|
161
|
+
verificationStatus === 'UNVERIFIED' ||
|
|
162
|
+
verificationStatus === 'REJECTED' ||
|
|
163
|
+
verificationStatus === 'CREATED') {
|
|
164
|
+
globalStore.kycVerificationStatus.setOpen(true);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
createDepositMutation.reset();
|
|
169
|
+
createDepositMutation.mutate({
|
|
170
|
+
amount: data.amount.toString(),
|
|
171
|
+
promo: data.promo ?? undefined,
|
|
172
|
+
redirectUrl: window.location.origin.includes('localhost')
|
|
173
|
+
? 'https://uat.powerplay.ph'
|
|
174
|
+
: window.location.origin,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}), 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) => {
|
|
178
|
+
o.field.onChange(details.value);
|
|
179
|
+
}, allowMouseWheel: true, children: [_jsx(NumberInput.Label, { children: "Enter amount you want to deposit" }), _jsxs(NumberInput.Control, { children: [_jsx(NumberInput.Input, {}), _jsx(NumberInput.IncrementTrigger, { children: _jsx(ChevronUpIcon, {}) }), _jsx(NumberInput.DecrementTrigger, { children: _jsx(ChevronDownIcon, {}) })] })] }), _jsx(Field.ErrorText, { children: form.formState.errors.amount?.message })] })) }), _jsx(AmountChoices, { value: parseDecimal(form.watch('amount'), 0), onChange: (value) => {
|
|
180
|
+
form.setValue('amount', value.toString(), {
|
|
181
|
+
shouldTouch: true,
|
|
182
|
+
shouldDirty: true,
|
|
183
|
+
shouldValidate: true,
|
|
184
|
+
});
|
|
185
|
+
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: (value) => {
|
|
186
|
+
o.field.onChange(value);
|
|
187
|
+
globalStore.depositWithdrawal.setPromo(null);
|
|
188
|
+
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "mt-lg text-text-tertiary-600 text-xs", children: ["By depositing, you agree to our", ' ', _jsx(Link, { href: depositWithdrawalProps.termsOfUseUrl ?? '/terms-of-use', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use" }), ' ', "and", ' ', _jsx(Link, { href: depositWithdrawalProps.privacyPolicyUrl ?? '/privacy-policy', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: disclosure.open, onOpenChange: (details) => {
|
|
189
|
+
disclosure.setOpen(details.open);
|
|
190
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
|
|
191
|
+
setStatus('waiting');
|
|
192
|
+
form.reset();
|
|
193
|
+
warn.setFalse();
|
|
194
|
+
}, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.Context, { children: (api) => (_jsx("button", { type: "button", className: "absolute top-2.5 right-2.5 flex icon:size-6 size-11 items-center justify-center text-text-quinary", onClick: () => {
|
|
195
|
+
if (status === 'success' && !warn.value) {
|
|
196
|
+
warn.setTrue();
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
api.setOpen(false);
|
|
200
|
+
}
|
|
201
|
+
}, children: _jsx(XIcon, {}) })) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && !warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary text-text-featured-icon-light-brand", children: _jsx(RefreshCcw01Icon, {}) })), status === 'success' && warn.value && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) })), status === 'confirmed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-success-secondary text-text-featured-icon-light-success", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) }))] }), _jsxs(AlertDialog.Body, { children: [_jsxs(AlertDialog.Title, { children: [status === 'processing' && 'Processing Deposit', status === 'success' &&
|
|
202
|
+
!warn.value &&
|
|
203
|
+
'Didn’t see the payment window?', status === 'success' && warn.value && (_jsx(_Fragment, { children: "Are you sure you want to close this\u00A0window?" })), status === 'confirmed' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
|
|
204
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
205
|
+
!warn.value &&
|
|
206
|
+
'Sometimes the payment pop up doesn’t appear right away. Don’t worry, just click the button below to reopen it and continue your deposit.', status === 'success' &&
|
|
207
|
+
warn.value &&
|
|
208
|
+
'Closing this window might cancel your current deposit. Do you want to continue?', status === 'confirmed' &&
|
|
209
|
+
'Your deposit has been successfully processed.', status === 'failed' &&
|
|
210
|
+
'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' ||
|
|
211
|
+
status === 'success' ||
|
|
212
|
+
status === 'confirmed') && (_jsxs(AlertDialog.Footer, { children: [status === 'success' && !warn.value && (_jsx(Button, { asChild: true, children: _jsx("a", { href: createDepositMutation.data?.checkoutUrl ?? '', target: "_blank", rel: "noopener noreferrer", children: "Try Again" }) })), status === 'success' && warn.value && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", onClick: () => {
|
|
213
|
+
warn.setFalse();
|
|
214
|
+
}, children: "Go back" }), _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Continue" })) })] })), status !== 'success' && (_jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => api.setOpen(false), children: "Ok" })) }))] }))] }) })] }) })] }));
|
|
215
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface AvailablePromosProps {
|
|
2
|
+
value?: string | null;
|
|
3
|
+
defaultValue?: string | null;
|
|
4
|
+
onChange?: (value: string | null) => void;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function AvailablePromos(props: AvailablePromosProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createListCollection } from '@ark-ui/react/collection';
|
|
3
|
+
import Image from 'next/image';
|
|
4
|
+
import { useAvailablePromosQuery } from '../../../client/hooks/useAvailablePromosQuery.js';
|
|
5
|
+
import { useControllableState } from '../../../client/hooks/useControllableState.js';
|
|
6
|
+
import { CheckIcon } from '../../../icons/CheckIcon.js';
|
|
7
|
+
import { ChevronDownIcon } from '../../../icons/ChevronDownIcon.js';
|
|
8
|
+
import gift from '../../../images/gift.png';
|
|
9
|
+
import { Select } from '../../../ui/Select/index.js';
|
|
10
|
+
export function AvailablePromos(props) {
|
|
11
|
+
const query = useAvailablePromosQuery();
|
|
12
|
+
const promos = query.data ?? [];
|
|
13
|
+
const [value, setValue] = useControllableState({
|
|
14
|
+
value: props.value,
|
|
15
|
+
defaultValue: props.defaultValue ?? null,
|
|
16
|
+
onChange: props.onChange,
|
|
17
|
+
});
|
|
18
|
+
const collection = createListCollection({
|
|
19
|
+
items: promos,
|
|
20
|
+
itemToValue: (item) => item.id,
|
|
21
|
+
itemToString: (item) => item.name,
|
|
22
|
+
});
|
|
23
|
+
return (_jsxs(Select.Root, { collection: collection, lazyMount: true, positioning: {
|
|
24
|
+
sameWidth: true,
|
|
25
|
+
}, value: value ? [value] : [], onValueChange: (details) => {
|
|
26
|
+
const value = details.value.at(0);
|
|
27
|
+
setValue(value ?? null);
|
|
28
|
+
}, className: props.className, children: [_jsx(Select.Label, { children: "Choose a bonus" }), _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, { placeholder: "Pay without bonus" }), _jsx(Select.Context, { children: (api) => (_jsx(_Fragment, { children: api.value.length ? (_jsx(Select.ClearTrigger, { asChild: true, children: _jsx("span", { onClick: (e) => {
|
|
29
|
+
e.stopPropagation();
|
|
30
|
+
}, children: "Clear" }) })) : (_jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })) })) })] }), _jsx(Select.Positioner, { children: _jsxs(Select.Content, { children: [collection.items.length <= 0 && (_jsxs("div", { className: "p-2", children: [_jsx(Image, { src: gift, alt: "", width: 160, height: 160, className: "mx-auto size-[8.313rem] grayscale" }), _jsx("p", { className: "mx-auto mt-1 max-w-[20rem] text-center text-sm text-text-tertiary-600", children: "No Bonuses are available at the moment. Please check back later!" })] })), collection.items.length > 0 && (_jsx(Select.ItemGroup, { children: collection.items.map((promo) => (_jsxs(Select.Item, { item: promo, children: [_jsxs(Select.ItemText, { children: [_jsx("span", { className: "block font-medium", children: promo.name }), _jsx("span", { className: "line-clamp-1 text-text-warning-primary-600", dangerouslySetInnerHTML: {
|
|
31
|
+
__html: promo.description,
|
|
32
|
+
} })] }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, promo.id))) }))] }) })] }));
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Deposit(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useFeatureFlag } from '../../../client/hooks/useFeatureFlag.js';
|
|
4
|
+
import { useIsMayaSessionValidQuery } from '../../../client/hooks/useIsMayaSessionValidQuery.js';
|
|
5
|
+
import { useMayaAuth } from '../../../client/hooks/useMayaAuth.js';
|
|
6
|
+
import { usePaymentSettingsQuery } from '../../../client/hooks/usePaymentSettingsQuery.js';
|
|
7
|
+
import { AlertCircleIcon } from '../../../icons/AlertCircleIcon.js';
|
|
8
|
+
import { SpinnerIcon } from '../../../icons/SpinnerIcon.js';
|
|
9
|
+
import { onMobileDevice } from '../../../utils/onMobileDevice.js';
|
|
10
|
+
import { PaymentMethods } from '../PaymentMethods.js';
|
|
11
|
+
import { AiOGCashDeposit } from './AiOGCashDeposit/AiOGCashDeposit.js';
|
|
12
|
+
import { AiOGrabPayDeposit } from './AiOGrabPayDeposit/AiOGrabPayDeposit.js';
|
|
13
|
+
import { AiOPalawanPayDeposit } from './AiOPalawanPayDeposit/AiOPalawanPayDeposit.js';
|
|
14
|
+
import { AiOPayMayaDeposit } from './AiOPayMayaDeposit/AiOPayMayaDeposit.js';
|
|
15
|
+
import { GCashDeposit } from './GCashDeposit/GCashDeposit.js';
|
|
16
|
+
import { GCashWebpayDeposit } from './GCashWebpayDeposit/GCashWebpayDeposit.js';
|
|
17
|
+
import { LibanganDeposit } from './LibanganDeposit/LibanganDeposit.js';
|
|
18
|
+
import { MayaAppDeposit } from './MayaAppDeposit/MayaAppDeposit.js';
|
|
19
|
+
import { MayaDeposit } from './MayaDeposit/MayaDeposit.js';
|
|
20
|
+
import { MayaWebpayDeposit } from './MayaWebpayDeposit/MayaWebpayDeposit.js';
|
|
21
|
+
import { OnlineBankDeposit } from './OnlineBankDeposit/OnlineBankDeposit.js';
|
|
22
|
+
import { PisoPayDeposit } from './PisoPayDeposit/PisoPayDeposit.js';
|
|
23
|
+
import { QRPHDeposit } from './QRPHDeposit/QRPHDeposit.js';
|
|
24
|
+
export function Deposit() {
|
|
25
|
+
const { onMaya } = useMayaAuth();
|
|
26
|
+
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
27
|
+
const paymentSettings = paymentSettingsQuery.data;
|
|
28
|
+
const featureFlag = useFeatureFlag();
|
|
29
|
+
const enabledPaymentMethods = (() => {
|
|
30
|
+
const l = [];
|
|
31
|
+
if (onMaya) {
|
|
32
|
+
l.push('MAYA_APP');
|
|
33
|
+
return l;
|
|
34
|
+
}
|
|
35
|
+
const isMobile = onMobileDevice();
|
|
36
|
+
const enabledKey = isMobile ? 'mobileWebEnabled' : 'webEnabled';
|
|
37
|
+
const paymentMethods = [
|
|
38
|
+
{
|
|
39
|
+
method: 'GCASH',
|
|
40
|
+
enabled: paymentSettings?.gcashDepositGatewaySettings?.[enabledKey],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
method: 'MAYA',
|
|
44
|
+
enabled: paymentSettings?.mayaDepositGatewaySettings?.[enabledKey],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
method: 'QRPH',
|
|
48
|
+
enabled: paymentSettings?.qrphDepositGatewaySettings?.[enabledKey],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
method: 'ONLINE_BANK',
|
|
52
|
+
enabled: paymentSettings?.onlineBankDepositGatewaySettings?.[enabledKey],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
method: 'LIBANGAN_PAY_IN',
|
|
56
|
+
enabled: paymentSettings?.libanganDepositGatewaySettings?.[enabledKey],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
method: 'PISO_PAY',
|
|
60
|
+
enabled: paymentSettings?.pisoPayDepositGatewaySettings?.[enabledKey],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
method: 'AIO_GCASH',
|
|
64
|
+
enabled: paymentSettings?.aioGCashDepositGatewaySettings?.[enabledKey],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
method: 'AIO_PAY_MAYA',
|
|
68
|
+
enabled: paymentSettings?.aioPayMayaDepositGatewaySettings?.[enabledKey],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
method: 'AIO_GRAB_PAY',
|
|
72
|
+
enabled: paymentSettings?.aioGrabPayDepositGatewaySettings?.[enabledKey],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
method: 'AIO_PALAWAN_PAY',
|
|
76
|
+
enabled: paymentSettings?.aioPalawanPayDepositGatewaySettings?.[enabledKey],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
method: 'GCASH_WEBPAY',
|
|
80
|
+
enabled: paymentSettings?.gcashWebpayDepositGatewaySettings?.[enabledKey] &&
|
|
81
|
+
featureFlag.enabled,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
method: 'MAYA_WEBPAY',
|
|
85
|
+
enabled: paymentSettings?.mayaWebpayDepositGatewaySettings?.[enabledKey] &&
|
|
86
|
+
featureFlag.enabled,
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
paymentMethods.forEach((o) => {
|
|
90
|
+
if (o.enabled) {
|
|
91
|
+
l.push(o.method);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return l;
|
|
95
|
+
})();
|
|
96
|
+
const [paymentMethod, setPaymentMethod] = useState();
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (enabledPaymentMethods.length > 0 && !paymentMethod) {
|
|
99
|
+
setPaymentMethod(enabledPaymentMethods[0]);
|
|
100
|
+
}
|
|
101
|
+
}, [enabledPaymentMethods, paymentMethod]);
|
|
102
|
+
const isMayaSessionValidQuery = useIsMayaSessionValidQuery();
|
|
103
|
+
const isMayaSessionValid = isMayaSessionValidQuery.data ?? true;
|
|
104
|
+
if (paymentSettingsQuery.isLoading || isMayaSessionValidQuery.isLoading) {
|
|
105
|
+
return _jsx(SpinnerIcon, { className: "mx-auto size-6" });
|
|
106
|
+
}
|
|
107
|
+
if (!isMayaSessionValid) {
|
|
108
|
+
return _jsx(MayaSessionSessionExpired, {});
|
|
109
|
+
}
|
|
110
|
+
if (enabledPaymentMethods.length <= 0) {
|
|
111
|
+
return _jsx(NoAvailablePaymentMethods, {});
|
|
112
|
+
}
|
|
113
|
+
return (_jsxs(_Fragment, { children: [_jsx(PaymentMethods, { value: paymentMethod, onChange: setPaymentMethod, options: enabledPaymentMethods }), paymentMethod === 'QRPH' && _jsx(QRPHDeposit, {}), paymentMethod === 'GCASH' && _jsx(GCashDeposit, {}), paymentMethod === 'MAYA' && _jsx(MayaDeposit, {}), paymentMethod === 'MAYA_APP' && _jsx(MayaAppDeposit, {}), paymentMethod === 'ONLINE_BANK' && _jsx(OnlineBankDeposit, {}), paymentMethod === 'LIBANGAN_PAY_IN' && _jsx(LibanganDeposit, {}), paymentMethod === 'PISO_PAY' && _jsx(PisoPayDeposit, {}), paymentMethod === 'AIO_GCASH' && _jsx(AiOGCashDeposit, {}), paymentMethod === 'AIO_PAY_MAYA' && _jsx(AiOPayMayaDeposit, {}), paymentMethod === 'AIO_GRAB_PAY' && _jsx(AiOGrabPayDeposit, {}), paymentMethod === 'AIO_PALAWAN_PAY' && _jsx(AiOPalawanPayDeposit, {}), paymentMethod === 'GCASH_WEBPAY' && _jsx(GCashWebpayDeposit, {}), paymentMethod === 'MAYA_WEBPAY' && _jsx(MayaWebpayDeposit, {})] }));
|
|
114
|
+
}
|
|
115
|
+
function MayaSessionSessionExpired() {
|
|
116
|
+
return (_jsxs("div", { className: "py-xl", children: [_jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-warning-secondary", children: _jsx(AlertCircleIcon, { className: "size-6 text-text-featured-icon-light-warning" }) }), _jsx("h2", { className: "mt-lg text-center font-semibold text-lg", children: "Session Expired" }), _jsx("p", { className: "mx-auto mt-xs max-w-[25rem] text-center text-sm text-text-tertiary-600", children: "Your session has timed out. To continue with deposits or withdrawals, Please try reloading the app." })] }));
|
|
117
|
+
}
|
|
118
|
+
function NoAvailablePaymentMethods() {
|
|
119
|
+
return (_jsxs("div", { className: "py-xl", children: [_jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-warning-secondary", children: _jsx(AlertCircleIcon, { className: "size-6 text-text-featured-icon-light-warning" }) }), _jsx("h2", { className: "mt-lg text-center font-semibold text-lg", children: "Not Available" }), _jsx("p", { className: "mx-auto mt-xs max-w-[25rem] text-center text-sm text-text-tertiary-600", children: "Deposit is not available at this time. Please try again later or contact support for assistance." })] }));
|
|
120
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function GCashDeposit(): import("react/jsx-runtime").JSX.Element;
|