@opexa/portal-components 0.0.427 → 0.0.428

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.
Files changed (223) hide show
  1. package/dist/components/Jackpots/Jackpots.module.css +184 -184
  2. package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +184 -184
  3. package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +184 -184
  4. package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.module.css +184 -184
  5. package/dist/components/Tournaments/TournamentsList/TournamentItem.module.css +184 -184
  6. package/dist/handlers/index.d.ts +7 -7
  7. package/dist/services/cmsPortal.js +1 -1
  8. package/dist/services/queries.js +2687 -2687
  9. package/dist/styles/theme.css +719 -719
  10. package/dist/ui/AlertDialog/AlertDialog.d.ts +121 -121
  11. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +11 -11
  12. package/dist/ui/Badge/Badge.d.ts +12 -12
  13. package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
  14. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  15. package/dist/ui/Carousel/Carousel.d.ts +45 -45
  16. package/dist/ui/Carousel/carousel.recipe.d.ts +5 -5
  17. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  18. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  19. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  20. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  21. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  22. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  23. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  24. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  25. package/dist/ui/Dialog/Dialog.d.ts +121 -121
  26. package/dist/ui/Dialog/dialog.recipe.d.ts +11 -11
  27. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  28. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  29. package/dist/ui/Field/Field.d.ts +21 -21
  30. package/dist/ui/Field/field.recipe.d.ts +3 -3
  31. package/dist/ui/Menu/Menu.d.ts +198 -198
  32. package/dist/ui/Menu/menu.recipe.d.ts +11 -11
  33. package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
  34. package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
  35. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  36. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  37. package/dist/ui/PinInput/PinInput.d.ts +12 -12
  38. package/dist/ui/PinInput/pinInput.recipe.d.ts +3 -3
  39. package/dist/ui/Popover/Popover.d.ts +55 -55
  40. package/dist/ui/Popover/popover.recipe.d.ts +5 -5
  41. package/dist/ui/Progress/Progress.d.ts +27 -27
  42. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  43. package/dist/ui/QrCode/QrCode.d.ts +25 -25
  44. package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
  45. package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
  46. package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
  47. package/dist/ui/Select/Select.d.ts +45 -45
  48. package/dist/ui/Select/select.recipe.d.ts +3 -3
  49. package/dist/ui/Table/Table.d.ts +21 -21
  50. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  51. package/dist/ui/Table/table.recipe.d.ts +3 -3
  52. package/package.json +161 -161
  53. package/dist/components/DigitainLauncher/Loading.d.ts +0 -1
  54. package/dist/components/DigitainLauncher/Loading.js +0 -5
  55. package/dist/components/Disclaimer/ResponsibleGaming.d.ts +0 -10
  56. package/dist/components/Disclaimer/ResponsibleGaming.js +0 -13
  57. package/dist/components/Disclaimer/TermsOfUse.d.ts +0 -11
  58. package/dist/components/Disclaimer/TermsOfUse.js +0 -13
  59. package/dist/components/FeatureFlag/FeatureFlag.d.ts +0 -1
  60. package/dist/components/FeatureFlag/FeatureFlag.js +0 -29
  61. package/dist/components/FeatureFlag/index.d.ts +0 -1
  62. package/dist/components/FeatureFlag/index.js +0 -1
  63. package/dist/components/KYC/AutoOpen.d.ts +0 -1
  64. package/dist/components/KYC/AutoOpen.js +0 -40
  65. package/dist/components/KYC/BasicInformation.d.ts +0 -1
  66. package/dist/components/KYC/BasicInformation.js +0 -101
  67. package/dist/components/KYC/CaptureIdDocument.d.ts +0 -1
  68. package/dist/components/KYC/CaptureIdDocument.js +0 -219
  69. package/dist/components/KYC/CaptureSelfie.d.ts +0 -1
  70. package/dist/components/KYC/CaptureSelfie.js +0 -285
  71. package/dist/components/KYC/DisplayImage.d.ts +0 -5
  72. package/dist/components/KYC/DisplayImage.js +0 -8
  73. package/dist/components/KYC/FileUpload.d.ts +0 -10
  74. package/dist/components/KYC/FileUpload.js +0 -72
  75. package/dist/components/KYC/IdentityVerification.d.ts +0 -1
  76. package/dist/components/KYC/IdentityVerification.js +0 -120
  77. package/dist/components/KYC/Indicator.d.ts +0 -1
  78. package/dist/components/KYC/Indicator.js +0 -8
  79. package/dist/components/KYC/KYC.lazy.d.ts +0 -6
  80. package/dist/components/KYC/KYC.lazy.js +0 -45
  81. package/dist/components/KYC/KYCContext.d.ts +0 -6
  82. package/dist/components/KYC/KYCContext.js +0 -2
  83. package/dist/components/KYC/NoCameraError.d.ts +0 -7
  84. package/dist/components/KYC/NoCameraError.js +0 -6
  85. package/dist/components/KYC/PersonOverlayDesktop.d.ts +0 -7
  86. package/dist/components/KYC/PersonOverlayDesktop.js +0 -9
  87. package/dist/components/KYC/PersonalInformation.d.ts +0 -1
  88. package/dist/components/KYC/PersonalInformation.js +0 -122
  89. package/dist/components/KYC/backup/Header.d.ts +0 -1
  90. package/dist/components/KYC/backup/Header.js +0 -8
  91. package/dist/components/KYC/backup/Indicator.d.ts +0 -1
  92. package/dist/components/KYC/backup/Indicator.js +0 -9
  93. package/dist/components/KYC/backup/KYC.d.ts +0 -1
  94. package/dist/components/KYC/backup/KYC.js +0 -14
  95. package/dist/components/KYC/backup/KYC.lazy.d.ts +0 -1
  96. package/dist/components/KYC/backup/KYC.lazy.js +0 -26
  97. package/dist/components/KYC/backup/KYCContext.d.ts +0 -6
  98. package/dist/components/KYC/backup/KYCContext.js +0 -2
  99. package/dist/components/KYC/backup/Step1.d.ts +0 -1
  100. package/dist/components/KYC/backup/Step1.js +0 -13
  101. package/dist/components/KYC/backup/Step2.d.ts +0 -1
  102. package/dist/components/KYC/backup/Step2.js +0 -13
  103. package/dist/components/KYC/backup/Step3.d.ts +0 -1
  104. package/dist/components/KYC/backup/Step3.js +0 -13
  105. package/dist/components/KYC/backup/Step4.d.ts +0 -1
  106. package/dist/components/KYC/backup/Step4.js +0 -7
  107. package/dist/components/KYC/backup/useKYC.d.ts +0 -10
  108. package/dist/components/KYC/backup/useKYC.js +0 -8
  109. package/dist/components/KYC/loadModels.d.ts +0 -1
  110. package/dist/components/KYC/loadModels.js +0 -9
  111. package/dist/components/KYC/useKYC.d.ts +0 -25
  112. package/dist/components/KYC/useKYC.js +0 -38
  113. package/dist/components/KYC/utils.d.ts +0 -9
  114. package/dist/components/KYC/utils.js +0 -79
  115. package/dist/components/Messages/Message.d.ts +0 -1
  116. package/dist/components/Messages/Message.js +0 -35
  117. package/dist/components/Messages/MessageContext.d.ts +0 -6
  118. package/dist/components/Messages/MessageContext.js +0 -2
  119. package/dist/components/Messages/MessagePopup.d.ts +0 -1
  120. package/dist/components/Messages/MessagePopup.js +0 -20
  121. package/dist/components/Messages/MessageTrigger.d.ts +0 -8
  122. package/dist/components/Messages/MessageTrigger.js +0 -19
  123. package/dist/components/PortalProvider/CXDTokenObserver.d.ts +0 -1
  124. package/dist/components/PortalProvider/CXDTokenObserver.js +0 -30
  125. package/dist/components/Quests/CountdownTimer.d.ts +0 -15
  126. package/dist/components/Quests/CountdownTimer.js +0 -33
  127. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +0 -4
  128. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.js +0 -78
  129. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.d.ts +0 -8
  130. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.js +0 -9
  131. package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +0 -4
  132. package/dist/components/Quests/OnboardingQuest/OnboardingQuest.js +0 -4
  133. package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +0 -4
  134. package/dist/components/Quests/WageringQuest/WageringQuest.js +0 -20
  135. package/dist/components/Quests/WageringQuest/WageringQuestModal.d.ts +0 -9
  136. package/dist/components/Quests/WageringQuest/WageringQuestModal.js +0 -9
  137. package/dist/components/SignIn/utils.d.ts +0 -8
  138. package/dist/components/SignIn/utils.js +0 -26
  139. package/dist/components/SignUp/SignUp.lazy.d.ts +0 -12
  140. package/dist/components/SignUp/SignUp.lazy.js +0 -18
  141. package/dist/components/SignUp/SignUpContext.d.ts +0 -6
  142. package/dist/components/SignUp/SignUpContext.js +0 -2
  143. package/dist/components/SignUp/SignUpDefault/SignUp.lazy.d.ts +0 -17
  144. package/dist/components/SignUp/SignUpDefault/SignUp.lazy.js +0 -18
  145. package/dist/components/SignUp/SignUpDefault/SignUpContext.d.ts +0 -6
  146. package/dist/components/SignUp/SignUpDefault/SignUpContext.js +0 -2
  147. package/dist/components/SignUp/SignUpDefault/SignUpForm.d.ts +0 -1
  148. package/dist/components/SignUp/SignUpDefault/SignUpForm.js +0 -310
  149. package/dist/components/SignUp/SignUpForm.d.ts +0 -1
  150. package/dist/components/SignUp/SignUpForm.js +0 -284
  151. package/dist/components/SignUp/SignUpKYC/CaptureIdDocument.d.ts +0 -1
  152. package/dist/components/SignUp/SignUpKYC/CaptureIdDocument.js +0 -198
  153. package/dist/components/SignUp/SignUpKYC/CaptureSelfie.d.ts +0 -1
  154. package/dist/components/SignUp/SignUpKYC/CaptureSelfie.js +0 -251
  155. package/dist/components/SignUp/SignUpKYC/ImageUploader.d.ts +0 -10
  156. package/dist/components/SignUp/SignUpKYC/ImageUploader.js +0 -42
  157. package/dist/components/SignUp/SignUpKYC/PersonOverlayDesktop.d.ts +0 -7
  158. package/dist/components/SignUp/SignUpKYC/PersonOverlayDesktop.js +0 -9
  159. package/dist/components/SignUp/SignUpKYC/SignUpFormKYC.d.ts +0 -1
  160. package/dist/components/SignUp/SignUpKYC/SignUpFormKYC.js +0 -464
  161. package/dist/components/SignUp/SignUpKYC/useImageUploader.d.ts +0 -11
  162. package/dist/components/SignUp/SignUpKYC/useImageUploader.js +0 -20
  163. package/dist/components/SignUp/SignUpKYC/utils.d.ts +0 -9
  164. package/dist/components/SignUp/SignUpKYC/utils.js +0 -79
  165. package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.d.ts +0 -1
  166. package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.js +0 -198
  167. package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.d.ts +0 -1
  168. package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.js +0 -251
  169. package/dist/components/SignUp/SignUpPagcor/ImageUploader.d.ts +0 -10
  170. package/dist/components/SignUp/SignUpPagcor/ImageUploader.js +0 -41
  171. package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.d.ts +0 -1
  172. package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.js +0 -429
  173. package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.d.ts +0 -13
  174. package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.js +0 -26
  175. package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.d.ts +0 -7
  176. package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.js +0 -2
  177. package/dist/components/SignUp/SignUpPagcor/useImageUploader.d.ts +0 -11
  178. package/dist/components/SignUp/SignUpPagcor/useImageUploader.js +0 -20
  179. package/dist/components/shared/IdDocumentField.client.d.ts +0 -25
  180. package/dist/components/shared/IdDocumentField.client.js +0 -204
  181. package/dist/components/shared/IdDocumentField.d.ts +0 -2
  182. package/dist/components/shared/IdDocumentField.js +0 -11
  183. package/dist/components/shared/SelfieField.client.d.ts +0 -20
  184. package/dist/components/shared/SelfieField.client.js +0 -327
  185. package/dist/components/shared/SelfieField.d.ts +0 -2
  186. package/dist/components/shared/SelfieField.js +0 -11
  187. package/dist/constants/BranchCode.d.ts +0 -4
  188. package/dist/constants/BranchCode.js +0 -42
  189. package/dist/constants/Branches.d.ts +0 -2
  190. package/dist/constants/Branches.js +0 -42
  191. package/dist/handlers/postTransformIdFrontImage.d.ts +0 -3
  192. package/dist/handlers/postTransformIdFrontImage.js +0 -67
  193. package/dist/handlers/postTransformSelfieImage.d.ts +0 -3
  194. package/dist/handlers/postTransformSelfieImage.js +0 -71
  195. package/dist/handlers.d.ts +0 -43
  196. package/dist/handlers.js +0 -297
  197. package/dist/icons/BellRingIcon.d.ts +0 -2
  198. package/dist/icons/BellRingIcon.js +0 -4
  199. package/dist/images/responsible-gaming-yellow.png +0 -0
  200. package/dist/third-parties/FacebookPixel/FacebookPixel.d.ts +0 -4
  201. package/dist/third-parties/FacebookPixel/FacebookPixel.js +0 -4
  202. package/dist/third-parties/FacebookPixel/api.d.ts +0 -0
  203. package/dist/third-parties/FacebookPixel/api.js +0 -1
  204. package/dist/third-parties/FacebookPixel/index.d.ts +0 -1
  205. package/dist/third-parties/FacebookPixel/index.js +0 -1
  206. package/dist/third-parties/GoogleRecaptcha/GoogleRecaptcha.d.ts +0 -4
  207. package/dist/third-parties/GoogleRecaptcha/GoogleRecaptcha.js +0 -4
  208. package/dist/third-parties/GoogleRecaptcha/api.d.ts +0 -0
  209. package/dist/third-parties/GoogleRecaptcha/api.js +0 -1
  210. package/dist/third-parties/GoogleRecaptcha/index.d.ts +0 -1
  211. package/dist/third-parties/GoogleRecaptcha/index.js +0 -1
  212. package/dist/third-parties/index.d.ts +0 -2
  213. package/dist/third-parties/index.js +0 -2
  214. package/dist/utils/dataUrlToBlob.d.ts +0 -1
  215. package/dist/utils/dataUrlToBlob.js +0 -11
  216. package/dist/utils/gamesAvailable3pmTo3am.d.ts +0 -1
  217. package/dist/utils/gamesAvailable3pmTo3am.js +0 -1
  218. package/dist/utils/getGameName.d.ts +0 -1
  219. package/dist/utils/getGameName.js +0 -6
  220. package/dist/utils/isBetween3amAnd3pm.d.ts +0 -1
  221. package/dist/utils/isBetween3amAnd3pm.js +0 -5
  222. package/dist/utils/resizeImageSize.d.ts +0 -2
  223. package/dist/utils/resizeImageSize.js +0 -11
