@opexa/portal-components 0.0.921 → 0.0.923
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/useUpdateMobileNumber.d.ts +3 -0
- package/dist/client/hooks/useUpdateMobileNumber.js +20 -0
- package/dist/components/AccountInfo/AccountInfo.js +1 -1
- package/dist/components/AccountSecurity/AccountSecurity.js +1 -1
- package/dist/components/DepositWithdrawal/AiOPaymentMethods.d.ts +11 -0
- package/dist/components/DepositWithdrawal/AiOPaymentMethods.js +55 -0
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/AurixPayQRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/AurixPayQRPHDeposit/useAurixPayQRPHDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/useOnlineBankDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.d.ts +1 -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/DigitainLauncher/Loading.d.ts +1 -0
- package/dist/components/DigitainLauncher/Loading.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/ForgotPassword/Crazywin/ForgotPassword.module.css +42 -42
- package/dist/components/Jackpots/Jackpots.module.css +288 -288
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +184 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +184 -0
- package/dist/components/KYC/AutoOpen.d.ts +1 -0
- package/dist/components/KYC/AutoOpen.js +40 -0
- package/dist/components/KYC/BasicInformation.d.ts +1 -0
- package/dist/components/KYC/BasicInformation.js +101 -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/IdentityVerification.d.ts +1 -0
- package/dist/components/KYC/IdentityVerification.js +120 -0
- package/dist/components/KYC/Indicator.d.ts +1 -0
- package/dist/components/KYC/Indicator.js +8 -0
- package/dist/components/KYC/KYC.lazy.d.ts +6 -0
- package/dist/components/KYC/KYC.lazy.js +45 -0
- package/dist/components/KYC/KYCContext.d.ts +6 -0
- package/dist/components/KYC/KYCContext.js +2 -0
- package/dist/components/KYC/KYCDefault/KYCVerificationStatus.lazy.js +2 -2
- package/dist/components/KYC/KYCNonPagCor/KYCVerificationStatus.lazy.js +2 -2
- package/dist/components/KYC/KYCVerificationStatus.lazy.js +13 -7
- 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.d.ts +1 -0
- package/dist/components/KYC/PersonalInformation.js +122 -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/useKYC.d.ts +25 -0
- package/dist/components/KYC/useKYC.js +38 -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.d.ts +1 -0
- package/dist/components/PortalProvider/CXDTokenObserver.js +30 -0
- package/dist/components/PortalProvider/LinkGoogleAccountObserver.d.ts +1 -0
- package/dist/components/PortalProvider/LinkGoogleAccountObserver.js +29 -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/ResponsibleGaming/ResponsibleGamingV2.lazy.js +1 -1
- package/dist/components/SessionWatcher/SessionWatcher.d.ts +1 -0
- package/dist/components/SessionWatcher/SessionWatcher.js +20 -0
- package/dist/components/SessionWatcher/index.d.ts +1 -0
- package/dist/components/SessionWatcher/index.js +1 -0
- package/dist/components/SignIn/utils.d.ts +8 -0
- package/dist/components/SignIn/utils.js +26 -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/TermsOfUse/TermsOfUseV2.lazy.js +1 -1
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.module.css +184 -184
- package/dist/components/Tournaments/TournamentsList/TournamentItem.module.css +184 -184
- package/dist/components/TransactionRecords/TableFilters.js +2 -2
- package/dist/components/UpdateMobileNumber/UpdateMobileNumber.d.ts +3 -0
- package/dist/components/UpdateMobileNumber/UpdateMobileNumber.js +136 -0
- package/dist/components/UpdateMobileNumber/index.d.ts +1 -0
- package/dist/components/UpdateMobileNumber/index.js +1 -0
- 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/Branches.d.ts +2 -0
- package/dist/constants/Branches.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/images/phone-icon.svg +10 -10
- package/dist/images/responsible-gaming-yellow.png +0 -0
- package/dist/services/account.d.ts +21 -0
- package/dist/services/account.js +11 -1
- package/dist/services/queries.d.ts +1 -0
- package/dist/services/queries.js +3351 -3337
- package/dist/styles/theme.css +776 -776
- 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/types/index.d.ts +1 -1
- package/dist/ui/AlertDialog/AlertDialog.d.ts +121 -121
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +11 -11
- package/dist/ui/Carousel/Carousel.d.ts +72 -72
- package/dist/ui/Carousel/carousel.recipe.d.ts +8 -8
- package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
- package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
- package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
- package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
- package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
- package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
- package/dist/ui/Combobox/Combobox.d.ts +42 -42
- package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
- package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
- package/dist/ui/Dialog/Dialog.d.ts +33 -33
- package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
- package/dist/ui/Drawer/Drawer.d.ts +33 -33
- package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
- package/dist/ui/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/mutationKeys.d.ts +1 -0
- package/dist/utils/mutationKeys.js +8 -1
- package/dist/utils/resizeImageSize.d.ts +2 -0
- package/dist/utils/resizeImageSize.js +11 -0
- package/package.json +179 -179
- package/dist/components/PortalProvider/AndroidOnlyComponents.d.ts +0 -1
- package/dist/components/PortalProvider/AndroidOnlyComponents.js +0 -12
|
@@ -0,0 +1,284 @@
|
|
|
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 Link from 'next/link';
|
|
9
|
+
import { useSearchParams } from 'next/navigation';
|
|
10
|
+
import { useRef, useState } from 'react';
|
|
11
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { useShallow } from 'zustand/shallow';
|
|
14
|
+
import { useControllableState } from '../../client/hooks/useControllableState.js';
|
|
15
|
+
import { useCooldown } from '../../client/hooks/useCooldown.js';
|
|
16
|
+
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
17
|
+
import { useLocaleInfo } from '../../client/hooks/useLocaleInfo.js';
|
|
18
|
+
import { useMobileNumberParser } from '../../client/hooks/useMobileNumberParser.js';
|
|
19
|
+
import { useSendVerificationCodeMutation } from '../../client/hooks/useSendVerificationCodeMutation.js';
|
|
20
|
+
import { useSignInMutation } from '../../client/hooks/useSignInMutation.js';
|
|
21
|
+
import { useSignUpMutation } from '../../client/hooks/useSignUpMutation.js';
|
|
22
|
+
import { useUpdateAccountMutation } from '../../client/hooks/useUpdateAccountMutation.js';
|
|
23
|
+
import { toaster } from '../../client/utils/toaster.js';
|
|
24
|
+
import { BRANCHES } from '../../constants/index.js';
|
|
25
|
+
import { ArrowLeftIcon } from '../../icons/ArrowLeftIcon.js';
|
|
26
|
+
import { CalendarIcon } from '../../icons/CalendarIcon.js';
|
|
27
|
+
import { CheckIcon } from '../../icons/CheckIcon.js';
|
|
28
|
+
import { ChevronDownIcon } from '../../icons/ChevronDownIcon.js';
|
|
29
|
+
import { ChevronLeftIcon } from '../../icons/ChevronLeftIcon.js';
|
|
30
|
+
import { ChevronRightIcon } from '../../icons/ChevronRightIcon.js';
|
|
31
|
+
import { HelpCircleIcon } from '../../icons/HelpCircleIcon.js';
|
|
32
|
+
import { ObjectType } from '../../services/ObjectType.js';
|
|
33
|
+
import { Button } from '../../ui/Button/index.js';
|
|
34
|
+
import { Checkbox } from '../../ui/Checkbox/index.js';
|
|
35
|
+
import { DatePicker } from '../../ui/DatePicker/index.js';
|
|
36
|
+
import { Field } from '../../ui/Field/index.js';
|
|
37
|
+
import { PinInput } from '../../ui/PinInput/index.js';
|
|
38
|
+
import { Select } from '../../ui/Select/index.js';
|
|
39
|
+
import { Tooltip } from '../../ui/Tooltip/index.js';
|
|
40
|
+
import { createPoll } from '../../utils/createPoll.js';
|
|
41
|
+
import { useSignUpPropsContext } from './SignUpContext.js';
|
|
42
|
+
export function SignUpForm() {
|
|
43
|
+
const signUpProps = useSignUpPropsContext();
|
|
44
|
+
const branchCollection = createListCollection({
|
|
45
|
+
items: signUpProps.branches ?? BRANCHES,
|
|
46
|
+
itemToValue: (item) => item.code,
|
|
47
|
+
itemToString: (item) => `${item.code} - ${item.name}`,
|
|
48
|
+
});
|
|
49
|
+
const [step, setStep] = useState(1);
|
|
50
|
+
const dialog = useDialogContext();
|
|
51
|
+
const search = useSearchParams();
|
|
52
|
+
const signInStore = useGlobalStore(useShallow((ctx) => ctx.signIn));
|
|
53
|
+
const signUpMutation = useSignUpMutation();
|
|
54
|
+
const signInMutation = useSignInMutation();
|
|
55
|
+
const updateAccountMutation = useUpdateAccountMutation();
|
|
56
|
+
const sendVerificationCodeMutation = useSendVerificationCodeMutation();
|
|
57
|
+
const localeInfo = useLocaleInfo();
|
|
58
|
+
const mobileNumberParser = useMobileNumberParser();
|
|
59
|
+
const Step1Definition = z.object({
|
|
60
|
+
mobileNumber: z
|
|
61
|
+
.string()
|
|
62
|
+
.min(1, 'Mobile number is required')
|
|
63
|
+
.superRefine((v, ctx) => {
|
|
64
|
+
if (!mobileNumberParser.validate(v)) {
|
|
65
|
+
ctx.addIssue({
|
|
66
|
+
code: z.ZodIssueCode.custom,
|
|
67
|
+
message: 'Invalid mobile number',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
termsAccepted: z.boolean().superRefine((v, ctx) => {
|
|
72
|
+
if (!v) {
|
|
73
|
+
ctx.addIssue({
|
|
74
|
+
code: z.ZodIssueCode.custom,
|
|
75
|
+
message: 'You must accept the terms and conditions',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
realName: z
|
|
80
|
+
.string()
|
|
81
|
+
.min(2, 'Real name must be 2 or more characters')
|
|
82
|
+
.max(50, 'Real name must not be more than 50 characters')
|
|
83
|
+
.trim(),
|
|
84
|
+
birthDay: z
|
|
85
|
+
.date({
|
|
86
|
+
invalid_type_error: 'Date of birth is required',
|
|
87
|
+
required_error: 'Date of birth is required',
|
|
88
|
+
})
|
|
89
|
+
.superRefine((val, ctx) => {
|
|
90
|
+
const now = new Date();
|
|
91
|
+
const age = differenceInYears(now, val);
|
|
92
|
+
if (age < 21) {
|
|
93
|
+
return ctx.addIssue({
|
|
94
|
+
code: z.ZodIssueCode.custom,
|
|
95
|
+
message: 'You must be at least 21 years old',
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}),
|
|
99
|
+
branchCode: z.string().min(1, 'Branch is required').trim(),
|
|
100
|
+
});
|
|
101
|
+
const Step2Definition = z.object({
|
|
102
|
+
verificationCode: z.array(z.string()).superRefine((val, ctx) => {
|
|
103
|
+
if (val.length !== 6 || val.some((v) => v.length !== 1)) {
|
|
104
|
+
ctx.addIssue({
|
|
105
|
+
code: z.ZodIssueCode.custom,
|
|
106
|
+
message: 'Please Enter your 6 digits verification code',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}),
|
|
110
|
+
});
|
|
111
|
+
const step1Form = useForm({
|
|
112
|
+
mode: 'all',
|
|
113
|
+
resolver: zodResolver(Step1Definition),
|
|
114
|
+
defaultValues: {
|
|
115
|
+
mobileNumber: '',
|
|
116
|
+
termsAccepted: false,
|
|
117
|
+
branchCode: signUpProps?.branches?.[0]?.code ?? BRANCHES[0].code,
|
|
118
|
+
realName: '',
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
const step2Form = useForm({
|
|
122
|
+
resolver: zodResolver(Step2Definition),
|
|
123
|
+
defaultValues: {
|
|
124
|
+
verificationCode: Array.from({ length: 6 }).fill(''),
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
const cooldown = useCooldown({
|
|
128
|
+
max: 60,
|
|
129
|
+
duration: 1000 * 60,
|
|
130
|
+
});
|
|
131
|
+
const form2Ref = useRef(null);
|
|
132
|
+
const birthDay = step1Form.watch('birthDay');
|
|
133
|
+
const branchCode = step1Form.watch('branchCode', '');
|
|
134
|
+
return (_jsxs(_Fragment, { children: [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) => {
|
|
135
|
+
try {
|
|
136
|
+
await sendVerificationCodeMutation.mutateAsync({
|
|
137
|
+
channel: 'SMS',
|
|
138
|
+
recipient: mobileNumberParser.format(data.mobileNumber),
|
|
139
|
+
});
|
|
140
|
+
setStep(2);
|
|
141
|
+
cooldown.start();
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
toaster.error({
|
|
145
|
+
description: e instanceof Error
|
|
146
|
+
? e.message
|
|
147
|
+
: 'Failed to send verification code',
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}), children: [_jsxs(Field.Root, { invalid: !!step1Form.formState.errors.mobileNumber, 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: {
|
|
151
|
+
paddingLeft: `calc(2.75rem + ${localeInfo.mobileNumber.areaCode.length}ch)`,
|
|
152
|
+
}, ...step1Form.register('mobileNumber') })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.mobileNumber?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.realName, className: "mt-xl", children: [_jsx(Field.Label, { children: "Real Name" }), _jsx(Field.Input, { placeholder: "Enter your real name", ...step1Form.register('realName') }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.realName?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.birthDay, className: "mt-xl", children: [_jsx(DateOfBirthField, { value: birthDay, onChange: (value) => {
|
|
153
|
+
if (!value)
|
|
154
|
+
return;
|
|
155
|
+
step1Form.setValue('birthDay', value, {
|
|
156
|
+
shouldDirty: true,
|
|
157
|
+
shouldTouch: true,
|
|
158
|
+
shouldValidate: true,
|
|
159
|
+
});
|
|
160
|
+
}, onBlur: () => {
|
|
161
|
+
step1Form.trigger('birthDay');
|
|
162
|
+
} }), _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) => {
|
|
163
|
+
step1Form.setValue('branchCode', details.value.at(0) ??
|
|
164
|
+
signUpProps?.branches?.[0]?.code ??
|
|
165
|
+
BRANCHES[0].code, {
|
|
166
|
+
shouldDirty: true,
|
|
167
|
+
shouldTouch: true,
|
|
168
|
+
shouldValidate: true,
|
|
169
|
+
});
|
|
170
|
+
}, collection: branchCollection, positioning: {
|
|
171
|
+
sameWidth: true,
|
|
172
|
+
placement: 'bottom',
|
|
173
|
+
}, lazyMount: true, unmountOnExit: true, children: [_jsxs(Select.Label, { className: "flex items-center gap-1", children: ["Branch", _jsxs(Tooltip.Root, { openDelay: 0, closeDelay: 100, lazyMount: true, unmountOnExit: true, positioning: {
|
|
174
|
+
placement: 'top',
|
|
175
|
+
}, children: [_jsx(Tooltip.Trigger, { children: _jsx(HelpCircleIcon, { className: "text-text-nav-item-button-icon size-4" }) }), _jsx(Tooltip.Positioner, { children: _jsxs(Tooltip.Content, { children: [_jsx(Tooltip.Arrow, { children: _jsx(Tooltip.ArrowTip, {}) }), "Choose branch closest to your residence."] }) })] })] }), _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) => {
|
|
176
|
+
const label = branchCollection.stringifyItem(item) ?? '';
|
|
177
|
+
return (_jsx(Select.Item, { item: item, children: _jsx("div", { title: label, className: "line-clamp-1", children: label }) }, item.code));
|
|
178
|
+
}) }) })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.branchCode?.message })] }), _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) => {
|
|
179
|
+
o.field.onChange(details.checked);
|
|
180
|
+
}, 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 accept the", ' ', _jsx(Link, { href: signUpProps.termsAndConditionsUrl ??
|
|
181
|
+
'/terms-and-conditions', onClick: () => {
|
|
182
|
+
dialog.setOpen(false);
|
|
183
|
+
}, className: "text-brand-400 whitespace-nowrap underline underline-offset-2", children: "Terms and Conditions." })] }), ' ', _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: () => {
|
|
184
|
+
dialog.setOpen(false);
|
|
185
|
+
signInStore.setOpen(true);
|
|
186
|
+
}, 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 }) => {
|
|
187
|
+
const id = ObjectId.generate(ObjectType.MemberAccount).toString();
|
|
188
|
+
const { mobileNumber } = step1Form.getValues();
|
|
189
|
+
try {
|
|
190
|
+
await signUpMutation.mutateAsync({
|
|
191
|
+
id,
|
|
192
|
+
mobileNumber: mobileNumberParser.format(mobileNumber),
|
|
193
|
+
verificationCode: verificationCode.join(''),
|
|
194
|
+
referralCode: search.get('referralCode') ?? undefined,
|
|
195
|
+
domain: search.get('domain') ?? undefined,
|
|
196
|
+
btag: search.get('btag') ?? undefined,
|
|
197
|
+
});
|
|
198
|
+
const name = mobileNumberParser.format(mobileNumber);
|
|
199
|
+
const password = `${name}${id}`;
|
|
200
|
+
const pollLogin = createPoll(async () => {
|
|
201
|
+
try {
|
|
202
|
+
await signInMutation.mutateAsync({
|
|
203
|
+
type: 'NAME_AND_PASSWORD',
|
|
204
|
+
name,
|
|
205
|
+
password,
|
|
206
|
+
});
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
until: (ok) => ok,
|
|
214
|
+
maxAttempt: 3,
|
|
215
|
+
});
|
|
216
|
+
const ok = await pollLogin();
|
|
217
|
+
if (!ok) {
|
|
218
|
+
signInStore.setOpen(true);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
const pollUpdateAccount = createPoll(async () => {
|
|
222
|
+
try {
|
|
223
|
+
await updateAccountMutation.mutateAsync({
|
|
224
|
+
branchCode: step1Form.getValues('branchCode'),
|
|
225
|
+
realName: step1Form.getValues('realName'),
|
|
226
|
+
birthDay: format(step1Form.getValues('birthDay'), 'yyyy-MM-dd'),
|
|
227
|
+
});
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
}, {
|
|
234
|
+
until: (ok) => ok,
|
|
235
|
+
maxAttempt: 3,
|
|
236
|
+
});
|
|
237
|
+
await pollUpdateAccount();
|
|
238
|
+
}
|
|
239
|
+
dialog.setOpen(false);
|
|
240
|
+
step1Form.reset();
|
|
241
|
+
step2Form.reset();
|
|
242
|
+
setStep(1);
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
toaster.error({
|
|
246
|
+
description: error instanceof Error
|
|
247
|
+
? error.message
|
|
248
|
+
: 'Invalid Verification Code',
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}), 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) => {
|
|
252
|
+
o.field.onChange(details.value);
|
|
253
|
+
}, onValueComplete: () => {
|
|
254
|
+
form2Ref.current?.requestSubmit();
|
|
255
|
+
}, 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 () => {
|
|
256
|
+
await sendVerificationCodeMutation.mutateAsync({
|
|
257
|
+
channel: 'SMS',
|
|
258
|
+
recipient: mobileNumberParser.format(step1Form.getValues('mobileNumber')),
|
|
259
|
+
});
|
|
260
|
+
cooldown.start();
|
|
261
|
+
}, children: cooldown.cooling
|
|
262
|
+
? `Resend in ${cooldown.countdown}s`
|
|
263
|
+
: '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: () => {
|
|
264
|
+
setStep(1);
|
|
265
|
+
step2Form.reset();
|
|
266
|
+
cooldown.stop();
|
|
267
|
+
}, children: [_jsx(ArrowLeftIcon, { className: "size-5" }), "Back"] })] })] }))] }));
|
|
268
|
+
}
|
|
269
|
+
const DEVICE_TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
270
|
+
function DateOfBirthField(props) {
|
|
271
|
+
const [value, setValue] = useControllableState({
|
|
272
|
+
value: props.value,
|
|
273
|
+
defaultValue: props.defaultValue ?? null,
|
|
274
|
+
onChange: props.onChange,
|
|
275
|
+
});
|
|
276
|
+
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) => {
|
|
277
|
+
const value = details.value.at(0)?.toDate(DEVICE_TIMEZONE);
|
|
278
|
+
setValue(value ?? null);
|
|
279
|
+
}, 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
|
|
280
|
+
.getMonthsGrid({ columns: 4, format: 'short' })
|
|
281
|
+
.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
|
|
282
|
+
.getYearsGrid({ columns: 4 })
|
|
283
|
+
.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))) }) })] })) }) })] }) })] }));
|
|
284
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CaptureIdDocument(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
import { ArrowLeftIcon } from '../../../icons/ArrowLeftIcon.js';
|
|
6
|
+
import { Camera01Icon } from '../../../icons/Camera01Icon.js';
|
|
7
|
+
import { CheckCircleIcon } from '../../../icons/CheckCircleIcon.js';
|
|
8
|
+
import { XIcon } from '../../../icons/XIcon.js';
|
|
9
|
+
import { Button } from '../../../ui/Button/index.js';
|
|
10
|
+
import { Dialog } from '../../../ui/Dialog/index.js';
|
|
11
|
+
import { Portal } from '../../../ui/Portal/index.js';
|
|
12
|
+
import { useSignUpKYCPropsContext } from './SignUpKYCContext.js';
|
|
13
|
+
import { dataURLtoBlob, resizeFile } from './utils.js';
|
|
14
|
+
export function CaptureIdDocument() {
|
|
15
|
+
const props = useSignUpKYCPropsContext();
|
|
16
|
+
const [videoStream, setVideoStream] = useState(null);
|
|
17
|
+
const [cameraError, setCameraError] = useState(null);
|
|
18
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
19
|
+
const [selectedImage, setSelectedImage] = useState(null);
|
|
20
|
+
const [captureInProgress, setCaptureInProgress] = useState(false);
|
|
21
|
+
const [proccessImageCanvas, setProccessImageCanvas] = useState(null);
|
|
22
|
+
const videoElement = useRef(null);
|
|
23
|
+
const containerRef = useRef(null);
|
|
24
|
+
function stopCamera() {
|
|
25
|
+
if (videoStream) {
|
|
26
|
+
videoStream.getTracks().forEach((track) => track.stop());
|
|
27
|
+
setVideoStream(null);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
return () => {
|
|
32
|
+
stopCamera();
|
|
33
|
+
};
|
|
34
|
+
}, [videoStream]);
|
|
35
|
+
async function startCamera() {
|
|
36
|
+
try {
|
|
37
|
+
setIsLoading(true);
|
|
38
|
+
setCameraError(null);
|
|
39
|
+
setCaptureInProgress(true);
|
|
40
|
+
console.log('Starting camera...');
|
|
41
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
42
|
+
video: {
|
|
43
|
+
facingMode: 'environment',
|
|
44
|
+
aspectRatio: 16 / 9,
|
|
45
|
+
width: { ideal: 1920, max: 1920 },
|
|
46
|
+
height: { ideal: 1080, max: 1080 },
|
|
47
|
+
frameRate: {
|
|
48
|
+
ideal: 30,
|
|
49
|
+
max: 60,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
audio: false,
|
|
53
|
+
});
|
|
54
|
+
// Set the stream directly to the video element
|
|
55
|
+
if (videoElement.current) {
|
|
56
|
+
videoElement.current.srcObject = stream;
|
|
57
|
+
videoElement.current.onloadedmetadata = () => {
|
|
58
|
+
console.log('Video metadata loaded, starting playback...');
|
|
59
|
+
videoElement.current
|
|
60
|
+
?.play()
|
|
61
|
+
.then(() => {
|
|
62
|
+
setVideoStream(stream);
|
|
63
|
+
setIsLoading(false);
|
|
64
|
+
})
|
|
65
|
+
.catch(() => {
|
|
66
|
+
setCameraError('Failed to start camera stream. Please try again.');
|
|
67
|
+
setIsLoading(false);
|
|
68
|
+
// Stop the stream if playback fails
|
|
69
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
videoElement.current.onerror = (err) => {
|
|
73
|
+
console.error('Video element error:', err);
|
|
74
|
+
setCameraError('Video playback error. Please try again.');
|
|
75
|
+
setIsLoading(false);
|
|
76
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
console.error('Video element not available');
|
|
81
|
+
setCameraError('Camera initialization failed. Please try again.');
|
|
82
|
+
setCaptureInProgress(false);
|
|
83
|
+
setIsLoading(false);
|
|
84
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
setIsLoading(false);
|
|
89
|
+
if (error instanceof DOMException) {
|
|
90
|
+
console.error('Error accessing camera:', error.message);
|
|
91
|
+
setCameraError(error.message);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
console.error('Unknown error accessing camera:', error);
|
|
95
|
+
setCameraError('An unknown error occurred. Please check permissions and try again.');
|
|
96
|
+
}
|
|
97
|
+
setCaptureInProgress(false);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function captureAndProcessImage() {
|
|
101
|
+
if (!videoElement.current || !videoStream) {
|
|
102
|
+
console.error('Video element or stream not available for capture');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const canvas = document.createElement('canvas');
|
|
107
|
+
const parentDiv = document.getElementById('parent');
|
|
108
|
+
canvas.width = parentDiv?.clientWidth || videoElement.current.width;
|
|
109
|
+
canvas.height = parentDiv?.clientHeight || videoElement.current.height;
|
|
110
|
+
const ctx = canvas.getContext('2d');
|
|
111
|
+
if (!ctx) {
|
|
112
|
+
console.error('Could not get 2D context for canvas');
|
|
113
|
+
setCameraError('Failed to process image. Please try again.');
|
|
114
|
+
setCaptureInProgress(false);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
ctx.drawImage(videoElement.current, 0, 0, canvas.width, canvas.height);
|
|
118
|
+
const imageSrc = canvas.toDataURL('image/png', 1.0);
|
|
119
|
+
setSelectedImage({ src: imageSrc });
|
|
120
|
+
setCaptureInProgress(false);
|
|
121
|
+
stopCamera();
|
|
122
|
+
const newImg = document.createElement('img');
|
|
123
|
+
newImg.src = imageSrc;
|
|
124
|
+
//@ts-expect-error jscanify is not typed
|
|
125
|
+
const scanner = new jscanify();
|
|
126
|
+
newImg.onload = () => {
|
|
127
|
+
try {
|
|
128
|
+
if (containerRef.current) {
|
|
129
|
+
// containerRef.current.innerHTML = '';
|
|
130
|
+
const paperWidth = parentDiv?.clientWidth || videoElement.current?.videoWidth;
|
|
131
|
+
const paperHeight = parentDiv?.clientHeight || videoElement.current?.videoHeight;
|
|
132
|
+
//@ts-expect-error jscanify is not typed
|
|
133
|
+
const contour = scanner.findPaperContour(cv.imread(newImg));
|
|
134
|
+
const cornerPoints = scanner.getCornerPoints(contour);
|
|
135
|
+
const resultCanvas = scanner.extractPaper(newImg, paperWidth, paperHeight, cornerPoints);
|
|
136
|
+
newImg.className =
|
|
137
|
+
'absolute inset-0 m-auto w-full h-auto md:max-h-[333px] md:max-w-[643px] aspect-video rounded-lg object-contain';
|
|
138
|
+
setProccessImageCanvas(resultCanvas);
|
|
139
|
+
containerRef.current.appendChild(resultCanvas);
|
|
140
|
+
setCaptureInProgress(false);
|
|
141
|
+
setSelectedImage({ src: resultCanvas.toDataURL('image/png') });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
console.error('Error processing image:', error);
|
|
146
|
+
setCameraError('Failed to process image. Please try again.');
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
newImg.onerror = () => {
|
|
150
|
+
console.error('Error loading image');
|
|
151
|
+
setCameraError('Failed to load image. Please try again.');
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
console.error('Error capturing image:', error);
|
|
156
|
+
setCameraError('Failed to capture image. Please try again.');
|
|
157
|
+
setCaptureInProgress(false);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async function uploadPhoto() {
|
|
161
|
+
if (!proccessImageCanvas) {
|
|
162
|
+
console.error('Failed to process the image. Please try again.');
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const blob = proccessImageCanvas.toDataURL('image/png', 1.0);
|
|
166
|
+
const processedBlob = dataURLtoBlob(blob);
|
|
167
|
+
const img = new File([processedBlob], 'frontImage', { type: 'image/jpeg' });
|
|
168
|
+
const resizedImage = (await resizeFile(img));
|
|
169
|
+
if (resizedImage) {
|
|
170
|
+
props.setFrontImage(resizedImage);
|
|
171
|
+
props.setCapturing(null);
|
|
172
|
+
stopCamera();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function retakePhoto() {
|
|
176
|
+
setSelectedImage(null);
|
|
177
|
+
setCaptureInProgress(true);
|
|
178
|
+
setCameraError(null);
|
|
179
|
+
if (containerRef.current) {
|
|
180
|
+
const canvas = containerRef.current.querySelector('canvas');
|
|
181
|
+
if (canvas) {
|
|
182
|
+
canvas.width = canvas.width;
|
|
183
|
+
}
|
|
184
|
+
containerRef.current.innerHTML = '';
|
|
185
|
+
}
|
|
186
|
+
if (videoElement.current) {
|
|
187
|
+
videoElement.current.play();
|
|
188
|
+
}
|
|
189
|
+
startCamera();
|
|
190
|
+
}
|
|
191
|
+
return (_jsx(Dialog.Root, { open: props.capturing === 'ID_DOCUMENT', lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsx(Dialog.Content, { className: twMerge('bg-bg-primary-alt mx-auto h-full w-full items-start overflow-y-auto p-3xl pb-4xl lg:h-auto lg:w-fit lg:rounded-xl', props.className), children: _jsxs("div", { className: "w-full p-4 lg:w-[640px] lg:px-12 lg:py-4xl", children: [_jsxs("button", { type: "button", className: "flex items-center gap-lg lg:absolute lg:right-5 lg:top-5 lg:p-md", onClick: () => {
|
|
192
|
+
stopCamera();
|
|
193
|
+
props.setCapturing(null);
|
|
194
|
+
}, children: [_jsx(XIcon, { className: "text-text-senary-300 hidden size-5 lg:block" }), _jsx(ArrowLeftIcon, { className: "text-text-senary-300 size-5 lg:hidden" }), _jsx("span", { className: "text-lg font-semibold lg:hidden", children: "Back" })] }), _jsx(Dialog.Title, { className: "mt-6 text-center text-lg font-semibold lg:mt-0", children: "Take a Picture of Your Front ID" }), _jsxs(Dialog.Description, { className: "lg:max-w-auto text-text-tertiary-600 mx-auto mt-sm max-w-[19rem] text-center text-sm lg:max-w-full", children: ["Make sure your ID is clearly visible, well-lit, and not blurry.", _jsx("br", { className: "hidden lg:block" }), " Avoid glare or reflections, and ensure all corners are within the frame."] }), _jsx("div", { id: "parent", className: "border-border-disabled mt-6 aspect-video rounded-xl border bg-black lg:mt-8", children: cameraError ? (_jsx("div", { className: "flex h-full items-center justify-center p-4", children: _jsxs("div", { className: "text-center", children: [_jsx("p", { className: "text-red-500 mb-2 text-sm", children: "Camera Error" }), _jsx("p", { className: "text-gray-400 text-xs", children: cameraError })] }) })) : captureInProgress ? (_jsxs("div", { className: "relative flex h-fit w-full flex-col items-center justify-center", children: [_jsx("video", { ref: videoElement, autoPlay: true, muted: true, playsInline: true, className: "relative h-[60vh] w-full rounded-lg object-cover md:aspect-video md:max-h-[333px]", width: "100%", height: "100%" }), _jsxs("div", { className: "pointer-events-none absolute inset-0 z-50", children: [_jsx("div", { className: twMerge('absolute inset-0 w-full bg-black/60 backdrop-blur-sm [clip-path:polygon(0%_0%,0%_100%,calc(50%-158px)_100%,calc(50%-158px)_calc(50%-100px),calc(50%+158px)_calc(50%-100px),calc(50%+158px)_calc(50%+100px),calc(50%-158px)_calc(50%+100px),calc(50%-158px)_100%,100%_100%,100%_0%)] md:[clip-path:polygon(0%_0%,0%_100%,calc(50%-225px)_100%,calc(50%-225px)_calc(50%-142px),calc(50%+225px)_calc(50%-142px),calc(50%+225px)_calc(50%+142px),calc(50%-225px)_calc(50%+142px),calc(50%-225px)_100%,100%_100%,100%_0%)]') }), _jsx("div", { className: "absolute inset-0 z-[60] mx-auto flex items-center justify-center", children: _jsx("div", { className: "relative aspect-[1011/638] h-[200px] md:h-[295px] md:w-[450px]", children: _jsx("div", { className: "h-full w-full rounded-lg border-4 border-dashed border-[#B54708]" }) }) })] })] })) : (_jsx("div", { ref: containerRef, className: "relative grid h-full w-full place-items-center rounded-lg object-contain md:max-h-[333px]" })) }), cameraError ? (_jsx("div", { className: "mt-4 text-center", children: _jsx(Button, { className: "mx-auto px-xl lg:w-fit", onClick: () => {
|
|
195
|
+
setCameraError(null);
|
|
196
|
+
startCamera();
|
|
197
|
+
}, children: "Try Again" }) })) : captureInProgress ? (_jsxs(Button, { className: "disabled:bg-bg-disabled disabled:text-text-disabled mx-auto mt-6 px-xl disabled:opacity-100 lg:mt-8 lg:w-fit", onClick: captureAndProcessImage, children: ["Capture Image", _jsx(Camera01Icon, { className: "size-5" })] })) : selectedImage && selectedImage.src ? (_jsxs("div", { className: "mt-4 flex flex-col items-center justify-center gap-2 md:flex-row", children: [_jsxs(Button, { className: "lg:w-fit", type: "button", onClick: retakePhoto, children: ["Retake Photo ", _jsx(Camera01Icon, { className: "ml-1" })] }), _jsxs(Button, { className: "lg:w-fit", type: "button", onClick: uploadPhoto, children: ["Use Photo ", _jsx(CheckCircleIcon, { className: "ml-1" })] })] })) : (_jsxs(Button, { className: "disabled:bg-bg-disabled disabled:text-text-disabled mx-auto mt-6 px-xl disabled:opacity-100 lg:mt-8 lg:w-fit", onClick: startCamera, disabled: isLoading || !!videoStream, children: [isLoading ? 'Starting Camera...' : 'Start Camera', _jsx(Camera01Icon, { className: "size-5" })] }))] }) }) })] }) }));
|
|
198
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CaptureSelfie(): import("react/jsx-runtime").JSX.Element;
|