@opexa/portal-components 0.0.205 → 0.0.206
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/useCreatePisoPayDepositMutation.d.ts +4 -0
- package/dist/client/hooks/useCreatePisoPayDepositMutation.js +73 -0
- package/dist/client/hooks/useCreatePisoPayWithdrawalMutation.d.ts +4 -0
- package/dist/client/hooks/useCreatePisoPayWithdrawalMutation.js +28 -0
- package/dist/client/hooks/useGlobalStore.d.ts +2 -7
- package/dist/client/hooks/useGlobalStore.js +8 -11
- package/dist/components/DepositWithdrawal/Deposit/Deposit.js +8 -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/PisoPayDeposit/PisoPayDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/PisoPayDeposit/PisoPayDeposit.js +182 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/PaymentMethods.js +6 -0
- package/dist/components/DepositWithdrawal/Withdrawal/PisoPayWithdrawal/PisoPayWithdrawal.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Withdrawal/PisoPayWithdrawal/PisoPayWithdrawal.js +151 -0
- package/dist/components/DepositWithdrawal/Withdrawal/Withdrawal.js +8 -1
- package/dist/components/DepositWithdrawal/utils.d.ts +1 -1
- package/dist/components/DepositWithdrawal/utils.js +1 -0
- package/dist/components/KYC/BasicInformation.js +16 -12
- package/dist/components/KYC/IdentityVerification.js +2 -2
- package/dist/components/KYC/Indicator.js +3 -6
- package/dist/components/KYC/KYC.js +1 -3
- package/dist/components/KYC/KYC.lazy.d.ts +2 -1
- package/dist/components/KYC/KYC.lazy.js +16 -11
- package/dist/components/KYC/KYCReminder.d.ts +2 -5
- package/dist/components/KYC/KYCReminder.js +11 -20
- package/dist/components/KYC/KYCReminder.lazy.d.ts +4 -0
- package/dist/components/KYC/KYCReminder.lazy.js +30 -0
- package/dist/components/KYC/index.d.ts +1 -0
- package/dist/components/KYC/index.js +1 -0
- package/dist/components/Messages/MessagesPopup.js +1 -1
- package/dist/components/SignIn/MobileNumberSignIn.js +6 -5
- package/dist/components/SignIn/NameAndPasswordSignIn.js +2 -0
- package/dist/components/SignUp/SignUpDefault/SignUpForm.js +11 -8
- package/dist/constants/PisoPayBanks.d.ts +4 -0
- package/dist/constants/PisoPayBanks.js +45 -0
- package/dist/constants/StorageKey.d.ts +0 -1
- package/dist/constants/StorageKey.js +0 -1
- package/dist/images/piso-pay.png +0 -0
- package/dist/services/queries.d.ts +2 -0
- package/dist/services/queries.js +68 -0
- package/dist/services/wallet.d.ts +27 -0
- package/dist/services/wallet.js +26 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/ui/AlertDialog/AlertDialog.d.ts +88 -88
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +8 -8
- 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 +45 -45
- package/dist/ui/Carousel/carousel.recipe.d.ts +5 -5
- 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 +32 -32
- 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 +88 -88
- package/dist/ui/Dialog/dialog.recipe.d.ts +8 -8
- package/dist/ui/Drawer/Drawer.d.ts +33 -33
- package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
- package/dist/ui/Menu/Menu.d.ts +144 -144
- package/dist/ui/Menu/menu.recipe.d.ts +5 -5
- package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
- package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
- package/dist/ui/Popover/Popover.d.ts +55 -55
- package/dist/ui/Progress/Progress.d.ts +27 -27
- package/dist/ui/Progress/progress.recipe.d.ts +3 -3
- package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
- package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
- 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/ui/Tooltip/tooltip.recipe.d.ts +5 -5
- package/dist/utils/mutationKeys.d.ts +2 -0
- package/dist/utils/mutationKeys.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SetOptional } from 'type-fest';
|
|
2
|
+
import { type CreatePisoPayDepositInput } from '../../services/wallet';
|
|
3
|
+
import type { Deposit, Mutation } from '../../types';
|
|
4
|
+
export declare const useCreatePisoPayDepositMutation: Mutation<Deposit, SetOptional<CreatePisoPayDepositInput, 'id'>>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ObjectId } from '@opexa/object-id';
|
|
2
|
+
import { useMutation } from '@tanstack/react-query';
|
|
3
|
+
import { clamp } from 'lodash-es';
|
|
4
|
+
import invariant from 'tiny-invariant';
|
|
5
|
+
import { ObjectType } from '../../services/ObjectType.js';
|
|
6
|
+
import { createPisoPayDeposit, getDeposit, } from '../../services/wallet.js';
|
|
7
|
+
import { createPoll } from '../../utils/createPoll.js';
|
|
8
|
+
import { getQueryClient } from '../../utils/getQueryClient.js';
|
|
9
|
+
import { getCreatePisoPayDepositMutationKey } from '../../utils/mutationKeys.js';
|
|
10
|
+
import { parseDecimal } from '../../utils/parseDecimal.js';
|
|
11
|
+
import { getAvailableQuestsQueryKey, getDepositsCountQueryKey, } from '../../utils/queryKeys.js';
|
|
12
|
+
import { getSession } from '../services/getSession.js';
|
|
13
|
+
export const useCreatePisoPayDepositMutation = (config) => {
|
|
14
|
+
const queryClient = getQueryClient();
|
|
15
|
+
const mutation = useMutation({
|
|
16
|
+
...config,
|
|
17
|
+
mutationKey: getCreatePisoPayDepositMutationKey(),
|
|
18
|
+
mutationFn: async (input) => {
|
|
19
|
+
const id = input.id ?? ObjectId.generate(ObjectType.Deposit).toString();
|
|
20
|
+
const session = await getSession();
|
|
21
|
+
invariant(session.status === 'authenticated');
|
|
22
|
+
await createPisoPayDeposit({ ...input, id }, {
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: `Bearer ${session.token}`,
|
|
25
|
+
...(session.domain && {
|
|
26
|
+
Domain: session.domain,
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const poll = createPoll(async () => {
|
|
31
|
+
const session = await getSession();
|
|
32
|
+
invariant(session.status === 'authenticated');
|
|
33
|
+
return await getDeposit(id, {
|
|
34
|
+
headers: {
|
|
35
|
+
Authorization: `Bearer ${session.token}`,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}, {
|
|
39
|
+
until(res) {
|
|
40
|
+
return !!res?.checkoutUrl;
|
|
41
|
+
},
|
|
42
|
+
interval: 1000,
|
|
43
|
+
maxAttempt: 5,
|
|
44
|
+
});
|
|
45
|
+
const res = await poll();
|
|
46
|
+
if (!res?.checkoutUrl) {
|
|
47
|
+
const error = new Error();
|
|
48
|
+
error.name = 'PisoPayDepositError';
|
|
49
|
+
error.message = 'Failed to process PisoPay deposit';
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
const depositsCount = queryClient.getQueryData(getDepositsCountQueryKey()) ?? 0;
|
|
53
|
+
if (depositsCount <= 0) {
|
|
54
|
+
queryClient.setQueryData(getAvailableQuestsQueryKey(), (prev) => {
|
|
55
|
+
return prev?.map((quest) => {
|
|
56
|
+
const progressPercentage = clamp(parseDecimal(quest.progressPercentage, 0) + 50, 100);
|
|
57
|
+
if (quest.type === 'ONBOARDING') {
|
|
58
|
+
return {
|
|
59
|
+
...quest,
|
|
60
|
+
status: progressPercentage >= 100 ? 'COMPLETED' : quest.status,
|
|
61
|
+
progressPercentage: progressPercentage.toFixed(2),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return quest;
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
queryClient.setQueryData(getDepositsCountQueryKey(), (prev) => prev ? prev + 1 : 1);
|
|
69
|
+
return res;
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
return mutation;
|
|
73
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SetOptional } from 'type-fest';
|
|
2
|
+
import { type CreatePisoPayWithdrawalInput } from '../../services/wallet';
|
|
3
|
+
import type { Mutation } from '../../types';
|
|
4
|
+
export declare const useCreatePisoPayWithdrawalMutation: Mutation<string, SetOptional<CreatePisoPayWithdrawalInput, 'id'>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ObjectId } from '@opexa/object-id';
|
|
2
|
+
import { useMutation } from '@tanstack/react-query';
|
|
3
|
+
import invariant from 'tiny-invariant';
|
|
4
|
+
import { ObjectType } from '../../services/ObjectType.js';
|
|
5
|
+
import { createPisoPayWithdrawal, } from '../../services/wallet.js';
|
|
6
|
+
import { getCreatePisoPayWithdrawalMutationKey } from '../../utils/mutationKeys.js';
|
|
7
|
+
import { getSession } from '../services/getSession.js';
|
|
8
|
+
export const useCreatePisoPayWithdrawalMutation = (config) => {
|
|
9
|
+
const mutation = useMutation({
|
|
10
|
+
...config,
|
|
11
|
+
mutationKey: getCreatePisoPayWithdrawalMutationKey(),
|
|
12
|
+
mutationFn: async (input) => {
|
|
13
|
+
const id = input.id ?? ObjectId.generate(ObjectType.Withdrawal).toString();
|
|
14
|
+
const session = await getSession();
|
|
15
|
+
invariant(session.status === 'authenticated');
|
|
16
|
+
await createPisoPayWithdrawal({ ...input, id }, {
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Bearer ${session.token}`,
|
|
19
|
+
...(session.domain && {
|
|
20
|
+
Domain: session.domain,
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
return id;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return mutation;
|
|
28
|
+
};
|
|
@@ -4,12 +4,6 @@ export interface PopupStore {
|
|
|
4
4
|
setOpen: (open: boolean) => void;
|
|
5
5
|
'~touched': boolean;
|
|
6
6
|
}
|
|
7
|
-
export interface KYCPopupStore extends PopupStore {
|
|
8
|
-
step: number;
|
|
9
|
-
setStep: (step: number) => void;
|
|
10
|
-
openKycReminder: boolean;
|
|
11
|
-
setKycReminder: (reminder: boolean) => void;
|
|
12
|
-
}
|
|
13
7
|
export type GameLaunchStore__Details = {
|
|
14
8
|
status: 'WAITING';
|
|
15
9
|
game?: null;
|
|
@@ -66,7 +60,8 @@ interface GlobalStore {
|
|
|
66
60
|
message: MessageStore;
|
|
67
61
|
sidebar: PopupStore;
|
|
68
62
|
sidebar__mobile: PopupStore;
|
|
69
|
-
kyc:
|
|
63
|
+
kyc: PopupStore;
|
|
64
|
+
kycReminder: PopupStore;
|
|
70
65
|
spotBonus: PopupStore;
|
|
71
66
|
}
|
|
72
67
|
export declare const useGlobalStore: import("zustand").UseBoundStore<import("zustand").StoreApi<GlobalStore>>;
|
|
@@ -193,22 +193,19 @@ export const useGlobalStore = create((set) => ({
|
|
|
193
193
|
},
|
|
194
194
|
}));
|
|
195
195
|
},
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
'~touched': false,
|
|
197
|
+
},
|
|
198
|
+
kycReminder: {
|
|
199
|
+
open: false,
|
|
200
|
+
setOpen(open) {
|
|
198
201
|
set((prev) => ({
|
|
199
|
-
|
|
200
|
-
...prev.
|
|
201
|
-
|
|
202
|
+
kycReminder: {
|
|
203
|
+
...prev.kycReminder,
|
|
204
|
+
open,
|
|
202
205
|
'~touched': true,
|
|
203
206
|
},
|
|
204
|
-
}));
|
|
205
|
-
},
|
|
206
|
-
openKycReminder: false,
|
|
207
|
-
setKycReminder(reminder) {
|
|
208
|
-
set((prev) => ({
|
|
209
207
|
kyc: {
|
|
210
208
|
...prev.kyc,
|
|
211
|
-
openKycReminder: reminder,
|
|
212
209
|
'~touched': true,
|
|
213
210
|
},
|
|
214
211
|
}));
|
|
@@ -12,6 +12,7 @@ import { LibanganDeposit } from './LibanganDeposit/LibanganDeposit.js';
|
|
|
12
12
|
import { MayaAppDeposit } from './MayaAppDeposit/MayaAppDeposit.js';
|
|
13
13
|
import { MayaDeposit } from './MayaDeposit/MayaDeposit.js';
|
|
14
14
|
import { OnlineBankDeposit } from './OnlineBankDeposit/OnlineBankDeposit.js';
|
|
15
|
+
import { PisoPayDeposit } from './PisoPayDeposit/PisoPayDeposit.js';
|
|
15
16
|
import { QRPHDeposit } from './QRPHDeposit/QRPHDeposit.js';
|
|
16
17
|
export function Deposit() {
|
|
17
18
|
const [onMMA] = useOnMMA();
|
|
@@ -38,6 +39,9 @@ export function Deposit() {
|
|
|
38
39
|
if (paymentSettings?.libanganDepositGatewaySettings?.mobileWebEnabled) {
|
|
39
40
|
l.push('LIBANGAN');
|
|
40
41
|
}
|
|
42
|
+
if (paymentSettings?.pisoPayDepositGatewaySettings?.mobileWebEnabled) {
|
|
43
|
+
l.push('PISO_PAY');
|
|
44
|
+
}
|
|
41
45
|
}
|
|
42
46
|
else {
|
|
43
47
|
if (paymentSettings?.gcashDepositGatewaySettings?.webEnabled) {
|
|
@@ -55,6 +59,9 @@ export function Deposit() {
|
|
|
55
59
|
if (paymentSettings?.libanganDepositGatewaySettings?.webEnabled) {
|
|
56
60
|
l.push('LIBANGAN');
|
|
57
61
|
}
|
|
62
|
+
if (paymentSettings?.pisoPayDepositGatewaySettings?.webEnabled) {
|
|
63
|
+
l.push('PISO_PAY');
|
|
64
|
+
}
|
|
58
65
|
}
|
|
59
66
|
return l;
|
|
60
67
|
})();
|
|
@@ -75,7 +82,7 @@ export function Deposit() {
|
|
|
75
82
|
if (enabledPaymentMethods.length <= 0) {
|
|
76
83
|
return _jsx(NoAvailablePaymentMethods, {});
|
|
77
84
|
}
|
|
78
|
-
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' && _jsx(LibanganDeposit, {})] }));
|
|
85
|
+
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' && _jsx(LibanganDeposit, {}), paymentMethod === 'PISO_PAY' && _jsx(PisoPayDeposit, {})] }));
|
|
79
86
|
}
|
|
80
87
|
function MayaSessionSessionExpired() {
|
|
81
88
|
return (_jsxs("div", { className: "py-xl", children: [_jsx("div", { className: "bg-bg-warning-secondary mx-auto flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, { className: "text-text-featured-icon-light-warning size-6" }) }), _jsx("h2", { className: "mt-lg text-center text-lg font-semibold", children: "Session Expired" }), _jsx("p", { className: "text-text-tertiary-600 mx-auto mt-xs max-w-[25rem] text-center text-sm", children: "Your session has timed out. To continue with deposits or withdrawals, Please try reloading the app." })] }));
|
package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const OnlineBankDepositContext: (props: {
|
|
2
2
|
value: {
|
|
3
|
-
view: "
|
|
3
|
+
view: "vca" | "form";
|
|
4
4
|
status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
|
|
5
5
|
verify: () => void;
|
|
6
6
|
reset: () => void;
|
|
@@ -13,7 +13,7 @@ export declare const OnlineBankDepositContext: (props: {
|
|
|
13
13
|
} & {
|
|
14
14
|
children?: import("react").ReactNode | undefined;
|
|
15
15
|
}) => React.ReactNode, useOnlineBankDepositContext: () => {
|
|
16
|
-
view: "
|
|
16
|
+
view: "vca" | "form";
|
|
17
17
|
status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
|
|
18
18
|
verify: () => void;
|
|
19
19
|
reset: () => void;
|
package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/useOnlineBankDeposit.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Deposit } from '../../../../types';
|
|
2
2
|
export type UseOnlineBankDepositReturn = ReturnType<typeof useOnlineBankDeposit>;
|
|
3
3
|
export declare function useOnlineBankDeposit(): {
|
|
4
|
-
view: "
|
|
4
|
+
view: "vca" | "form";
|
|
5
5
|
status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
|
|
6
6
|
verify: () => void;
|
|
7
7
|
reset: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PisoPayDeposit(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } 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 { z } from 'zod';
|
|
9
|
+
import { useShallow } from 'zustand/shallow';
|
|
10
|
+
import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
|
|
11
|
+
import { useCreatePisoPayDepositMutation } from '../../../../client/hooks/useCreatePisoPayDepositMutation.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 { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
|
|
17
|
+
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
18
|
+
import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
|
|
19
|
+
import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
|
|
20
|
+
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
21
|
+
import { XIcon } from '../../../../icons/XIcon.js';
|
|
22
|
+
import { ObjectType } from '../../../../services/ObjectType.js';
|
|
23
|
+
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
24
|
+
import { Button } from '../../../../ui/Button/index.js';
|
|
25
|
+
import { Field } from '../../../../ui/Field/index.js';
|
|
26
|
+
import { NumberInput } from '../../../../ui/NumberInput/index.js';
|
|
27
|
+
import { Portal } from '../../../../ui/Portal/index.js';
|
|
28
|
+
import { parseDecimal } from '../../../../utils/parseDecimal.js';
|
|
29
|
+
import { AmountChoices } from '../../AmountChoices.js';
|
|
30
|
+
import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
|
|
31
|
+
import { AvailablePromos } from '../AvailablePromos.js';
|
|
32
|
+
export function PisoPayDeposit() {
|
|
33
|
+
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
34
|
+
const disclosure = useDisclosure();
|
|
35
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
36
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
37
|
+
})));
|
|
38
|
+
const [status, setStatus] = useState('waiting');
|
|
39
|
+
const createDepositMutation = useCreatePisoPayDepositMutation({
|
|
40
|
+
onMutate() {
|
|
41
|
+
disclosure.setOpen(true);
|
|
42
|
+
setStatus('processing');
|
|
43
|
+
},
|
|
44
|
+
onSuccess(data) {
|
|
45
|
+
invariant(data.checkoutUrl);
|
|
46
|
+
window.open(data.checkoutUrl, '_blank', 'noopener,noreferrer');
|
|
47
|
+
form.reset();
|
|
48
|
+
disclosure.setOpen(false);
|
|
49
|
+
},
|
|
50
|
+
onError() {
|
|
51
|
+
disclosure.setOpen(true);
|
|
52
|
+
setStatus('failed');
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
const depositQuery = useDepositQuery(createDepositMutation.data?.id, {
|
|
56
|
+
enabled: createDepositMutation.data != null,
|
|
57
|
+
refetchInterval(ctx) {
|
|
58
|
+
if (ctx.state.data?.status === 'CANCELLED' ||
|
|
59
|
+
ctx.state.data?.status === 'CONFIRMED') {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return 2500;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (depositQuery.data?.status === 'CANCELLED') {
|
|
69
|
+
disclosure.setOpen(true);
|
|
70
|
+
setStatus('failed');
|
|
71
|
+
}
|
|
72
|
+
else if (depositQuery.data?.status === 'CONFIRMED') {
|
|
73
|
+
disclosure.setOpen(true);
|
|
74
|
+
setStatus('success');
|
|
75
|
+
}
|
|
76
|
+
}, [depositQuery.data?.status, disclosure]);
|
|
77
|
+
const depositsCountQuery = useDepositsCountQuery();
|
|
78
|
+
const depositsCount = depositsCountQuery.data ?? 0;
|
|
79
|
+
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
80
|
+
const paymentSettings = paymentSettingsQuery.data;
|
|
81
|
+
const gatewaySettings = paymentSettings?.pisoPayDepositGatewaySettings;
|
|
82
|
+
const maximumAmount = parseDecimal(gatewaySettings?.maximumAmount, 0);
|
|
83
|
+
const minimumAmount = depositsCount <= 0
|
|
84
|
+
? parseDecimal(paymentSettingsQuery.data?.minimumFirstDepositAmount, 0)
|
|
85
|
+
: parseDecimal(gatewaySettings?.minimumAmount, 0);
|
|
86
|
+
const promosQuery = useAvailablePromosQuery();
|
|
87
|
+
const promos = promosQuery.data ?? [];
|
|
88
|
+
const definition = z
|
|
89
|
+
.object({
|
|
90
|
+
amount: z.string().superRefine((val, ctx) => {
|
|
91
|
+
const n = parseDecimal(val, 0);
|
|
92
|
+
if (n < minimumAmount) {
|
|
93
|
+
ctx.addIssue({
|
|
94
|
+
type: 'number',
|
|
95
|
+
code: z.ZodIssueCode.too_small,
|
|
96
|
+
inclusive: true,
|
|
97
|
+
minimum: minimumAmount,
|
|
98
|
+
message: `Minimum amount is ${minimumAmount.toLocaleString()}`,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (n > maximumAmount) {
|
|
102
|
+
ctx.addIssue({
|
|
103
|
+
type: 'number',
|
|
104
|
+
code: z.ZodIssueCode.too_big,
|
|
105
|
+
inclusive: true,
|
|
106
|
+
maximum: maximumAmount,
|
|
107
|
+
message: `Maximum amount is ${maximumAmount.toLocaleString()}`,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}),
|
|
111
|
+
promo: z.string().optional().nullable(),
|
|
112
|
+
})
|
|
113
|
+
.superRefine((value, ctx) => {
|
|
114
|
+
const promo = promos.find((o) => o.id === value.promo);
|
|
115
|
+
const promoMinAmount = parseDecimal(promo?.minimumDepositAmount, 0);
|
|
116
|
+
const promoMaxAmount = parseDecimal(promo?.maximumDepositAmount, 0);
|
|
117
|
+
const amount = parseDecimal(value.amount, 0);
|
|
118
|
+
if (promo && amount < promoMinAmount) {
|
|
119
|
+
ctx.addIssue({
|
|
120
|
+
path: ['amount'],
|
|
121
|
+
code: z.ZodIssueCode.custom,
|
|
122
|
+
message: `Minimum amount for this promo is ${promoMinAmount.toLocaleString()}`,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (promo && amount > promoMaxAmount) {
|
|
126
|
+
ctx.addIssue({
|
|
127
|
+
path: ['amount'],
|
|
128
|
+
code: z.ZodIssueCode.custom,
|
|
129
|
+
message: `Maximum amount for this promo is ${promoMaxAmount}`,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
const form = useForm({
|
|
134
|
+
mode: 'all',
|
|
135
|
+
resolver: zodResolver(definition),
|
|
136
|
+
defaultValues: {
|
|
137
|
+
amount: '0',
|
|
138
|
+
promo: globalStore.depositWithdrawal.promo ?? null,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (minimumAmount) {
|
|
143
|
+
form.reset({
|
|
144
|
+
amount: minimumAmount.toString(),
|
|
145
|
+
promo: form.getValues('promo') ?? null,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}, [form, minimumAmount]);
|
|
149
|
+
const depositId = ObjectId.generate(ObjectType.Deposit).toString();
|
|
150
|
+
const url = new URL(window.location.href);
|
|
151
|
+
const rootDomain = url.hostname;
|
|
152
|
+
return (_jsxs("form", { onSubmit: form.handleSubmit(async (data) => {
|
|
153
|
+
createDepositMutation.reset();
|
|
154
|
+
createDepositMutation.mutate({
|
|
155
|
+
id: depositId,
|
|
156
|
+
amount: data.amount.toString(),
|
|
157
|
+
promo: data.promo ?? undefined,
|
|
158
|
+
redirectionUrl: `${rootDomain}/pisopay/checkout/${depositId}`,
|
|
159
|
+
});
|
|
160
|
+
}), 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) => {
|
|
161
|
+
o.field.onChange(details.value);
|
|
162
|
+
}, formatOptions: {
|
|
163
|
+
maximumFractionDigits: 2,
|
|
164
|
+
minimumFractionDigits: 0,
|
|
165
|
+
}, 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) => {
|
|
166
|
+
form.setValue('amount', value.toString(), {
|
|
167
|
+
shouldTouch: true,
|
|
168
|
+
shouldDirty: true,
|
|
169
|
+
shouldValidate: true,
|
|
170
|
+
});
|
|
171
|
+
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: (value) => {
|
|
172
|
+
o.field.onChange(value);
|
|
173
|
+
globalStore.depositWithdrawal.setPromo(null);
|
|
174
|
+
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx(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) => {
|
|
175
|
+
disclosure.setOpen(details.open);
|
|
176
|
+
}, lazyMount: true, unmountOnExit: true, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "text-text-brand-primary-600 size-12" })), status === 'success' && (_jsx("div", { className: "bg-bg-success-secondary text-text-featured-icon-light-success flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "bg-bg-error-secondary text-text-featured-icon-light-error flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, {}) }))] }), _jsxs(AlertDialog.Body, { children: [_jsxs(AlertDialog.Title, { children: [status === 'processing' && 'Processing Deposit', status === 'success' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
|
|
177
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
178
|
+
'Your deposit has been successfully processed.', status === 'failed' &&
|
|
179
|
+
'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' || status === 'success') && (_jsx(AlertDialog.Footer, { children: _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => {
|
|
180
|
+
api.setOpen(false);
|
|
181
|
+
}, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
|
|
182
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const QRPHDepositContext: (props: {
|
|
2
2
|
value: {
|
|
3
|
-
view: "
|
|
3
|
+
view: "qrCode" | "form";
|
|
4
4
|
status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
|
|
5
5
|
verify: () => void;
|
|
6
6
|
reset: () => void;
|
|
@@ -13,7 +13,7 @@ export declare const QRPHDepositContext: (props: {
|
|
|
13
13
|
} & {
|
|
14
14
|
children?: import("react").ReactNode | undefined;
|
|
15
15
|
}) => React.ReactNode, useQRPHDepositContext: () => {
|
|
16
|
-
view: "
|
|
16
|
+
view: "qrCode" | "form";
|
|
17
17
|
status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
|
|
18
18
|
verify: () => void;
|
|
19
19
|
reset: () => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Deposit } from '../../../../types';
|
|
2
2
|
export type UseQRPHDepositReturn = ReturnType<typeof useQRPHDeposit>;
|
|
3
3
|
export declare function useQRPHDeposit(): {
|
|
4
|
-
view: "
|
|
4
|
+
view: "qrCode" | "form";
|
|
5
5
|
status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
|
|
6
6
|
verify: () => void;
|
|
7
7
|
reset: () => void;
|
|
@@ -9,6 +9,7 @@ import instapay from '../../images/instapay.png';
|
|
|
9
9
|
import libangan from '../../images/libangan.png';
|
|
10
10
|
import maya from '../../images/maya.png';
|
|
11
11
|
import onlineBank from '../../images/online-bank.png';
|
|
12
|
+
import pisoPay from '../../images/piso-pay.png';
|
|
12
13
|
import { Checkbox } from '../../ui/Checkbox/index.js';
|
|
13
14
|
import { Field } from '../../ui/Field/index.js';
|
|
14
15
|
import { PaymentMethodDefinition } from './utils.js';
|
|
@@ -48,6 +49,11 @@ const OPTIONS = [
|
|
|
48
49
|
label: 'Libangan',
|
|
49
50
|
image: libangan,
|
|
50
51
|
},
|
|
52
|
+
{
|
|
53
|
+
value: 'PISO_PAY',
|
|
54
|
+
label: 'Piso Pay',
|
|
55
|
+
image: pisoPay,
|
|
56
|
+
},
|
|
51
57
|
];
|
|
52
58
|
export function PaymentMethods(props) {
|
|
53
59
|
const options = props.options?.length
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PisoPayWithdrawal(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createListCollection } from '@ark-ui/react/collection';
|
|
3
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
6
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { useShallow } from 'zustand/shallow';
|
|
9
|
+
import { useCreatePisoPayWithdrawalMutation } from '../../../../client/hooks/useCreatePisoPayWithdrawalMutation.js';
|
|
10
|
+
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
11
|
+
import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
|
|
12
|
+
import { PISO_PAY_BANKS } from '../../../../constants/PisoPayBanks.js';
|
|
13
|
+
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
14
|
+
import { CheckIcon } from '../../../../icons/CheckIcon.js';
|
|
15
|
+
import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
|
|
16
|
+
import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
|
|
17
|
+
import { EyeIcon } from '../../../../icons/EyeIcon.js';
|
|
18
|
+
import { EyeOffIcon } from '../../../../icons/EyeOffIcon.js';
|
|
19
|
+
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
20
|
+
import { XIcon } from '../../../../icons/XIcon.js';
|
|
21
|
+
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
22
|
+
import { Button } from '../../../../ui/Button/index.js';
|
|
23
|
+
import { Field } from '../../../../ui/Field/index.js';
|
|
24
|
+
import { NumberInput } from '../../../../ui/NumberInput/index.js';
|
|
25
|
+
import { PasswordInput } from '../../../../ui/PasswordInput/index.js';
|
|
26
|
+
import { Portal } from '../../../../ui/Portal/index.js';
|
|
27
|
+
import { Select } from '../../../../ui/Select/index.js';
|
|
28
|
+
import { parseDecimal } from '../../../../utils/parseDecimal.js';
|
|
29
|
+
import { AmountChoices } from '../../AmountChoices.js';
|
|
30
|
+
import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
|
|
31
|
+
export function PisoPayWithdrawal() {
|
|
32
|
+
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
33
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
34
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
35
|
+
})));
|
|
36
|
+
const [status, setStatus] = useState('waiting');
|
|
37
|
+
const createWithdrawalMutation = useCreatePisoPayWithdrawalMutation({
|
|
38
|
+
onMutate() {
|
|
39
|
+
setStatus('processing');
|
|
40
|
+
},
|
|
41
|
+
onSuccess() {
|
|
42
|
+
form.reset();
|
|
43
|
+
setStatus('success');
|
|
44
|
+
},
|
|
45
|
+
onError() {
|
|
46
|
+
setStatus('failed');
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
50
|
+
const paymentSettings = paymentSettingsQuery.data;
|
|
51
|
+
const gatewaySettings = paymentSettings?.pisoPayWithdrawalGatewaySettings;
|
|
52
|
+
const minimumAmount = parseDecimal(gatewaySettings?.minimumAmount, 0);
|
|
53
|
+
const maximumAmount = parseDecimal(gatewaySettings?.maximumAmount, 0);
|
|
54
|
+
const definition = z.object({
|
|
55
|
+
amount: z.string().superRefine((val, ctx) => {
|
|
56
|
+
const n = parseDecimal(val, 0);
|
|
57
|
+
if (n < minimumAmount) {
|
|
58
|
+
ctx.addIssue({
|
|
59
|
+
type: 'number',
|
|
60
|
+
code: z.ZodIssueCode.too_small,
|
|
61
|
+
inclusive: true,
|
|
62
|
+
minimum: minimumAmount,
|
|
63
|
+
message: `Minimum amount is ${minimumAmount.toLocaleString()}`,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (n > maximumAmount) {
|
|
67
|
+
ctx.addIssue({
|
|
68
|
+
type: 'number',
|
|
69
|
+
code: z.ZodIssueCode.too_big,
|
|
70
|
+
inclusive: true,
|
|
71
|
+
maximum: maximumAmount,
|
|
72
|
+
message: `Maximum amount is ${maximumAmount.toLocaleString()}`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
password: z
|
|
77
|
+
.string()
|
|
78
|
+
.min(8, 'Password must be 8 or more characters')
|
|
79
|
+
.max(64, 'Password must be not be more than 64 characters'),
|
|
80
|
+
accountNumber: z.string().min(1).trim(),
|
|
81
|
+
bankCode: z.string().min(1, 'Bank is required').trim(),
|
|
82
|
+
});
|
|
83
|
+
const form = useForm({
|
|
84
|
+
mode: 'all',
|
|
85
|
+
resolver: zodResolver(definition),
|
|
86
|
+
defaultValues: {
|
|
87
|
+
amount: '0',
|
|
88
|
+
password: '',
|
|
89
|
+
accountNumber: '',
|
|
90
|
+
bankCode: '',
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (minimumAmount) {
|
|
95
|
+
form.reset({
|
|
96
|
+
amount: minimumAmount.toString(),
|
|
97
|
+
bankCode: form.getValues('bankCode'),
|
|
98
|
+
password: '',
|
|
99
|
+
accountNumber: '',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}, [form, minimumAmount]);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (PISO_PAY_BANKS?.length) {
|
|
105
|
+
form.reset({
|
|
106
|
+
amount: form.getValues('amount'),
|
|
107
|
+
bankCode: PISO_PAY_BANKS[0].code,
|
|
108
|
+
password: '',
|
|
109
|
+
accountNumber: '',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}, [form]);
|
|
113
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
114
|
+
createWithdrawalMutation.mutate({
|
|
115
|
+
amount: data.amount,
|
|
116
|
+
transactionPassword: data.password,
|
|
117
|
+
accountNumber: data.accountNumber,
|
|
118
|
+
bankCode: data.bankCode,
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
const bankCollection = useMemo(() => createListCollection({
|
|
122
|
+
items: PISO_PAY_BANKS ?? [],
|
|
123
|
+
itemToValue: (item) => item.code,
|
|
124
|
+
itemToString: (item) => item.name,
|
|
125
|
+
}), []);
|
|
126
|
+
return (_jsxs("form", { onSubmit: handleSubmit, noValidate: true, autoComplete: "off", children: [_jsx(Controller, { control: form.control, name: "bankCode", render: (o) => (_jsxs(Field.Root, { invalid: !!form.formState.errors.bankCode, children: [_jsxs(Select.Root, { collection: bankCollection, positioning: {
|
|
127
|
+
sameWidth: true,
|
|
128
|
+
}, value: o.field.value ? [o.field.value] : [], onValueChange: (details) => {
|
|
129
|
+
o.field.onChange(details.value.at(0) ?? '');
|
|
130
|
+
}, children: [_jsx(Select.Label, { children: "Bank" }), _jsx(Select.Control, { children: _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })] }) }), _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: _jsx(Select.ItemGroup, { children: bankCollection.items.map((item, index) => (_jsxs(Select.Item, { item: item, children: [_jsx(Select.ItemText, { children: item.name }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, index))) }) }) })] }), _jsx(Field.ErrorText, { children: form.formState.errors.bankCode?.message })] })) }), _jsxs(Field.Root, { invalid: !!form.formState.errors.accountNumber, className: "mt-3xl", children: [_jsx(Field.Label, { children: "Bank 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-3xl", children: [_jsxs(NumberInput.Root, { min: 0, step: 1, value: o.field.value, onValueChange: (details) => {
|
|
131
|
+
o.field.onChange(details.value);
|
|
132
|
+
}, formatOptions: {
|
|
133
|
+
maximumFractionDigits: 2,
|
|
134
|
+
minimumFractionDigits: 0,
|
|
135
|
+
}, allowMouseWheel: true, children: [_jsx(NumberInput.Label, { children: "Enter amount you want to withdraw" }), _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) => {
|
|
136
|
+
form.setValue('amount', value.toString(), {
|
|
137
|
+
shouldTouch: true,
|
|
138
|
+
shouldDirty: true,
|
|
139
|
+
shouldValidate: true,
|
|
140
|
+
});
|
|
141
|
+
}, min: minimumAmount, max: maximumAmount, className: "mt-xl" }), _jsxs(Field.Root, { className: "mt-3xl", invalid: !!form.formState.errors.password, children: [_jsxs(PasswordInput.Root, { children: [_jsx(PasswordInput.Label, { children: "Password" }), _jsxs(PasswordInput.Control, { children: [_jsx(PasswordInput.Input, { ...form.register('password') }), _jsx(PasswordInput.VisibilityTrigger, { children: _jsx(PasswordInput.Indicator, { fallback: _jsx(EyeOffIcon, {}), asChild: true, children: _jsx(EyeIcon, {}) }) })] })] }), _jsx(Field.ErrorText, { children: form.formState.errors.password?.message })] }), _jsxs("p", { className: "mt-4xl text-xs", children: ["Upon clicking the deposit button, you agree to the", ' ', _jsx(Link, { href: depositWithdrawalProps.termsOfUseUrl ?? '/terms-of-use', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "underline underline-offset-2", children: "Terms of Use" }), ' ', "and", ' ', _jsx(Link, { href: depositWithdrawalProps.termsOfUseUrl ?? '/privacy-policy', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "underline underline-offset-2", children: "Privacy Policy" }), "."] }), _jsx(Button, { type: "submit", className: "mt-4.5", disabled: createWithdrawalMutation.isPending, children: "Withdraw" }), _jsx(AlertDialog.Root, { open: status !== 'waiting', onOpenChange: (details) => {
|
|
142
|
+
if (!details.open) {
|
|
143
|
+
setStatus('waiting');
|
|
144
|
+
}
|
|
145
|
+
}, lazyMount: true, unmountOnExit: true, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.CloseTrigger, { disabled: status === 'processing', children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "text-text-brand-primary-600 size-12" })), status === 'success' && (_jsx("div", { className: "bg-bg-success-secondary text-text-featured-icon-light-success flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "bg-bg-error-secondary text-text-featured-icon-light-error flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, {}) }))] }), _jsxs(AlertDialog.Body, { children: [_jsxs(AlertDialog.Title, { children: [status === 'processing' && 'Processing Withdraw', status === 'success' && 'Withdrawal Submitted', status === 'failed' && 'Withdraw Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
|
|
146
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
147
|
+
'Your withdrawal request has been submitted successfully and is awaiting confirmation. You won’t have to wait long — once approved, the funds will be credited to your account.', status === 'failed' &&
|
|
148
|
+
'Something went wrong while processing your withdrawal. Please try again or contact support.'] })] }), (status === 'failed' || status === 'success') && (_jsx(AlertDialog.Footer, { children: _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => {
|
|
149
|
+
api.setOpen(false);
|
|
150
|
+
}, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
|
|
151
|
+
}
|