@opexa/portal-components 0.0.106 → 0.0.108
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/useAuthenticateMutation.js +2 -1
- package/dist/client/hooks/useCheckInDailyCheckInQuestMutation.d.ts +1 -1
- package/dist/client/hooks/useCheckInDailyCheckInQuestMutation.js +20 -2
- package/dist/client/hooks/useClaimCashbackBonusMutation.js +2 -1
- package/dist/client/hooks/useClaimSpotBonusMutation.js +2 -1
- package/dist/client/hooks/useCompleteOnboardingMutation.d.ts +3 -0
- package/dist/client/hooks/useCompleteOnboardingMutation.js +25 -0
- package/dist/client/hooks/useCreateGCashDepositMutation.js +2 -1
- package/dist/client/hooks/useCreateGCashWithdrawalMutation.js +1 -1
- package/dist/client/hooks/useCreateGameSessionMutation.js +1 -1
- package/dist/client/hooks/useCreateInstapayWithdrawalMutation.js +1 -1
- package/dist/client/hooks/useCreateMayaAppDepositMutation.js +2 -1
- package/dist/client/hooks/useCreateMayaAppWithdrawalMutation.js +1 -1
- package/dist/client/hooks/useCreateMayaDepositMutation.js +2 -1
- package/dist/client/hooks/useCreateMayaWithdrawalMutation.js +1 -1
- package/dist/client/hooks/useCreateMemberVerificationMutation.d.ts +4 -0
- package/dist/client/hooks/useCreateMemberVerificationMutation.js +45 -0
- package/dist/client/hooks/useCreateOnlineBankDepositMutation.js +2 -1
- package/dist/client/hooks/useCreateQRPHDepositMutation.js +2 -1
- package/dist/client/hooks/useEndGameSessionMutation.js +1 -1
- package/dist/client/hooks/useFileQuery.d.ts +2 -0
- package/dist/client/hooks/useFileQuery.js +30 -0
- package/dist/client/hooks/useMarkGameAsFavoriteMutation.js +24 -5
- package/dist/client/hooks/useMarkMessageAsReadMutation.js +16 -7
- package/dist/client/hooks/useOnboardingStatusQuery.d.ts +2 -0
- package/dist/client/hooks/useOnboardingStatusQuery.js +28 -0
- package/dist/client/hooks/useRecommendedGamesQuery.d.ts +2 -0
- package/dist/client/hooks/useRecommendedGamesQuery.js +27 -0
- package/dist/client/hooks/useSendVerificationCodeMutation.js +1 -1
- package/dist/client/hooks/useSignInMutation.js +2 -1
- package/dist/client/hooks/useSignOutMutation.js +2 -1
- package/dist/client/hooks/useSignUpMutation.js +1 -1
- package/dist/client/hooks/useSiteQuery.d.ts +2 -0
- package/dist/client/hooks/useSiteQuery.js +16 -0
- package/dist/client/hooks/useSkipOnboardingMutation.d.ts +2 -0
- package/dist/client/hooks/useSkipOnboardingMutation.js +25 -0
- package/dist/client/hooks/useUnmarkGameAsFavoriteMutation.js +5 -5
- package/dist/client/hooks/useUpdateAccountMutation.js +2 -1
- package/dist/client/hooks/useUpdateMemberVerificationMutation.d.ts +6 -0
- package/dist/client/hooks/useUpdateMemberVerificationMutation.js +38 -0
- package/dist/client/hooks/useUploadImageFileMutation.d.ts +4 -0
- package/dist/client/hooks/useUploadImageFileMutation.js +24 -0
- package/dist/client/utils/createContext.js +1 -1
- package/dist/client/utils/createRecipeContext.js +1 -1
- package/dist/components/BetRecords/BetRecords.client.js +1 -1
- package/dist/components/Bonuses/Bonuses.client.js +1 -1
- package/dist/components/Disclaimer/DisclaimerV1.js +1 -1
- package/dist/components/Games/Game.js +1 -1
- package/dist/components/Games/GamesCarousel.client.js +1 -1
- package/dist/components/Games/GamesList.client.js +1 -1
- package/dist/components/Jackpots/JackpotsList/JackpotsList.d.ts +1 -0
- package/dist/components/Jackpots/JackpotsList/JackpotsList.js +1 -1
- package/dist/components/Jackpots/JackpotsList/JackpotsListItemDesktop.d.ts +2 -1
- package/dist/components/Jackpots/JackpotsList/JackpotsListItemDesktop.js +3 -3
- package/dist/components/Jackpots/JackpotsList/JackpotsListItemMobile.d.ts +2 -1
- package/dist/components/Jackpots/JackpotsList/JackpotsListItemMobile.js +2 -2
- package/dist/components/KYC/BasicInformation.js +85 -4
- package/dist/components/KYC/CaptureIdDocument.d.ts +1 -0
- package/dist/components/KYC/CaptureIdDocument.js +11 -0
- package/dist/components/KYC/CaptureSelfie.d.ts +1 -0
- package/dist/components/KYC/CaptureSelfie.js +11 -0
- package/dist/components/KYC/IdentityVerification.js +20 -4
- package/dist/components/KYC/Indicator.js +1 -1
- package/dist/components/KYC/KYC.lazy.js +7 -1
- package/dist/components/KYC/PersonalInformation.js +92 -5
- package/dist/components/KYC/useKYC.d.ts +15 -0
- package/dist/components/KYC/useKYC.js +18 -1
- package/dist/components/Messages/Messages.lazy.js +1 -1
- package/dist/components/News/News.d.ts +10 -0
- package/dist/components/News/News.js +10 -0
- package/dist/components/News/index.d.ts +1 -0
- package/dist/components/News/index.js +1 -0
- package/dist/components/NewsFeed/NewsFeed.d.ts +18 -0
- package/dist/components/NewsFeed/NewsFeed.js +11 -0
- package/dist/components/NewsFeed/index.d.ts +1 -0
- package/dist/components/NewsFeed/index.js +1 -0
- package/dist/components/Promos/PromosCarousel.js +1 -1
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +1 -4
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.js +28 -25
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestRules.d.ts +6 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestRules.js +15 -0
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +1 -4
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.js +27 -3
- package/dist/components/Quests/OnboardingQuest/OnboardingQuestRules.d.ts +6 -0
- package/dist/components/Quests/OnboardingQuest/OnboardingQuestRules.js +15 -0
- package/dist/components/Quests/Quests.client.js +22 -7
- package/dist/components/Quests/QuestsContext.d.ts +2 -0
- package/dist/components/Quests/QuestsContext.js +2 -0
- package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +1 -4
- package/dist/components/Quests/WageringQuest/WageringQuest.js +12 -9
- package/dist/components/Quests/WageringQuest/WageringQuestRules.d.ts +7 -0
- package/dist/components/Quests/WageringQuest/WageringQuestRules.js +17 -0
- package/dist/components/Search/Search.lazy.d.ts +8 -0
- package/dist/components/Search/Search.lazy.js +8 -3
- package/dist/components/SignIn/MobileNumberSignIn.js +7 -4
- package/dist/components/SignIn/NameAndPasswordSignIn.js +10 -5
- package/dist/components/SignUp/SignUpForm.js +13 -7
- package/dist/components/TransactionRecords/DepositRecordsTable.js +1 -1
- package/dist/components/TransactionRecords/TransactionRecordsTable.js +1 -1
- package/dist/components/TransactionRecords/WithdrawalRecordsTable.js +1 -1
- package/dist/constants/{endpoints.js → Endpoint.js} +1 -1
- package/dist/constants/index.d.ts +7 -7
- package/dist/constants/index.js +7 -7
- package/dist/server/utils/prefetchAccountQuery.js +5 -2
- package/dist/server/utils/prefetchAvailablePromosQuery.js +5 -2
- package/dist/server/utils/prefetchAvailableQuestsCountQuery.js +5 -2
- package/dist/server/utils/prefetchAvailableQuestsQuery.js +5 -2
- package/dist/server/utils/prefetchBetRecordsQuery.js +5 -2
- package/dist/server/utils/prefetchBonusQuery.js +5 -2
- package/dist/server/utils/prefetchBonusesCountQuery.js +5 -2
- package/dist/server/utils/prefetchBonusesQuery.js +5 -2
- package/dist/server/utils/prefetchCashbackBonusQuery.js +5 -2
- package/dist/server/utils/prefetchCashbackBonusesCountQuery.js +5 -2
- package/dist/server/utils/prefetchCashbackBonusesQuery.js +5 -2
- package/dist/server/utils/prefetchCashbackQuery.js +5 -2
- package/dist/server/utils/prefetchCashbacksQuery.js +5 -2
- package/dist/server/utils/prefetchDepositQuery.js +5 -2
- package/dist/server/utils/prefetchDepositRecordsQuery.js +5 -2
- package/dist/server/utils/prefetchDepositsCountQuery.js +5 -2
- package/dist/server/utils/prefetchFavoriteGamesQuery.js +5 -2
- package/dist/server/utils/prefetchFileQuery.d.ts +1 -0
- package/dist/server/utils/prefetchFileQuery.js +23 -0
- package/dist/server/utils/prefetchGamesQuery.js +5 -2
- package/dist/server/utils/prefetchInstapayBankListQuery.js +5 -2
- package/dist/server/utils/prefetchIsMayaSessionValidQuery.js +5 -2
- package/dist/server/utils/prefetchJackpotsCountQuery.js +5 -2
- package/dist/server/utils/prefetchJackpotsQuery.js +5 -2
- package/dist/server/utils/prefetchMemberVerificationQuery.js +5 -2
- package/dist/server/utils/prefetchOnboardingStatusQuery.d.ts +1 -0
- package/dist/server/utils/prefetchOnboardingStatusQuery.js +24 -0
- package/dist/server/utils/prefetchPaymentSettingsQuery.js +5 -2
- package/dist/server/utils/prefetchPlatformQuery.js +5 -2
- package/dist/server/utils/prefetchProfileCompletionQuery.js +5 -2
- package/dist/server/utils/prefetchPromoQuery.js +5 -2
- package/dist/server/utils/prefetchPromosQuery.js +5 -2
- package/dist/server/utils/prefetchRecommendedGamesQuery.d.ts +1 -0
- package/dist/server/utils/prefetchRecommendedGamesQuery.js +23 -0
- package/dist/server/utils/prefetchSessionQuery.js +6 -3
- package/dist/server/utils/prefetchSiteQuery.d.ts +1 -0
- package/dist/server/utils/prefetchSiteQuery.js +17 -0
- package/dist/server/utils/prefetchTopWinsQuery.js +5 -2
- package/dist/server/utils/prefetchTournamentsCountQuery.js +5 -2
- package/dist/server/utils/prefetchTournamentsQuery.js +5 -2
- package/dist/server/utils/prefetchTransactionRecordsQuery.js +5 -2
- package/dist/server/utils/prefetchUnreadMessagesCountQuery.js +5 -2
- package/dist/server/utils/prefetchWalletQuery.js +5 -2
- package/dist/server/utils/prefetchWithdrawalRecordsQuery.js +5 -2
- package/dist/services/account.d.ts +1 -0
- package/dist/services/account.js +11 -1
- package/dist/services/queries.d.ts +2 -1
- package/dist/services/queries.js +19 -1
- package/dist/styles/theme.css +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
- package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
- package/dist/ui/Checkbox/checkbox.recipe.js +2 -2
- package/dist/ui/Combobox/Combobox.d.ts +42 -42
- package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
- package/dist/ui/Dialog/dialog.recipe.js +1 -1
- package/dist/ui/Menu/Menu.d.ts +144 -144
- package/dist/ui/Menu/menu.recipe.d.ts +8 -8
- 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/callIfFn.d.ts +8 -0
- package/dist/utils/callIfFn.js +8 -0
- package/dist/utils/createPoll.d.ts +1 -0
- package/dist/utils/createPoll.js +1 -0
- package/dist/utils/createSplitProps.d.ts +9 -0
- package/dist/utils/createSplitProps.js +9 -0
- package/dist/utils/log.d.ts +3 -0
- package/dist/utils/log.js +18 -0
- package/dist/utils/mutationKeys.d.ts +29 -0
- package/dist/utils/mutationKeys.js +104 -0
- package/dist/utils/queryKeys.d.ts +5 -24
- package/dist/utils/queryKeys.js +80 -97
- package/package.json +1 -1
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.d.ts +0 -8
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.js +0 -9
- package/dist/components/Quests/WageringQuest/WageringQuestModal.d.ts +0 -9
- package/dist/components/Quests/WageringQuest/WageringQuestModal.js +0 -9
- /package/dist/components/{Empty.d.ts → shared/Empty.d.ts} +0 -0
- /package/dist/components/{Empty.js → shared/Empty.js} +0 -0
- /package/dist/components/{InfiniteScroll.d.ts → shared/InfiniteScroll.d.ts} +0 -0
- /package/dist/components/{InfiniteScroll.js → shared/InfiniteScroll.js} +0 -0
- /package/dist/constants/{endpoints.d.ts → Endpoint.d.ts} +0 -0
- /package/dist/constants/{envVars.d.ts → EnvVar.d.ts} +0 -0
- /package/dist/constants/{envVars.js → EnvVar.js} +0 -0
- /package/dist/constants/{gameProviders.d.ts → GameProvider.d.ts} +0 -0
- /package/dist/constants/{gameProviders.js → GameProvider.js} +0 -0
- /package/dist/constants/{gameTypes.d.ts → GameType.d.ts} +0 -0
- /package/dist/constants/{gameTypes.js → GameType.js} +0 -0
- /package/dist/constants/{headerKeys.d.ts → HeaderKey.d.ts} +0 -0
- /package/dist/constants/{headerKeys.js → HeaderKey.js} +0 -0
- /package/dist/constants/{secretQuestions.d.ts → SecretQuestion.d.ts} +0 -0
- /package/dist/constants/{secretQuestions.js → SecretQuestion.js} +0 -0
- /package/dist/constants/{storageKeys.d.ts → StorageKey.d.ts} +0 -0
- /package/dist/constants/{storageKeys.js → StorageKey.js} +0 -0
|
@@ -1,20 +1,107 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { useForm } from 'react-hook-form';
|
|
5
|
+
import { z } from 'zod';
|
|
2
6
|
import { useShallow } from 'zustand/shallow';
|
|
7
|
+
import { useCreateMemberVerificationMutation } from '../../client/hooks/useCreateMemberVerificationMutation.js';
|
|
3
8
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
9
|
+
import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
|
|
10
|
+
import { useUpdateMemberVerificationMutation } from '../../client/hooks/useUpdateMemberVerificationMutation.js';
|
|
11
|
+
import { toaster } from '../../client/utils/toaster.js';
|
|
4
12
|
import { CheckIcon } from '../../icons/CheckIcon.js';
|
|
5
13
|
import { Button } from '../../ui/Button/index.js';
|
|
6
14
|
import { Checkbox } from '../../ui/Checkbox/index.js';
|
|
7
15
|
import { Dialog } from '../../ui/Dialog/index.js';
|
|
8
16
|
import { Field } from '../../ui/Field/index.js';
|
|
9
17
|
import { useKYCContext } from './KYCContext.js';
|
|
18
|
+
const definition = z.object({
|
|
19
|
+
address: z.string().trim().min(1, 'Current address is required'),
|
|
20
|
+
permanentAddress: z.string().trim().min(1, 'Permanent address is required'),
|
|
21
|
+
sourceOfIncome: z.string().trim().min(1, 'Source of Income is required'),
|
|
22
|
+
natureOfWork: z.string().trim().min(1, 'Nature of Work is required'),
|
|
23
|
+
placeOfBirth: z.string().trim().min(1, 'Place of Birth is required'),
|
|
24
|
+
nationality: z.string().trim().min(1, 'Nationality is required'),
|
|
25
|
+
});
|
|
10
26
|
export function PersonalInformation() {
|
|
11
27
|
const kyc = useKYCContext();
|
|
12
28
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
13
29
|
kyc: ctx.kyc,
|
|
14
30
|
})));
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
const memberVerificationQuery = useMemberVerificationQuery();
|
|
32
|
+
const memberVerification = memberVerificationQuery.data;
|
|
33
|
+
const updateMemberVerificationMutation = useUpdateMemberVerificationMutation({
|
|
34
|
+
onError(error) {
|
|
35
|
+
toaster.error({
|
|
36
|
+
description: error.message,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
onSuccess() {
|
|
40
|
+
kyc.setDone(true);
|
|
41
|
+
globalStore.kyc.setOpen(false);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
const createMemberVerificationMutation = useCreateMemberVerificationMutation({
|
|
45
|
+
onError(error) {
|
|
46
|
+
toaster.error({
|
|
47
|
+
description: error.message,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
onSuccess() {
|
|
51
|
+
kyc.setDone(true);
|
|
52
|
+
globalStore.kyc.setOpen(false);
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
const form = useForm({
|
|
56
|
+
resolver: zodResolver(definition),
|
|
57
|
+
defaultValues: {
|
|
58
|
+
address: '',
|
|
59
|
+
nationality: '',
|
|
60
|
+
natureOfWork: '',
|
|
61
|
+
placeOfBirth: '',
|
|
62
|
+
permanentAddress: '',
|
|
63
|
+
},
|
|
64
|
+
mode: 'all',
|
|
65
|
+
});
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (memberVerification) {
|
|
68
|
+
form.reset(memberVerification);
|
|
69
|
+
}
|
|
70
|
+
}, [form, memberVerification]);
|
|
71
|
+
const address = form.watch('address');
|
|
72
|
+
const permanentAddress = form.watch('permanentAddress');
|
|
73
|
+
return (_jsxs("div", { children: [_jsx(Dialog.Title, { className: "text-center text-lg font-semibold", children: "Personal Information" }), _jsx(Dialog.Description, { className: "text-text-secondary-700 mt-xs text-center text-sm", children: "Provide your basic details and work info." }), _jsxs("form", { className: "mt-7", onSubmit: form.handleSubmit((data) => {
|
|
74
|
+
if (memberVerification) {
|
|
75
|
+
updateMemberVerificationMutation.mutate({
|
|
76
|
+
id: memberVerification.id,
|
|
77
|
+
data: {
|
|
78
|
+
...data,
|
|
79
|
+
selfieImage: '',
|
|
80
|
+
idFrontImage: '',
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
createMemberVerificationMutation.mutate({
|
|
86
|
+
...data,
|
|
87
|
+
selfieImage: '',
|
|
88
|
+
idFrontImage: '',
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}), children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.permanentAddress, children: [_jsx(Field.Label, { children: "Permanent address" }), _jsx(Field.Input, { placeholder: "Enter your permanent address", ...form.register('permanentAddress') }), _jsx(Field.ErrorText, { children: form.formState.errors.permanentAddress?.message })] }), _jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.address, children: [_jsx(Field.Label, { children: "Current address" }), _jsx(Field.Input, { placeholder: "Enter your current address", ...form.register('address') }), _jsx(Field.ErrorText, { children: form.formState.errors.address?.message })] }), _jsxs(Checkbox.Root, { className: "mt-md", checked: address !== '' &&
|
|
92
|
+
permanentAddress !== '' &&
|
|
93
|
+
address === permanentAddress, onCheckedChange: (details) => {
|
|
94
|
+
if (details.checked === true) {
|
|
95
|
+
form.setValue('address', form.getValues('permanentAddress'), {
|
|
96
|
+
shouldDirty: true,
|
|
97
|
+
shouldTouch: true,
|
|
98
|
+
shouldValidate: true,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}, disabled: !permanentAddress, children: [_jsx(Checkbox.Control, { children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsx(Checkbox.Label, { children: "Use permanent address as current address" }), _jsx(Checkbox.HiddenInput, {})] }), _jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.sourceOfIncome, children: [_jsx(Field.Label, { children: "Source of income" }), _jsx(Field.Input, { placeholder: "Enter your source of income", ...form.register('sourceOfIncome') }), _jsx(Field.ErrorText, { children: form.formState.errors.sourceOfIncome?.message })] }), _jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.natureOfWork, children: [_jsx(Field.Label, { children: "Work Description" }), _jsx(Field.Input, { placeholder: "Enter your work description", ...form.register('natureOfWork') }), _jsx(Field.ErrorText, { children: form.formState.errors.natureOfWork?.message })] }), _jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.placeOfBirth, children: [_jsx(Field.Label, { children: "Place of birth" }), _jsx(Field.Input, { placeholder: "Enter your place of birth", ...form.register('placeOfBirth') }), _jsx(Field.ErrorText, { children: form.formState.errors.placeOfBirth?.message })] }), _jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.nationality, children: [_jsx(Field.Label, { children: "Nationality" }), _jsx(Field.Input, { placeholder: "Enter your nationality", ...form.register('nationality') }), _jsx(Field.ErrorText, { children: form.formState.errors.nationality?.message })] }), _jsx(Button, { type: "submit", className: "mt-4xl", disabled: updateMemberVerificationMutation.isPending ||
|
|
102
|
+
createMemberVerificationMutation.isPending, children: "Continue" }), _jsx(Button, { variant: "outline", colorScheme: "gray", className: "mt-lg", onClick: () => {
|
|
103
|
+
kyc.setDone(true);
|
|
104
|
+
globalStore.kyc.setOpen(false);
|
|
105
|
+
}, disabled: updateMemberVerificationMutation.isPending ||
|
|
106
|
+
createMemberVerificationMutation.isPending, children: "Skip for now" })] })] }));
|
|
20
107
|
}
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
type EventDetail = {
|
|
2
|
+
type: 'SELFIE_CAPTURED';
|
|
3
|
+
data: string;
|
|
4
|
+
} | {
|
|
5
|
+
type: 'ID_DOCUMENT_CAPTURED';
|
|
6
|
+
data: string;
|
|
7
|
+
};
|
|
8
|
+
type UnsubscribeFn = () => void;
|
|
9
|
+
type Subscriber = (detail: EventDetail) => UnsubscribeFn;
|
|
10
|
+
type CaptureSubject = 'SELFIE' | 'ID_DOCUMENT';
|
|
1
11
|
export interface UseKYCReturn {
|
|
2
12
|
step: number;
|
|
3
13
|
setStep: (step: number) => void;
|
|
4
14
|
done: boolean;
|
|
5
15
|
setDone: (done: boolean) => void;
|
|
16
|
+
capturing: CaptureSubject | null;
|
|
17
|
+
setCapturing: (capturing: CaptureSubject | null) => void;
|
|
18
|
+
subscribe: (subscriber: Subscriber) => UnsubscribeFn;
|
|
19
|
+
triggerEvent: (detail: EventDetail) => void;
|
|
6
20
|
}
|
|
7
21
|
export declare function useKYC(): UseKYCReturn;
|
|
22
|
+
export {};
|
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
2
|
export function useKYC() {
|
|
3
3
|
const [step, setStep] = useState(1);
|
|
4
4
|
const [done, setDone] = useState(false);
|
|
5
|
+
const [capturing, setCapturing] = useState(null);
|
|
6
|
+
const subscribers = useRef([]);
|
|
7
|
+
const subscribe = (subscriber) => {
|
|
8
|
+
subscribers.current.push(subscriber);
|
|
9
|
+
return () => {
|
|
10
|
+
subscribers.current = subscribers.current.filter((item) => item !== subscriber);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const triggerEvent = (detail) => {
|
|
14
|
+
subscribers.current.forEach((subscriber) => {
|
|
15
|
+
subscriber(detail);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
5
18
|
return {
|
|
6
19
|
step,
|
|
7
20
|
setStep,
|
|
8
21
|
done,
|
|
9
22
|
setDone,
|
|
23
|
+
capturing,
|
|
24
|
+
setCapturing,
|
|
25
|
+
subscribe,
|
|
26
|
+
triggerEvent,
|
|
10
27
|
};
|
|
11
28
|
}
|
|
@@ -11,7 +11,7 @@ import { XIcon } from '../../icons/XIcon.js';
|
|
|
11
11
|
import { Drawer } from '../../ui/Drawer/index.js';
|
|
12
12
|
import { Portal } from '../../ui/Portal/index.js';
|
|
13
13
|
import { Tabs } from '../../ui/Tabs/index.js';
|
|
14
|
-
import { InfiniteScroll } from '../InfiniteScroll.js';
|
|
14
|
+
import { InfiniteScroll } from '../shared/InfiniteScroll.js';
|
|
15
15
|
import { Message } from './Message.js';
|
|
16
16
|
import { MessageContext } from './MessageContext.js';
|
|
17
17
|
import { MessagePopup } from './MessagePopup.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { News as TNews } from '../../types';
|
|
3
|
+
export interface NewsProps {
|
|
4
|
+
news: TNews;
|
|
5
|
+
/** @default 'News' */
|
|
6
|
+
viewAllUrl?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
}
|
|
10
|
+
export declare function News(props: NewsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Image from 'next/image';
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { ChevronLeftIcon } from '../../icons/ChevronLeftIcon.js';
|
|
5
|
+
import { Prose } from '../../ui/Prose/index.js';
|
|
6
|
+
export function News(props) {
|
|
7
|
+
return (_jsxs("div", { style: props.style, className: props.className, children: [_jsxs(Link, { href: props.viewAllUrl ?? '/news', className: "text-button-secondary-fg flex items-center gap-lg text-lg font-semibold", children: [_jsx(ChevronLeftIcon, { className: "size-6" }), "Back to all News"] }), _jsx(Image, { src: props.news.image, alt: "", width: 356, height: 244, className: "mt-3xl block h-auto w-full rounded-xl lg:mt-6" }), _jsx("p", { className: "text-brand-400 mt-xl text-sm font-semibold lg:mt-6", children: props.news.category }), _jsx("h2", { className: "mt-xl text-2xl font-semibold lg:mt-6", children: props.news.title }), _jsx(Prose, { className: "mt-xl lg:mt-6", dangerouslySetInnerHTML: {
|
|
8
|
+
__html: props.news.content,
|
|
9
|
+
} })] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './News';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './News.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { News } from '../../types';
|
|
3
|
+
export interface NewsFeedProps {
|
|
4
|
+
newsFeed: News[];
|
|
5
|
+
/** @default 'News' */
|
|
6
|
+
heading?: string;
|
|
7
|
+
/**
|
|
8
|
+
* @default '/news'
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* '/custom-path' // '/custom-path/123'
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
viewDetailsUrl?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
}
|
|
18
|
+
export declare function NewsFeed(props: NewsFeedProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Image from 'next/image';
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { Button } from '../../ui/Button/index.js';
|
|
5
|
+
export function NewsFeed(props) {
|
|
6
|
+
const heading = props.heading ?? 'News';
|
|
7
|
+
const viewDetailsUrl = props.viewDetailsUrl ?? '/news';
|
|
8
|
+
return (_jsxs("div", { style: props.style, className: props.className, children: [_jsx("h2", { className: "text-lg font-semibold", children: heading }), _jsx("div", { className: "mt-lg grid gap-3xl lg:grid-cols-3 lg:gap-2xl", children: props.newsFeed.map((news) => (_jsxs("div", { className: "bg-bg-primary-alt border-border-primary flex flex-col overflow-hidden rounded-2xl border shadow-md", children: [_jsx(Image, { src: news.image, alt: "", width: 356, height: 244, className: "block h-auto w-full" }), _jsxs("div", { className: "flex grow flex-col p-3xl", children: [_jsxs("div", { className: "grow", children: [_jsx("p", { className: "text-brand-400 text-sm font-semibold", children: news.category }), _jsx("h2", { className: "mt-2 text-lg font-semibold", children: news.title }), _jsx("p", { className: "text-text-tertiary-600 mt-xs line-clamp-3", dangerouslySetInnerHTML: {
|
|
9
|
+
__html: news.content,
|
|
10
|
+
} })] }), _jsx(Button, { asChild: true, className: "mt-2xl", children: _jsx(Link, { href: `${viewDetailsUrl}/${news.id}`, children: "Read More" }) })] })] }, news.id))) })] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NewsFeed';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NewsFeed.js';
|
|
@@ -11,7 +11,7 @@ import { ArrowRightIcon } from '../../icons/ArrowRightIcon.js';
|
|
|
11
11
|
import { ChevronRightIcon } from '../../icons/ChevronRightIcon.js';
|
|
12
12
|
import { Gift01Icon } from '../../icons/Gift01Icon.js';
|
|
13
13
|
import { Button } from '../../ui/Button/index.js';
|
|
14
|
-
import { Empty } from '../Empty.js';
|
|
14
|
+
import { Empty } from '../shared/Empty.js';
|
|
15
15
|
import { Cashback } from './Cashback.js';
|
|
16
16
|
import { Promo } from './Promo.js';
|
|
17
17
|
export function PromosCarousel(props) {
|
|
@@ -4,6 +4,8 @@ import { addDays, isEqual, startOfDay } from 'date-fns';
|
|
|
4
4
|
import { useState } from 'react';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
6
6
|
import { useCheckInDailyCheckInQuestMutation } from '../../../client/hooks/useCheckInDailyCheckInQuestMutation.js';
|
|
7
|
+
import { useDisclosure } from '../../../client/hooks/useDisclosure.js';
|
|
8
|
+
import { useLocaleInfo } from '../../../client/hooks/useLocaleInfo.js';
|
|
7
9
|
import { toaster } from '../../../client/utils/toaster.js';
|
|
8
10
|
import { CalendarIcon } from '../../../icons/CalendarIcon.js';
|
|
9
11
|
import { CheckIcon } from '../../../icons/CheckIcon.js';
|
|
@@ -11,13 +13,19 @@ import { ClockStopWatchIcon } from '../../../icons/ClockStopWatchIcon.js';
|
|
|
11
13
|
import { InfoCircleIcon } from '../../../icons/InfoCircleIcon.js';
|
|
12
14
|
import { Badge } from '../../../ui/Badge/index.js';
|
|
13
15
|
import { Button } from '../../../ui/Button/index.js';
|
|
16
|
+
import { dataAttr } from '../../../utils/dataAttr.js';
|
|
17
|
+
import { formatNumber } from '../../../utils/formatNumber.js';
|
|
14
18
|
import { getQueryClient } from '../../../utils/getQueryClient.js';
|
|
19
|
+
import { parseDecimal } from '../../../utils/parseDecimal.js';
|
|
15
20
|
import { getAvailableQuestsQueryKey } from '../../../utils/queryKeys.js';
|
|
16
21
|
import CountdownTimer from '../CountdownTimer.js';
|
|
17
|
-
import {
|
|
18
|
-
|
|
22
|
+
import { useQuestContext } from '../QuestsContext.js';
|
|
23
|
+
import { DailyCheckInQuestRules } from './DailyCheckInQuestRules.js';
|
|
24
|
+
export function DailyCheckInQuest() {
|
|
25
|
+
const quest = useQuestContext();
|
|
19
26
|
const queryClient = getQueryClient();
|
|
20
|
-
const
|
|
27
|
+
const disclosure = useDisclosure();
|
|
28
|
+
const localeInfo = useLocaleInfo();
|
|
21
29
|
const [isExpired, setIsExpired] = useState(false);
|
|
22
30
|
const { name, description, status, lastCheckInDate, progressPercentage, checkInStreak, thirdDayBonusAmount, sixthDayBonusAmount, seventhDayBonusAmount, endDateTime, id, } = quest;
|
|
23
31
|
const today = startOfDay(new Date());
|
|
@@ -25,26 +33,23 @@ export function DailyCheckInQuest({ quest }) {
|
|
|
25
33
|
? isEqual(today, startOfDay(new Date(lastCheckInDate)))
|
|
26
34
|
: false;
|
|
27
35
|
const checkedInRewards = {
|
|
28
|
-
3: thirdDayBonusAmount,
|
|
29
|
-
6: sixthDayBonusAmount,
|
|
30
|
-
7: seventhDayBonusAmount,
|
|
36
|
+
3: parseDecimal(thirdDayBonusAmount, 0),
|
|
37
|
+
6: parseDecimal(sixthDayBonusAmount, 0),
|
|
38
|
+
7: parseDecimal(seventhDayBonusAmount, 0),
|
|
31
39
|
};
|
|
32
40
|
const dailyCheckedInData = Array.from({ length: 7 }, (_, i) => {
|
|
33
41
|
const day = i + 1;
|
|
34
42
|
return {
|
|
35
43
|
day,
|
|
36
|
-
reward: checkedInRewards[day]
|
|
44
|
+
reward: checkedInRewards[day] ? checkedInRewards[day] : null,
|
|
37
45
|
};
|
|
38
46
|
});
|
|
39
|
-
const
|
|
47
|
+
const checkInDailyQuestMutation = useCheckInDailyCheckInQuestMutation({
|
|
40
48
|
onSuccess() {
|
|
41
49
|
toaster.success({
|
|
42
50
|
title: 'Check-in successful 🎉',
|
|
43
51
|
description: 'You’ve successfully checked in for today! Keep it up to maintain your streak!',
|
|
44
52
|
});
|
|
45
|
-
queryClient.invalidateQueries({
|
|
46
|
-
queryKey: getAvailableQuestsQueryKey(),
|
|
47
|
-
});
|
|
48
53
|
},
|
|
49
54
|
onError(e) {
|
|
50
55
|
toaster.error({
|
|
@@ -53,26 +58,24 @@ export function DailyCheckInQuest({ quest }) {
|
|
|
53
58
|
});
|
|
54
59
|
},
|
|
55
60
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "border-border-primary bg-bg-tertiary flex h-full w-full flex-col space-y-6 rounded-2xl border px-4 pb-6 pt-5", children: [_jsxs("div", { className: "flex flex-col space-y-2", children: [_jsxs("div", { className: "flex max-h-7.5 items-start justify-between", children: [_jsx(CountdownTimer, { endDateTime: endDateTime, renderAction: (timeLeft) => (_jsxs(Badge.Root, { size: "lg", colorScheme: "brand", round: false, children: [_jsx(Badge.Icon, { children: _jsx(ClockStopWatchIcon, {}) }), _jsxs(Badge.Label, { children: [timeLeft.days, "d:", timeLeft.hours, "h:", timeLeft.minutes, "m:", timeLeft.seconds, "s"] })] })), onEnd: () => setIsExpired(true) }), _jsx("div", { role: "button", className: "bg-bg-primary border-border-secondary flex size-9 cursor-pointer items-center justify-center rounded-md border", onClick: () => disclosure.setOpen(true), children: _jsx(InfoCircleIcon, { className: "text-text-disabled size-5" }) })] }), _jsx("p", { className: "text-xl font-semibold", children: name }), _jsx("p", { className: "text-text-secondary-700 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: description } })] }), _jsxs("div", { className: "flex w-full flex-col space-y-2", children: [_jsx("div", { className: "grid grid-cols-7", children: dailyCheckedInData.map((item) => {
|
|
62
|
+
const reward = item.reward
|
|
63
|
+
? `+${formatNumber(item.reward, {
|
|
64
|
+
currency: localeInfo.currency.code,
|
|
65
|
+
minDecimalPlaces: 0,
|
|
66
|
+
maxDecimalPlaces: 0,
|
|
67
|
+
})}`
|
|
68
|
+
: '-';
|
|
62
69
|
return (_jsx("div", { className: twMerge('flex items-center justify-center', item.day <= (checkInStreak || 0)
|
|
63
70
|
? 'text-brand-400'
|
|
64
71
|
: 'text-text-secondary-700'), children: _jsx("p", { children: reward }) }, item.day));
|
|
65
|
-
}) }), _jsx("div", { className: "bg-bg-primary h-2 w-full overflow-hidden rounded-full", children: _jsx("div", { className: "bg-utility-brand-600 h-full rounded-full transition-all duration-300", style: { width: `${progressPercentage}%` } }) }), _jsx("div", { className: "grid grid-cols-7", children: dailyCheckedInData.map((item) => (
|
|
72
|
+
}) }), _jsx("div", { className: "bg-bg-primary h-2 w-full overflow-hidden rounded-full", children: _jsx("div", { className: "bg-utility-brand-600 h-full rounded-full transition-all duration-300", style: { width: `${progressPercentage}%` } }) }), _jsx("div", { className: "grid grid-cols-7 place-items-center", children: dailyCheckedInData.map((item) => (_jsxs("div", { className: "text-text-secondary-700 ui-active:text-brand-400 group relative size-fit", "data-active": dataAttr(item.day <= (checkInStreak ?? 0)), children: [_jsx(CalendarIcon, { className: "h-4.5 w-auto" }), _jsx("p", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-2xs leading-none", children: item.day })] }, item.day))) })] }), _jsx(Button, { onClick: () => checkInDailyQuestMutation.mutate(id), className: "disabled:bg-bg-primary disabled:text-text-disabled", disabled: isExpired ||
|
|
66
73
|
status === 'COMPLETED' ||
|
|
67
74
|
status === 'FAILED' ||
|
|
68
|
-
hasCheckedInToday
|
|
75
|
+
hasCheckedInToday ||
|
|
76
|
+
checkInDailyQuestMutation.isPending, children: hasCheckedInToday && status === 'IN_PROGRESS' ? (_jsx(CountdownTimer, { endDateTime: startOfDay(addDays(new Date(), 1)).toISOString(), renderAction: (timeLeft) => (_jsxs("div", { className: "flex items-center space-x-0.5", children: [_jsx(CheckIcon, { className: "size-5" }), _jsxs("p", { children: [timeLeft.hours, "h:", timeLeft.minutes, "m:", timeLeft.seconds, "s"] })] })), onEnd: () => {
|
|
69
77
|
queryClient.invalidateQueries({
|
|
70
78
|
queryKey: getAvailableQuestsQueryKey(),
|
|
71
79
|
});
|
|
72
|
-
} })) : ('Check-In') })] })] }));
|
|
73
|
-
}
|
|
74
|
-
function CalendarWithDayNumber({ day, currentCheckedInDays, }) {
|
|
75
|
-
return (_jsxs("div", { className: twMerge('group relative h-fit w-fit', day <= currentCheckedInDays
|
|
76
|
-
? 'text-brand-400'
|
|
77
|
-
: 'text-text-secondary-700'), children: [_jsx(CalendarIcon, {}), _jsx("div", { className: "absolute inset-0 mt-1 flex items-center justify-center text-2xs lg:mt-[2px]", children: _jsx("p", { className: "text-center", children: day }) })] }));
|
|
80
|
+
} })) : ('Check-In') })] }), _jsx(DailyCheckInQuestRules, { open: disclosure.open, onOpenChange: disclosure.setOpen })] }));
|
|
78
81
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useControllableState } from '../../../client/hooks/useControllableState.js';
|
|
4
|
+
import { XIcon } from '../../../icons/XIcon.js';
|
|
5
|
+
import { Button } from '../../../ui/Button/index.js';
|
|
6
|
+
import { Dialog } from '../../../ui/Dialog/index.js';
|
|
7
|
+
import { Portal } from '../../../ui/Portal/index.js';
|
|
8
|
+
export function DailyCheckInQuestRules(props) {
|
|
9
|
+
const [open, setOpen] = useControllableState({
|
|
10
|
+
value: props.open,
|
|
11
|
+
defaultValue: props.defaultOpen ?? false,
|
|
12
|
+
onChange: props.onOpenChange,
|
|
13
|
+
});
|
|
14
|
+
return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: open, onOpenChange: (details) => setOpen(details.open), closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto max-w-[343px] rounded-xl px-4 pb-0 pt-5", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "flex flex-col space-y-5", children: [_jsx("h2", { className: "text-text-primary-900 text-lg font-semibold", children: "Daily Check-In Rules" }), _jsxs("ol", { className: "text-text-tertiary-600 group list-disc text-wrap pl-4 text-sm font-normal", children: [_jsx("li", { children: "Earn rewards just for checking in each day!" }), _jsx("li", { children: "Stay consistent to unlock special rewards on the 3rd, 5th, and 7th day." }), _jsx("li", { children: "Missing a day will reset your streak, starting again from Day 1." }), _jsx("li", { children: "Each check-in unlocks the next one on the following day." }), _jsx("li", { children: "Successfully check in for 7 consecutive days to complete the quest and reset the cycle." })] })] }), _jsx("div", { className: "pb-4 pt-6", children: _jsx(Button, { onClick: () => setOpen(false), children: "Ok" }) })] }) })] }) }));
|
|
15
|
+
}
|
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useShallow } from 'zustand/shallow';
|
|
3
|
+
import { useDisclosure } from '../../../client/hooks/useDisclosure.js';
|
|
4
|
+
import { useGlobalStore } from '../../../client/hooks/useGlobalStore.js';
|
|
5
|
+
import { CheckIcon } from '../../../icons/CheckIcon.js';
|
|
6
|
+
import { ClockStopWatchIcon } from '../../../icons/ClockStopWatchIcon.js';
|
|
7
|
+
import { CoinsHandIcon } from '../../../icons/CoinsHandIcon.js';
|
|
8
|
+
import { FileCheck02Icon } from '../../../icons/FileCheck02Icon.js';
|
|
9
|
+
import { InfoCircleIcon } from '../../../icons/InfoCircleIcon.js';
|
|
10
|
+
import { Badge } from '../../../ui/Badge/index.js';
|
|
11
|
+
import { Button } from '../../../ui/Button/index.js';
|
|
12
|
+
import { Checkbox } from '../../../ui/Checkbox/index.js';
|
|
13
|
+
import { useQuestContext } from '../QuestsContext.js';
|
|
14
|
+
import { OnboardingQuestRules } from './OnboardingQuestRules.js';
|
|
15
|
+
export function OnboardingQuest() {
|
|
16
|
+
const quest = useQuestContext();
|
|
17
|
+
const disclosure = useDisclosure();
|
|
18
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
19
|
+
kyc: ctx.kyc,
|
|
20
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
21
|
+
})));
|
|
22
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "border-border-primary bg-bg-tertiary flex h-full w-full flex-col space-y-6 rounded-2xl border px-4 pb-6 pt-5", children: [_jsxs("div", { className: "flex flex-col space-y-2", children: [_jsxs("div", { className: "flex max-h-7.5 items-start justify-between", children: [_jsxs(Badge.Root, { size: "lg", colorScheme: "brand", round: false, children: [_jsx(Badge.Icon, { children: _jsx(ClockStopWatchIcon, {}) }), _jsx(Badge.Label, { children: "123" })] }), _jsx("div", { role: "button", className: "bg-bg-primary border-border-secondary flex size-9 cursor-pointer items-center justify-center rounded-md border", children: _jsx(InfoCircleIcon, { className: "text-text-disabled size-5" }) })] }), _jsx("h2", { className: "text-xl font-semibold", children: quest.name }), _jsx("p", { className: "text-text-secondary-700 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: quest.description } })] }), _jsxs("div", { className: "w-full grow space-y-2", children: [_jsxs(Checkbox.Root, { children: [_jsx(Checkbox.Control, { className: "bg-transparent", children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsx(Checkbox.Label, { className: "text-sm font-medium leading-tight", children: "Complete personal verification" }), _jsx(Checkbox.HiddenInput, {})] }), _jsxs(Checkbox.Root, { children: [_jsx(Checkbox.Control, { className: "bg-transparent", children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsx(Checkbox.Label, { className: "text-sm font-medium leading-tight", children: "Make your first deposit" }), _jsx(Checkbox.HiddenInput, {})] })] }), _jsxs("div", { className: "flex gap-lg", children: [_jsxs(Button, { size: "sm", onClick: () => {
|
|
23
|
+
globalStore.kyc.setOpen(true);
|
|
24
|
+
}, children: [_jsx(FileCheck02Icon, { className: "size-5" }), "Verify"] }), _jsxs(Button, { size: "sm", onClick: () => {
|
|
25
|
+
globalStore.depositWithdrawal.setTab('DEPOSIT');
|
|
26
|
+
globalStore.depositWithdrawal.setOpen(true);
|
|
27
|
+
}, children: [_jsx(CoinsHandIcon, { className: "size-5" }), "Deposit"] })] })] }), _jsx(OnboardingQuestRules, { open: disclosure.open, onOpenChange: disclosure.setOpen })] }));
|
|
4
28
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useControllableState } from '../../../client/hooks/useControllableState.js';
|
|
4
|
+
import { XIcon } from '../../../icons/XIcon.js';
|
|
5
|
+
import { Button } from '../../../ui/Button/index.js';
|
|
6
|
+
import { Dialog } from '../../../ui/Dialog/index.js';
|
|
7
|
+
import { Portal } from '../../../ui/Portal/index.js';
|
|
8
|
+
export function OnboardingQuestRules(props) {
|
|
9
|
+
const [open, setOpen] = useControllableState({
|
|
10
|
+
value: props.open,
|
|
11
|
+
defaultValue: props.defaultOpen ?? false,
|
|
12
|
+
onChange: props.onOpenChange,
|
|
13
|
+
});
|
|
14
|
+
return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: open, onOpenChange: (details) => setOpen(details.open), closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto max-w-[343px] rounded-xl px-4 pb-0 pt-5", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "flex flex-col space-y-5", children: [_jsx("h2", { className: "text-text-primary-900 text-lg font-semibold", children: "Welcome Quest Rules" }), _jsxs("ol", { className: "text-text-tertiary-600 group list-disc text-wrap pl-4 text-sm font-normal", children: [_jsx("li", { children: "Begin your quest whenever you're ready" }), _jsx("li", { children: "Tackle the tasks in any order you like" }), _jsx("li", { children: "Finish all tasks and we'll credit your reward automatically!" })] })] }), _jsx("div", { className: "pb-4 pt-6", children: _jsx(Button, { onClick: () => setOpen(false), children: "Ok" }) })] }) })] }) }));
|
|
15
|
+
}
|
|
@@ -1,27 +1,42 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import Image from 'next/image';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { z } from 'zod';
|
|
4
6
|
import { useAvailableQuestsQuery } from '../../client/hooks/useAvailableQuestsQuery.js';
|
|
5
7
|
import { SpinnerIcon } from '../../icons/SpinnerIcon.js';
|
|
6
8
|
import closeChest from '../../images/close-chest.png';
|
|
9
|
+
import { SegmentGroup } from '../../ui/SegmentGroup/index.js';
|
|
7
10
|
import { DailyCheckInQuest } from './DailyCheckInQuest/DailyCheckInQuest.js';
|
|
8
11
|
import { OnboardingQuest } from './OnboardingQuest/OnboardingQuest.js';
|
|
12
|
+
import { QuestContext } from './QuestsContext.js';
|
|
9
13
|
import { WageringQuest } from './WageringQuest/WageringQuest.js';
|
|
10
14
|
const QUEST_COMPONENT_MAP = {
|
|
11
15
|
DAILY_CHECKIN: DailyCheckInQuest,
|
|
12
16
|
ONBOARDING: OnboardingQuest,
|
|
13
17
|
WAGERING: WageringQuest,
|
|
14
18
|
};
|
|
19
|
+
const TabDefinition = z.enum(['AVAILABLE', 'COMPLETED']);
|
|
15
20
|
export function Quests__client(props) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
const [tab, setTab] = useState('AVAILABLE');
|
|
22
|
+
const questsQuery = useAvailableQuestsQuery();
|
|
23
|
+
const quests = !questsQuery.data?.length
|
|
24
|
+
? []
|
|
25
|
+
: questsQuery.data.filter((quest) => {
|
|
26
|
+
return tab === 'COMPLETED'
|
|
27
|
+
? quest.status !== 'IN_PROGRESS'
|
|
28
|
+
: quest.status === 'IN_PROGRESS';
|
|
29
|
+
});
|
|
30
|
+
if (questsQuery.isLoading) {
|
|
31
|
+
return (_jsxs("div", { className: props.className, children: [_jsx("h2", { className: "mb-3 text-lg font-semibold", children: props.heading ?? 'Quests' }), _jsx(SpinnerIcon, { className: "mx-auto size-5 h-[50vh]" })] }));
|
|
19
32
|
}
|
|
20
|
-
if (!
|
|
21
|
-
return (_jsxs("div", { className: props.className, children: [_jsx("
|
|
33
|
+
if (!questsQuery.data?.length) {
|
|
34
|
+
return (_jsxs("div", { className: props.className, children: [_jsx("h2", { className: "mb-3 text-lg font-semibold", children: props.heading ?? 'Quests' }), _jsxs("div", { className: "mt-11 flex flex-col items-center justify-center", children: [_jsx(Image, { src: closeChest, width: 100, height: 100, alt: "No Quests Available", className: "mix-blend-luminosity", quality: 100 }), _jsx("div", { className: "text-text-primary-900 mt-4 text-base font-semibold", children: props.heading ?? 'Quests' }), _jsx("div", { className: "text-text-tertiary-600 mt-1 text-center text-sm", children: "No available quests. Please check back later!" })] })] }));
|
|
22
35
|
}
|
|
23
|
-
return (_jsxs("div", { className: props.className, children: [_jsx("
|
|
36
|
+
return (_jsxs("div", { className: props.className, children: [_jsx("h2", { className: "text-lg font-semibold", children: props.heading ?? 'Quests' }), _jsxs(SegmentGroup.Root, { value: tab, onValueChange: (details) => {
|
|
37
|
+
setTab(TabDefinition.catch('AVAILABLE').parse(details.value));
|
|
38
|
+
}, className: "mt-3 w-full overflow-x-auto lg:mt-4.5 lg:w-fit", children: [_jsxs(SegmentGroup.Item, { value: "AVAILABLE", className: "w-full lg:w-fit", children: [_jsx(SegmentGroup.ItemText, { children: "Available" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "COMPLETED", className: "w-full lg:w-fit", children: [_jsx(SegmentGroup.ItemText, { children: "Completed" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsx(SegmentGroup.Indicator, {})] }), _jsx("div", { className: "mt-3xl grid gap-3xl lg:mt-lg lg:grid-cols-3", children: quests.map((quest) => {
|
|
24
39
|
const QuestComponent = QUEST_COMPONENT_MAP[quest.type];
|
|
25
|
-
return _jsx(
|
|
40
|
+
return (_jsx(QuestContext, { value: quest, children: _jsx(QuestComponent, {}) }, quest.id));
|
|
26
41
|
}) })] }));
|
|
27
42
|
}
|
|
@@ -2,19 +2,22 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
import { useDisclosure } from '../../../client/hooks/useDisclosure.js';
|
|
6
|
+
import { useLocaleInfo } from '../../../client/hooks/useLocaleInfo.js';
|
|
5
7
|
import { ClockStopWatchIcon } from '../../../icons/ClockStopWatchIcon.js';
|
|
6
8
|
import { InfoCircleIcon } from '../../../icons/InfoCircleIcon.js';
|
|
7
9
|
import { Badge } from '../../../ui/Badge/index.js';
|
|
10
|
+
import { parseDecimal } from '../../../utils/parseDecimal.js';
|
|
8
11
|
import CountdownTimer from '../CountdownTimer.js';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
import { useQuestContext } from '../QuestsContext.js';
|
|
13
|
+
import { WageringQuestModal } from './WageringQuestRules.js';
|
|
14
|
+
export function WageringQuest() {
|
|
15
|
+
const quest = useQuestContext();
|
|
16
|
+
const disclosure = useDisclosure();
|
|
17
|
+
const localeInfo = useLocaleInfo();
|
|
12
18
|
const [isExpired, setIsExpired] = useState(false);
|
|
13
19
|
const { progressPercentage, turnover, targetTurnover, name, description, endDateTime, bonus, status, } = quest;
|
|
14
|
-
return (_jsxs(_Fragment, { children: [_jsx(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} }), _jsxs("div", { className: "border-border-primary bg-bg-tertiary flex h-full w-full flex-col space-y-6 rounded-2xl border px-4 pb-6 pt-5", children: [_jsxs("div", { className: "flex flex-col space-y-2", children: [_jsxs("div", { className: "flex max-h-7.5 items-start justify-between", children: [_jsx(CountdownTimer, { endDateTime: endDateTime, renderAction: (timeLeft) => (_jsxs(Badge.Root, { size: "lg", colorScheme: "brand", round: false, children: [_jsx(Badge.Icon, { children: _jsx(ClockStopWatchIcon, {}) }), _jsxs(Badge.Label, { children: [timeLeft.days, "d:", timeLeft.hours, "h:", timeLeft.minutes, "m:", timeLeft.seconds, "s"] })] })), onEnd: () => setIsExpired(true) }), _jsx("div", { role: "button", className: "bg-bg-primary border-border-secondary flex size-9 cursor-pointer items-center justify-center rounded-md border", onClick: () => setShowRules((prev) => !prev), children: _jsx(InfoCircleIcon, { className: "text-text-disabled size-5" }) })] }), _jsx("p", { className: "text-xl font-semibold", children: name }), _jsx("p", { className: "text-text-secondary-700 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: description } })] }), _jsxs("div", { className: "flex w-full flex-col space-y-2", children: [_jsxs("div", { className: "text-text-primary-brand group flex items-center justify-between", children: [_jsxs("p", { children: ["Progress ", parseInt(progressPercentage).toFixed(2), "%"] }), _jsxs("p", { children: [turnover, _jsxs("span", { className: "text-text-quarterary-brand", children: ["/", targetTurnover, " PHP"] })] })] }), _jsx("div", { className: "bg-bg-primary h-2 w-full overflow-hidden rounded-full", children: _jsx("div", { className: "bg-utility-brand-600 h-full rounded-full transition-all duration-300", style: { width: `${progressPercentage}%` } }) })] }), _jsx("div", { className: "flex h-full items-end", children: _jsx("div", { className: "bg-button-secondary-bg border-bg-primary-hover w-full rounded-md border px-3.5 py-2.5 text-center text-white", children: _jsxs("p", { className: twMerge(isExpired || status === 'COMPLETED' || status === 'FAILED'
|
|
18
|
-
? ['opacity-50 grayscale']
|
|
19
|
-
: ''), children: ["Complete to get ", _jsxs("span", { className: "text-brand-400", children: ["\u20B1", bonus] }), ' ', "bonus!"] }) }) })] })] }));
|
|
20
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "border-border-primary bg-bg-tertiary flex h-full w-full flex-col space-y-6 rounded-2xl border px-4 pb-6 pt-5", children: [_jsxs("div", { className: "flex flex-col space-y-2", children: [_jsxs("div", { className: "flex max-h-7.5 items-start justify-between", children: [_jsx(CountdownTimer, { endDateTime: endDateTime, renderAction: (timeLeft) => (_jsxs(Badge.Root, { size: "lg", colorScheme: "brand", round: false, children: [_jsx(Badge.Icon, { children: _jsx(ClockStopWatchIcon, {}) }), _jsxs(Badge.Label, { children: [timeLeft.days, "d:", timeLeft.hours, "h:", timeLeft.minutes, "m:", timeLeft.seconds, "s"] })] })), onEnd: () => setIsExpired(true) }), _jsx("div", { role: "button", className: "bg-bg-primary border-border-secondary flex size-9 cursor-pointer items-center justify-center rounded-md border", onClick: () => disclosure.setOpen(true), children: _jsx(InfoCircleIcon, { className: "text-text-disabled size-5" }) })] }), _jsx("p", { className: "text-xl font-semibold", children: name }), _jsx("p", { className: "text-text-secondary-700 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: description } })] }), _jsxs("div", { className: "flex w-full flex-col space-y-2", children: [_jsxs("div", { className: "text-text-primary-brand group flex items-center justify-between", children: [_jsxs("p", { children: ["Progress ", parseDecimal(progressPercentage, 0).toFixed(2), "%"] }), _jsxs("p", { children: [turnover, _jsxs("span", { className: "text-text-quarterary-brand", children: ["/", targetTurnover, " ", localeInfo.currency.code] })] })] }), _jsx("div", { className: "bg-bg-primary h-2 w-full overflow-hidden rounded-full", children: _jsx("div", { className: "bg-utility-brand-600 h-full rounded-full transition-all duration-300", style: { width: `${progressPercentage}%` } }) })] }), _jsx("div", { className: "flex h-full items-end", children: _jsx("div", { className: "bg-button-secondary-bg border-bg-primary-hover w-full rounded-md border px-3.5 py-2.5 text-center text-white", children: _jsxs("p", { className: twMerge(isExpired || status === 'COMPLETED' || status === 'FAILED'
|
|
21
|
+
? 'opacity-50 grayscale'
|
|
22
|
+
: ''), children: ["Complete to get ", _jsxs("span", { className: "text-brand-400", children: ["\u20B1", bonus] }), ' ', "bonus!"] }) }) })] }), _jsx(WageringQuestModal, { open: disclosure.open, onOpenChange: disclosure.setOpen })] }));
|
|
20
23
|
}
|