@opexa/portal-components 0.0.889 → 0.0.891
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/client/hooks/useCreateAiOGCashDepositMutation.d.ts +4 -0
- package/dist/client/hooks/useCreateAiOGCashDepositMutation.js +90 -0
- package/dist/client/hooks/useCreateAiOGrabPayDepositMutation.d.ts +4 -0
- package/dist/client/hooks/useCreateAiOGrabPayDepositMutation.js +80 -0
- package/dist/client/hooks/useCreateAiOPalawanPayDepositMutation.d.ts +4 -0
- package/dist/client/hooks/useCreateAiOPalawanPayDepositMutation.js +80 -0
- package/dist/client/hooks/useCreateAiOPayMayaDepositMutation.d.ts +4 -0
- package/dist/client/hooks/useCreateAiOPayMayaDepositMutation.js +80 -0
- package/dist/client/hooks/useCreateAurixPayGCashDepositMutation.d.ts +4 -0
- package/dist/client/hooks/useCreateAurixPayGCashDepositMutation.js +82 -0
- package/dist/client/hooks/useCreateAurixPayGrabPayDepositMutation.d.ts +4 -0
- package/dist/client/hooks/useCreateAurixPayGrabPayDepositMutation.js +88 -0
- package/dist/client/hooks/useCreateAurixPayPayMayaDepositMutation.d.ts +4 -0
- package/dist/client/hooks/useCreateAurixPayPayMayaDepositMutation.js +88 -0
- package/dist/client/hooks/useCreateAurixPayQrphDepositMutation.d.ts +4 -0
- package/dist/client/hooks/useCreateAurixPayQrphDepositMutation.js +88 -0
- package/dist/components/DepositWithdrawal/Deposit/AiOGCashDeposit/AiOGCashDeposit.js +1 -1
- package/dist/components/DepositWithdrawal/Deposit/AiOGrabPayDeposit/AiOGrabPayDeposit.js +1 -1
- package/dist/components/DepositWithdrawal/Deposit/AiOPalawanPayDeposit/AiOPalawanPayDeposit.js +1 -1
- package/dist/components/DepositWithdrawal/Deposit/AiOPayMayaDeposit/AiOPayMayaDeposit.js +1 -1
- package/dist/components/DepositWithdrawal/Deposit/AurixPayGCashDeposit/AurixPayGCashDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayGCashDeposit/AurixPayGCashDeposit.js +241 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayGrabPayDeposit/AurixPayGrabPayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayGrabPayDeposit/AurixPayGrabPayDeposit.js +241 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayPayMayaDeposit/AurixPayGrabPayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayPayMayaDeposit/AurixPayGrabPayDeposit.js +241 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/AurixPayQRPHDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/AurixPayQRPHDeposit.js +12 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/AurixPayQRPHDepositContext.d.ts +25 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/AurixPayQRPHDepositContext.js +2 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/Confirmed.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/Confirmed.js +11 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/Failed.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/Failed.js +13 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/Form.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/Form.js +126 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/GeneratingQrCode.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/GeneratingQrCode.js +10 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/QrCodeGenerated.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/QrCodeGenerated.js +41 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/useAurixPayQRPHDeposit.d.ts +17 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/useAurixPayQRPHDeposit.js +117 -0
- package/dist/components/DepositWithdrawal/Deposit/Deposit.js +23 -1
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/useOnlineBankDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QrCodeGenerated.js +37 -1
- package/dist/components/DepositWithdrawal/DepositWithdrawal.lazy.d.ts +6 -0
- package/dist/components/DepositWithdrawal/PaymentMethods.js +20 -0
- package/dist/components/DepositWithdrawal/utils.d.ts +1 -1
- package/dist/components/DepositWithdrawal/utils.js +4 -0
- package/dist/components/ForgotPassword/ForgotPassword.lazy.d.ts +2 -2
- package/dist/components/ForgotPassword/ForgotPassword.lazy.js +14 -3
- package/dist/components/ForgotPassword/ForgotPasswordForm.d.ts +5 -1
- package/dist/components/ForgotPassword/ForgotPasswordForm.js +68 -33
- package/dist/components/SignUp/SignUpDefault/SignUpDefaultFormInternational.js +4 -1
- package/dist/components/Tournaments/TournamentsCarousel/TournamentCarouselItem.Crazywin.d.ts +1 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentCarouselItem.Crazywin.js +53 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarousel.d.ts +1 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarousel.js +9 -2
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.HappyBingo.d.ts +1 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.HappyBingo.js +54 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.js +2 -2
- package/dist/components/TransactionRecords/DepositRecordsTable.js +6 -21
- package/dist/components/TransactionRecords/WithdrawalRecordsTable.js +1 -1
- package/dist/images/tourna-icon.webp +0 -0
- package/dist/schemas/forgotPasswordSchema.d.ts +8 -8
- package/dist/services/queries.d.ts +6 -2
- package/dist/services/queries.js +179 -1
- package/dist/services/wallet.d.ts +55 -0
- package/dist/services/wallet.js +44 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/ui/AlertDialog/AlertDialog.d.ts +154 -154
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +14 -14
- package/dist/ui/Badge/Badge.d.ts +12 -12
- package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
- package/dist/ui/Badge/badge.recipe.d.ts +3 -3
- package/dist/ui/Carousel/Carousel.d.ts +72 -72
- package/dist/ui/Carousel/carousel.recipe.d.ts +8 -8
- package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
- package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
- package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
- package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
- package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
- package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
- package/dist/ui/Combobox/Combobox.d.ts +42 -42
- package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
- package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
- package/dist/ui/Dialog/Dialog.d.ts +33 -33
- package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
- package/dist/ui/Drawer/Drawer.d.ts +33 -33
- package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
- package/dist/ui/Field/Field.d.ts +21 -21
- package/dist/ui/Field/field.recipe.d.ts +3 -3
- package/dist/ui/Menu/Menu.d.ts +307 -307
- package/dist/ui/Menu/menu.recipe.d.ts +17 -17
- package/dist/ui/Popover/Popover.d.ts +121 -121
- package/dist/ui/Popover/popover.recipe.d.ts +11 -11
- package/dist/ui/Progress/Progress.d.ts +27 -27
- package/dist/ui/Progress/progress.recipe.d.ts +3 -3
- package/dist/ui/QrCode/QrCode.d.ts +40 -40
- package/dist/ui/QrCode/qrCode.recipe.d.ts +8 -8
- package/dist/ui/Select/Select.d.ts +45 -45
- package/dist/ui/Select/select.recipe.d.ts +3 -3
- package/dist/ui/Table/Table.d.ts +21 -21
- package/dist/ui/Table/table.anatomy.d.ts +1 -1
- package/dist/ui/Table/table.recipe.d.ts +3 -3
- package/dist/ui/Tabs/Tabs.d.ts +15 -15
- package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
- package/dist/utils/capitalize.d.ts +11 -0
- package/dist/utils/capitalize.js +48 -5
- package/dist/utils/countries/types.d.ts +1 -1
- package/dist/utils/downloadImage.d.ts +4 -0
- package/dist/utils/downloadImage.js +47 -0
- package/dist/utils/mutationKeys.d.ts +4 -0
- package/dist/utils/mutationKeys.js +16 -0
- package/package.json +1 -1
package/dist/components/DepositWithdrawal/Deposit/AurixPayPayMayaDeposit/AurixPayGrabPayDeposit.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
3
|
+
import { ObjectId } from '@opexa/object-id';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
7
|
+
import invariant from 'tiny-invariant';
|
|
8
|
+
import { useBoolean } from 'usehooks-ts';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { useShallow } from 'zustand/shallow';
|
|
11
|
+
import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
|
|
12
|
+
import { useCreateAurixPayGrabPayDepositMutation } from '../../../../client/hooks/useCreateAurixPayGrabPayDepositMutation.js';
|
|
13
|
+
import { useDepositQuery } from '../../../../client/hooks/useDepositQuery.js';
|
|
14
|
+
import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
|
|
15
|
+
import { useDisclosure } from '../../../../client/hooks/useDisclosure.js';
|
|
16
|
+
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
17
|
+
import { useMemberVerificationQuery } from '../../../../client/hooks/useMemberVerificationQuery.js';
|
|
18
|
+
import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
|
|
19
|
+
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
20
|
+
import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
|
|
21
|
+
import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
|
|
22
|
+
import { RefreshCcw01Icon } from '../../../../icons/RefreshCcw01Icon.js';
|
|
23
|
+
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
24
|
+
import { XIcon } from '../../../../icons/XIcon.js';
|
|
25
|
+
import { ObjectType } from '../../../../services/ObjectType.js';
|
|
26
|
+
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
27
|
+
import { Button } from '../../../../ui/Button/index.js';
|
|
28
|
+
import { Field } from '../../../../ui/Field/index.js';
|
|
29
|
+
import { NumberInput } from '../../../../ui/NumberInput/index.js';
|
|
30
|
+
import { Portal } from '../../../../ui/Portal/index.js';
|
|
31
|
+
import { getQueryClient } from '../../../../utils/getQueryClient.js';
|
|
32
|
+
import { parseDecimal } from '../../../../utils/parseDecimal.js';
|
|
33
|
+
import { getDepositsCountQueryKey } from '../../../../utils/queryKeys.js';
|
|
34
|
+
import { AmountChoices } from '../../AmountChoices.js';
|
|
35
|
+
import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
|
|
36
|
+
import { AvailablePromos } from '../AvailablePromos.js';
|
|
37
|
+
export function AurixPayGrabPayDeposit() {
|
|
38
|
+
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
39
|
+
const disclosure = useDisclosure({
|
|
40
|
+
onOpenChange(open) {
|
|
41
|
+
if (!open) {
|
|
42
|
+
form.reset();
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
47
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
48
|
+
kycVerificationStatus: ctx.kycVerificationStatus,
|
|
49
|
+
})));
|
|
50
|
+
const verificationQuery = useMemberVerificationQuery();
|
|
51
|
+
const verificationStatus = verificationQuery.data?.status ?? 'UNVERIFIED';
|
|
52
|
+
const [status, setStatus] = useState('waiting');
|
|
53
|
+
const [errorMessage, setErrorMessage] = useState(null);
|
|
54
|
+
const createDepositMutation = useCreateAurixPayGrabPayDepositMutation({
|
|
55
|
+
onMutate() {
|
|
56
|
+
disclosure.setOpen(true);
|
|
57
|
+
setStatus('processing');
|
|
58
|
+
},
|
|
59
|
+
onSuccess(data) {
|
|
60
|
+
const queryClient = getQueryClient();
|
|
61
|
+
invariant(data.checkoutUrl);
|
|
62
|
+
window.open(data.checkoutUrl, '_blank', 'noopener,noreferrer');
|
|
63
|
+
queryClient.invalidateQueries({
|
|
64
|
+
queryKey: getDepositsCountQueryKey(),
|
|
65
|
+
});
|
|
66
|
+
setStatus('success');
|
|
67
|
+
},
|
|
68
|
+
onError(data) {
|
|
69
|
+
setStatus('failed');
|
|
70
|
+
setErrorMessage({
|
|
71
|
+
name: data.name,
|
|
72
|
+
message: data.message,
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
const warn = useBoolean();
|
|
77
|
+
const depositQuery = useDepositQuery(createDepositMutation.data?.id, {
|
|
78
|
+
enabled: !warn.value && status === 'success',
|
|
79
|
+
refetchInterval: (ctx) => ctx.state.data?.status === 'CONFIRMED' ||
|
|
80
|
+
ctx.state.data?.status === 'REJECTED' ||
|
|
81
|
+
ctx.state.data?.status === 'CANCELLED'
|
|
82
|
+
? false
|
|
83
|
+
: 1000,
|
|
84
|
+
});
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (depositQuery.data?.status === 'CONFIRMED') {
|
|
87
|
+
setStatus('confirmed');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (depositQuery.data?.status === 'REJECTED' ||
|
|
91
|
+
depositQuery.data?.status === 'CANCELLED') {
|
|
92
|
+
setStatus('failed');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}, [depositQuery.data?.status]);
|
|
96
|
+
const depositsCountQuery = useDepositsCountQuery();
|
|
97
|
+
const depositsCount = depositsCountQuery.data ?? 0;
|
|
98
|
+
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
99
|
+
const paymentSettings = paymentSettingsQuery.data;
|
|
100
|
+
const gatewaySettings = paymentSettings?.aioGCashDepositGatewaySettings;
|
|
101
|
+
const maximumAmount = parseDecimal(gatewaySettings?.maximumAmount, 0);
|
|
102
|
+
const minimumAmount = depositsCount <= 0
|
|
103
|
+
? parseDecimal(paymentSettingsQuery.data?.minimumFirstDepositAmount, 0)
|
|
104
|
+
: parseDecimal(gatewaySettings?.minimumAmount, 0);
|
|
105
|
+
const promosQuery = useAvailablePromosQuery();
|
|
106
|
+
const promos = promosQuery.data ?? [];
|
|
107
|
+
const definition = z
|
|
108
|
+
.object({
|
|
109
|
+
amount: z.string().superRefine((val, ctx) => {
|
|
110
|
+
const n = parseDecimal(val, 0);
|
|
111
|
+
if (n < minimumAmount) {
|
|
112
|
+
ctx.addIssue({
|
|
113
|
+
type: 'number',
|
|
114
|
+
code: z.ZodIssueCode.too_small,
|
|
115
|
+
inclusive: true,
|
|
116
|
+
minimum: minimumAmount,
|
|
117
|
+
message: `Please enter ${minimumAmount.toLocaleString()} or more to proceed with your deposit.`,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (n > maximumAmount) {
|
|
121
|
+
ctx.addIssue({
|
|
122
|
+
type: 'number',
|
|
123
|
+
code: z.ZodIssueCode.too_big,
|
|
124
|
+
inclusive: true,
|
|
125
|
+
maximum: maximumAmount,
|
|
126
|
+
message: `Maximum amount is ${maximumAmount.toLocaleString()}`,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
promo: z.string().optional().nullable(),
|
|
131
|
+
accountNumber: z
|
|
132
|
+
.string()
|
|
133
|
+
.min(1, 'Account number is required')
|
|
134
|
+
.min(8, 'Account number must be 8 or more characters')
|
|
135
|
+
.max(32, 'Account number must not be more than 32 characters'),
|
|
136
|
+
})
|
|
137
|
+
.superRefine((value, ctx) => {
|
|
138
|
+
const promo = promos.find((o) => o.id === value.promo);
|
|
139
|
+
const promoMinAmount = parseDecimal(promo?.minimumDepositAmount, 0);
|
|
140
|
+
const promoMaxAmount = parseDecimal(promo?.maximumDepositAmount, 0);
|
|
141
|
+
const amount = parseDecimal(value.amount, 0);
|
|
142
|
+
if (promo && amount < promoMinAmount) {
|
|
143
|
+
ctx.addIssue({
|
|
144
|
+
path: ['amount'],
|
|
145
|
+
code: z.ZodIssueCode.custom,
|
|
146
|
+
message: `Minimum amount for this promo is ${promoMinAmount.toLocaleString()}`,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
if (promo && amount > promoMaxAmount) {
|
|
150
|
+
ctx.addIssue({
|
|
151
|
+
path: ['amount'],
|
|
152
|
+
code: z.ZodIssueCode.custom,
|
|
153
|
+
message: `Maximum amount for this promo is ${promoMaxAmount}`,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
const form = useForm({
|
|
158
|
+
mode: 'all',
|
|
159
|
+
resolver: zodResolver(definition),
|
|
160
|
+
defaultValues: {
|
|
161
|
+
amount: '0',
|
|
162
|
+
promo: globalStore.depositWithdrawal.promo ?? null,
|
|
163
|
+
accountNumber: '',
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (minimumAmount) {
|
|
168
|
+
form.reset({
|
|
169
|
+
amount: minimumAmount.toString(),
|
|
170
|
+
promo: form.getValues('promo') ?? null,
|
|
171
|
+
accountNumber: form.getValues('accountNumber') ?? '',
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}, [form, minimumAmount]);
|
|
175
|
+
const redirectUrl = (() => {
|
|
176
|
+
const path = depositWithdrawalProps.depositSuccessPageUrl ?? '/deposits/:id/status';
|
|
177
|
+
const origin = window.location.origin.includes('localhost')
|
|
178
|
+
? 'https://uat.powerplay.ph/deposit-success' +
|
|
179
|
+
depositWithdrawalProps.depositSuccessPageUrl
|
|
180
|
+
: window.location.origin;
|
|
181
|
+
return `${origin}${path}`;
|
|
182
|
+
})();
|
|
183
|
+
return (_jsxs("form", { onSubmit: form.handleSubmit(async (data) => {
|
|
184
|
+
if (!depositWithdrawalProps.bypassDepositKycCheck &&
|
|
185
|
+
(verificationStatus === 'PENDING' ||
|
|
186
|
+
verificationStatus === 'UNVERIFIED' ||
|
|
187
|
+
verificationStatus === 'REJECTED' ||
|
|
188
|
+
verificationStatus === 'CREATED')) {
|
|
189
|
+
globalStore.kycVerificationStatus.setOpen(true);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
const id = ObjectId.generate(ObjectType.Deposit).toString();
|
|
194
|
+
createDepositMutation.reset();
|
|
195
|
+
createDepositMutation.mutate({
|
|
196
|
+
id,
|
|
197
|
+
amount: data.amount.toString(),
|
|
198
|
+
promo: data.promo ?? undefined,
|
|
199
|
+
redirectUrl: redirectUrl.replace(':id', id),
|
|
200
|
+
accountNumber: data.accountNumber,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}), noValidate: true, children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.accountNumber, children: [_jsx(Field.Label, { children: "Account number" }), _jsx(Field.Input, { ...form.register('accountNumber') }), _jsx(Field.ErrorText, { children: form.formState.errors.accountNumber?.message })] }), _jsx(Controller, { control: form.control, name: "amount", render: (o) => (_jsxs(Field.Root, { invalid: !!form.formState.errors.amount, className: "mt-lg", children: [_jsxs(NumberInput.Root, { min: 0, step: 1, value: o.field.value, onValueChange: (details) => {
|
|
204
|
+
o.field.onChange(details.value);
|
|
205
|
+
}, 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) => {
|
|
206
|
+
form.setValue('amount', value.toString(), {
|
|
207
|
+
shouldTouch: true,
|
|
208
|
+
shouldDirty: true,
|
|
209
|
+
shouldValidate: true,
|
|
210
|
+
});
|
|
211
|
+
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: (value) => {
|
|
212
|
+
o.field.onChange(value);
|
|
213
|
+
globalStore.depositWithdrawal.setPromo(null);
|
|
214
|
+
}, 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) => {
|
|
215
|
+
disclosure.setOpen(details.open);
|
|
216
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
|
|
217
|
+
setStatus('waiting');
|
|
218
|
+
setErrorMessage(null);
|
|
219
|
+
form.reset();
|
|
220
|
+
warn.setFalse();
|
|
221
|
+
}, 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: () => {
|
|
222
|
+
if (status === 'success' && !warn.value) {
|
|
223
|
+
warn.setTrue();
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
api.setOpen(false);
|
|
227
|
+
}
|
|
228
|
+
}, 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' &&
|
|
229
|
+
!warn.value &&
|
|
230
|
+
'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' && errorMessage?.name] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
|
|
231
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
232
|
+
!warn.value &&
|
|
233
|
+
'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' &&
|
|
234
|
+
warn.value &&
|
|
235
|
+
'Closing this window might cancel your current deposit. Do you want to continue?', status === 'confirmed' &&
|
|
236
|
+
'Your deposit has been successfully processed.', status === 'failed' && errorMessage?.message] })] }), (status === 'failed' ||
|
|
237
|
+
status === 'success' ||
|
|
238
|
+
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: () => {
|
|
239
|
+
warn.setFalse();
|
|
240
|
+
}, 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" })) }))] }))] }) })] }) })] }));
|
|
241
|
+
}
|
package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/AurixPayQRPHDeposit.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AurixPayQRPHDeposit(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AurixPayQRPHDepositContext } from './AurixPayQRPHDepositContext.js';
|
|
3
|
+
import { Confirmed } from './Confirmed.js';
|
|
4
|
+
import { Failed } from './Failed.js';
|
|
5
|
+
import { Form } from './Form.js';
|
|
6
|
+
import { GeneratingQrCode } from './GeneratingQrCode.js';
|
|
7
|
+
import { QrCodeGenerated } from './QrCodeGenerated.js';
|
|
8
|
+
import { useAurixPayQRPHDeposit } from './useAurixPayQRPHDeposit.js';
|
|
9
|
+
export function AurixPayQRPHDeposit() {
|
|
10
|
+
const context = useAurixPayQRPHDeposit();
|
|
11
|
+
return (_jsxs(AurixPayQRPHDepositContext, { value: context, children: [_jsx(Form, {}), _jsx(GeneratingQrCode, {}), _jsx(QrCodeGenerated, {}), _jsx(Failed, {}), _jsx(Confirmed, {})] }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const AurixPayQRPHDepositContext: (props: {
|
|
2
|
+
value: {
|
|
3
|
+
status: "idle" | "generating-qr-code" | "qr-code-generated" | "failed" | "confirmed";
|
|
4
|
+
deposit: import("../../../../types").Deposit | null;
|
|
5
|
+
errorMessage: {
|
|
6
|
+
name: string;
|
|
7
|
+
message: string;
|
|
8
|
+
} | null;
|
|
9
|
+
generateQRCode: (input: import("./useAurixPayQRPHDeposit").GenerateQRCodeInput) => Promise<void>;
|
|
10
|
+
regenerateQRCode: () => Promise<void>;
|
|
11
|
+
reset: () => void;
|
|
12
|
+
};
|
|
13
|
+
} & {
|
|
14
|
+
children?: import("react").ReactNode | undefined;
|
|
15
|
+
}) => React.ReactNode, useAurixPayQRPHDepositContext: () => {
|
|
16
|
+
status: "idle" | "generating-qr-code" | "qr-code-generated" | "failed" | "confirmed";
|
|
17
|
+
deposit: import("../../../../types").Deposit | null;
|
|
18
|
+
errorMessage: {
|
|
19
|
+
name: string;
|
|
20
|
+
message: string;
|
|
21
|
+
} | null;
|
|
22
|
+
generateQRCode: (input: import("./useAurixPayQRPHDeposit").GenerateQRCodeInput) => Promise<void>;
|
|
23
|
+
regenerateQRCode: () => Promise<void>;
|
|
24
|
+
reset: () => void;
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Confirmed(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CheckCircleIcon } from '../../../../icons/CheckCircleIcon.js';
|
|
3
|
+
import { XIcon } from '../../../../icons/XIcon.js';
|
|
4
|
+
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
5
|
+
import { Button } from '../../../../ui/Button/index.js';
|
|
6
|
+
import { Portal } from '../../../../ui/Portal/index.js';
|
|
7
|
+
import { useAurixPayQRPHDepositContext } from './AurixPayQRPHDepositContext.js';
|
|
8
|
+
export function Confirmed() {
|
|
9
|
+
const context = useAurixPayQRPHDepositContext();
|
|
10
|
+
return (_jsx(AlertDialog.Root, { open: context.status === 'confirmed', lazyMount: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+3)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+4)]", children: _jsxs(AlertDialog.Content, { children: [_jsx("button", { type: "button", className: "absolute top-4 right-4 icon:size-6 p-md text-text-quinary disabled:cursor-not-allowed disabled:opacity-50", onClick: context.reset, children: _jsx(XIcon, {}) }), _jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-success-secondary", children: _jsx(CheckCircleIcon, { className: "size-6 text-text-featured-icon-light-success" }) }), _jsx(AlertDialog.Title, { className: "mt-xl", children: "Your deposit was successful!" }), _jsx(AlertDialog.Description, { className: "mt-xl px-3", children: "The funds have been added to your account." }), _jsx(Button, { className: "mt-4xl w-full", onClick: context.reset, children: "Ok" })] }) })] }) }));
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Failed(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
3
|
+
import { XIcon } from '../../../../icons/XIcon.js';
|
|
4
|
+
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
5
|
+
import { Button } from '../../../../ui/Button/index.js';
|
|
6
|
+
import { Portal } from '../../../../ui/Portal/index.js';
|
|
7
|
+
import { useAurixPayQRPHDepositContext } from './AurixPayQRPHDepositContext.js';
|
|
8
|
+
export function Failed() {
|
|
9
|
+
const context = useAurixPayQRPHDepositContext();
|
|
10
|
+
return (_jsx(AlertDialog.Root, { open: context.status === 'failed', lazyMount: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+3)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+4)]", children: _jsxs(AlertDialog.Content, { children: [_jsx("button", { type: "button", className: "absolute top-4 right-4 icon:size-6 p-md text-text-quinary disabled:cursor-not-allowed disabled:opacity-50", onClick: context.reset, children: _jsx(XIcon, {}) }), _jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-error-secondary", children: _jsx(AlertCircleIcon, { className: "size-6 text-text-featured-icon-light-error" }) }), _jsx(AlertDialog.Title, { className: "mt-xl", children: context.errorMessage?.name ||
|
|
11
|
+
'Your deposit failed or was cancelled.' }), _jsx(AlertDialog.Description, { className: "mt-xl px-3", children: context.errorMessage?.message ||
|
|
12
|
+
'Your deposit was not completed or has been cancelled. You can try again by generating a new QR code.' }), _jsx(Button, { className: "mt-4xl w-full", variant: "outline", onClick: context.regenerateQRCode, children: "Generate New QR Code" })] }) })] }) }));
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Form(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
6
|
+
import { useBoolean } from 'usehooks-ts';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { useShallow } from 'zustand/shallow';
|
|
9
|
+
import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
|
|
10
|
+
import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
|
|
11
|
+
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
12
|
+
import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
|
|
13
|
+
import { QrCode02Icon } from '../../../../icons/QrCode02Icon.js';
|
|
14
|
+
import { XIcon } from '../../../../icons/XIcon.js';
|
|
15
|
+
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
16
|
+
import { Button } from '../../../../ui/Button/index.js';
|
|
17
|
+
import { Field } from '../../../../ui/Field/index.js';
|
|
18
|
+
import { Portal } from '../../../../ui/Portal/index.js';
|
|
19
|
+
import { parseDecimal } from '../../../../utils/parseDecimal.js';
|
|
20
|
+
import { AmountChoices } from '../../AmountChoices.js';
|
|
21
|
+
import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
|
|
22
|
+
import { AvailablePromos } from '../AvailablePromos.js';
|
|
23
|
+
import { useAurixPayQRPHDepositContext } from './AurixPayQRPHDepositContext.js';
|
|
24
|
+
export function Form() {
|
|
25
|
+
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
26
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
27
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
28
|
+
})));
|
|
29
|
+
const context = useAurixPayQRPHDepositContext();
|
|
30
|
+
const depositsCountQuery = useDepositsCountQuery();
|
|
31
|
+
const depositsCount = depositsCountQuery.data ?? 0;
|
|
32
|
+
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
33
|
+
const paymentSettings = paymentSettingsQuery.data;
|
|
34
|
+
const gatewaySettings = paymentSettings?.qrphDepositGatewaySettings;
|
|
35
|
+
const maximumAmount = parseDecimal(gatewaySettings?.maximumAmount, 0);
|
|
36
|
+
const minimumAmount = depositsCount <= 0
|
|
37
|
+
? parseDecimal(paymentSettingsQuery.data?.minimumFirstDepositAmount, 0)
|
|
38
|
+
: parseDecimal(gatewaySettings?.minimumAmount, 0);
|
|
39
|
+
const promosQuery = useAvailablePromosQuery();
|
|
40
|
+
const promos = promosQuery.data ?? [];
|
|
41
|
+
const definition = z
|
|
42
|
+
.object({
|
|
43
|
+
amount: z.string().superRefine((val, ctx) => {
|
|
44
|
+
const n = parseDecimal(val, 0);
|
|
45
|
+
if (val.includes('.')) {
|
|
46
|
+
ctx.addIssue({
|
|
47
|
+
code: z.ZodIssueCode.custom,
|
|
48
|
+
message: 'Amount must be a whole number',
|
|
49
|
+
});
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (n < minimumAmount) {
|
|
53
|
+
ctx.addIssue({
|
|
54
|
+
type: 'number',
|
|
55
|
+
code: z.ZodIssueCode.too_small,
|
|
56
|
+
inclusive: true,
|
|
57
|
+
minimum: minimumAmount,
|
|
58
|
+
message: `Please enter ${minimumAmount.toLocaleString()} or more to proceed with your deposit.`,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (n > maximumAmount) {
|
|
62
|
+
ctx.addIssue({
|
|
63
|
+
type: 'number',
|
|
64
|
+
code: z.ZodIssueCode.too_big,
|
|
65
|
+
inclusive: true,
|
|
66
|
+
maximum: maximumAmount,
|
|
67
|
+
message: `Maximum amount is ${maximumAmount.toLocaleString()}`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
promo: z.string().optional().nullable(),
|
|
72
|
+
})
|
|
73
|
+
.superRefine((value, ctx) => {
|
|
74
|
+
const promo = promos.find((o) => o.id === value.promo);
|
|
75
|
+
const promoMinAmount = parseDecimal(promo?.minimumDepositAmount, 0);
|
|
76
|
+
const promoMaxAmount = parseDecimal(promo?.maximumDepositAmount, 0);
|
|
77
|
+
const amount = parseDecimal(value.amount, 0);
|
|
78
|
+
if (promo && amount < promoMinAmount) {
|
|
79
|
+
ctx.addIssue({
|
|
80
|
+
path: ['amount'],
|
|
81
|
+
code: z.ZodIssueCode.custom,
|
|
82
|
+
message: `Minimum amount for this promo is ${promoMinAmount.toLocaleString()}`,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (promo && amount > promoMaxAmount) {
|
|
86
|
+
ctx.addIssue({
|
|
87
|
+
path: ['amount'],
|
|
88
|
+
code: z.ZodIssueCode.custom,
|
|
89
|
+
message: `Maximum amount for this promo is ${promoMaxAmount}`,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
const form = useForm({
|
|
94
|
+
mode: 'all',
|
|
95
|
+
resolver: zodResolver(definition),
|
|
96
|
+
defaultValues: {
|
|
97
|
+
amount: '0',
|
|
98
|
+
promo: globalStore.depositWithdrawal.promo ?? null,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (minimumAmount) {
|
|
103
|
+
form.reset({
|
|
104
|
+
amount: minimumAmount.toString(),
|
|
105
|
+
promo: form.getValues('promo') ?? null,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}, [form, minimumAmount]);
|
|
109
|
+
const confirm = useBoolean();
|
|
110
|
+
return (_jsxs("form", { onSubmit: (e) => {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
confirm.setTrue();
|
|
113
|
+
}, noValidate: true, children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.amount, className: "mt-3xl", children: [_jsx(Field.Label, { children: "Enter the amount you want to deposit" }), _jsx(Field.Input, { type: "number", ...form.register('amount') }), _jsx(Field.ErrorText, { children: form.formState.errors.amount?.message })] }), _jsx(AmountChoices, { value: parseDecimal(form.watch('amount'), 0), onChange: (value) => {
|
|
114
|
+
form.setValue('amount', value.toString(), {
|
|
115
|
+
shouldTouch: true,
|
|
116
|
+
shouldDirty: true,
|
|
117
|
+
shouldValidate: true,
|
|
118
|
+
});
|
|
119
|
+
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: (value) => {
|
|
120
|
+
o.field.onChange(value);
|
|
121
|
+
globalStore.depositWithdrawal.setPromo(null);
|
|
122
|
+
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: !!form.formState.errors.amount, children: "Deposit" }), depositWithdrawalProps.hasPrivacyPolicyAndTermsOfUse && (_jsxs("p", { className: "mt-lg text-text-tertiary-600 text-xs", children: ["By depositing, you agree to our", ' ', _jsx(Link, { href: depositWithdrawalProps.termsOfUseUrl ?? '/terms-of-use', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use" }), ' ', "and", ' ', _jsx(Link, { href: depositWithdrawalProps.privacyPolicyUrl ?? '/privacy-policy', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Privacy Policy" }), "."] })), _jsx(AlertDialog.Root, { open: confirm.value, lazyMount: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.CloseTrigger, { onClick: confirm.setFalse, children: _jsx(XIcon, {}) }), _jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary", children: _jsx(QrCode02Icon, { className: "size-6 text-text-featured-icon-light-brand" }) }), _jsx(AlertDialog.Title, { className: "mt-xl", children: "Generate Single Use QR Code" }), _jsx(AlertDialog.Description, { className: "mt-xs px-2", children: "To proceed with your QRPH deposit, please generate a QR code first." }), _jsx(Button, { className: "mt-4xl", variant: "outline", colorScheme: "gray", onClick: form.handleSubmit(async (data) => {
|
|
123
|
+
confirm.setFalse();
|
|
124
|
+
await context.generateQRCode(data);
|
|
125
|
+
}), children: "Generate QR code" })] }) })] }) })] }));
|
|
126
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function GeneratingQrCode(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Spinner02Icon } from '../../../../icons/Spinner02Icon.js';
|
|
3
|
+
import { XIcon } from '../../../../icons/XIcon.js';
|
|
4
|
+
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
5
|
+
import { Portal } from '../../../../ui/Portal/index.js';
|
|
6
|
+
import { useAurixPayQRPHDepositContext } from './AurixPayQRPHDepositContext.js';
|
|
7
|
+
export function GeneratingQrCode() {
|
|
8
|
+
const context = useAurixPayQRPHDepositContext();
|
|
9
|
+
return (_jsx(AlertDialog.Root, { open: context.status === 'generating-qr-code', lazyMount: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.CloseTrigger, { disabled: true, children: _jsx(XIcon, {}) }), _jsx(Spinner02Icon, { className: "mx-auto size-12 text-text-featured-icon-light-brand" }), _jsx(AlertDialog.Title, { className: "mt-xl", children: "Generating Single Use QR Code" }), _jsxs(AlertDialog.Description, { className: "mt-xs px-3", children: [_jsx("span", { className: "block", children: "Please hold tight as we verify the account details and amount. Once verified, a QRPH code will be displayed for you to scan and complete the transaction." }), _jsxs("span", { className: "mt-3 block", children: ["Please wait ", _jsx("span", { className: "font-bold", children: "60" }), " seconds..."] })] })] }) })] }) }));
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function QrCodeGenerated(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Image from 'next/image';
|
|
3
|
+
import { useBoolean } from 'usehooks-ts';
|
|
4
|
+
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
5
|
+
import { ArrowCircleDownIcon } from '../../../../icons/ArrowCircleDownIcon.js';
|
|
6
|
+
import { QrCode02Icon } from '../../../../icons/QrCode02Icon.js';
|
|
7
|
+
import { XIcon } from '../../../../icons/XIcon.js';
|
|
8
|
+
import qrphIcon from '../../../../images/qrph-icon.png';
|
|
9
|
+
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
10
|
+
import { Button } from '../../../../ui/Button/index.js';
|
|
11
|
+
import { Portal } from '../../../../ui/Portal/index.js';
|
|
12
|
+
import { QrCode } from '../../../../ui/QrCode/index.js';
|
|
13
|
+
import { useAurixPayQRPHDepositContext } from './AurixPayQRPHDepositContext.js';
|
|
14
|
+
export function QrCodeGenerated() {
|
|
15
|
+
const context = useAurixPayQRPHDepositContext();
|
|
16
|
+
const confirm = useBoolean(false);
|
|
17
|
+
return (_jsx(AlertDialog.Root, { open: context.status === 'qr-code-generated', lazyMount: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx("button", { type: "button", className: "absolute top-4 right-4 icon:size-6 p-md text-text-quinary disabled:cursor-not-allowed disabled:opacity-50", onClick: () => {
|
|
18
|
+
if (!confirm.value) {
|
|
19
|
+
confirm.setTrue();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
confirm.setFalse();
|
|
23
|
+
}, children: _jsx(XIcon, {}) }), !confirm.value ? (_jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary", children: _jsx(QrCode02Icon, { className: "size-6 text-text-featured-icon-light-brand" }) })) : (_jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-error-secondary", children: _jsx(AlertCircleIcon, { className: "size-6 text-text-featured-icon-light-error" }) })), _jsx(AlertDialog.Title, { className: "mt-xl", dangerouslySetInnerHTML: {
|
|
24
|
+
__html: confirm.value
|
|
25
|
+
? 'Are you sure you want to close this window?'
|
|
26
|
+
: 'Single Use QR Code',
|
|
27
|
+
} }), _jsx(AlertDialog.Description, { className: "mt-xs px-3", children: confirm.value
|
|
28
|
+
? 'Closing this window will cancel your current deposit. Do you want to continue?'
|
|
29
|
+
: 'Scan the QR code below with your banking app, or upload it to complete your deposit.' }), !confirm.value && (_jsx("div", { className: "mx-auto mt-xl w-[14.125rem] rounded-xl bg-bg-primary-alt p-6", children: _jsxs(QrCode.Root, { value: context.deposit?.qrCode ?? '', encoding: {
|
|
30
|
+
ecc: 'H',
|
|
31
|
+
boostEcc: true,
|
|
32
|
+
}, children: [_jsxs("div", { className: "relative", children: [_jsx(QrCode.Frame, { className: "mx-auto size-[10rem] rounded-[0.25rem] border border-border-primary 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 }) })] }), _jsxs(QrCode.DownloadTrigger, { type: "button", fileName: `QRPH-${Date.now()}.jpg`, mimeType: "image/jpeg", className: "mx-auto mt-5 flex w-fit items-center gap-1 font-semibold text-button-tertiary-fg", children: [_jsx(ArrowCircleDownIcon, { className: "size-5" }), "Download QR Code"] })] }) })), confirm.value && (_jsxs("div", { className: "mt-4xl flex gap-lg", children: [_jsx(Button, { variant: "outline", onClick: confirm.setFalse, children: "Go back" }), _jsx(Button, { onClick: () => {
|
|
33
|
+
context.reset();
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
confirm.setFalse();
|
|
36
|
+
}, 2);
|
|
37
|
+
}, children: "Continue" })] })), !confirm.value && _jsx(Instruction, {})] }) })] }) }));
|
|
38
|
+
}
|
|
39
|
+
function Instruction() {
|
|
40
|
+
return (_jsxs(AlertDialog.Root, { lazyMount: true, closeOnEscape: false, closeOnInteractOutside: false, children: [_jsxs("p", { className: "mt-lg text-center text-text-tertiary-600 text-xs", children: ["Need help using the QR Code?", ' ', _jsx(AlertDialog.Trigger, { className: "text-text-brand", children: "See instructions" })] }), _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+3)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+4)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary", children: _jsx(QrCode02Icon, { className: "size-6 text-text-featured-icon-light-brand" }) }), _jsx(AlertDialog.Title, { className: "mt-xl", children: "How to Use the QR Code for Payment" }), _jsx(AlertDialog.Description, { className: "mt-xl px-3", children: "Follow these simple steps to complete your\u00A0transaction:" }), _jsx("div", { className: "mt-4 text-sm text-text-tertiary-600", children: _jsxs("ol", { className: "list-decimal pl-4", children: [_jsx("li", { className: "marker:font-mono marker:text-sm", children: "Open your preferred banking or EMI mobile app and select 'Transfer Money' or 'Pay via QR.'" }), _jsx("li", { className: "marker:font-mono marker:text-sm", children: "Scan or upload the generated QR Ph code. If prompted by the app, enter the amount to be sent." }), _jsx("li", { className: "marker:font-mono marker:text-sm", children: "Proceed with the transfer or payment." })] }) })] }) })] })] }));
|
|
41
|
+
}
|
package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/useAurixPayQRPHDeposit.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Deposit } from '../../../../types';
|
|
2
|
+
export type UseAurixPayQRPHDepositReturn = ReturnType<typeof useAurixPayQRPHDeposit>;
|
|
3
|
+
export interface GenerateQRCodeInput {
|
|
4
|
+
amount: string;
|
|
5
|
+
promo?: string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function useAurixPayQRPHDeposit(): {
|
|
8
|
+
status: "idle" | "generating-qr-code" | "qr-code-generated" | "failed" | "confirmed";
|
|
9
|
+
deposit: Deposit | null;
|
|
10
|
+
errorMessage: {
|
|
11
|
+
name: string;
|
|
12
|
+
message: string;
|
|
13
|
+
} | null;
|
|
14
|
+
generateQRCode: (input: GenerateQRCodeInput) => Promise<void>;
|
|
15
|
+
regenerateQRCode: () => Promise<void>;
|
|
16
|
+
reset: () => void;
|
|
17
|
+
};
|