@opexa/portal-components 0.0.303 → 0.0.305
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/useGlobalStore.d.ts +8 -0
- package/dist/client/hooks/useGlobalStore.js +21 -0
- package/dist/components/DepositWithdrawal/DepositWithdrawal.lazy.js +26 -13
- package/dist/components/DepositWithdrawal/HasPendingBonuses.d.ts +5 -0
- package/dist/components/DepositWithdrawal/HasPendingBonuses.js +22 -0
- package/dist/components/DepositWithdrawal/Withdrawal/GCashWithdrawal/GCashWithdrawal.js +5 -0
- package/dist/components/DepositWithdrawal/Withdrawal/InstapayWithdrawal/InstapayWithdrawal.js +18 -41
- package/dist/components/DepositWithdrawal/Withdrawal/MayaAppWithdrawal/MayaAppWithdrawal.js +5 -0
- package/dist/components/DepositWithdrawal/Withdrawal/MayaWithdrawal/MayaWithdrawal.js +5 -0
- package/dist/components/DepositWithdrawal/Withdrawal/PisoPayWithdrawal/PisoPayWithdrawal.js +5 -0
- package/dist/components/DepositWithdrawal/Withdrawal/VentajaWithdrawal/VentajaWithdrawal.js +5 -0
- 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/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/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/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/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/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/SignUpDefault.lazy.d.ts +1 -2
- package/dist/components/SignUp/SignUpDefault/SignUpDefault.lazy.js +1 -1
- package/dist/components/SignUp/SignUpDefault/SignUpDefaultForm.js +6 -4
- 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/SignUpKYC.lazy.d.ts +1 -1
- package/dist/components/SignUp/SignUpKYC/SignUpKYCForm.js +7 -5
- 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/constants/index.d.ts +0 -1
- package/dist/constants/index.js +0 -1
- 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/next.config.js +11 -36
- package/dist/services/queries.js +2639 -2639
- package/dist/styles/theme.css +706 -706
- package/dist/third-parties/FacebookPixel/FacebookPixel.d.ts +4 -0
- package/dist/third-parties/FacebookPixel/FacebookPixel.js +4 -0
- package/dist/third-parties/FacebookPixel/api.d.ts +0 -0
- package/dist/third-parties/FacebookPixel/api.js +1 -0
- package/dist/third-parties/FacebookPixel/index.d.ts +1 -0
- package/dist/third-parties/FacebookPixel/index.js +1 -0
- package/dist/third-parties/GoogleRecaptcha/GoogleRecaptcha.d.ts +4 -0
- package/dist/third-parties/GoogleRecaptcha/GoogleRecaptcha.js +4 -0
- package/dist/third-parties/GoogleRecaptcha/api.d.ts +0 -0
- package/dist/third-parties/GoogleRecaptcha/api.js +1 -0
- package/dist/third-parties/GoogleRecaptcha/index.d.ts +1 -0
- package/dist/third-parties/GoogleRecaptcha/index.js +1 -0
- package/dist/third-parties/index.d.ts +2 -0
- package/dist/third-parties/index.js +2 -0
- package/dist/ui/AlertDialog/AlertDialog.d.ts +121 -121
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +11 -11
- package/dist/ui/Avatar/Avatar.d.ts +9 -9
- package/dist/ui/Avatar/avatar.recipe.d.ts +3 -3
- 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 +99 -99
- package/dist/ui/Carousel/carousel.recipe.d.ts +11 -11
- package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
- package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
- package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
- package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
- package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
- package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
- package/dist/ui/Combobox/Combobox.d.ts +42 -42
- package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
- package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
- package/dist/ui/Dialog/Dialog.d.ts +121 -121
- package/dist/ui/Dialog/dialog.recipe.d.ts +11 -11
- 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/PasswordInput/PasswordInput.d.ts +18 -18
- package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
- package/dist/ui/Popover/Popover.d.ts +187 -187
- package/dist/ui/Popover/popover.recipe.d.ts +17 -17
- 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/ui/Tabs/Tabs.d.ts +15 -15
- package/dist/ui/Tabs/tabs.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 +164 -164
- package/dist/client/utils/recaptcha.d.ts +0 -14
- package/dist/client/utils/recaptcha.js +0 -18
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { createListCollection, parseDate } from '@ark-ui/react';
|
|
4
|
+
import { useDialogContext } from '@ark-ui/react/dialog';
|
|
5
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
6
|
+
import { ObjectId } from '@opexa/object-id';
|
|
7
|
+
import { differenceInYears, format } from 'date-fns';
|
|
8
|
+
import Image from 'next/image';
|
|
9
|
+
import { useSearchParams } from 'next/navigation';
|
|
10
|
+
import { useEffect, useRef, useState } from 'react';
|
|
11
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
12
|
+
import { twMerge } from 'tailwind-merge';
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { useShallow } from 'zustand/shallow';
|
|
15
|
+
import { useControllableState } from '../../../client/hooks/useControllableState.js';
|
|
16
|
+
import { useCooldown } from '../../../client/hooks/useCooldown.js';
|
|
17
|
+
import { useCreateMemberVerificationMutation } from '../../../client/hooks/useCreateMemberVerificationMutation.js';
|
|
18
|
+
import { useGlobalStore } from '../../../client/hooks/useGlobalStore.js';
|
|
19
|
+
import { useLocaleInfo } from '../../../client/hooks/useLocaleInfo.js';
|
|
20
|
+
import { useMemberVerificationQuery } from '../../../client/hooks/useMemberVerificationQuery.js';
|
|
21
|
+
import { useMobileNumberParser } from '../../../client/hooks/useMobileNumberParser.js';
|
|
22
|
+
import { useSendVerificationCodeMutation } from '../../../client/hooks/useSendVerificationCodeMutation.js';
|
|
23
|
+
import { useSignInMutation } from '../../../client/hooks/useSignInMutation.js';
|
|
24
|
+
import { useSignUpMutation } from '../../../client/hooks/useSignUpMutation.js';
|
|
25
|
+
import { useUpdateAccountMutation } from '../../../client/hooks/useUpdateAccountMutation.js';
|
|
26
|
+
import { useUpdateMemberVerificationMutation } from '../../../client/hooks/useUpdateMemberVerificationMutation.js';
|
|
27
|
+
import { useUploadImageFileMutation } from '../../../client/hooks/useUploadImageFileMutation.js';
|
|
28
|
+
import { toaster } from '../../../client/utils/toaster.js';
|
|
29
|
+
import { BRANCHES } from '../../../constants/index.js';
|
|
30
|
+
import { ArrowLeftIcon } from '../../../icons/ArrowLeftIcon.js';
|
|
31
|
+
import { CalendarIcon } from '../../../icons/CalendarIcon.js';
|
|
32
|
+
import { CheckIcon } from '../../../icons/CheckIcon.js';
|
|
33
|
+
import { ChevronDownIcon } from '../../../icons/ChevronDownIcon.js';
|
|
34
|
+
import { ChevronLeftIcon } from '../../../icons/ChevronLeftIcon.js';
|
|
35
|
+
import { ChevronRightIcon } from '../../../icons/ChevronRightIcon.js';
|
|
36
|
+
import { EyeIcon } from '../../../icons/EyeIcon.js';
|
|
37
|
+
import { EyeOffIcon } from '../../../icons/EyeOffIcon.js';
|
|
38
|
+
import pagcorLogo from '../../../images/pagcor.png';
|
|
39
|
+
import responsibleGamingLogo from '../../../images/responsible-gaming-yellow.png';
|
|
40
|
+
import { ObjectType } from '../../../services/ObjectType.js';
|
|
41
|
+
import { Button } from '../../../ui/Button/index.js';
|
|
42
|
+
import { Checkbox } from '../../../ui/Checkbox/index.js';
|
|
43
|
+
import { DatePicker } from '../../../ui/DatePicker/index.js';
|
|
44
|
+
import { Field } from '../../../ui/Field/index.js';
|
|
45
|
+
import { PasswordInput } from '../../../ui/PasswordInput/index.js';
|
|
46
|
+
import { PinInput } from '../../../ui/PinInput/index.js';
|
|
47
|
+
import { Select } from '../../../ui/Select/index.js';
|
|
48
|
+
import { createPoll } from '../../../utils/createPoll.js';
|
|
49
|
+
import { getQueryClient } from '../../../utils/getQueryClient.js';
|
|
50
|
+
import { getMemberVerificationQueryKey } from '../../../utils/queryKeys.js';
|
|
51
|
+
import { ResponsibleGaming } from '../../Disclaimer/ResponsibleGaming.js';
|
|
52
|
+
import { TermsOfUse } from '../../Disclaimer/TermsOfUse.js';
|
|
53
|
+
import ImageUploader from './ImageUploader.js';
|
|
54
|
+
import { useSignUpKYCPropsContext } from './SignUpKYCContext.js';
|
|
55
|
+
export function SignUpFormKYC() {
|
|
56
|
+
const props = useSignUpKYCPropsContext();
|
|
57
|
+
const branchCollection = createListCollection({
|
|
58
|
+
items: props.branches ?? BRANCHES,
|
|
59
|
+
itemToValue: (item) => item.code,
|
|
60
|
+
itemToString: (item) => `${item.code} - ${item.name}`,
|
|
61
|
+
});
|
|
62
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
63
|
+
kycReminder: ctx.kycReminder,
|
|
64
|
+
})));
|
|
65
|
+
const [step, setStep] = useState(1);
|
|
66
|
+
const dialog = useDialogContext();
|
|
67
|
+
const search = useSearchParams();
|
|
68
|
+
const signInStore = useGlobalStore(useShallow((ctx) => ctx.signIn));
|
|
69
|
+
const signUpMutation = useSignUpMutation();
|
|
70
|
+
const signInMutation = useSignInMutation();
|
|
71
|
+
const updateAccountMutation = useUpdateAccountMutation();
|
|
72
|
+
const sendVerificationCodeMutation = useSendVerificationCodeMutation();
|
|
73
|
+
const localeInfo = useLocaleInfo();
|
|
74
|
+
const mobileNumberParser = useMobileNumberParser();
|
|
75
|
+
const fileSchema = z
|
|
76
|
+
.instanceof(File)
|
|
77
|
+
.refine((file) => file.size > 0, {
|
|
78
|
+
message: 'File is required.',
|
|
79
|
+
})
|
|
80
|
+
.refine((file) => file.type.startsWith('image/'), {
|
|
81
|
+
message: 'File must be an image.',
|
|
82
|
+
});
|
|
83
|
+
const Step1Definition = z.object({
|
|
84
|
+
name: z
|
|
85
|
+
.string()
|
|
86
|
+
.min(8, 'Username must be 8 or more characters')
|
|
87
|
+
.max(30, 'Username must not be more than 30 characters')
|
|
88
|
+
.trim(),
|
|
89
|
+
password: z
|
|
90
|
+
.string()
|
|
91
|
+
.min(8, 'Password must be 8 or more characters')
|
|
92
|
+
.max(30, 'Password must not be more than 30 characters')
|
|
93
|
+
.trim(),
|
|
94
|
+
mobileNumber: z
|
|
95
|
+
.string()
|
|
96
|
+
.min(1, 'Mobile number is required')
|
|
97
|
+
.superRefine((v, ctx) => {
|
|
98
|
+
if (!mobileNumberParser.validate(v)) {
|
|
99
|
+
ctx.addIssue({
|
|
100
|
+
code: z.ZodIssueCode.custom,
|
|
101
|
+
message: 'Invalid mobile number',
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}),
|
|
105
|
+
firstName: z
|
|
106
|
+
.string()
|
|
107
|
+
.min(2, 'First name must be 2 or more characters')
|
|
108
|
+
.max(20, 'First name must not be more than 50 characters')
|
|
109
|
+
.regex(/\S/, 'First name cannot be empty or contain only spaces')
|
|
110
|
+
.trim(),
|
|
111
|
+
middleName: z
|
|
112
|
+
.string()
|
|
113
|
+
.min(2, 'Middle name must be 2 or more characters')
|
|
114
|
+
.max(20, 'Middle name must not be more than 50 characters')
|
|
115
|
+
.regex(/\S/, 'Middle name cannot be empty or contain only spaces')
|
|
116
|
+
.trim(),
|
|
117
|
+
lastName: z
|
|
118
|
+
.string()
|
|
119
|
+
.min(2, 'Last name must be 2 or more characters')
|
|
120
|
+
.max(20, 'Last name must not be more than 50 characters')
|
|
121
|
+
.regex(/\S/, 'Last name cannot be empty or contain only spaces')
|
|
122
|
+
.trim(),
|
|
123
|
+
birthDay: z
|
|
124
|
+
.date({
|
|
125
|
+
invalid_type_error: 'Date of birth is required',
|
|
126
|
+
required_error: 'Date of birth is required',
|
|
127
|
+
})
|
|
128
|
+
.superRefine((val, ctx) => {
|
|
129
|
+
const now = new Date();
|
|
130
|
+
const age = differenceInYears(now, val);
|
|
131
|
+
if (age < 21) {
|
|
132
|
+
return ctx.addIssue({
|
|
133
|
+
code: z.ZodIssueCode.custom,
|
|
134
|
+
message: 'You must be at least 21 years old',
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
branchCode: z.string().min(1, 'Branch is required').trim(),
|
|
139
|
+
selfieImage: fileSchema,
|
|
140
|
+
frontImage: fileSchema,
|
|
141
|
+
termsAccepted: z.boolean().superRefine((v, ctx) => {
|
|
142
|
+
if (!v) {
|
|
143
|
+
ctx.addIssue({
|
|
144
|
+
code: z.ZodIssueCode.custom,
|
|
145
|
+
message: 'You must accept the terms and conditions and the responsible gaming guidelines',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}),
|
|
149
|
+
});
|
|
150
|
+
const Step2Definition = z.object({
|
|
151
|
+
verificationCode: z.array(z.string()).superRefine((val, ctx) => {
|
|
152
|
+
if (val.length !== 6 || val.some((v) => v.length !== 1)) {
|
|
153
|
+
ctx.addIssue({
|
|
154
|
+
code: z.ZodIssueCode.custom,
|
|
155
|
+
message: 'Please Enter your 6 digits verification code',
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}),
|
|
159
|
+
});
|
|
160
|
+
const step1Form = useForm({
|
|
161
|
+
mode: 'all',
|
|
162
|
+
resolver: zodResolver(Step1Definition),
|
|
163
|
+
defaultValues: {
|
|
164
|
+
name: '',
|
|
165
|
+
password: '',
|
|
166
|
+
mobileNumber: '',
|
|
167
|
+
firstName: '',
|
|
168
|
+
middleName: '',
|
|
169
|
+
lastName: '',
|
|
170
|
+
branchCode: props?.branches?.[0]?.code ?? BRANCHES[0].code,
|
|
171
|
+
termsAccepted: false,
|
|
172
|
+
frontImage: undefined,
|
|
173
|
+
selfieImage: undefined,
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
const step2Form = useForm({
|
|
177
|
+
resolver: zodResolver(Step2Definition),
|
|
178
|
+
defaultValues: {
|
|
179
|
+
verificationCode: Array.from({ length: 6 }).fill(''),
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
const cooldown = useCooldown({
|
|
183
|
+
max: 60,
|
|
184
|
+
duration: 1000 * 60,
|
|
185
|
+
});
|
|
186
|
+
const form2Ref = useRef(null);
|
|
187
|
+
const birthDay = step1Form.watch('birthDay');
|
|
188
|
+
const branchCode = step1Form.watch('branchCode', '');
|
|
189
|
+
const [isTermsOfUseOpen, setTermsOfUseOpen] = useState(false);
|
|
190
|
+
const [isResponsibleGamingOpen, setResponsibleGamingOpen] = useState(false);
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
if (props.frontImage) {
|
|
193
|
+
step1Form.setValue('frontImage', props.frontImage);
|
|
194
|
+
}
|
|
195
|
+
if (props.selfieImage) {
|
|
196
|
+
step1Form.setValue('selfieImage', props.selfieImage);
|
|
197
|
+
}
|
|
198
|
+
}, [step1Form, props]);
|
|
199
|
+
const { mutateAsync: createMemberVerification } = useCreateMemberVerificationMutation({
|
|
200
|
+
onError: (error) => {
|
|
201
|
+
toaster.error({
|
|
202
|
+
title: 'Failed to upload ID Front Image & Selfie Image',
|
|
203
|
+
description: error.message,
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
const { mutateAsync: updateMemberVerification } = useUpdateMemberVerificationMutation({
|
|
208
|
+
onSuccess: () => {
|
|
209
|
+
const queryClient = getQueryClient();
|
|
210
|
+
queryClient.setQueryData(getMemberVerificationQueryKey(), (prev) => {
|
|
211
|
+
if (!prev)
|
|
212
|
+
return prev;
|
|
213
|
+
return {
|
|
214
|
+
...prev,
|
|
215
|
+
status: 'CREATED',
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
onError: (error) => {
|
|
220
|
+
toaster.error({
|
|
221
|
+
title: 'Failed to upload ID Front Image & Selfie Image',
|
|
222
|
+
description: error.message,
|
|
223
|
+
});
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
const memberVerification = useMemberVerificationQuery();
|
|
227
|
+
const memberId = memberVerification.data?.id;
|
|
228
|
+
const { mutate: uploadImageFile } = useUploadImageFileMutation();
|
|
229
|
+
const [isTermsOfUseAccepted, setIsTermsOfUseAccepted] = useState(false);
|
|
230
|
+
const [isResponsibleGamingAccepted, setIsResponsibleGamingAccepted] = useState(false);
|
|
231
|
+
useEffect(() => {
|
|
232
|
+
if (isTermsOfUseAccepted && isResponsibleGamingAccepted) {
|
|
233
|
+
step1Form.setValue('termsAccepted', true);
|
|
234
|
+
}
|
|
235
|
+
}, [isResponsibleGamingAccepted, isTermsOfUseAccepted, step1Form]);
|
|
236
|
+
return (_jsxs(_Fragment, { children: [_jsx(TermsOfUse, { termsOfUseContent: props.termsOfUseContent ?? 'Terms of Use content', siteName: props.siteName ?? 'Site', logo: props.logo, open: isTermsOfUseOpen, onCloseAction: () => {
|
|
237
|
+
setIsTermsOfUseAccepted(true);
|
|
238
|
+
setTermsOfUseOpen(false);
|
|
239
|
+
}, responsibleGamingLogo: props.responsibleGamingLogo }), _jsx(ResponsibleGaming, { responsibleGamingContent: props.responsibleGamingContent ?? 'Responsible Gaming content', logo: props.logo, open: isResponsibleGamingOpen, onCloseAction: () => {
|
|
240
|
+
setIsResponsibleGamingAccepted(true);
|
|
241
|
+
setResponsibleGamingOpen(false);
|
|
242
|
+
}, responsibleGamingLogo: props.responsibleGamingLogo }), step === 1 && (_jsxs(_Fragment, { children: [_jsx("h2", { className: "mt-xl text-center text-lg font-semibold", children: "Create an account" }), _jsx("p", { className: "text-text-secondary-700 mt-xs text-center text-sm", children: "Register instantly and start playing!" }), _jsxs("form", { className: "mt-3xl", autoComplete: "off", onSubmit: step1Form.handleSubmit(async (data) => {
|
|
243
|
+
try {
|
|
244
|
+
await sendVerificationCodeMutation.mutateAsync({
|
|
245
|
+
channel: 'SMS',
|
|
246
|
+
recipient: mobileNumberParser.format(data.mobileNumber),
|
|
247
|
+
});
|
|
248
|
+
setStep(2);
|
|
249
|
+
cooldown.start();
|
|
250
|
+
}
|
|
251
|
+
catch (e) {
|
|
252
|
+
toaster.error({
|
|
253
|
+
description: e instanceof Error
|
|
254
|
+
? e.message
|
|
255
|
+
: 'Failed to send verification code',
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}), children: [_jsxs(Field.Root, { invalid: !!step1Form.formState.errors.name, className: "mt-xl", children: [_jsx(Field.Label, { children: "Account Username" }), _jsx(Field.Input, { placeholder: "Enter Username", ...step1Form.register('name') }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.name?.message })] }), _jsx(Field.Root, { invalid: !!step1Form.formState.errors.password, className: "mt-xl", children: _jsxs(PasswordInput.Root, { children: [_jsx(PasswordInput.Label, { children: "Password" }), _jsxs(PasswordInput.Control, { children: [_jsx(PasswordInput.Input, { placeholder: "Enter your password", ...step1Form.register('password') }), _jsx(PasswordInput.VisibilityTrigger, { children: _jsx(PasswordInput.Indicator, { fallback: _jsx(EyeOffIcon, {}), asChild: true, children: _jsx(EyeIcon, {}) }) })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.password?.message })] }) }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.mobileNumber, className: "mt-xl", children: [_jsx(Field.Label, { children: "Mobile Number" }), _jsxs("div", { className: "relative", children: [_jsxs("div", { className: "absolute left-3.5 top-1/2 flex shrink-0 -translate-y-1/2 items-center gap-md", children: [_jsx(localeInfo.country.flag, { className: "size-5" }), _jsx("span", { className: "text-text-placeholder", children: localeInfo.mobileNumber.areaCode })] }), _jsx(Field.Input, { style: {
|
|
259
|
+
paddingLeft: `calc(2.75rem + ${localeInfo.mobileNumber.areaCode.length}ch)`,
|
|
260
|
+
}, ...step1Form.register('mobileNumber') })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.mobileNumber?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.firstName, className: "mt-xl", children: [_jsx(Field.Label, { children: "First Name" }), _jsx(Field.Input, { placeholder: "Enter your First Name", ...step1Form.register('firstName') }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.firstName?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.middleName, className: "mt-xl", children: [_jsx(Field.Label, { children: "Middle Name" }), _jsx(Field.Input, { placeholder: "Enter your Middle Name", ...step1Form.register('middleName') }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.middleName?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.lastName, className: "mt-xl", children: [_jsx(Field.Label, { children: "Last Name" }), _jsx(Field.Input, { placeholder: "Enter your Last Name", ...step1Form.register('lastName') }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.lastName?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.birthDay, className: "mt-xl", children: [_jsx(DateOfBirthField, { value: birthDay, onChange: (value) => {
|
|
261
|
+
if (!value)
|
|
262
|
+
return;
|
|
263
|
+
step1Form.setValue('birthDay', value, {
|
|
264
|
+
shouldDirty: true,
|
|
265
|
+
shouldTouch: true,
|
|
266
|
+
shouldValidate: true,
|
|
267
|
+
});
|
|
268
|
+
}, onBlur: () => {
|
|
269
|
+
step1Form.trigger('birthDay');
|
|
270
|
+
} }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.birthDay?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.branchCode, className: "mt-xl", children: [_jsxs(Select.Root, { value: [branchCode], onValueChange: (details) => {
|
|
271
|
+
step1Form.setValue('branchCode', details.value.at(0) ??
|
|
272
|
+
props?.branches?.[0]?.code ??
|
|
273
|
+
BRANCHES[0].code, {
|
|
274
|
+
shouldDirty: true,
|
|
275
|
+
shouldTouch: true,
|
|
276
|
+
shouldValidate: true,
|
|
277
|
+
});
|
|
278
|
+
}, collection: branchCollection, positioning: {
|
|
279
|
+
sameWidth: true,
|
|
280
|
+
placement: 'bottom',
|
|
281
|
+
}, lazyMount: true, unmountOnExit: true, children: [_jsx(Select.Label, { className: "flex items-center gap-1", children: "Select Nearest Branch Around You" }), _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })] }), _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: branchCollection.items.map((item) => {
|
|
282
|
+
const label = branchCollection.stringifyItem(item) ?? '';
|
|
283
|
+
return (_jsx(Select.Item, { item: item, "aria-disabled": item.disabled, className: twMerge(item.disabled && 'text-border-disabled'), children: _jsx("div", { title: label, className: "line-clamp-1", children: label }) }, item.code));
|
|
284
|
+
}) }) })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.branchCode?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.frontImage, className: "mt-xl", children: [_jsx(Field.Label, { children: "Front of your ID" }), _jsx(ImageUploader, { value: props.frontImage || null, hasDescription: true, name: "idFrontImage", captureObject: "ID_DOCUMENT", onChange: (file) => {
|
|
285
|
+
step1Form.setValue('frontImage', file);
|
|
286
|
+
props.setFrontImage(file);
|
|
287
|
+
} }, "id-front-image-upload"), _jsx(Field.ErrorText, { children: step1Form.formState.errors.frontImage?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.selfieImage, className: "mt-xl", children: [_jsx(Field.Label, { children: "Selfie holding your ID" }), _jsx(ImageUploader, { value: props.selfieImage || null, name: "selfieImage", captureObject: "SELFIE", hasDescription: false, onChange: (file) => {
|
|
288
|
+
step1Form.setValue('selfieImage', file);
|
|
289
|
+
props.setSelfieImage(file);
|
|
290
|
+
} }, "selfie-image-upload"), _jsx(Field.ErrorText, { children: step1Form.formState.errors.selfieImage?.message })] }), _jsxs("div", { className: "mt-xl text-center text-sm", children: ["Prohibition to play in open and public places", _jsxs("div", { className: "mt-5 flex items-center justify-center gap-3xl", children: [_jsx("div", { className: "flex size-5xl items-center justify-center overflow-hidden rounded-full bg-white", children: _jsx(Image, { src: pagcorLogo, alt: "", draggable: false, height: 62, width: 186, className: "h-9.5 w-auto object-contain" }) }), _jsx(Image, { src: responsibleGamingLogo, alt: "", height: 62, width: 186, className: "h-10 w-auto", draggable: false })] })] }), _jsx(Controller, { control: step1Form.control, name: "termsAccepted", render: (o) => (_jsxs(Field.Root, { className: "mt-2xl", invalid: o.fieldState.invalid, children: [_jsxs(Checkbox.Root, { checked: o.field.value, onCheckedChange: (details) => {
|
|
291
|
+
o.field.onChange(details.checked);
|
|
292
|
+
if (!details.checked) {
|
|
293
|
+
setIsTermsOfUseAccepted(false);
|
|
294
|
+
setIsResponsibleGamingAccepted(false);
|
|
295
|
+
}
|
|
296
|
+
}, children: [_jsx(Checkbox.Control, { children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsxs(Checkbox.Label, { children: ["I am at least 21 years of age and I have read and accept the", ' ', _jsx("button", { type: "button", className: "text-brand-400 underline underline-offset-2", onClick: () => {
|
|
297
|
+
setTermsOfUseOpen(true);
|
|
298
|
+
}, children: "Terms and Conditions" }), ' ', "and", ' ', _jsx("button", { type: "button", className: "text-brand-400 underline underline-offset-2", onClick: () => {
|
|
299
|
+
setResponsibleGamingOpen(true);
|
|
300
|
+
}, children: "Responsible Gaming" }), ' ', "guidelines."] }), _jsx(Checkbox.HiddenInput, {})] }), _jsx(Field.ErrorText, { className: "ml-6 text-xs", children: o.fieldState.error?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: step1Form.formState.isSubmitting, children: "Create Account" })] }), _jsxs("div", { className: "mt-6 flex w-full items-center justify-center gap-xs text-sm", children: [_jsx("span", { className: "text-text-tertiary-600", children: "Already have an account?" }), _jsx("button", { type: "submit", className: "text-button-tertiary-fg font-semibold", onClick: () => {
|
|
301
|
+
dialog.setOpen(false);
|
|
302
|
+
signInStore.setOpen(true);
|
|
303
|
+
}, children: "Log In" })] })] })), step === 2 && (_jsxs(_Fragment, { children: [_jsx("h2", { className: "mt-xl text-center text-lg font-semibold", children: "Check your Phone" }), _jsxs("p", { className: "text-text-secondary-700 mt-xs text-center text-sm", children: ["We\u2019ve sent a verification code to your mobile number", ' ', _jsx("span", { className: "font-semibold", children: mobileNumberParser.format(step1Form.getValues('mobileNumber')) }), ' ', "via text"] }), _jsxs("form", { ref: form2Ref, className: "mt-5", onSubmit: step2Form.handleSubmit(async ({ verificationCode }) => {
|
|
304
|
+
const id = ObjectId.generate(ObjectType.MemberAccount).toString();
|
|
305
|
+
const { mobileNumber } = step1Form.getValues();
|
|
306
|
+
try {
|
|
307
|
+
await signUpMutation.mutateAsync({
|
|
308
|
+
id,
|
|
309
|
+
mobileNumber: mobileNumberParser.format(mobileNumber),
|
|
310
|
+
verificationCode: verificationCode.join(''),
|
|
311
|
+
referralCode: search.get('referralCode') ?? undefined,
|
|
312
|
+
btag: search.get('btag') ?? undefined,
|
|
313
|
+
});
|
|
314
|
+
const name = mobileNumberParser.format(mobileNumber);
|
|
315
|
+
const password = `${name}${id}`;
|
|
316
|
+
const pollLogin = createPoll(async () => {
|
|
317
|
+
try {
|
|
318
|
+
await signInMutation.mutateAsync({
|
|
319
|
+
type: 'NAME_AND_PASSWORD',
|
|
320
|
+
name,
|
|
321
|
+
password,
|
|
322
|
+
});
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
}, {
|
|
329
|
+
until: (ok) => ok,
|
|
330
|
+
maxAttempt: 3,
|
|
331
|
+
});
|
|
332
|
+
const ok = await pollLogin();
|
|
333
|
+
if (!ok) {
|
|
334
|
+
signInStore.setOpen(true);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
const pollUpdateAccount = createPoll(async () => {
|
|
338
|
+
try {
|
|
339
|
+
await updateAccountMutation.mutateAsync({
|
|
340
|
+
name: step1Form.getValues('name'),
|
|
341
|
+
password: step1Form.getValues('password'),
|
|
342
|
+
branchCode: step1Form.getValues('branchCode'),
|
|
343
|
+
realName: [
|
|
344
|
+
step1Form.getValues('firstName'),
|
|
345
|
+
step1Form.getValues('middleName'),
|
|
346
|
+
step1Form.getValues('lastName'),
|
|
347
|
+
]
|
|
348
|
+
.filter(Boolean)
|
|
349
|
+
.join(' '),
|
|
350
|
+
birthDay: format(step1Form.getValues('birthDay'), 'yyyy-MM-dd'),
|
|
351
|
+
});
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
catch {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
}, {
|
|
358
|
+
until: (ok) => ok,
|
|
359
|
+
maxAttempt: 5,
|
|
360
|
+
interval: 300,
|
|
361
|
+
});
|
|
362
|
+
const pollImageUpload = createPoll(async () => {
|
|
363
|
+
const uploadImage = (file) => new Promise((resolve, reject) => {
|
|
364
|
+
if (!file) {
|
|
365
|
+
return reject(new Error('No file provided'));
|
|
366
|
+
}
|
|
367
|
+
uploadImageFile({ file }, {
|
|
368
|
+
onSuccess: (result) => resolve(result),
|
|
369
|
+
onError: (error) => reject(error || new Error('Upload failed')),
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
try {
|
|
373
|
+
const selfieFile = step1Form.getValues('selfieImage');
|
|
374
|
+
const frontFile = step1Form.getValues('frontImage');
|
|
375
|
+
if (!(selfieFile instanceof File) ||
|
|
376
|
+
!(frontFile instanceof File)) {
|
|
377
|
+
throw new Error('Invalid or missing image files');
|
|
378
|
+
}
|
|
379
|
+
const selfieImageId = await uploadImage(selfieFile);
|
|
380
|
+
const frontImageId = await uploadImage(frontFile);
|
|
381
|
+
const data = {
|
|
382
|
+
selfieImage: selfieImageId,
|
|
383
|
+
idFrontImage: frontImageId,
|
|
384
|
+
};
|
|
385
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
386
|
+
await delay(2000);
|
|
387
|
+
if (!memberId) {
|
|
388
|
+
await createMemberVerification({
|
|
389
|
+
...data,
|
|
390
|
+
address: '',
|
|
391
|
+
nationality: '',
|
|
392
|
+
natureOfWork: '',
|
|
393
|
+
permanentAddress: '',
|
|
394
|
+
placeOfBirth: '',
|
|
395
|
+
sourceOfIncome: '',
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
await updateMemberVerification({
|
|
400
|
+
id: memberId,
|
|
401
|
+
data,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
console.error('Image upload or verification failed:', error);
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
}, {
|
|
411
|
+
until: (ok) => ok,
|
|
412
|
+
maxAttempt: 5,
|
|
413
|
+
interval: 300,
|
|
414
|
+
});
|
|
415
|
+
await pollUpdateAccount();
|
|
416
|
+
await pollImageUpload();
|
|
417
|
+
}
|
|
418
|
+
dialog.setOpen(false);
|
|
419
|
+
globalStore.kycReminder.setOpen(true);
|
|
420
|
+
step1Form.reset();
|
|
421
|
+
step2Form.reset();
|
|
422
|
+
setStep(1);
|
|
423
|
+
}
|
|
424
|
+
catch (error) {
|
|
425
|
+
toaster.error({
|
|
426
|
+
description: error instanceof Error
|
|
427
|
+
? error.message
|
|
428
|
+
: 'Invalid Verification Code',
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
}), children: [_jsx(Controller, { name: "verificationCode", control: step2Form.control, render: (o) => (_jsxs(Field.Root, { invalid: o.fieldState.invalid, children: [_jsxs(PinInput.Root, { placeholder: "0", value: o.field.value, onValueChange: (details) => {
|
|
432
|
+
o.field.onChange(details.value);
|
|
433
|
+
}, onValueComplete: () => {
|
|
434
|
+
form2Ref.current?.requestSubmit();
|
|
435
|
+
}, children: [_jsxs(PinInput.Control, { className: "grid-cols-[1fr_1fr_1fr_auto_1fr_1fr_1fr] items-center gap-md", children: [_jsx(PinInput.Input, { index: 0 }), _jsx(PinInput.Input, { index: 1 }), _jsx(PinInput.Input, { index: 2 }), _jsx("span", { className: "text-text-placeholder-subtle text-2xl font-medium", children: "\u2013" }), _jsx(PinInput.Input, { index: 3 }), _jsx(PinInput.Input, { index: 4 }), _jsx(PinInput.Input, { index: 5 })] }), _jsx(PinInput.HiddenInput, {})] }), _jsx(Field.ErrorText, { children: o.formState.errors.verificationCode?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-4xl", disabled: step2Form.formState.isSubmitting, children: "Verify" }), _jsxs("div", { className: "mt-3 flex w-full items-center justify-center gap-xs text-sm", children: [_jsx("span", { className: "text-text-secondary-700", children: "Didn't recieve the code?" }), _jsx("button", { type: "button", className: "text-button-secondary-fg font-semibold disabled:cursor-not-allowed disabled:opacity-75", disabled: cooldown.cooling, onClick: async () => {
|
|
436
|
+
await sendVerificationCodeMutation.mutateAsync({
|
|
437
|
+
channel: 'SMS',
|
|
438
|
+
recipient: mobileNumberParser.format(step1Form.getValues('mobileNumber')),
|
|
439
|
+
});
|
|
440
|
+
cooldown.start();
|
|
441
|
+
}, children: cooldown.cooling
|
|
442
|
+
? `Resend in ${cooldown.countdown}s`
|
|
443
|
+
: 'Resend' })] }), _jsxs("button", { type: "button", className: "text-text-tertiary-600 mx-auto mt-3xl flex w-fit items-center gap-1 text-sm font-semibold", onClick: () => {
|
|
444
|
+
setStep(1);
|
|
445
|
+
step2Form.reset();
|
|
446
|
+
cooldown.stop();
|
|
447
|
+
}, children: [_jsx(ArrowLeftIcon, { className: "size-5" }), "Back"] })] })] }))] }));
|
|
448
|
+
}
|
|
449
|
+
const DEVICE_TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
450
|
+
function DateOfBirthField(props) {
|
|
451
|
+
const [value, setValue] = useControllableState({
|
|
452
|
+
value: props.value,
|
|
453
|
+
defaultValue: props.defaultValue ?? null,
|
|
454
|
+
onChange: props.onChange,
|
|
455
|
+
});
|
|
456
|
+
return (_jsxs(DatePicker.Root, { size: "md", variant: "outline", placeholder: "MM/DD/YYYY", lazyMount: true, unmountOnExit: true, fixedWeeks: true, selectionMode: "single", value: value ? [parseDate(value)] : [], onValueChange: (details) => {
|
|
457
|
+
const value = details.value.at(0)?.toDate(DEVICE_TIMEZONE);
|
|
458
|
+
setValue(value ?? null);
|
|
459
|
+
}, children: [_jsx(DatePicker.Label, { children: "Date of Birth" }), _jsxs(DatePicker.Control, { children: [_jsx(DatePicker.Input, { onBlur: props.onBlur, onFocus: props.onFocus }), _jsx(DatePicker.Trigger, { children: _jsx(CalendarIcon, {}) })] }), _jsx(DatePicker.Positioner, { children: _jsxs(DatePicker.Content, { children: [_jsx(DatePicker.View, { view: "day", children: _jsx(DatePicker.Context, { children: (api) => (_jsxs(_Fragment, { children: [_jsxs(DatePicker.ViewControl, { children: [_jsx(DatePicker.PrevTrigger, { children: _jsx(ChevronLeftIcon, {}) }), _jsx(DatePicker.ViewTrigger, { children: _jsx(DatePicker.RangeText, {}) }), _jsx(DatePicker.NextTrigger, { children: _jsx(ChevronRightIcon, {}) })] }), _jsxs(DatePicker.Table, { children: [_jsx(DatePicker.TableHead, { children: _jsx(DatePicker.TableRow, { children: api.weekDays.map((weekDay, id) => (_jsx(DatePicker.TableHeader, { children: weekDay.short.substring(0, 2) }, id))) }) }), _jsx(DatePicker.TableBody, { children: api.weeks.map((week, id) => (_jsx(DatePicker.TableRow, { children: week.map((day, id) => (_jsx(DatePicker.TableCell, { value: day, children: _jsx(DatePicker.TableCellTrigger, { children: day.day }) }, id))) }, id))) })] })] })) }) }), _jsx(DatePicker.View, { view: "month", children: _jsx(DatePicker.Context, { children: (datePicker) => (_jsxs(_Fragment, { children: [_jsxs(DatePicker.ViewControl, { children: [_jsx(DatePicker.PrevTrigger, { children: _jsx(ChevronLeftIcon, {}) }), _jsx(DatePicker.ViewTrigger, { children: _jsx(DatePicker.RangeText, {}) }), _jsx(DatePicker.NextTrigger, { children: _jsx(ChevronRightIcon, {}) })] }), _jsx(DatePicker.Table, { children: _jsx(DatePicker.TableBody, { children: datePicker
|
|
460
|
+
.getMonthsGrid({ columns: 4, format: 'short' })
|
|
461
|
+
.map((months, id) => (_jsx(DatePicker.TableRow, { children: months.map((month, id) => (_jsx(DatePicker.TableCell, { value: month.value, children: _jsx(DatePicker.TableCellTrigger, { className: "w-[4.425rem]", children: month.label }) }, id))) }, id))) }) })] })) }) }), _jsx(DatePicker.View, { view: "year", children: _jsx(DatePicker.Context, { children: (datePicker) => (_jsxs(_Fragment, { children: [_jsxs(DatePicker.ViewControl, { children: [_jsx(DatePicker.PrevTrigger, { children: _jsx(ChevronLeftIcon, {}) }), _jsx(DatePicker.ViewTrigger, { children: _jsx(DatePicker.RangeText, {}) }), _jsx(DatePicker.NextTrigger, { children: _jsx(ChevronRightIcon, {}) })] }), _jsx(DatePicker.Table, { children: _jsx(DatePicker.TableBody, { children: datePicker
|
|
462
|
+
.getYearsGrid({ columns: 4 })
|
|
463
|
+
.map((years, id) => (_jsx(DatePicker.TableRow, { children: years.map((year, id) => (_jsx(DatePicker.TableCell, { value: year.value, children: _jsx(DatePicker.TableCellTrigger, { className: "w-[4.425rem]", children: year.label }) }, id))) }, id))) }) })] })) }) })] }) })] }));
|
|
464
|
+
}
|
|
@@ -53,7 +53,7 @@ import { useSignUpKYCPropsContext } from './SignUpKYCContext.js';
|
|
|
53
53
|
export function SignUpKYCForm() {
|
|
54
54
|
const props = useSignUpKYCPropsContext();
|
|
55
55
|
const branchCollection = createListCollection({
|
|
56
|
-
items: props.branches,
|
|
56
|
+
items: props.branches ?? [],
|
|
57
57
|
itemToValue: (item) => item.code,
|
|
58
58
|
itemToString: (item) => `${item.code} - ${item.name}`,
|
|
59
59
|
});
|
|
@@ -138,7 +138,9 @@ export function SignUpKYCForm() {
|
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
}),
|
|
141
|
-
branchCode:
|
|
141
|
+
branchCode: (props?.branches ?? []).length > 0
|
|
142
|
+
? z.string().min(1, 'Branch is required').trim()
|
|
143
|
+
: z.string().optional(),
|
|
142
144
|
selfieImage: fileSchema,
|
|
143
145
|
frontImage: fileSchema,
|
|
144
146
|
termsAccepted: z.boolean().superRefine((v, ctx) => {
|
|
@@ -250,7 +252,7 @@ export function SignUpKYCForm() {
|
|
|
250
252
|
});
|
|
251
253
|
}, onBlur: () => {
|
|
252
254
|
step1Form.trigger('birthDay');
|
|
253
|
-
} }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.birthDay?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.branchCode, className: "mt-xl", children: [_jsxs(Select.Root, { value: [branchCode], onValueChange: (details) => {
|
|
255
|
+
} }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.birthDay?.message })] }), props.branches && (_jsxs(Field.Root, { invalid: !!step1Form.formState.errors.branchCode, className: "mt-xl", children: [_jsxs(Select.Root, { value: [branchCode ?? ''], onValueChange: (details) => {
|
|
254
256
|
step1Form.setValue('branchCode', details.value?.[0], {
|
|
255
257
|
shouldDirty: true,
|
|
256
258
|
shouldTouch: true,
|
|
@@ -262,7 +264,7 @@ export function SignUpKYCForm() {
|
|
|
262
264
|
}, lazyMount: true, unmountOnExit: true, children: [_jsx(Select.Label, { className: "flex items-center gap-1", children: "Select Nearest Branch Around You" }), _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })] }), _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: branchCollection.items.map((item) => {
|
|
263
265
|
const label = branchCollection.stringifyItem(item) ?? '';
|
|
264
266
|
return (_jsx(Select.Item, { item: item, "aria-disabled": item.disabled, className: twMerge(item.disabled && 'text-border-disabled'), children: _jsx("div", { title: label, className: "line-clamp-1", children: label }) }, item.code));
|
|
265
|
-
}) }) })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.branchCode?.message })] }), _jsx(Controller, { control: step1Form.control, name: "frontImage", render: (o) => (_jsxs(Field.Root, { invalid: o.fieldState.invalid, className: "mt-xl", children: [_jsx(Field.Label, { children: "Front of your ID" }), _jsx(IdFrontImageField, { value: o.field.value, onChange: o.field.onChange, onError: (error) => {
|
|
267
|
+
}) }) })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.branchCode?.message })] })), _jsx(Controller, { control: step1Form.control, name: "frontImage", render: (o) => (_jsxs(Field.Root, { invalid: o.fieldState.invalid, className: "mt-xl", children: [_jsx(Field.Label, { children: "Front of your ID" }), _jsx(IdFrontImageField, { value: o.field.value, onChange: o.field.onChange, onError: (error) => {
|
|
266
268
|
step1Form.setValue('frontImage', null);
|
|
267
269
|
step1Form.setError('frontImage', {
|
|
268
270
|
type: 'validate',
|
|
@@ -300,7 +302,7 @@ export function SignUpKYCForm() {
|
|
|
300
302
|
globalStore.responsibleGaming.setNext('SIGN_UP');
|
|
301
303
|
globalStore.signUp.setOpen(false);
|
|
302
304
|
}
|
|
303
|
-
}, children: "Responsible Gaming" }), ' ', "guidelines."] }), _jsx(Checkbox.HiddenInput, {})] }), _jsx(Field.ErrorText, { className: "ml-6 text-xs", children: o.fieldState.error?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: step1Form.formState.isSubmitting, children: "Create Account" })] }), _jsxs("div", { className: "gap-xs mt-6 flex w-full items-center justify-center text-sm
|
|
305
|
+
}, children: "Responsible Gaming" }), ' ', "guidelines."] }), _jsx(Checkbox.HiddenInput, {})] }), _jsx(Field.ErrorText, { className: "ml-6 text-xs", children: o.fieldState.error?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: step1Form.formState.isSubmitting, children: "Create Account" })] }), _jsxs("div", { className: "gap-xs mt-6 flex w-full items-center justify-center pb-8 text-sm", children: [_jsx("span", { className: "text-text-tertiary-600", children: "Already have an account?" }), _jsx("button", { type: "submit", className: "text-button-tertiary-fg font-semibold", onClick: () => {
|
|
304
306
|
dialog.setOpen(false);
|
|
305
307
|
globalStore.signIn.setOpen(true);
|
|
306
308
|
}, children: "Log In" })] })] })), step === 2 && (_jsxs(_Fragment, { children: [_jsx("h2", { className: "mt-xl text-center text-lg font-semibold", children: "Check your Phone" }), _jsxs("p", { className: "text-text-secondary-700 mt-xs text-center text-sm", children: ["We\u2019ve sent a verification code to your mobile number", ' ', _jsx("span", { className: "font-semibold", children: mobileNumberParser.format(step1Form.getValues('mobileNumber')) }), ' ', "via text"] }), _jsxs("form", { ref: form2Ref, className: "mt-5", onSubmit: step2Form.handleSubmit(async ({ verificationCode }) => {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type CaptureSubject = 'SELFIE' | 'ID_DOCUMENT';
|
|
2
|
+
export interface UseImageUploaderReturn {
|
|
3
|
+
capturing: CaptureSubject | null;
|
|
4
|
+
setCapturing: (capturing: CaptureSubject | null) => void;
|
|
5
|
+
frontImage: File | null;
|
|
6
|
+
setFrontImage: (id: File | null) => void;
|
|
7
|
+
selfieImage: File | null;
|
|
8
|
+
setSelfieImage: (id: File | null) => void;
|
|
9
|
+
reset: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function useImageUploader(): UseImageUploaderReturn;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
export function useImageUploader() {
|
|
3
|
+
const [frontImage, setFrontImage] = useState(null);
|
|
4
|
+
const [selfieImage, setSelfieImage] = useState(null);
|
|
5
|
+
const [capturing, setCapturing] = useState(null);
|
|
6
|
+
const reset = () => {
|
|
7
|
+
setCapturing(null);
|
|
8
|
+
setFrontImage(null);
|
|
9
|
+
setSelfieImage(null);
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
capturing,
|
|
13
|
+
setCapturing,
|
|
14
|
+
frontImage,
|
|
15
|
+
setFrontImage,
|
|
16
|
+
selfieImage,
|
|
17
|
+
setSelfieImage,
|
|
18
|
+
reset,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function loadFaceApiModels(): Promise<void>;
|
|
2
|
+
export declare function dataURLtoBlob(dataURL: string): Blob;
|
|
3
|
+
export declare const resizeFile: (file: File) => Promise<unknown>;
|
|
4
|
+
export declare const MAX_FILE_SIZE = 10;
|
|
5
|
+
export declare const MAX_NAME_LENGTH = 52;
|
|
6
|
+
export declare const SUPPORTED_FILES: string[];
|
|
7
|
+
export declare function validateFile(file: File): "File too large" | "File name too long" | "Unsupported file" | undefined;
|
|
8
|
+
export declare function showPermissionInstructions(): void;
|
|
9
|
+
export declare const cameraErrorDescriptions: Record<string, string>;
|