@opexa/portal-components 0.0.842 → 0.0.844
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/useAiOGCashDepositMutation.js +10 -0
- package/dist/client/hooks/useCreateGCashDepositMutation.js +10 -0
- package/dist/client/hooks/useCreateMayaDepositMutation.js +10 -0
- package/dist/client/hooks/useCreateOnlineBankDepositMutation.js +10 -0
- package/dist/client/hooks/useCreateQRPHDepositMutation.js +10 -0
- package/dist/components/DepositWithdrawal/Deposit/AiOGCashDeposit/AiOGCashDeposit.js +9 -4
- package/dist/components/DepositWithdrawal/Deposit/AiOPayMayaDeposit/AiOPayMayaDeposit.js +9 -4
- package/dist/components/DepositWithdrawal/Deposit/GCashDeposit/GCashDeposit.js +10 -5
- package/dist/components/DepositWithdrawal/Deposit/MayaAppDeposit/MayaAppDeposit.js +9 -4
- package/dist/components/DepositWithdrawal/Deposit/MayaDeposit/MayaDeposit.js +9 -4
- 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/Failed.js +1 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositContext.d.ts +8 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.d.ts +4 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.js +8 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__legacy/QRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__legacy/useQRPHDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Confirmed.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Confirmed.js +11 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Failed.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Failed.js +11 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Form.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Form.js +126 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/GeneratingQrCode.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/GeneratingQrCode.js +10 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDeposit.js +12 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDepositContext.d.ts +17 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDepositContext.js +2 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QrCodeGenerated.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QrCodeGenerated.js +41 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/useQRPHDeposit.d.ts +13 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/useQRPHDeposit.js +91 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/useOnlineBankDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/useQRPHDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/PaymentMethods.js +20 -10
- package/dist/components/DepositWithdrawal/Withdrawal/InstapayGCashWithdrawal/InstapayGcashWithdrawal.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Withdrawal/InstapayGCashWithdrawal/InstapayGcashWithdrawal.js +143 -0
- package/dist/components/DepositWithdrawal/Withdrawal/InstapayPaymayaWithdrawal/InstapayPaymayaWithdrawal.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Withdrawal/InstapayPaymayaWithdrawal/InstapayPaymayaWithdrawal.js +143 -0
- package/dist/components/DepositWithdrawal/Withdrawal/InstapayWithdrawal/InstapayWithdrawal.js +2 -1
- package/dist/components/DepositWithdrawal/Withdrawal/Withdrawal.js +13 -1
- package/dist/components/DepositWithdrawal/utils.d.ts +1 -1
- package/dist/components/DepositWithdrawal/utils.js +3 -0
- package/dist/components/DigitainLauncher/Loading.js +1 -1
- package/dist/components/Disclaimer/ResponsibleGaming.d.ts +10 -0
- package/dist/components/Disclaimer/ResponsibleGaming.js +13 -0
- package/dist/components/Disclaimer/TermsOfUse.d.ts +11 -0
- package/dist/components/Disclaimer/TermsOfUse.js +13 -0
- package/dist/components/FeatureFlag/FeatureFlag.d.ts +1 -0
- package/dist/components/FeatureFlag/FeatureFlag.js +29 -0
- package/dist/components/FeatureFlag/index.d.ts +1 -0
- package/dist/components/FeatureFlag/index.js +1 -0
- package/dist/components/Jackpots/Jackpots.module.css +221 -221
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +184 -184
- package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +184 -184
- package/dist/components/KYC/AutoOpen.d.ts +1 -0
- package/dist/components/KYC/AutoOpen.js +40 -0
- package/dist/components/KYC/BasicInformation.js +1 -1
- package/dist/components/KYC/CaptureIdDocument.d.ts +1 -0
- package/dist/components/KYC/CaptureIdDocument.js +219 -0
- package/dist/components/KYC/CaptureSelfie.d.ts +1 -0
- package/dist/components/KYC/CaptureSelfie.js +285 -0
- package/dist/components/KYC/DisplayImage.d.ts +5 -0
- package/dist/components/KYC/DisplayImage.js +8 -0
- package/dist/components/KYC/FileUpload.d.ts +10 -0
- package/dist/components/KYC/FileUpload.js +72 -0
- package/dist/components/KYC/IdentityVerification.js +1 -1
- package/dist/components/KYC/KYC.lazy.js +1 -1
- package/dist/components/KYC/KYCDefault/KYCVerificationStatus.lazy.js +2 -2
- package/dist/components/KYC/KYCVerificationStatus.lazy.js +8 -5
- package/dist/components/KYC/NoCameraError.d.ts +7 -0
- package/dist/components/KYC/NoCameraError.js +6 -0
- package/dist/components/KYC/PersonOverlayDesktop.d.ts +7 -0
- package/dist/components/KYC/PersonOverlayDesktop.js +9 -0
- package/dist/components/KYC/PersonalInformation.js +1 -1
- package/dist/components/KYC/backup/Header.d.ts +1 -0
- package/dist/components/KYC/backup/Header.js +8 -0
- package/dist/components/KYC/backup/Indicator.d.ts +1 -0
- package/dist/components/KYC/backup/Indicator.js +9 -0
- package/dist/components/KYC/backup/KYC.d.ts +1 -0
- package/dist/components/KYC/backup/KYC.js +14 -0
- package/dist/components/KYC/backup/KYC.lazy.d.ts +1 -0
- package/dist/components/KYC/backup/KYC.lazy.js +26 -0
- package/dist/components/KYC/backup/KYCContext.d.ts +6 -0
- package/dist/components/KYC/backup/KYCContext.js +2 -0
- package/dist/components/KYC/backup/Step1.d.ts +1 -0
- package/dist/components/KYC/backup/Step1.js +13 -0
- package/dist/components/KYC/backup/Step2.d.ts +1 -0
- package/dist/components/KYC/backup/Step2.js +13 -0
- package/dist/components/KYC/backup/Step3.d.ts +1 -0
- package/dist/components/KYC/backup/Step3.js +13 -0
- package/dist/components/KYC/backup/Step4.d.ts +1 -0
- package/dist/components/KYC/backup/Step4.js +7 -0
- package/dist/components/KYC/backup/useKYC.d.ts +10 -0
- package/dist/components/KYC/backup/useKYC.js +8 -0
- package/dist/components/KYC/loadModels.d.ts +1 -0
- package/dist/components/KYC/loadModels.js +9 -0
- package/dist/components/KYC/utils.d.ts +9 -0
- package/dist/components/KYC/utils.js +79 -0
- package/dist/components/Messages/Message.d.ts +1 -0
- package/dist/components/Messages/Message.js +35 -0
- package/dist/components/Messages/MessageContext.d.ts +6 -0
- package/dist/components/Messages/MessageContext.js +2 -0
- package/dist/components/Messages/MessagePopup.d.ts +1 -0
- package/dist/components/Messages/MessagePopup.js +20 -0
- package/dist/components/Messages/MessageTrigger.d.ts +8 -0
- package/dist/components/Messages/MessageTrigger.js +19 -0
- package/dist/components/PortalProvider/CXDTokenObserver.js +11 -11
- package/dist/components/Quests/CountdownTimer.d.ts +15 -0
- package/dist/components/Quests/CountdownTimer.js +33 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +4 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.js +78 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.d.ts +8 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.js +9 -0
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +4 -0
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.js +4 -0
- package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +4 -0
- package/dist/components/Quests/WageringQuest/WageringQuest.js +20 -0
- package/dist/components/Quests/WageringQuest/WageringQuestModal.d.ts +9 -0
- package/dist/components/Quests/WageringQuest/WageringQuestModal.js +9 -0
- package/dist/components/SignUp/SignUp.lazy.d.ts +12 -0
- package/dist/components/SignUp/SignUp.lazy.js +18 -0
- package/dist/components/SignUp/SignUpContext.d.ts +6 -0
- package/dist/components/SignUp/SignUpContext.js +2 -0
- package/dist/components/SignUp/SignUpDefault/SignUp.lazy.d.ts +17 -0
- package/dist/components/SignUp/SignUpDefault/SignUp.lazy.js +18 -0
- package/dist/components/SignUp/SignUpDefault/SignUpContext.d.ts +6 -0
- package/dist/components/SignUp/SignUpDefault/SignUpContext.js +2 -0
- package/dist/components/SignUp/SignUpDefault/SignUpForm.d.ts +1 -0
- package/dist/components/SignUp/SignUpDefault/SignUpForm.js +310 -0
- package/dist/components/SignUp/SignUpForm.d.ts +1 -0
- package/dist/components/SignUp/SignUpForm.js +284 -0
- package/dist/components/SignUp/SignUpKYC/CaptureIdDocument.d.ts +1 -0
- package/dist/components/SignUp/SignUpKYC/CaptureIdDocument.js +198 -0
- package/dist/components/SignUp/SignUpKYC/CaptureSelfie.d.ts +1 -0
- package/dist/components/SignUp/SignUpKYC/CaptureSelfie.js +251 -0
- package/dist/components/SignUp/SignUpKYC/ImageUploader.d.ts +10 -0
- package/dist/components/SignUp/SignUpKYC/ImageUploader.js +42 -0
- package/dist/components/SignUp/SignUpKYC/PersonOverlayDesktop.d.ts +7 -0
- package/dist/components/SignUp/SignUpKYC/PersonOverlayDesktop.js +9 -0
- package/dist/components/SignUp/SignUpKYC/SignUpFormKYC.d.ts +1 -0
- package/dist/components/SignUp/SignUpKYC/SignUpFormKYC.js +464 -0
- package/dist/components/SignUp/SignUpKYC/useImageUploader.d.ts +11 -0
- package/dist/components/SignUp/SignUpKYC/useImageUploader.js +20 -0
- package/dist/components/SignUp/SignUpKYC/utils.d.ts +9 -0
- package/dist/components/SignUp/SignUpKYC/utils.js +79 -0
- package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.d.ts +1 -0
- package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.js +198 -0
- package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.d.ts +1 -0
- package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.js +251 -0
- package/dist/components/SignUp/SignUpPagcor/ImageUploader.d.ts +10 -0
- package/dist/components/SignUp/SignUpPagcor/ImageUploader.js +41 -0
- package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.d.ts +1 -0
- package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.js +429 -0
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.d.ts +13 -0
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.js +26 -0
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.d.ts +7 -0
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.js +2 -0
- package/dist/components/SignUp/SignUpPagcor/useImageUploader.d.ts +11 -0
- package/dist/components/SignUp/SignUpPagcor/useImageUploader.js +20 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.module.css +184 -184
- package/dist/components/Tournaments/TournamentsList/TournamentItem.module.css +184 -184
- package/dist/components/shared/IdDocumentField.client.d.ts +25 -0
- package/dist/components/shared/IdDocumentField.client.js +204 -0
- package/dist/components/shared/IdDocumentField.d.ts +2 -0
- package/dist/components/shared/IdDocumentField.js +11 -0
- package/dist/components/shared/SelfieField.client.d.ts +20 -0
- package/dist/components/shared/SelfieField.client.js +327 -0
- package/dist/components/shared/SelfieField.d.ts +2 -0
- package/dist/components/shared/SelfieField.js +11 -0
- package/dist/constants/BranchCode.d.ts +4 -0
- package/dist/constants/BranchCode.js +42 -0
- package/dist/handlers/postTransformIdFrontImage.d.ts +3 -0
- package/dist/handlers/postTransformIdFrontImage.js +67 -0
- package/dist/handlers/postTransformSelfieImage.d.ts +3 -0
- package/dist/handlers/postTransformSelfieImage.js +71 -0
- package/dist/handlers.d.ts +43 -0
- package/dist/handlers.js +297 -0
- package/dist/icons/BellRingIcon.d.ts +2 -0
- package/dist/icons/BellRingIcon.js +4 -0
- package/dist/services/queries.js +3153 -3153
- package/dist/styles/theme.css +776 -776
- package/dist/ui/AlertDialog/AlertDialog.d.ts +55 -55
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +5 -5
- 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/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 +252 -252
- package/dist/ui/Menu/menu.recipe.d.ts +14 -14
- package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
- package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
- package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
- package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
- package/dist/ui/PinInput/PinInput.d.ts +12 -12
- package/dist/ui/PinInput/pinInput.recipe.d.ts +3 -3
- package/dist/ui/Popover/Popover.d.ts +55 -55
- package/dist/ui/Popover/popover.recipe.d.ts +5 -5
- 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 +25 -25
- package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
- package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
- package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
- 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/utils/dataUrlToBlob.d.ts +1 -0
- package/dist/utils/dataUrlToBlob.js +11 -0
- package/dist/utils/gamesAvailable3pmTo3am.d.ts +1 -0
- package/dist/utils/gamesAvailable3pmTo3am.js +1 -0
- package/dist/utils/getGameName.d.ts +1 -0
- package/dist/utils/getGameName.js +6 -0
- package/dist/utils/isBetween3amAnd3pm.d.ts +1 -0
- package/dist/utils/isBetween3amAnd3pm.js +5 -0
- package/dist/utils/resizeImageSize.d.ts +2 -0
- package/dist/utils/resizeImageSize.js +11 -0
- package/package.json +177 -177
- package/dist/components/Banner/Banner.client.d.ts +0 -12
- package/dist/components/Banner/Banner.client.js +0 -49
- package/dist/components/PortalProvider/AndroidOnlyComponents.d.ts +0 -1
- package/dist/components/PortalProvider/AndroidOnlyComponents.js +0 -12
|
@@ -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 { useQRPHDepositContext } from './QRPHDepositContext.js';
|
|
24
|
+
export function Form() {
|
|
25
|
+
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
26
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
27
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
28
|
+
})));
|
|
29
|
+
const context = useQRPHDepositContext();
|
|
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: `Minimum amount is ${minimumAmount.toLocaleString()}`,
|
|
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", 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, { 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 { useQRPHDepositContext } from './QRPHDepositContext.js';
|
|
7
|
+
export function GeneratingQrCode() {
|
|
8
|
+
const context = useQRPHDepositContext();
|
|
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 QRPHDeposit(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Confirmed } from './Confirmed.js';
|
|
3
|
+
import { Failed } from './Failed.js';
|
|
4
|
+
import { Form } from './Form.js';
|
|
5
|
+
import { GeneratingQrCode } from './GeneratingQrCode.js';
|
|
6
|
+
import { QRPHDepositContext } from './QRPHDepositContext.js';
|
|
7
|
+
import { QrCodeGenerated } from './QrCodeGenerated.js';
|
|
8
|
+
import { useQRPHDeposit } from './useQRPHDeposit.js';
|
|
9
|
+
export function QRPHDeposit() {
|
|
10
|
+
const context = useQRPHDeposit();
|
|
11
|
+
return (_jsxs(QRPHDepositContext, { value: context, children: [_jsx(Form, {}), _jsx(GeneratingQrCode, {}), _jsx(QrCodeGenerated, {}), _jsx(Failed, {}), _jsx(Confirmed, {})] }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const QRPHDepositContext: (props: {
|
|
2
|
+
value: {
|
|
3
|
+
status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
|
|
4
|
+
deposit: import("../../../../types").Deposit | null;
|
|
5
|
+
generateQRCode: (input: import("./useQRPHDeposit").GenerateQRCodeInput) => Promise<void>;
|
|
6
|
+
regenerateQRCode: () => Promise<void>;
|
|
7
|
+
reset: () => void;
|
|
8
|
+
};
|
|
9
|
+
} & {
|
|
10
|
+
children?: import("react").ReactNode | undefined;
|
|
11
|
+
}) => React.ReactNode, useQRPHDepositContext: () => {
|
|
12
|
+
status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
|
|
13
|
+
deposit: import("../../../../types").Deposit | null;
|
|
14
|
+
generateQRCode: (input: import("./useQRPHDeposit").GenerateQRCodeInput) => Promise<void>;
|
|
15
|
+
regenerateQRCode: () => Promise<void>;
|
|
16
|
+
reset: () => void;
|
|
17
|
+
};
|
|
@@ -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 { useQRPHDepositContext } from './QRPHDepositContext.js';
|
|
14
|
+
export function QrCodeGenerated() {
|
|
15
|
+
const context = useQRPHDepositContext();
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Deposit } from '../../../../types';
|
|
2
|
+
export type UseQRPHDepositReturn = ReturnType<typeof useQRPHDeposit>;
|
|
3
|
+
export interface GenerateQRCodeInput {
|
|
4
|
+
amount: string;
|
|
5
|
+
promo?: string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function useQRPHDeposit(): {
|
|
8
|
+
status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
|
|
9
|
+
deposit: Deposit | null;
|
|
10
|
+
generateQRCode: (input: GenerateQRCodeInput) => Promise<void>;
|
|
11
|
+
regenerateQRCode: () => Promise<void>;
|
|
12
|
+
reset: () => void;
|
|
13
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import invariant from 'tiny-invariant';
|
|
3
|
+
import { useShallow } from 'zustand/shallow';
|
|
4
|
+
import { useCreateQRPHDepositMutation } from '../../../../client/hooks/useCreateQRPHDepositMutation.js';
|
|
5
|
+
import { useDepositQuery } from '../../../../client/hooks/useDepositQuery.js';
|
|
6
|
+
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
7
|
+
import { useMemberVerificationQuery } from '../../../../client/hooks/useMemberVerificationQuery.js';
|
|
8
|
+
export function useQRPHDeposit() {
|
|
9
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
10
|
+
kycVerificationStatus: ctx.kycVerificationStatus,
|
|
11
|
+
})));
|
|
12
|
+
const inputRef = useRef(null);
|
|
13
|
+
const [deposit, setDeposit] = useState(null);
|
|
14
|
+
const [status, setStatus] = useState('idle');
|
|
15
|
+
const verificationQuery = useMemberVerificationQuery();
|
|
16
|
+
const verificationStatus = verificationQuery.data?.status ?? 'UNVERIFIED';
|
|
17
|
+
const mutation = useCreateQRPHDepositMutation({
|
|
18
|
+
onMutate() {
|
|
19
|
+
setStatus('generating-qr-code');
|
|
20
|
+
},
|
|
21
|
+
onSuccess(data) {
|
|
22
|
+
invariant(data.qrCode);
|
|
23
|
+
setStatus('qr-code-generated');
|
|
24
|
+
setDeposit(data);
|
|
25
|
+
},
|
|
26
|
+
onError() {
|
|
27
|
+
setStatus('failed');
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const query = useDepositQuery(deposit?.id, {
|
|
31
|
+
enabled: !!deposit && status === 'qr-code-generated',
|
|
32
|
+
refetchInterval: (ctx) => {
|
|
33
|
+
if (ctx.state.data?.status === 'APPROVED' ||
|
|
34
|
+
ctx.state.data?.status === 'CONFIRMED' ||
|
|
35
|
+
ctx.state.data?.status === 'CANCELLED' ||
|
|
36
|
+
ctx.state.data?.status === 'REJECTED' ||
|
|
37
|
+
ctx.state.data?.status === 'FAILED') {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return 2000;
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (query.data?.status === 'APPROVED' ||
|
|
45
|
+
query.data?.status === 'CONFIRMED') {
|
|
46
|
+
setStatus('confirmed');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (query.data?.status === 'CANCELLED' ||
|
|
50
|
+
query.data?.status === 'REJECTED' ||
|
|
51
|
+
query.data?.status === 'FAILED') {
|
|
52
|
+
setStatus('failed');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}, [query.data?.status]);
|
|
56
|
+
const generateQRCode = async (input) => {
|
|
57
|
+
if (verificationStatus === 'PENDING' ||
|
|
58
|
+
verificationStatus === 'UNVERIFIED' ||
|
|
59
|
+
verificationStatus === 'REJECTED' ||
|
|
60
|
+
verificationStatus === 'CREATED') {
|
|
61
|
+
globalStore.kycVerificationStatus.setOpen(true);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
inputRef.current = input;
|
|
65
|
+
mutation.mutate({
|
|
66
|
+
amount: input.amount,
|
|
67
|
+
promo: input.promo ?? undefined,
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const regenerateQRCode = async () => {
|
|
71
|
+
invariant(inputRef.current);
|
|
72
|
+
mutation.reset();
|
|
73
|
+
await new Promise((resolve) => setTimeout(resolve, 1));
|
|
74
|
+
mutation.mutate({
|
|
75
|
+
amount: inputRef.current.amount,
|
|
76
|
+
promo: inputRef.current.promo ?? undefined,
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const reset = () => {
|
|
80
|
+
setStatus('idle');
|
|
81
|
+
setDeposit(null);
|
|
82
|
+
inputRef.current = null;
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
status,
|
|
86
|
+
deposit,
|
|
87
|
+
generateQRCode,
|
|
88
|
+
regenerateQRCode,
|
|
89
|
+
reset,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -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;
|
|
@@ -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;
|
package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositContext.d.ts
CHANGED
|
@@ -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;
|
|
@@ -31,6 +31,16 @@ const OPTIONS = [
|
|
|
31
31
|
label: 'Maya',
|
|
32
32
|
image: maya,
|
|
33
33
|
},
|
|
34
|
+
{
|
|
35
|
+
value: 'AIO_GCASH',
|
|
36
|
+
label: 'GCash',
|
|
37
|
+
image: gcash,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
value: 'AIO_PAY_MAYA',
|
|
41
|
+
label: 'Maya',
|
|
42
|
+
image: maya,
|
|
43
|
+
},
|
|
34
44
|
{
|
|
35
45
|
value: 'QRPH',
|
|
36
46
|
label: 'QRPH',
|
|
@@ -41,6 +51,16 @@ const OPTIONS = [
|
|
|
41
51
|
label: 'Online Bank',
|
|
42
52
|
image: onlineBank,
|
|
43
53
|
},
|
|
54
|
+
{
|
|
55
|
+
value: 'INSTAPAY_GCASH',
|
|
56
|
+
label: 'Instapay GCash',
|
|
57
|
+
image: gcash,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
value: 'INSTAPAY_PAYMAYA',
|
|
61
|
+
label: 'Instapay PayMaya',
|
|
62
|
+
image: maya,
|
|
63
|
+
},
|
|
44
64
|
{
|
|
45
65
|
value: 'INSTAPAY',
|
|
46
66
|
label: 'Instapay',
|
|
@@ -61,16 +81,6 @@ const OPTIONS = [
|
|
|
61
81
|
label: 'Piso Pay',
|
|
62
82
|
image: pisoPay,
|
|
63
83
|
},
|
|
64
|
-
{
|
|
65
|
-
value: 'AIO_GCASH',
|
|
66
|
-
label: 'GCash',
|
|
67
|
-
image: gcash,
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
value: 'AIO_PAY_MAYA',
|
|
71
|
-
label: 'Maya',
|
|
72
|
-
image: maya,
|
|
73
|
-
},
|
|
74
84
|
{
|
|
75
85
|
value: 'AIO_GRAB_PAY',
|
|
76
86
|
label: 'GrabPay',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function InstapayGCashWithdrawal(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,143 @@
|
|
|
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, useState } from 'react';
|
|
5
|
+
import { useForm } from 'react-hook-form';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { useShallow } from 'zustand/shallow';
|
|
8
|
+
import { useAccountQuery } from '../../../../client/hooks/useAccountQuery.js';
|
|
9
|
+
import { useCreateInstapayWithdrawalMutation } from '../../../../client/hooks/useCreateInstapayWithdrawalMutation.js';
|
|
10
|
+
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
11
|
+
import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
|
|
12
|
+
import { useWalletQuery } from '../../../../client/hooks/useWalletQuery.js';
|
|
13
|
+
import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
|
|
14
|
+
import { EyeIcon } from '../../../../icons/EyeIcon.js';
|
|
15
|
+
import { EyeOffIcon } from '../../../../icons/EyeOffIcon.js';
|
|
16
|
+
import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
|
|
17
|
+
import { XIcon } from '../../../../icons/XIcon.js';
|
|
18
|
+
import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
|
|
19
|
+
import { Button } from '../../../../ui/Button/index.js';
|
|
20
|
+
import { Field } from '../../../../ui/Field/index.js';
|
|
21
|
+
import { PasswordInput } from '../../../../ui/PasswordInput/index.js';
|
|
22
|
+
import { Portal } from '../../../../ui/Portal/index.js';
|
|
23
|
+
import { parseDecimal } from '../../../../utils/parseDecimal.js';
|
|
24
|
+
import { AmountChoices } from '../../AmountChoices.js';
|
|
25
|
+
import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
|
|
26
|
+
import { explainError } from '../../utils.js';
|
|
27
|
+
import { ActiveTurnoverRequirement } from '../ActiveTurnoverRequirement.js';
|
|
28
|
+
import { RequireFirstDeposit } from '../RequireFirstDeposit.js';
|
|
29
|
+
import { TransactionPasswordNotSet } from '../TransactionPasswordNotSet.js';
|
|
30
|
+
export function InstapayGCashWithdrawal() {
|
|
31
|
+
const depositWithdrawalProps = useDepositWithdrawalPropsContext();
|
|
32
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
33
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
34
|
+
hasPendingBonus: ctx.pendingBonus,
|
|
35
|
+
})));
|
|
36
|
+
const [status, setStatus] = useState('waiting');
|
|
37
|
+
const createWithdrawalMutation = useCreateInstapayWithdrawalMutation({
|
|
38
|
+
onMutate() {
|
|
39
|
+
setStatus('processing');
|
|
40
|
+
},
|
|
41
|
+
onSuccess() {
|
|
42
|
+
form.reset();
|
|
43
|
+
setStatus('success');
|
|
44
|
+
},
|
|
45
|
+
onError() {
|
|
46
|
+
setStatus('failed');
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
const accountQuery = useAccountQuery();
|
|
50
|
+
const walletQuery = useWalletQuery();
|
|
51
|
+
const turnoverRequirement = parseDecimal(walletQuery.data?.turnoverRequirement, 0);
|
|
52
|
+
const paymentSettingsQuery = usePaymentSettingsQuery();
|
|
53
|
+
const paymentSettings = paymentSettingsQuery.data;
|
|
54
|
+
const gatewaySettings = paymentSettings?.instapayWithdrawalGatewaySettings;
|
|
55
|
+
const minimumAmount = parseDecimal(gatewaySettings?.minimumAmount, 0);
|
|
56
|
+
const maximumAmount = parseDecimal(gatewaySettings?.maximumAmount, 0);
|
|
57
|
+
const definition = z.object({
|
|
58
|
+
amount: z.string().superRefine((val, ctx) => {
|
|
59
|
+
const n = parseDecimal(val, 0);
|
|
60
|
+
if (val.includes('.')) {
|
|
61
|
+
ctx.addIssue({
|
|
62
|
+
code: z.ZodIssueCode.custom,
|
|
63
|
+
message: 'Amount must be a whole number',
|
|
64
|
+
});
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (n < minimumAmount) {
|
|
68
|
+
ctx.addIssue({
|
|
69
|
+
type: 'number',
|
|
70
|
+
code: z.ZodIssueCode.too_small,
|
|
71
|
+
inclusive: true,
|
|
72
|
+
minimum: minimumAmount,
|
|
73
|
+
message: `Please enter ${minimumAmount.toLocaleString()} or more to proceed with your deposit.`,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (n > maximumAmount) {
|
|
77
|
+
ctx.addIssue({
|
|
78
|
+
type: 'number',
|
|
79
|
+
code: z.ZodIssueCode.too_big,
|
|
80
|
+
inclusive: true,
|
|
81
|
+
maximum: maximumAmount,
|
|
82
|
+
message: `Maximum amount is ${maximumAmount.toLocaleString()}`,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}),
|
|
86
|
+
password: z
|
|
87
|
+
.string()
|
|
88
|
+
.min(8, 'Password must be 8 or more characters')
|
|
89
|
+
.max(64, 'Password must be not be more than 64 characters'),
|
|
90
|
+
accountNumber: z.string().min(1).trim(),
|
|
91
|
+
accountName: z
|
|
92
|
+
.string({ required_error: 'Account name is required' })
|
|
93
|
+
.min(4, 'Account name must be at least 4 characters'),
|
|
94
|
+
});
|
|
95
|
+
const form = useForm({
|
|
96
|
+
mode: 'all',
|
|
97
|
+
resolver: zodResolver(definition),
|
|
98
|
+
defaultValues: {
|
|
99
|
+
amount: '0',
|
|
100
|
+
password: '',
|
|
101
|
+
accountNumber: '',
|
|
102
|
+
accountName: accountQuery.data?.realName ?? '',
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (minimumAmount) {
|
|
107
|
+
form.reset({
|
|
108
|
+
amount: minimumAmount.toString(),
|
|
109
|
+
password: '',
|
|
110
|
+
accountNumber: '',
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}, [form, minimumAmount]);
|
|
114
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
115
|
+
if (globalStore.hasPendingBonus.shouldShowWarning) {
|
|
116
|
+
globalStore.hasPendingBonus.setOpen(true);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
createWithdrawalMutation.mutate({
|
|
120
|
+
amount: data.amount,
|
|
121
|
+
transactionPassword: data.password,
|
|
122
|
+
accountNumber: data.accountNumber,
|
|
123
|
+
accountName: data.accountName,
|
|
124
|
+
bankCode: "BNKGCH",
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
return (_jsxs("form", { onSubmit: handleSubmit, noValidate: true, autoComplete: "off", id: "hook-form", children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.accountNumber, children: [_jsx(Field.Label, { children: "Phone Number" }), _jsx(Field.Input, { ...form.register('accountNumber') }), _jsx(Field.ErrorText, { children: form.formState.errors.accountNumber?.message })] }), _jsxs(Field.Root, { invalid: !!form.formState.errors.accountName, className: "mt-3xl", children: [_jsx(Field.Label, { children: "Account name" }), _jsx(Field.Input, { ...form.register('accountName') }), _jsx(Field.ErrorText, { children: form.formState.errors.accountName?.message })] }), _jsxs(Field.Root, { invalid: !!form.formState.errors.amount, className: "mt-3xl", children: [_jsx(Field.Label, { children: "Enter amount you want to withdraw" }), _jsx(Field.Input, { type: "number", ...form.register('amount') }), _jsx(Field.ErrorText, { children: form.formState.errors.amount?.message })] }), _jsx(AmountChoices, { value: parseDecimal(form.watch('amount').trim().replace(/,/g, ''), 0), onChange: (value) => {
|
|
128
|
+
form.setValue('amount', value.toString(), {
|
|
129
|
+
shouldTouch: true,
|
|
130
|
+
shouldDirty: true,
|
|
131
|
+
shouldValidate: true,
|
|
132
|
+
});
|
|
133
|
+
}, 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: "Transaction Password" }), _jsxs(PasswordInput.Control, { children: [_jsx(PasswordInput.Input, { placeholder: "Enter password", ...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 })] }), _jsx(TransactionPasswordNotSet, {}), _jsx(ActiveTurnoverRequirement, {}), _jsx(RequireFirstDeposit, {}), _jsx(Button, { type: "submit", className: "mt-6", disabled: createWithdrawalMutation.isPending || turnoverRequirement > 0, children: "Withdraw" }), depositWithdrawalProps.hasPrivacyPolicyAndTermsOfUse && (_jsxs("p", { className: "mt-lg text-text-tertiary-600 text-xs", children: ["Upon withdrawing, 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: status !== 'waiting', onOpenChange: (details) => {
|
|
134
|
+
if (!details.open) {
|
|
135
|
+
setStatus('waiting');
|
|
136
|
+
}
|
|
137
|
+
}, lazyMount: true, unmountOnExit: 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: status === 'processing', children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && (_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 Withdraw', status === 'success' && 'Withdrawal Submitted', status === 'failed' && 'Withdraw Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
|
|
138
|
+
"We're verifying your account and amount. Please hold a moment.", status === 'success' &&
|
|
139
|
+
'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' &&
|
|
140
|
+
explainError(createWithdrawalMutation.error?.name)] })] }), (status === 'failed' || status === 'success') && (_jsx(AlertDialog.Footer, { children: _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => {
|
|
141
|
+
api.setOpen(false);
|
|
142
|
+
}, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
|
|
143
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function InstapayPaymayaWithdrawal(): import("react/jsx-runtime").JSX.Element;
|