@opexa/portal-components 0.0.275 → 0.0.277
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/index.d.ts +65 -0
- package/dist/client/hooks/index.js +65 -0
- package/dist/client/services/index.d.ts +4 -0
- package/dist/client/services/index.js +4 -0
- package/dist/client/utils/index.d.ts +3 -0
- package/dist/client/utils/index.js +3 -0
- package/dist/components/Bonus/Bonus.client.js +1 -1
- package/dist/components/Cashback/Cashback.client.js +1 -1
- package/dist/components/CashbackBonus/CashbackBonus.client.d.ts +2 -0
- package/dist/components/CashbackBonus/CashbackBonus.client.js +9 -0
- package/dist/components/CashbackBonus/CashbackBonus.d.ts +10 -0
- package/dist/components/CashbackBonus/CashbackBonus.js +5 -0
- package/dist/components/CashbackBonus/index.d.ts +1 -0
- package/dist/components/CashbackBonus/index.js +1 -0
- package/dist/components/CustomPromo/CustomPromo.js +1 -1
- package/dist/components/Empty.d.ts +9 -0
- package/dist/components/Empty.js +7 -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/GameLaunch/GameLaunch.lazy.js +1 -1
- package/dist/components/Games/GameContext.d.ts +2 -0
- package/dist/components/Games/GameContext.js +2 -0
- package/dist/components/GamesSearch/GamesSearch.js +1 -1
- package/dist/components/InfiniteScroll.d.ts +10 -0
- package/dist/components/InfiniteScroll.js +25 -0
- package/dist/components/JackpotCounter/JackpotCounter.client.d.ts +2 -0
- package/dist/components/JackpotCounter/JackpotCounter.client.js +66 -0
- package/dist/components/JackpotCounter/JackpotCounter.d.ts +17 -0
- package/dist/components/JackpotCounter/JackpotCounter.js +21 -0
- package/dist/components/JackpotCounter/JackpotCounterItem.d.ts +18 -0
- package/dist/components/JackpotCounter/JackpotCounterItem.js +109 -0
- package/dist/components/JackpotCounter/JackpotCounterItem.module.css +184 -0
- package/dist/components/JackpotCounter/index.d.ts +1 -0
- package/dist/components/JackpotCounter/index.js +1 -0
- package/dist/components/Jackpots/JackpotDesktop.d.ts +1 -0
- package/dist/components/Jackpots/JackpotDesktop.js +45 -0
- package/dist/components/Jackpots/JackpotGameProviders.d.ts +5 -0
- package/dist/components/Jackpots/JackpotGameProviders.js +41 -0
- package/dist/components/Jackpots/JackpotItemDesktop.d.ts +9 -0
- package/dist/components/Jackpots/JackpotItemDesktop.js +43 -0
- package/dist/components/Jackpots/JackpotItemMobile.d.ts +9 -0
- package/dist/components/Jackpots/JackpotItemMobile.js +44 -0
- package/dist/components/Jackpots/JackpotMobile.d.ts +1 -0
- package/dist/components/Jackpots/JackpotMobile.js +46 -0
- package/dist/components/Jackpots/JackpotRules.d.ts +5 -0
- package/dist/components/Jackpots/JackpotRules.js +11 -0
- package/dist/components/Jackpots/Jackpots.client.d.ts +2 -0
- package/dist/components/Jackpots/Jackpots.client.js +29 -0
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +184 -184
- package/dist/components/Jackpots/JackpotsContext.d.ts +4 -0
- package/dist/components/Jackpots/JackpotsContext.js +3 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +184 -184
- package/dist/components/Jackpots/useJackpotData.d.ts +14 -0
- package/dist/components/Jackpots/useJackpotData.js +93 -0
- package/dist/components/Jackpots/useJackpotItemData.d.ts +20 -0
- package/dist/components/Jackpots/useJackpotItemData.js +87 -0
- package/dist/components/KYC/AutoOpen.d.ts +1 -0
- package/dist/components/KYC/AutoOpen.js +45 -0
- package/dist/components/KYC/Header.d.ts +1 -0
- package/dist/components/KYC/Header.js +8 -0
- package/dist/components/KYC/KYCReminder.lazy.js +0 -2
- package/dist/components/KYC/Step1.d.ts +1 -0
- package/dist/components/KYC/Step1.js +13 -0
- package/dist/components/KYC/Step2.d.ts +1 -0
- package/dist/components/KYC/Step2.js +13 -0
- package/dist/components/KYC/Step3.d.ts +1 -0
- package/dist/components/KYC/Step3.js +13 -0
- package/dist/components/KYC/Step4.d.ts +1 -0
- package/dist/components/KYC/Step4.js +7 -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.js +18 -18
- package/dist/components/Messages/Message.d.ts +1 -0
- package/dist/components/Messages/Message.js +34 -0
- package/dist/components/Messages/MessageContext.d.ts +6 -0
- package/dist/components/Messages/MessageContext.js +2 -0
- package/dist/components/Messages/MessageItem.d.ts +4 -0
- package/dist/components/Messages/MessageItem.js +34 -0
- package/dist/components/Messages/MessagePopup.d.ts +1 -0
- package/dist/components/Messages/MessagePopup.js +19 -0
- package/dist/components/Messages/MessageTrigger.d.ts +8 -0
- package/dist/components/Messages/MessageTrigger.js +19 -0
- package/dist/components/Messages/MessagesPopup.js +2 -2
- package/dist/components/News/News.js +1 -1
- package/dist/components/PortalProvider/FeatureFlag.js +1 -1
- package/dist/components/Promo/Promo.client.js +1 -1
- package/dist/components/Promo/PromoContent.d.ts +2 -0
- package/dist/components/Promo/PromoContent.js +9 -0
- package/dist/components/Promos/PromoCarousel.d.ts +2 -0
- package/dist/components/Promos/PromoCarousel.js +41 -0
- package/dist/components/Promos/PromoGrid.d.ts +2 -0
- package/dist/components/Promos/PromoGrid.js +12 -0
- package/dist/components/Promos/PromoItem.d.ts +7 -0
- package/dist/components/Promos/PromoItem.js +10 -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/Search/Search.lazy.js +1 -1
- 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/SignUpForm.js +7 -3
- package/dist/components/SignUp/SignUpForm.d.ts +1 -0
- package/dist/components/SignUp/SignUpForm.js +288 -0
- package/dist/components/SignUp/SignUpKYC/utils.js +18 -18
- package/dist/components/TournamentCounter/TournamentCounter.client.d.ts +2 -0
- package/dist/components/TournamentCounter/TournamentCounter.client.js +50 -0
- package/dist/components/TournamentCounter/TournamentCounter.d.ts +8 -0
- package/dist/components/TournamentCounter/TournamentCounter.js +21 -0
- package/dist/components/TournamentCounter/TournamentCounterItem.d.ts +8 -0
- package/dist/components/TournamentCounter/TournamentCounterItem.js +106 -0
- package/dist/components/TournamentCounter/index.d.ts +1 -0
- package/dist/components/TournamentCounter/index.js +1 -0
- package/dist/components/Tournaments/TournamentDesktop.d.ts +1 -0
- package/dist/components/Tournaments/TournamentDesktop.js +57 -0
- package/dist/components/Tournaments/TournamentGameProviders.d.ts +5 -0
- package/dist/components/Tournaments/TournamentGameProviders.js +38 -0
- package/dist/components/Tournaments/TournamentItemDesktop.d.ts +7 -0
- package/dist/components/Tournaments/TournamentItemDesktop.js +56 -0
- package/dist/components/Tournaments/TournamentItemMobile.d.ts +7 -0
- package/dist/components/Tournaments/TournamentItemMobile.js +54 -0
- package/dist/components/Tournaments/TournamentMobile.d.ts +1 -0
- package/dist/components/Tournaments/TournamentMobile.js +55 -0
- package/dist/components/Tournaments/TournamentRules.d.ts +5 -0
- package/dist/components/Tournaments/TournamentRules.js +11 -0
- package/dist/components/Tournaments/Tournaments.client.d.ts +2 -0
- package/dist/components/Tournaments/Tournaments.client.js +20 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.module.css +184 -184
- package/dist/components/Tournaments/TournamentsContext.d.ts +4 -0
- package/dist/components/Tournaments/TournamentsContext.js +3 -0
- package/dist/components/Tournaments/TournamentsList/TournamentItem.module.css +184 -184
- package/dist/components/Tournaments/useTournamentData.d.ts +10 -0
- package/dist/components/Tournaments/useTournamentData.js +72 -0
- package/dist/components/Tournaments/useTournamentItemData.d.ts +16 -0
- package/dist/components/Tournaments/useTournamentItemData.js +64 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/index.js +33 -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/endpoints.d.ts +10 -0
- package/dist/constants/endpoints.js +41 -0
- package/dist/constants/envVars.d.ts +5 -0
- package/dist/constants/envVars.js +28 -0
- package/dist/constants/gameProviders.d.ts +76 -0
- package/dist/constants/gameProviders.js +361 -0
- package/dist/constants/gameTypes.d.ts +3 -0
- package/dist/constants/gameTypes.js +64 -0
- package/dist/constants/headerKeys.d.ts +2 -0
- package/dist/constants/headerKeys.js +2 -0
- package/dist/constants/secretQuestions.d.ts +3 -0
- package/dist/constants/secretQuestions.js +24 -0
- package/dist/constants/storageKeys.d.ts +2 -0
- package/dist/constants/storageKeys.js +2 -0
- package/dist/handlers/index.d.ts +2 -2
- 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/icons/index.d.ts +65 -0
- package/dist/icons/index.js +65 -0
- package/dist/images/hacksaw-gaming.png +0 -0
- package/dist/server/services/index.d.ts +4 -0
- package/dist/server/services/index.js +4 -0
- package/dist/server/utils/index.d.ts +29 -0
- package/dist/server/utils/index.js +29 -0
- package/dist/services/queries.js +2570 -2570
- package/dist/styles/theme.css +695 -695
- package/dist/ui/Avatar/Avatar.d.ts +9 -9
- package/dist/ui/Avatar/avatar.recipe.d.ts +3 -3
- 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/Field/Field.d.ts +21 -21
- package/dist/ui/Field/field.recipe.d.ts +3 -3
- package/dist/ui/Menu/Menu.d.ts +198 -198
- package/dist/ui/Menu/menu.recipe.d.ts +11 -11
- package/dist/ui/Popover/Popover.d.ts +55 -55
- package/dist/ui/Popover/popover.recipe.d.ts +5 -5
- package/dist/ui/Presence.d.ts +2 -0
- package/dist/ui/Presence.js +7 -0
- package/dist/ui/Progress/Progress.d.ts +27 -27
- package/dist/ui/Progress/progress.recipe.d.ts +3 -3
- package/dist/ui/Prose.d.ts +2 -0
- package/dist/ui/Prose.js +5 -0
- package/dist/ui/QrCode/QrCode.d.ts +25 -25
- package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
- package/dist/ui/Select/Select.d.ts +45 -45
- package/dist/ui/Select/select.recipe.d.ts +3 -3
- package/dist/ui/Table/Table.d.ts +21 -21
- package/dist/ui/Table/table.anatomy.d.ts +1 -1
- package/dist/ui/Table/table.recipe.d.ts +3 -3
- package/dist/ui/Tabs/Tabs.d.ts +15 -15
- package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
- package/dist/ui/index.d.ts +26 -0
- package/dist/ui/index.js +26 -0
- package/dist/utils/createErrorFromCode.d.ts +2 -0
- package/dist/utils/createErrorFromCode.js +11 -0
- package/dist/utils/dataUrlToBlob.d.ts +1 -0
- package/dist/utils/dataUrlToBlob.js +11 -0
- package/dist/utils/index.d.ts +17 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/isMobile.d.ts +5 -0
- package/dist/utils/isMobile.js +9 -0
- package/dist/utils/resizeImageSize.d.ts +1 -0
- package/dist/utils/resizeImageSize.js +6 -0
- package/package.json +163 -163
- package/dist/handlers/postTransformIdFrontImage.d.ts +0 -3
- package/dist/handlers/postTransformIdFrontImage.js +0 -82
- package/dist/handlers/postTransformSelfieImage.d.ts +0 -3
- package/dist/handlers/postTransformSelfieImage.js +0 -82
|
@@ -0,0 +1,288 @@
|
|
|
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 globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
50
|
+
kyc: ctx.kyc,
|
|
51
|
+
})));
|
|
52
|
+
const [step, setStep] = useState(1);
|
|
53
|
+
const dialog = useDialogContext();
|
|
54
|
+
const search = useSearchParams();
|
|
55
|
+
const signInStore = useGlobalStore(useShallow((ctx) => ctx.signIn));
|
|
56
|
+
const signUpMutation = useSignUpMutation();
|
|
57
|
+
const signInMutation = useSignInMutation();
|
|
58
|
+
const updateAccountMutation = useUpdateAccountMutation();
|
|
59
|
+
const sendVerificationCodeMutation = useSendVerificationCodeMutation();
|
|
60
|
+
const localeInfo = useLocaleInfo();
|
|
61
|
+
const mobileNumberParser = useMobileNumberParser();
|
|
62
|
+
const Step1Definition = z.object({
|
|
63
|
+
mobileNumber: z
|
|
64
|
+
.string()
|
|
65
|
+
.min(1, 'Mobile number is required')
|
|
66
|
+
.superRefine((v, ctx) => {
|
|
67
|
+
if (!mobileNumberParser.validate(v)) {
|
|
68
|
+
ctx.addIssue({
|
|
69
|
+
code: z.ZodIssueCode.custom,
|
|
70
|
+
message: 'Invalid mobile number',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
termsAccepted: z.boolean().superRefine((v, ctx) => {
|
|
75
|
+
if (!v) {
|
|
76
|
+
ctx.addIssue({
|
|
77
|
+
code: z.ZodIssueCode.custom,
|
|
78
|
+
message: 'You must accept the terms and conditions',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
realName: z
|
|
83
|
+
.string()
|
|
84
|
+
.min(2, 'Real name must be 2 or more characters')
|
|
85
|
+
.max(50, 'Real name must not be more than 50 characters')
|
|
86
|
+
.trim(),
|
|
87
|
+
birthDay: z
|
|
88
|
+
.date({
|
|
89
|
+
invalid_type_error: 'Date of birth is required',
|
|
90
|
+
required_error: 'Date of birth is required',
|
|
91
|
+
})
|
|
92
|
+
.superRefine((val, ctx) => {
|
|
93
|
+
const now = new Date();
|
|
94
|
+
const age = differenceInYears(now, val);
|
|
95
|
+
if (age < 21) {
|
|
96
|
+
return ctx.addIssue({
|
|
97
|
+
code: z.ZodIssueCode.custom,
|
|
98
|
+
message: 'You must be at least 21 years old',
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
branchCode: z.string().min(1, 'Branch is required').trim(),
|
|
103
|
+
});
|
|
104
|
+
const Step2Definition = z.object({
|
|
105
|
+
verificationCode: z.array(z.string()).superRefine((val, ctx) => {
|
|
106
|
+
if (val.length !== 6 || val.some((v) => v.length !== 1)) {
|
|
107
|
+
ctx.addIssue({
|
|
108
|
+
code: z.ZodIssueCode.custom,
|
|
109
|
+
message: 'Please Enter your 6 digits verification code',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}),
|
|
113
|
+
});
|
|
114
|
+
const step1Form = useForm({
|
|
115
|
+
mode: 'all',
|
|
116
|
+
resolver: zodResolver(Step1Definition),
|
|
117
|
+
defaultValues: {
|
|
118
|
+
mobileNumber: '',
|
|
119
|
+
termsAccepted: false,
|
|
120
|
+
branchCode: signUpProps?.branches?.[0]?.code ?? BRANCHES[0].code,
|
|
121
|
+
realName: '',
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
const step2Form = useForm({
|
|
125
|
+
resolver: zodResolver(Step2Definition),
|
|
126
|
+
defaultValues: {
|
|
127
|
+
verificationCode: Array.from({ length: 6 }).fill(''),
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
const cooldown = useCooldown({
|
|
131
|
+
max: 60,
|
|
132
|
+
duration: 1000 * 60,
|
|
133
|
+
});
|
|
134
|
+
const form2Ref = useRef(null);
|
|
135
|
+
const birthDay = step1Form.watch('birthDay');
|
|
136
|
+
const branchCode = step1Form.watch('branchCode', '');
|
|
137
|
+
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) => {
|
|
138
|
+
try {
|
|
139
|
+
await sendVerificationCodeMutation.mutateAsync({
|
|
140
|
+
channel: 'SMS',
|
|
141
|
+
recipient: mobileNumberParser.format(data.mobileNumber),
|
|
142
|
+
});
|
|
143
|
+
setStep(2);
|
|
144
|
+
cooldown.start();
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
toaster.error({
|
|
148
|
+
description: e instanceof Error
|
|
149
|
+
? e.message
|
|
150
|
+
: 'Failed to send verification code',
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}), 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: {
|
|
154
|
+
paddingLeft: `calc(2.75rem + ${localeInfo.mobileNumber.areaCode.length}ch)`,
|
|
155
|
+
}, ...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) => {
|
|
156
|
+
if (!value)
|
|
157
|
+
return;
|
|
158
|
+
step1Form.setValue('birthDay', value, {
|
|
159
|
+
shouldDirty: true,
|
|
160
|
+
shouldTouch: true,
|
|
161
|
+
shouldValidate: true,
|
|
162
|
+
});
|
|
163
|
+
}, onBlur: () => {
|
|
164
|
+
step1Form.trigger('birthDay');
|
|
165
|
+
} }), _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) => {
|
|
166
|
+
step1Form.setValue('branchCode', details.value.at(0) ??
|
|
167
|
+
signUpProps?.branches?.[0]?.code ??
|
|
168
|
+
BRANCHES[0].code, {
|
|
169
|
+
shouldDirty: true,
|
|
170
|
+
shouldTouch: true,
|
|
171
|
+
shouldValidate: true,
|
|
172
|
+
});
|
|
173
|
+
}, collection: branchCollection, positioning: {
|
|
174
|
+
sameWidth: true,
|
|
175
|
+
placement: 'bottom',
|
|
176
|
+
}, 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: {
|
|
177
|
+
placement: 'top',
|
|
178
|
+
}, 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) => {
|
|
179
|
+
const label = branchCollection.stringifyItem(item) ?? '';
|
|
180
|
+
return (_jsx(Select.Item, { item: item, children: _jsx("div", { title: label, className: "line-clamp-1", children: label }) }, item.code));
|
|
181
|
+
}) }) })] }), _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) => {
|
|
182
|
+
o.field.onChange(details.checked);
|
|
183
|
+
}, 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 ??
|
|
184
|
+
'/terms-and-conditions', onClick: () => {
|
|
185
|
+
dialog.setOpen(false);
|
|
186
|
+
}, 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: () => {
|
|
187
|
+
dialog.setOpen(false);
|
|
188
|
+
signInStore.setOpen(true);
|
|
189
|
+
}, 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 }) => {
|
|
190
|
+
const id = ObjectId.generate(ObjectType.MemberAccount).toString();
|
|
191
|
+
const { mobileNumber } = step1Form.getValues();
|
|
192
|
+
try {
|
|
193
|
+
await signUpMutation.mutateAsync({
|
|
194
|
+
id,
|
|
195
|
+
mobileNumber: mobileNumberParser.format(mobileNumber),
|
|
196
|
+
verificationCode: verificationCode.join(''),
|
|
197
|
+
referralCode: search.get('referralCode') ?? undefined,
|
|
198
|
+
domain: search.get('domain') ?? undefined,
|
|
199
|
+
btag: search.get('btag') ?? undefined,
|
|
200
|
+
});
|
|
201
|
+
const name = mobileNumberParser.format(mobileNumber);
|
|
202
|
+
const password = `${name}${id}`;
|
|
203
|
+
const pollLogin = createPoll(async () => {
|
|
204
|
+
try {
|
|
205
|
+
await signInMutation.mutateAsync({
|
|
206
|
+
type: 'NAME_AND_PASSWORD',
|
|
207
|
+
name,
|
|
208
|
+
password,
|
|
209
|
+
});
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
}, {
|
|
216
|
+
until: (ok) => ok,
|
|
217
|
+
maxAttempt: 3,
|
|
218
|
+
});
|
|
219
|
+
const ok = await pollLogin();
|
|
220
|
+
if (!ok) {
|
|
221
|
+
signInStore.setOpen(true);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
const pollUpdateAccount = createPoll(async () => {
|
|
225
|
+
try {
|
|
226
|
+
await updateAccountMutation.mutateAsync({
|
|
227
|
+
branchCode: step1Form.getValues('branchCode'),
|
|
228
|
+
realName: step1Form.getValues('realName'),
|
|
229
|
+
birthDay: format(step1Form.getValues('birthDay'), 'yyyy-MM-dd'),
|
|
230
|
+
});
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
}, {
|
|
237
|
+
until: (ok) => ok,
|
|
238
|
+
maxAttempt: 3,
|
|
239
|
+
});
|
|
240
|
+
await pollUpdateAccount();
|
|
241
|
+
}
|
|
242
|
+
dialog.setOpen(false);
|
|
243
|
+
step1Form.reset();
|
|
244
|
+
step2Form.reset();
|
|
245
|
+
globalStore.kyc.setOpen(true);
|
|
246
|
+
setStep(1);
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
toaster.error({
|
|
250
|
+
description: error instanceof Error
|
|
251
|
+
? error.message
|
|
252
|
+
: 'Invalid Verification Code',
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}), 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) => {
|
|
256
|
+
o.field.onChange(details.value);
|
|
257
|
+
}, onValueComplete: () => {
|
|
258
|
+
form2Ref.current?.requestSubmit();
|
|
259
|
+
}, 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 () => {
|
|
260
|
+
await sendVerificationCodeMutation.mutateAsync({
|
|
261
|
+
channel: 'SMS',
|
|
262
|
+
recipient: mobileNumberParser.format(step1Form.getValues('mobileNumber')),
|
|
263
|
+
});
|
|
264
|
+
cooldown.start();
|
|
265
|
+
}, children: cooldown.cooling
|
|
266
|
+
? `Resend in ${cooldown.countdown}s`
|
|
267
|
+
: '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: () => {
|
|
268
|
+
setStep(1);
|
|
269
|
+
step2Form.reset();
|
|
270
|
+
cooldown.stop();
|
|
271
|
+
}, children: [_jsx(ArrowLeftIcon, { className: "size-5" }), "Back"] })] })] }))] }));
|
|
272
|
+
}
|
|
273
|
+
const DEVICE_TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
274
|
+
function DateOfBirthField(props) {
|
|
275
|
+
const [value, setValue] = useControllableState({
|
|
276
|
+
value: props.value,
|
|
277
|
+
defaultValue: props.defaultValue ?? null,
|
|
278
|
+
onChange: props.onChange,
|
|
279
|
+
});
|
|
280
|
+
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) => {
|
|
281
|
+
const value = details.value.at(0)?.toDate(DEVICE_TIMEZONE);
|
|
282
|
+
setValue(value ?? null);
|
|
283
|
+
}, 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
|
|
284
|
+
.getMonthsGrid({ columns: 4, format: 'short' })
|
|
285
|
+
.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
|
|
286
|
+
.getYearsGrid({ columns: 4 })
|
|
287
|
+
.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))) }) })] })) }) })] }) })] }));
|
|
288
|
+
}
|
|
@@ -50,24 +50,24 @@ export function validateFile(file) {
|
|
|
50
50
|
return 'Unsupported file';
|
|
51
51
|
}
|
|
52
52
|
export function showPermissionInstructions() {
|
|
53
|
-
const instructions = `
|
|
54
|
-
Camera access is blocked. To enable camera access:
|
|
55
|
-
|
|
56
|
-
Chrome/Edge:
|
|
57
|
-
1. Click the camera icon in the address bar
|
|
58
|
-
2. Select "Always allow" and click "Done"
|
|
59
|
-
3. Or go to Settings > Privacy and security > Site settings > Camera
|
|
60
|
-
|
|
61
|
-
Firefox:
|
|
62
|
-
1. Click the shield icon in the address bar
|
|
63
|
-
2. Click on "Camera blocked"
|
|
64
|
-
3. Select "Allow" and refresh the page
|
|
65
|
-
|
|
66
|
-
Safari:
|
|
67
|
-
1. Go to Safari > Settings > Websites > Camera
|
|
68
|
-
2. Find this website and change to "Allow"
|
|
69
|
-
|
|
70
|
-
After changing permissions, please refresh the page and try again.
|
|
53
|
+
const instructions = `
|
|
54
|
+
Camera access is blocked. To enable camera access:
|
|
55
|
+
|
|
56
|
+
Chrome/Edge:
|
|
57
|
+
1. Click the camera icon in the address bar
|
|
58
|
+
2. Select "Always allow" and click "Done"
|
|
59
|
+
3. Or go to Settings > Privacy and security > Site settings > Camera
|
|
60
|
+
|
|
61
|
+
Firefox:
|
|
62
|
+
1. Click the shield icon in the address bar
|
|
63
|
+
2. Click on "Camera blocked"
|
|
64
|
+
3. Select "Allow" and refresh the page
|
|
65
|
+
|
|
66
|
+
Safari:
|
|
67
|
+
1. Go to Safari > Settings > Websites > Camera
|
|
68
|
+
2. Find this website and change to "Allow"
|
|
69
|
+
|
|
70
|
+
After changing permissions, please refresh the page and try again.
|
|
71
71
|
`;
|
|
72
72
|
alert(instructions);
|
|
73
73
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import useEmblaCarousel from 'embla-carousel-react';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
6
|
+
import { useTournamentsQuery } from '../../client/hooks/index.js';
|
|
7
|
+
import { ArrowLeftIcon, ArrowRightIcon, ChevronRightIcon } from '../../icons/index.js';
|
|
8
|
+
import { Button } from '../../ui/index.js';
|
|
9
|
+
import { TournamentCounterItem } from './TournamentCounterItem.js';
|
|
10
|
+
export function TournamentCounter__client(props) {
|
|
11
|
+
const [emblaRef, emblaApi] = useEmblaCarousel({
|
|
12
|
+
align: 'start',
|
|
13
|
+
slidesToScroll: 1,
|
|
14
|
+
});
|
|
15
|
+
const scrollPrev = useCallback(() => {
|
|
16
|
+
if (emblaApi)
|
|
17
|
+
emblaApi.scrollPrev();
|
|
18
|
+
}, [emblaApi]);
|
|
19
|
+
const scrollNext = useCallback(() => {
|
|
20
|
+
if (emblaApi)
|
|
21
|
+
emblaApi.scrollNext();
|
|
22
|
+
}, [emblaApi]);
|
|
23
|
+
const [canScrollPrev, setCanScrollPrev] = useState(false);
|
|
24
|
+
const [canScrollNext, setCanScrollNext] = useState(false);
|
|
25
|
+
const onSelect = useCallback(() => {
|
|
26
|
+
if (!emblaApi)
|
|
27
|
+
return;
|
|
28
|
+
setCanScrollPrev(emblaApi.canScrollPrev());
|
|
29
|
+
setCanScrollNext(emblaApi.canScrollNext());
|
|
30
|
+
}, [emblaApi]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!emblaApi)
|
|
33
|
+
return;
|
|
34
|
+
onSelect();
|
|
35
|
+
emblaApi.on('select', onSelect);
|
|
36
|
+
emblaApi.on('reInit', onSelect);
|
|
37
|
+
}, [emblaApi, onSelect]);
|
|
38
|
+
const tournamentsQuery = useTournamentsQuery({
|
|
39
|
+
first: 100,
|
|
40
|
+
filter: {
|
|
41
|
+
status: {
|
|
42
|
+
equal: 'ACTIVE',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const tournaments = tournamentsQuery.data?.pages[0].edges.map((edge) => edge.node) ?? [];
|
|
47
|
+
if (tournaments.length <= 0)
|
|
48
|
+
return null;
|
|
49
|
+
return (_jsxs("div", { className: props.className, children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-lg font-semibold", children: props.heading ?? 'Tournaments' }), _jsxs("div", { className: "flex items-center md:gap-3xl", children: [_jsxs(Link, { href: props.viewAllUrl ?? '/tournaments', className: "text-button-tertiary-fg flex gap-sm text-sm font-semibold", children: ["See All", _jsx(ChevronRightIcon, { className: "size-5 lg:hidden" })] }), _jsxs("div", { className: "hidden lg:flex", children: [_jsx(Button, { disabled: !canScrollPrev, onClick: scrollPrev, variant: "outline", colorScheme: "gray", className: "rounded-r-none border-r-0", "aria-label": "Previous", children: _jsx(ArrowLeftIcon, { className: "size-5" }) }), _jsxs(Button, { disabled: !canScrollNext, onClick: scrollNext, variant: "outline", colorScheme: "gray", className: "rounded-l-none", "aria-label": "Next", children: [_jsx("span", { className: "sr-only", children: "Next" }), _jsx(ArrowRightIcon, { className: "size-5" })] })] })] })] }), _jsx("div", { className: "relative mt-lg lg:overflow-hidden", ref: emblaRef, children: _jsx("div", { className: "flex gap-2.5", children: tournaments.map((tournament, i) => (_jsx(TournamentCounterItem, { tournament: tournament, viewAllUrl: props.viewAllUrl, className: "w-full" }, i))) }) })] }));
|
|
50
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface TournamentCounterProps {
|
|
2
|
+
/** @default "Tournaments" */
|
|
3
|
+
heading?: string;
|
|
4
|
+
/** @default "/tournaments" */
|
|
5
|
+
viewAllUrl?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function TournamentCounter(props: TournamentCounterProps): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { prefetchJackpotsQuery } from '../../server/utils/index.js';
|
|
3
|
+
import { TournamentCounter__client } from './TournamentCounter.client.js';
|
|
4
|
+
export async function TournamentCounter(props) {
|
|
5
|
+
await prefetchJackpotsQuery({
|
|
6
|
+
first: 100,
|
|
7
|
+
filter: {
|
|
8
|
+
status: {
|
|
9
|
+
equal: 'ACTIVE',
|
|
10
|
+
},
|
|
11
|
+
deleted: {
|
|
12
|
+
equal: false,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
sort: {
|
|
16
|
+
cursor: 'POOL',
|
|
17
|
+
order: 'DESC',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
return _jsx(TournamentCounter__client, { ...props });
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Tournament } from '@opexa/portal-sdk-core';
|
|
2
|
+
export interface TournamentCounterItemProps {
|
|
3
|
+
tournament: Tournament;
|
|
4
|
+
className?: string;
|
|
5
|
+
/** @default "/tournaments" */
|
|
6
|
+
viewAllUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function TournamentCounterItem({ tournament, className, viewAllUrl, }: TournamentCounterItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { pick } from 'lodash-es';
|
|
4
|
+
import Image from 'next/image';
|
|
5
|
+
import Link from 'next/link';
|
|
6
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
7
|
+
import { twMerge } from 'tailwind-merge';
|
|
8
|
+
import { useLocaleInfo } from '../../client/hooks/index.js';
|
|
9
|
+
import { ChevronRightIcon, Trophy01Icon, User01Icon } from '../../icons/index.js';
|
|
10
|
+
import { Award01Icon } from '../../icons/Award01Icon.js';
|
|
11
|
+
import { StarIcon } from '../../icons/StarIcon.js';
|
|
12
|
+
import firstPlace from '../../images/first-place.png';
|
|
13
|
+
import trophyTwo from '../../images/trophy-two.png';
|
|
14
|
+
import trophy from '../../images/trophy.png';
|
|
15
|
+
import { formatNumber, mask } from '../../utils/index.js';
|
|
16
|
+
import styles from '../JackpotCounter/JackpotCounterItem.module.css';
|
|
17
|
+
export function TournamentCounterItem({ tournament, className, viewAllUrl, }) {
|
|
18
|
+
const localeInfo = useLocaleInfo();
|
|
19
|
+
const [timeRemaining, setTimeRemaining] = useState({
|
|
20
|
+
days: 0,
|
|
21
|
+
hours: 0,
|
|
22
|
+
minutes: 0,
|
|
23
|
+
seconds: 0,
|
|
24
|
+
isPast: false,
|
|
25
|
+
});
|
|
26
|
+
const activationEndDateTime = useMemo(() => new Date(tournament.activationEndDateTime), [tournament.activationEndDateTime]);
|
|
27
|
+
const calculateRemainingTime = React.useCallback(() => {
|
|
28
|
+
const now = new Date();
|
|
29
|
+
const diffMs = activationEndDateTime.getTime() - now.getTime();
|
|
30
|
+
if (diffMs <= 0) {
|
|
31
|
+
setTimeRemaining({
|
|
32
|
+
days: 0,
|
|
33
|
+
hours: 0,
|
|
34
|
+
minutes: 0,
|
|
35
|
+
seconds: 0,
|
|
36
|
+
isPast: true,
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const diffSeconds = Math.floor(diffMs / 1000);
|
|
41
|
+
const days = Math.floor(diffSeconds / (3600 * 24));
|
|
42
|
+
const hours = Math.floor((diffSeconds % (3600 * 24)) / 3600);
|
|
43
|
+
const minutes = Math.floor((diffSeconds % 3600) / 60);
|
|
44
|
+
const seconds = diffSeconds % 60;
|
|
45
|
+
const updated = pick({ days, hours, minutes, seconds, isPast: false }, [
|
|
46
|
+
'days',
|
|
47
|
+
'hours',
|
|
48
|
+
'minutes',
|
|
49
|
+
'seconds',
|
|
50
|
+
'isPast',
|
|
51
|
+
]);
|
|
52
|
+
setTimeRemaining(updated);
|
|
53
|
+
}, [activationEndDateTime]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
calculateRemainingTime();
|
|
56
|
+
const interval = setInterval(calculateRemainingTime, 1000); // Update every second
|
|
57
|
+
return () => clearInterval(interval);
|
|
58
|
+
}, [activationEndDateTime, calculateRemainingTime]);
|
|
59
|
+
const timeParts = [
|
|
60
|
+
{ label: 'Day', value: timeRemaining.days },
|
|
61
|
+
{ label: 'Hour', value: timeRemaining.hours },
|
|
62
|
+
{ label: 'Min', value: timeRemaining.minutes },
|
|
63
|
+
{ label: 'Sec', value: timeRemaining.seconds },
|
|
64
|
+
];
|
|
65
|
+
const tournamentReward = Object.values(tournament.rewardSettings)
|
|
66
|
+
.map(Number)
|
|
67
|
+
.reduce((sum, val) => sum + val, 0);
|
|
68
|
+
const prizeAmountsByRank = Object.values(tournament.rewardSettings).map(Number);
|
|
69
|
+
return (_jsxs("div", { className: twMerge('bg-bg-tertiary border-border-primary relative flex shrink-0 rounded-2xl border p-3 text-center lg:gap-6 lg:p-5', className), children: [_jsx("div", { className: "z-1 relative flex flex-1 flex-col", children: _jsx("div", { className: "flex h-full flex-col justify-between", children: _jsx("div", { className: "flex w-full justify-between", children: _jsxs("div", { className: "flex w-full flex-col", children: [_jsxs("div", { className: "relative flex w-full justify-between", children: [_jsxs("div", { className: "w-full", children: [_jsxs("div", { className: "flex w-full justify-between", children: [_jsxs("div", { className: "border-utility-brand-200 bg-utility-brand-50 text-utility-brand-700 flex h-fit w-fit items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium", children: [_jsx(Award01Icon, { className: "text-utility-brand-500 size-3.5" }), "Multiplier"] }), _jsx("div", { className: "flex h-fit", children: timeParts.map((part, idx) => (_jsxs(React.Fragment, { children: [_jsxs("div", { className: twMerge('bg-bg-primary text-text-primary-900 flex h-fit w-8 flex-col items-center rounded-[4px] pb-1.5'), children: [_jsx("span", { className: "text-base font-medium", children: String(part.value).padStart(2, '0') }), _jsx("span", { className: "text-[8px]", children: part.label })] }), idx < timeParts.length - 1 && (_jsxs("div", { className: "flex flex-col justify-center gap-[6px] px-[6px]", children: [_jsx("div", { className: "bg-bg-primary h-1 w-1 rounded-full" }), _jsx("div", { className: "bg-bg-primary h-1 w-1 rounded-full" })] }))] }, part.label))) })] }), _jsxs("div", { className: "flex justify-between", children: [_jsxs("div", { children: [_jsx("div", { className: "text-text-primary-900 mt-2.5 text-left text-lg font-medium lg:mt-5 lg:text-2xl", children: tournament.name }), _jsx("div", { className: "bg-bg-primary text-brand-400 mt-1.5 w-fit rounded-md px-2 py-1 text-2xl font-bold lg:mt-2 lg:text-4xl", children: formatNumber(tournamentReward, {
|
|
70
|
+
currency: localeInfo.currency.code,
|
|
71
|
+
minDecimalPlaces: 2,
|
|
72
|
+
maxDecimalPlaces: 2,
|
|
73
|
+
}) }), _jsx("div", { className: "text-text-primary-900 mt-4 block text-left text-base lg:hidden", children: "Play and Win!" })] }), _jsx("div", { className: "flex items-end lg:hidden", children: _jsx(Image, { src: trophy, alt: "trophy", quality: 100, width: 155, height: 155, className: "h-23 w-auto" }) })] })] }), _jsx("div", { className: "z-1 absolute -bottom-16 right-0 hidden lg:block", children: _jsx(Image, { quality: 100, width: 155, height: 155, src: trophy, alt: "trophy", className: "px-6 py-2.5" }) })] }), tournament.topPayouts.length ? (_jsx("div", { children: _jsxs("div", { className: "bg-bg-primary relative mt-4 hidden w-full gap-4 rounded-lg p-4 lg:flex", children: [_jsxs("div", { className: "bg-bg-tertiary relative flex h-18 w-18 items-center justify-center rounded-full", children: [_jsx(User01Icon, { className: "text-text-quarterary-500 size-9" }), _jsx("div", { className: "bg-yellow-400 text-brand-950 border-bg-primary absolute bottom-0 right-0 flex h-6 w-6 items-center justify-center rounded-full border-[1.5px] text-xs font-bold", children: "1st" })] }), _jsxs("div", { className: "flex flex-col gap-1 text-left", children: [_jsxs("div", { className: "border-utility-brand-200 bg-utility-brand-50 text-utility-brand-700 flex h-fit w-fit items-center gap-1 rounded-sm border px-2 py-0.5 text-xs font-medium", children: [_jsx(Trophy01Icon, { className: "text-utility-brand-600 size-3.5" }), "Top Payout"] }), _jsx("div", { className: "font-semibold", children: mask(tournament?.topPayouts[0]?.member?.name || '') }), _jsx("div", { className: "text-brand-400 text-2xl", children: formatNumber(tournament?.topPayouts[0]?.amount, {
|
|
74
|
+
currency: localeInfo.currency.code,
|
|
75
|
+
minDecimalPlaces: 2,
|
|
76
|
+
maxDecimalPlaces: 2,
|
|
77
|
+
}) })] })] }) })) : (_jsxs("div", { className: "bg-bg-primary relative mt-4 hidden w-full gap-4 rounded-lg p-4 lg:flex", children: [_jsx(Image, { width: 66, height: 87, src: firstPlace, alt: "closeChest", className: "size-full h-auto w-[66px] mix-blend-luminosity" }), _jsxs("div", { className: "flex flex-col gap-1 text-left", children: [_jsxs("div", { className: "border-utility-brand-200 bg-utility-brand-50 text-utility-brand-700 flex h-fit w-fit items-center gap-1 rounded-sm border px-2 py-0.5 text-xs font-medium", children: [_jsx(Trophy01Icon, { className: "text-utility-brand-600 size-3.5" }), "Top Payout"] }), _jsx("div", { className: "font-semibold", children: "No winners yet" }), _jsx("div", { className: "text-text-secondary-700 text-xs", children: "You could be the first to win the tournament!" })] })] }))] }) }) }) }), _jsxs("div", { className: "z-1 hidden flex-1 space-y-4 lg:block", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Image, { width: 24, height: 24, src: trophyTwo, quality: 100, alt: "leaderboardIcon", className: "size-full w-6" }), _jsx("div", { className: "text-text-primary-900 text-lg font-semibold", children: tournament.currentLeaderboard.edges.length
|
|
78
|
+
? 'Leaderboard'
|
|
79
|
+
: 'Starting soon!' })] }), _jsxs(Link, { className: "text-button-tertiary-fg flex text-sm font-semibold", href: viewAllUrl ?? '/tournaments', children: ["See details", _jsx(ChevronRightIcon, { className: "size-5" })] })] }), _jsx("div", { className: twMerge('max-h-[272px] overflow-y-scroll', styles['scrollArea']), children: _jsx("div", { className: "border-gray-200 overflow-hidden rounded-xl", children: _jsxs("table", { className: "w-full", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-bg-secondary text-text-tertiary-600 h-8 text-xs font-medium", children: [_jsx("th", { className: "w-[52px]", children: "#" }), _jsx("th", { children: "Player" }), _jsx("th", { children: "Multiplier" }), _jsx("th", { children: "Prize" })] }) }), _jsx("tbody", { children: tournament.currentLeaderboard.edges.length ? (_jsx(_Fragment, { children: tournament.currentLeaderboard.edges.map((tournament, i) => (_jsxs("tr", { className: "bg-bg-primary text-text-secondary-700 text-sm", children: [_jsx("td", { className: "border-border-secondary h-12 w-[52px] border-t-2", children: i + 1 < 6 ? (_jsxs("div", { className: "relative", children: [_jsx(StarIcon, { className: twMerge('mx-auto size-6.5', starTierStyles[i].starColor) }), _jsx("span", { className: twMerge('absolute inset-0 mt-0.5 flex items-center justify-center text-2xs font-bold', starTierStyles[i].numberColor), children: i + 1 })] })) : (i + 1) }), _jsx("td", { className: "border-border-secondary h-12 border-t-2", children: mask(tournament.node.username) }), _jsxs("td", { className: "border-border-secondary h-12 border-t-2", children: [tournament.node.multiplier, "x"] }), i + 1 <= prizeAmountsByRank.length ? (_jsx("td", { className: "border-border-secondary text-brand-400 h-12 border-t-2", children: formatNumber(prizeAmountsByRank[i], {
|
|
80
|
+
currency: localeInfo.currency.code,
|
|
81
|
+
minDecimalPlaces: 2,
|
|
82
|
+
maxDecimalPlaces: 2,
|
|
83
|
+
}) })) : (_jsx("td", { className: "border-border-secondary h-12 border-t-2", children: "-" }))] }, i))) })) : (_jsx(_Fragment, { children: Array.from({ length: 10 }).map((_, i) => (_jsxs("tr", { className: "bg-bg-primary text-text-secondary-700 text-sm", children: [_jsx("td", { className: "border-border-secondary h-12 w-[52px] border-t-2", children: i + 1 < 6 ? (_jsxs("div", { className: "relative", children: [_jsx(StarIcon, { className: twMerge('mx-auto size-6.5', starTierStyles[i].starColor) }), _jsx("span", { className: twMerge('absolute inset-0 mt-0.5 flex items-center justify-center text-2xs font-bold', starTierStyles[i].numberColor), children: i + 1 })] })) : (i + 1) }), _jsx("td", { className: "border-border-secondary h-12 border-t-2", children: "-" }), _jsx("td", { className: "border-border-secondary h-12 border-t-2", children: "-" }), _jsx("td", { className: "border-border-secondary h-12 border-t-2", children: "-" })] }, i))) })) })] }) }) })] })] }));
|
|
84
|
+
}
|
|
85
|
+
const starTierStyles = [
|
|
86
|
+
{
|
|
87
|
+
starColor: 'text-yellow-400',
|
|
88
|
+
numberColor: 'text-bg-primary',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
starColor: 'text-utility-gray-700',
|
|
92
|
+
numberColor: 'text-bg-primary',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
starColor: 'text-yellow-700',
|
|
96
|
+
numberColor: 'text-bg-primary',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
starColor: 'text-bg-quaternary',
|
|
100
|
+
numberColor: 'text-text-primary-900',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
starColor: 'text-bg-quaternary',
|
|
104
|
+
numberColor: 'text-text-primary-900',
|
|
105
|
+
},
|
|
106
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TournamentCounter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TournamentCounter.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function TournamentDesktop(): import("react/jsx-runtime").JSX.Element;
|