@@ -1,29 +0,0 @@
1
- 'use client';
2
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { useRouter, useSearchParams } from 'next/navigation';
4
- import { useEffect } from 'react';
5
- import { FEATURE_FLAG_KEY, useFeatureFlag, } from '../../client/hooks/useFeatureFlag.js';
6
- export function FeatureFlag() {
7
- const { featureFlagEnabled, setFeatureFlagEnabled } = useFeatureFlag();
8
- const searchParams = useSearchParams();
9
- const router = useRouter();
10
- useEffect(() => {
11
- const futureFlagParam = searchParams.get('future');
12
- if (futureFlagParam !== null) {
13
- const isEnabled = futureFlagParam === 'true';
14
- setFeatureFlagEnabled(isEnabled);
15
- localStorage.setItem(FEATURE_FLAG_KEY, isEnabled.toString());
16
- }
17
- }, [searchParams, setFeatureFlagEnabled]);
18
- function disableFeatureFlag() {
19
- setFeatureFlagEnabled(false);
20
- localStorage.removeItem(FEATURE_FLAG_KEY);
21
- const params = new URLSearchParams(searchParams.toString());
22
- params.delete('future');
23
- router.replace(`?${params.toString()}`, { scroll: false });
24
- }
25
- if (!featureFlagEnabled) {
26
- return null;
27
- }
28
- return (_jsx("div", { className: "fixed bottom-3 flex w-full flex-col items-center justify-center", children: _jsxs("div", { className: "bg-black/70 p-1", children: ["Experimental features are enabled.", ' ', _jsxs("button", { onClick: () => disableFeatureFlag(), className: "cursor-pointer underline", children: [' ', "Disable"] })] }) }));
29
- }
@@ -1 +0,0 @@
1
- export * from './FeatureFlag';
@@ -1 +0,0 @@
1
- export * from './FeatureFlag.js';
@@ -1 +0,0 @@
1
- export declare function AutoOpen(): null;
@@ -1,40 +0,0 @@
1
- import { useEffect } from 'react';
2
- import { useShallow } from 'zustand/shallow';
3
- import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
4
- import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
5
- import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
6
- import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
7
- import { KYC_PROMPT_LOCALSTORAGE_KEY } from '../../constants/index.js';
8
- export function AutoOpen() {
9
- const kycStore = useGlobalStore(useShallow((ctx) => ctx.kyc));
10
- const { data: session } = useSessionQuery();
11
- const { data: account } = useAccountQuery();
12
- const { data: verification } = useMemberVerificationQuery();
13
- const isBasicInfoCompleted = account?.realName !== null && account?.birthDay !== null;
14
- const isUploadCompleted = verification &&
15
- verification.idFrontImage !== null &&
16
- verification.selfieImage !== null;
17
- const isRejected = Boolean(verification?.status === 'REJECTED');
18
- const step = !isBasicInfoCompleted
19
- ? 1
20
- : isRejected
21
- ? 2
22
- : isUploadCompleted
23
- ? 3
24
- : 2;
25
- const shouldOpen = !isBasicInfoCompleted || !isUploadCompleted || isRejected;
26
- useEffect(() => {
27
- if (session?.status == 'authenticated' &&
28
- shouldOpen &&
29
- localStorage.getItem(KYC_PROMPT_LOCALSTORAGE_KEY) === null) {
30
- kycStore.setKycReminder(true);
31
- return;
32
- }
33
- }, [kycStore, session?.status, shouldOpen]);
34
- useEffect(() => {
35
- if (step) {
36
- kycStore.setStep(step);
37
- }
38
- }, [kycStore, step]);
39
- return null;
40
- }
@@ -1 +0,0 @@
1
- export declare function BasicInformation(): import("react/jsx-runtime").JSX.Element;
@@ -1,101 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { zodResolver } from '@hookform/resolvers/zod';
3
- import { differenceInYears, format, isSameDay, isValid, parse } from 'date-fns';
4
- import { isNil, omitBy, size } from 'lodash-es';
5
- import { useEffect } from 'react';
6
- import { useForm } from 'react-hook-form';
7
- import invariant from 'tiny-invariant';
8
- import { z } from 'zod';
9
- import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
10
- import { useUpdateAccountMutation } from '../../client/hooks/useUpdateAccountMutation.js';
11
- import { toaster } from '../../client/utils/toaster.js';
12
- import { Button } from '../../ui/Button/index.js';
13
- import { Dialog } from '../../ui/Dialog/index.js';
14
- import { Field } from '../../ui/Field/index.js';
15
- import { useKYCContext } from './KYCContext.js';
16
- const definition = z.object({
17
- realName: z
18
- .string()
19
- .min(3, 'Name must be 3 or more characters')
20
- .max(50, 'Name must not be more than 50 characters')
21
- .regex(/^[a-z0-9 ]+$/gi, 'Name must not contain special characters')
22
- .trim(),
23
- birthDay: z
24
- .string()
25
- .min(1, 'Date of birth is required')
26
- .superRefine((value, ctx) => {
27
- const dob = parse(value, 'yyyy-MM-dd', new Date());
28
- if (!isValid(dob)) {
29
- return ctx.addIssue({
30
- code: z.ZodIssueCode.invalid_date,
31
- });
32
- }
33
- const now = new Date();
34
- const age = differenceInYears(now, dob);
35
- if (age < 21) {
36
- return ctx.addIssue({
37
- code: z.ZodIssueCode.custom,
38
- message: 'You must be at least 21 years old',
39
- });
40
- }
41
- }),
42
- branchCode: z.string().min(4).max(10).optional().or(z.literal('')),
43
- });
44
- export function BasicInformation() {
45
- const kyc = useKYCContext();
46
- const form = useForm({
47
- resolver: zodResolver(definition),
48
- mode: 'all',
49
- defaultValues: {
50
- birthDay: '',
51
- branchCode: '',
52
- realName: '',
53
- },
54
- });
55
- const accountQuery = useAccountQuery();
56
- const account = accountQuery.data;
57
- const stepCompleted = account != null && account.realName != null && account.birthDay != null;
58
- useEffect(() => {
59
- if (stepCompleted)
60
- kyc.setStep(2);
61
- }, [stepCompleted, kyc]);
62
- useEffect(() => {
63
- if (account) {
64
- form.reset({
65
- realName: account.realName ?? '',
66
- birthDay: account.birthDay
67
- ? format(account.birthDay, 'yyyy-MM-dd')
68
- : '',
69
- });
70
- }
71
- }, [account, form]);
72
- const updateAccountMutation = useUpdateAccountMutation({
73
- onError(error) {
74
- toaster.error({
75
- title: 'Error',
76
- description: error.message,
77
- });
78
- },
79
- onSuccess() {
80
- kyc.setStep(2);
81
- toaster.success({
82
- title: 'Success',
83
- description: 'Basic information has been set successfully.',
84
- });
85
- },
86
- });
87
- return (_jsxs("div", { children: [_jsx(Dialog.Title, { className: "text-center text-lg font-semibold", children: "Basic Information" }), _jsx(Dialog.Description, { className: "text-text-secondary-700 mt-xs text-center text-sm", children: "Enter your basic details for identification and communication." }), _jsxs("form", { className: "mt-3", onSubmit: form.handleSubmit((data) => {
88
- invariant(account);
89
- const input = omitBy({
90
- realName: account.realName === data.realName ? undefined : data.realName,
91
- birthDay: account.birthDay && isSameDay(data.birthDay, account.birthDay)
92
- ? undefined
93
- : format(data.birthDay, 'yyyy-MM-dd'),
94
- }, isNil);
95
- if (size(input) === 0)
96
- return kyc.setStep(2);
97
- updateAccountMutation.mutate(input);
98
- }), children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.realName, readOnly: !!accountQuery.data?.realName, children: [_jsx(Field.Label, { children: "Real Name" }), _jsx(Field.Input, { placeholder: "Enter your real name", ...form.register('realName') }), _jsx(Field.ErrorText, { children: form.formState.errors.realName?.message })] }), _jsxs(Field.Root, { className: "mt-3", invalid: !!form.formState.errors.branchCode, readOnly: !!accountQuery.data?.birthDay, children: [_jsx(Field.Label, { children: "Date of Birth" }), _jsx(Field.Input, { type: "date", ...form.register('birthDay') }), _jsx(Field.ErrorText, { children: form.formState.errors.birthDay?.message })] }), _jsx(Button, { type: "submit", className: "mt-8", disabled: accountQuery.isLoading ||
99
- updateAccountMutation.isPending ||
100
- stepCompleted, children: "Continue" })] })] }));
101
- }
@@ -1 +0,0 @@
1
- export declare function CaptureIdDocument(): import("react/jsx-runtime").JSX.Element;
@@ -1,219 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useEffect, useRef, useState } from 'react';
4
- import { twMerge } from 'tailwind-merge';
5
- import { useUploadImageFileMutation } from '../../client/hooks/useUploadImageFileMutation.js';
6
- import { ArrowLeftIcon } from '../../icons/ArrowLeftIcon.js';
7
- import { Camera01Icon } from '../../icons/Camera01Icon.js';
8
- import { CheckCircleIcon } from '../../icons/CheckCircleIcon.js';
9
- import { XIcon } from '../../icons/XIcon.js';
10
- import { Button } from '../../ui/Button/index.js';
11
- import { Dialog } from '../../ui/Dialog/index.js';
12
- import { useKYCContext } from './KYCContext.js';
13
- import NoCameraError from './NoCameraError.js';
14
- import { cameraErrorDescriptions, dataURLtoBlob, resizeFile, showPermissionInstructions, } from './utils.js';
15
- export function CaptureIdDocument() {
16
- const kyc = useKYCContext();
17
- const { mutate, isPending } = useUploadImageFileMutation();
18
- const [videoStream, setVideoStream] = useState(null);
19
- const [cameraError, setCameraError] = useState(null);
20
- const [isLoading, setIsLoading] = useState(false);
21
- const [selectedImage, setSelectedImage] = useState(null);
22
- const [captureInProgress, setCaptureInProgress] = useState(false);
23
- const [proccessImageCanvas, setProccessImageCanvas] = useState(null);
24
- const videoElement = useRef(null);
25
- const containerRef = useRef(null);
26
- function stopCamera() {
27
- if (videoStream) {
28
- videoStream.getTracks().forEach((track) => track.stop());
29
- setVideoStream(null);
30
- }
31
- }
32
- useEffect(() => {
33
- return () => {
34
- stopCamera();
35
- };
36
- }, [videoStream]);
37
- async function startCamera() {
38
- try {
39
- setIsLoading(true);
40
- setCameraError(null);
41
- setCaptureInProgress(true);
42
- console.log('Starting camera...');
43
- const stream = await navigator.mediaDevices.getUserMedia({
44
- video: {
45
- facingMode: 'environment',
46
- aspectRatio: 16 / 9,
47
- width: { ideal: 1920, max: 1920 },
48
- height: { ideal: 1080, max: 1080 },
49
- frameRate: {
50
- ideal: 30,
51
- max: 60,
52
- },
53
- },
54
- audio: false,
55
- });
56
- // Set the stream directly to the video element
57
- if (videoElement.current) {
58
- videoElement.current.srcObject = stream;
59
- videoElement.current.onloadedmetadata = () => {
60
- console.log('Video metadata loaded, starting playback...');
61
- videoElement.current
62
- ?.play()
63
- .then(() => {
64
- setVideoStream(stream);
65
- setIsLoading(false);
66
- })
67
- .catch(() => {
68
- setCameraError('Failed to start camera stream. Please try again.');
69
- setIsLoading(false);
70
- // Stop the stream if playback fails
71
- stream.getTracks().forEach((track) => track.stop());
72
- });
73
- };
74
- videoElement.current.onerror = (err) => {
75
- console.error('Video element error:', err);
76
- setCameraError('Video playback error. Please try again.');
77
- setIsLoading(false);
78
- stream.getTracks().forEach((track) => track.stop());
79
- };
80
- }
81
- else {
82
- console.error('Video element not available');
83
- setCameraError('Camera initialization failed. Please try again.');
84
- setCaptureInProgress(false);
85
- setIsLoading(false);
86
- stream.getTracks().forEach((track) => track.stop());
87
- }
88
- }
89
- catch (error) {
90
- setIsLoading(false);
91
- if (error instanceof DOMException) {
92
- console.error('Error accessing camera:', error.message);
93
- setCameraError(error.name);
94
- }
95
- else {
96
- console.error('Unknown error accessing camera:', error);
97
- setCameraError('An unknown error occurred. Please check permissions and try again.');
98
- }
99
- setCaptureInProgress(false);
100
- }
101
- }
102
- function captureAndProcessImage() {
103
- if (!videoElement.current || !videoStream) {
104
- console.error('Video element or stream not available for capture');
105
- return;
106
- }
107
- try {
108
- const canvas = document.createElement('canvas');
109
- const parentDiv = document.getElementById('parent');
110
- canvas.width = parentDiv?.clientWidth || videoElement.current.width;
111
- canvas.height = parentDiv?.clientHeight || videoElement.current.height;
112
- const ctx = canvas.getContext('2d');
113
- if (!ctx) {
114
- console.error('Could not get 2D context for canvas');
115
- setCameraError('Failed to process image. Please try again.');
116
- setCaptureInProgress(false);
117
- return;
118
- }
119
- ctx.drawImage(videoElement.current, 0, 0, canvas.width, canvas.height);
120
- const imageSrc = canvas.toDataURL('image/png', 1.0);
121
- setSelectedImage({ src: imageSrc });
122
- setCaptureInProgress(false);
123
- stopCamera();
124
- const newImg = document.createElement('img');
125
- newImg.src = imageSrc;
126
- //@ts-expect-error jscanify is not typed
127
- const scanner = new jscanify();
128
- newImg.onload = () => {
129
- try {
130
- if (containerRef.current) {
131
- // containerRef.current.innerHTML = '';
132
- const paperWidth = parentDiv?.clientWidth || videoElement.current?.videoWidth;
133
- const paperHeight = parentDiv?.clientHeight || videoElement.current?.videoHeight;
134
- //@ts-expect-error jscanify is not typed
135
- const contour = scanner.findPaperContour(cv.imread(newImg));
136
- const cornerPoints = scanner.getCornerPoints(contour);
137
- const resultCanvas = scanner.extractPaper(newImg, paperWidth, paperHeight, cornerPoints);
138
- newImg.className =
139
- 'absolute inset-0 m-auto w-full h-auto md:max-h-[333px] md:max-w-[643px] aspect-video rounded-lg object-contain';
140
- setProccessImageCanvas(resultCanvas);
141
- containerRef.current.appendChild(resultCanvas);
142
- setCaptureInProgress(false);
143
- setSelectedImage({ src: resultCanvas.toDataURL('image/png') });
144
- }
145
- }
146
- catch (error) {
147
- console.error('Error processing image:', error);
148
- setCameraError('Failed to process image. Please try again.');
149
- }
150
- };
151
- newImg.onerror = () => {
152
- console.error('Error loading image');
153
- setCameraError('NoIdDetectedError');
154
- };
155
- }
156
- catch (error) {
157
- console.error('Error capturing image:', error);
158
- setCameraError('NoIdDetectedError');
159
- setCaptureInProgress(false);
160
- }
161
- }
162
- async function uploadPhoto() {
163
- if (!proccessImageCanvas) {
164
- console.error('Failed to process the image. Please try again.');
165
- return;
166
- }
167
- const blob = proccessImageCanvas.toDataURL('image/png', 1.0);
168
- const processedBlob = dataURLtoBlob(blob);
169
- const img = new File([processedBlob], 'frontImage', { type: 'image/jpeg' });
170
- const resizedImage = (await resizeFile(img));
171
- if (resizedImage) {
172
- await mutate({
173
- file: resizedImage,
174
- }, {
175
- onSuccess: (data) => {
176
- kyc.setFrontImageId(data);
177
- kyc.setCapturing(null);
178
- },
179
- });
180
- }
181
- }
182
- function retakePhoto() {
183
- setSelectedImage(null);
184
- setCaptureInProgress(true);
185
- setCameraError(null);
186
- if (containerRef.current) {
187
- const canvas = containerRef.current.querySelector('canvas');
188
- if (canvas) {
189
- canvas.width = canvas.width;
190
- }
191
- containerRef.current.innerHTML = '';
192
- }
193
- if (videoElement.current) {
194
- videoElement.current.play();
195
- }
196
- startCamera();
197
- }
198
- function checkCameraPermission() {
199
- const constraints = { video: true };
200
- navigator.mediaDevices
201
- .getUserMedia(constraints)
202
- .then(() => {
203
- setCameraError(null);
204
- startCamera();
205
- })
206
- .catch(() => {
207
- showPermissionInstructions();
208
- });
209
- }
210
- return (_jsx(_Fragment, { 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: () => {
211
- stopCamera();
212
- kyc.setCapturing(null);
213
- }, 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: [
214
- 'NotAllowedError',
215
- 'NotReadableError',
216
- 'NotFoundError',
217
- 'NoIdDetectedError',
218
- ].includes(cameraError) ? (_jsx(NoCameraError, { onRetry: checkCameraPermission, title: "Camera Access Required", description: cameraErrorDescriptions[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-[50vh] 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]" })) }), 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, disabled: isPending, children: ["Use Photo ", _jsx(CheckCircleIcon, { className: "ml-1" })] })] })) : (_jsxs(Button, { className: twMerge('disabled:bg-bg-disabled disabled:text-text-disabled mx-auto mt-6 px-xl disabled:opacity-100 lg:mt-8 lg:w-fit', cameraError && 'hidden'), onClick: startCamera, disabled: isLoading || !!videoStream, children: [isLoading ? 'Starting Camera...' : 'Start Camera', _jsx(Camera01Icon, { className: "size-5" })] }))] }) }));
219
- }
@@ -1 +0,0 @@
1
- export declare function CaptureSelfie(): import("react/jsx-runtime").JSX.Element;