@opexa/portal-components 0.0.94 → 0.0.96
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 +2 -0
- package/dist/client/hooks/index.js +2 -0
- package/dist/client/hooks/useBonusesCountQuery.d.ts +2 -0
- package/dist/client/hooks/useBonusesCountQuery.js +27 -0
- package/dist/client/hooks/useCashbackBonusesCountQuery.d.ts +2 -0
- package/dist/client/hooks/useCashbackBonusesCountQuery.js +26 -0
- package/dist/client/hooks/useClaimCashbackBonusMutation.js +4 -1
- package/dist/components/Account/Account.js +13 -4
- package/dist/components/DepositWithdrawal/Deposit/AvailablePromos.js +1 -1
- package/dist/components/DepositWithdrawal/Deposit/GCashDeposit/GCashDeposit.js +11 -4
- package/dist/components/DepositWithdrawal/Deposit/MayaAppDeposit/MayaAppDeposit.js +11 -4
- package/dist/components/DepositWithdrawal/Deposit/MayaDeposit/MayaDeposit.js +11 -4
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositForm.js +11 -4
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositForm.js +11 -4
- package/dist/components/DepositWithdrawal/DepositWithdrawal.js +3 -0
- package/dist/server/utils/index.d.ts +2 -0
- package/dist/server/utils/index.js +2 -0
- package/dist/server/utils/prefetchBonusesCountQuery.d.ts +1 -0
- package/dist/server/utils/prefetchBonusesCountQuery.js +19 -0
- package/dist/server/utils/prefetchCashbackBonusesCountQuery.d.ts +1 -0
- package/dist/server/utils/prefetchCashbackBonusesCountQuery.js +19 -0
- package/dist/services/queries.d.ts +2 -0
- package/dist/services/queries.js +14 -0
- package/dist/services/wallet.service.d.ts +13 -1
- package/dist/services/wallet.service.js +10 -2
- package/dist/ui/AlertDialog/AlertDialog.d.ts +121 -121
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +11 -11
- package/dist/ui/Avatar/Avatar.d.ts +9 -9
- package/dist/ui/Avatar/avatar.recipe.d.ts +3 -3
- package/dist/ui/Badge/Badge.d.ts +12 -12
- package/dist/ui/Badge/badge.recipe.d.ts +3 -3
- 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 +336 -336
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +14 -14
- package/dist/ui/Dialog/Dialog.d.ts +121 -121
- package/dist/ui/Dialog/dialog.recipe.d.ts +11 -11
- package/dist/ui/Drawer/Drawer.d.ts +33 -33
- package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
- package/dist/ui/Field/Field.d.ts +21 -21
- package/dist/ui/Field/field.recipe.d.ts +3 -3
- package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
- package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
- package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
- package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
- package/dist/ui/PinInput/PinInput.d.ts +12 -12
- package/dist/ui/PinInput/pinInput.recipe.d.ts +3 -3
- package/dist/ui/Popover/Popover.d.ts +88 -88
- package/dist/ui/Popover/popover.recipe.d.ts +8 -8
- package/dist/ui/Progress/Progress.d.ts +27 -27
- package/dist/ui/Progress/progress.recipe.d.ts +3 -3
- package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
- package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
- package/dist/ui/Select/Select.d.ts +45 -45
- package/dist/ui/Select/select.recipe.d.ts +3 -3
- package/dist/ui/Table/Table.d.ts +21 -21
- package/dist/ui/Table/table.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/queryKeys.d.ts +2 -0
- package/dist/utils/queryKeys.js +4 -0
- package/package.json +1 -1
|
@@ -4,8 +4,10 @@ export * from './useAvailablePromosQuery';
|
|
|
4
4
|
export * from './useAvailableQuestsCountQuery';
|
|
5
5
|
export * from './useAvailableQuestsQuery';
|
|
6
6
|
export * from './useBetRecordsQuery';
|
|
7
|
+
export * from './useBonusesCountQuery';
|
|
7
8
|
export * from './useBonusesQuery';
|
|
8
9
|
export * from './useBonusQuery';
|
|
10
|
+
export * from './useCashbackBonusesCountQuery';
|
|
9
11
|
export * from './useCashbackBonusesQuery';
|
|
10
12
|
export * from './useCashbackBonusQuery';
|
|
11
13
|
export * from './useCashbackQuery';
|
|
@@ -4,8 +4,10 @@ export * from './useAvailablePromosQuery.js';
|
|
|
4
4
|
export * from './useAvailableQuestsCountQuery.js';
|
|
5
5
|
export * from './useAvailableQuestsQuery.js';
|
|
6
6
|
export * from './useBetRecordsQuery.js';
|
|
7
|
+
export * from './useBonusesCountQuery.js';
|
|
7
8
|
export * from './useBonusesQuery.js';
|
|
8
9
|
export * from './useBonusQuery.js';
|
|
10
|
+
export * from './useCashbackBonusesCountQuery.js';
|
|
9
11
|
export * from './useCashbackBonusesQuery.js';
|
|
10
12
|
export * from './useCashbackBonusQuery.js';
|
|
11
13
|
export * from './useCashbackQuery.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import invariant from 'tiny-invariant';
|
|
3
|
+
import { getBonusesCount } from '../../services/index.js';
|
|
4
|
+
import { getBonusesCountQueryKey } from '../../utils/index.js';
|
|
5
|
+
import { getSession } from '../services/index.js';
|
|
6
|
+
import { useSessionQuery } from './useSessionQuery.js';
|
|
7
|
+
export const useBonusesCountQuery = (config) => {
|
|
8
|
+
const sessionQuery = useSessionQuery();
|
|
9
|
+
const query = useQuery({
|
|
10
|
+
...config,
|
|
11
|
+
enabled: config?.enabled === false
|
|
12
|
+
? false
|
|
13
|
+
: sessionQuery.data?.status === 'authenticated',
|
|
14
|
+
queryKey: getBonusesCountQueryKey(),
|
|
15
|
+
queryFn: async ({ signal }) => {
|
|
16
|
+
const session = await getSession();
|
|
17
|
+
invariant(session.status === 'authenticated');
|
|
18
|
+
return await getBonusesCount({
|
|
19
|
+
signal,
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${session.token}`,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
return query;
|
|
27
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import invariant from 'tiny-invariant';
|
|
3
|
+
import { getCashbackBonusesCount } from '../../services/index.js';
|
|
4
|
+
import { getCashbackBonusesCountQueryKey } from '../../utils/index.js';
|
|
5
|
+
import { getSession } from '../services/index.js';
|
|
6
|
+
import { useSessionQuery } from './useSessionQuery.js';
|
|
7
|
+
export const useCashbackBonusesCountQuery = (config) => {
|
|
8
|
+
const sessionQuery = useSessionQuery();
|
|
9
|
+
return useQuery({
|
|
10
|
+
...config,
|
|
11
|
+
enabled: config?.enabled === false
|
|
12
|
+
? false
|
|
13
|
+
: sessionQuery.data?.status === 'authenticated',
|
|
14
|
+
queryKey: getCashbackBonusesCountQueryKey(),
|
|
15
|
+
queryFn: async ({ signal }) => {
|
|
16
|
+
const session = await getSession();
|
|
17
|
+
invariant(session.status === 'authenticated');
|
|
18
|
+
return await getCashbackBonusesCount({
|
|
19
|
+
signal,
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${session.token}`,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMutation } from '@tanstack/react-query';
|
|
2
2
|
import invariant from 'tiny-invariant';
|
|
3
3
|
import { claimCashbackBonus } from '../../services/index.js';
|
|
4
|
-
import { getCashbackBonusesQueryKey, getClaimCashbackBonusMutationKey, getQueryClient, } from '../../utils/index.js';
|
|
4
|
+
import { getCashbackBonusesCountQueryKey, getCashbackBonusesQueryKey, getClaimCashbackBonusMutationKey, getQueryClient, } from '../../utils/index.js';
|
|
5
5
|
import { getSession } from '../services/index.js';
|
|
6
6
|
export const useClaimCashbackBonusMutation = (config) => {
|
|
7
7
|
const queryClient = getQueryClient();
|
|
@@ -17,6 +17,9 @@ export const useClaimCashbackBonusMutation = (config) => {
|
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
queryClient.setQueryData(getCashbackBonusesQueryKey(), (prev) => prev?.filter((bonus) => bonus.id !== id));
|
|
20
|
+
queryClient.setQueryData(getCashbackBonusesCountQueryKey(), (prev) => {
|
|
21
|
+
return !prev ? 0 : prev > 0 ? prev - 1 : 0;
|
|
22
|
+
});
|
|
20
23
|
},
|
|
21
24
|
});
|
|
22
25
|
};
|
|
@@ -5,7 +5,7 @@ import Image from 'next/image';
|
|
|
5
5
|
import Link from 'next/link';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
7
|
import { useShallow } from 'zustand/shallow';
|
|
8
|
-
import { useAccountQuery, useGlobalStore, useLocaleInfo, useSignOutMutation, useUnreadMessagesCountQuery, useWalletQuery, } from '../../client/hooks/index.js';
|
|
8
|
+
import { useAccountQuery, useBonusesCountQuery, useCashbackBonusesCountQuery, useGlobalStore, useLocaleInfo, useProfileCompletionQuery, useSignOutMutation, useUnreadMessagesCountQuery, useWalletQuery, } from '../../client/hooks/index.js';
|
|
9
9
|
import { AlertCircleIcon, Bell01Icon, ChevronRightIcon, CoinsStacked02Icon, CoinsSwap02Icon, Gift01Icon, Logout01Icon, Settings02Icon, } from '../../icons/index.js';
|
|
10
10
|
import avatarPlaceholder from '../../images/placeholder-avatar.png';
|
|
11
11
|
import { Badge, Button, Drawer, Popover } from '../../ui/index.js';
|
|
@@ -86,17 +86,26 @@ function Links(props) {
|
|
|
86
86
|
messages: ctx.messages,
|
|
87
87
|
})));
|
|
88
88
|
const unreadMessagesCountQuery = useUnreadMessagesCountQuery({}, { refetchInterval: 5000 });
|
|
89
|
+
const unreadMessagesCount = unreadMessagesCountQuery.data ?? 0;
|
|
90
|
+
const profileCompletionQuery = useProfileCompletionQuery();
|
|
91
|
+
const profileCompletion = profileCompletionQuery.data;
|
|
92
|
+
const profileCompletionPercentage = parseDecimal(profileCompletion?.completionPercentage, 0);
|
|
93
|
+
const bonusesCountQuery = useBonusesCountQuery();
|
|
94
|
+
const bonusesCount = bonusesCountQuery.data ?? 0;
|
|
95
|
+
const cashbackBonusesCountQuery = useCashbackBonusesCountQuery();
|
|
96
|
+
const cashbackBonusesCount = cashbackBonusesCountQuery.data ?? 0;
|
|
97
|
+
const rewardsCount = bonusesCount + cashbackBonusesCount;
|
|
89
98
|
return (_jsxs("nav", { className: recipe.nav({ className: 'mt-xl' }), children: [_jsxs("ul", { children: [_jsx("li", { className: recipe.navItemRoot(), children: _jsxs("button", { type: "button", className: recipe.navItemLink(), onClick: () => {
|
|
90
99
|
globalStore.account.setOpen(false);
|
|
91
100
|
globalStore.account__mobile.setOpen(false);
|
|
92
101
|
globalStore.messages.setOpen(true);
|
|
93
|
-
}, children: [_jsx(Bell01Icon, { className: recipe.navItemIcon() }), _jsx("span", { className: recipe.navItemLabel(), children: "Notifications" }), _jsx("span", { className: recipe.navItemBadge(), "data-type": "warning", children:
|
|
102
|
+
}, children: [_jsx(Bell01Icon, { className: recipe.navItemIcon() }), _jsx("span", { className: recipe.navItemLabel(), children: "Notifications" }), unreadMessagesCount > 0 && (_jsx("span", { className: recipe.navItemBadge(), "data-type": "warning", children: unreadMessagesCount })), _jsx(ChevronRightIcon, { className: recipe.navItemIndicator() })] }) }), _jsx("li", { className: recipe.navItemRoot(), children: _jsxs(Link, { href: props.rewardsUrl, className: recipe.navItemLink(), onClick: () => {
|
|
94
103
|
globalStore.account.setOpen(false);
|
|
95
104
|
globalStore.account__mobile.setOpen(false);
|
|
96
|
-
}, children: [_jsx(Gift01Icon, { className: recipe.navItemIcon() }), _jsx("span", { className: recipe.navItemLabel(), children: "Rewards" }), _jsx("span", { className: recipe.navItemBadge(), "data-type": "warning", children:
|
|
105
|
+
}, children: [_jsx(Gift01Icon, { className: recipe.navItemIcon() }), _jsx("span", { className: recipe.navItemLabel(), children: "Rewards" }), rewardsCount > 0 && (_jsx("span", { className: recipe.navItemBadge(), "data-type": "warning", children: rewardsCount })), _jsx(ChevronRightIcon, { className: recipe.navItemIndicator() })] }) })] }), props.shouldShowSettings && (_jsx("ul", { children: _jsx("li", { className: recipe.navItemRoot(), children: _jsxs(Link, { href: props.accountSettingsUrl, className: recipe.navItemLink(), onClick: () => {
|
|
97
106
|
globalStore.account.setOpen(false);
|
|
98
107
|
globalStore.account__mobile.setOpen(false);
|
|
99
|
-
}, children: [_jsx(Settings02Icon, { className: recipe.navItemIcon() }), _jsx("span", { className: recipe.navItemLabel(), children: "Settings" }), _jsx("span", { className: recipe.navItemBadge(), "data-type": "error", children: _jsx(AlertCircleIcon, {}) }), _jsx(ChevronRightIcon, { className: recipe.navItemIndicator() })] }) }) })), _jsxs("ul", { children: [_jsx("li", { className: recipe.navItemRoot(), children: _jsxs(Link, { href: props.betRecordsUrl, className: recipe.navItemLink(), onClick: () => {
|
|
108
|
+
}, children: [_jsx(Settings02Icon, { className: recipe.navItemIcon() }), _jsx("span", { className: recipe.navItemLabel(), children: "Settings" }), profileCompletionPercentage < 100 && (_jsx("span", { className: recipe.navItemBadge(), "data-type": "error", children: _jsx(AlertCircleIcon, {}) })), _jsx(ChevronRightIcon, { className: recipe.navItemIndicator() })] }) }) })), _jsxs("ul", { children: [_jsx("li", { className: recipe.navItemRoot(), children: _jsxs(Link, { href: props.betRecordsUrl, className: recipe.navItemLink(), onClick: () => {
|
|
100
109
|
globalStore.account.setOpen(false);
|
|
101
110
|
globalStore.account__mobile.setOpen(false);
|
|
102
111
|
}, children: [_jsx(CoinsStacked02Icon, { className: recipe.navItemIcon() }), _jsx("span", { className: recipe.navItemLabel(), children: "Bet Records" }), _jsx(ChevronRightIcon, { className: recipe.navItemIndicator() })] }) }), _jsx("li", { className: recipe.navItemRoot(), children: _jsxs(Link, { href: props.transactionsUrl, className: recipe.navItemLink(), onClick: () => {
|
|
@@ -25,7 +25,7 @@ export function AvailablePromos(props) {
|
|
|
25
25
|
setValue(value ?? null);
|
|
26
26
|
}, className: props.className, children: [_jsx(Select.Label, { children: "Choose a bonus" }), _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, { placeholder: "Pay without bonus" }), _jsx(Select.Context, { children: (api) => (_jsx(_Fragment, { children: api.value.length ? (_jsx(Select.ClearTrigger, { asChild: true, children: _jsx("span", { onClick: (e) => {
|
|
27
27
|
e.stopPropagation();
|
|
28
|
-
}, children: "Clear" }) })) : (_jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })) })) })] }), _jsx(Select.Positioner, { children: _jsxs(Select.Content, { children: [collection.items.length <= 0 && (_jsxs("div", { className: "p-2", children: [_jsx(Image, { src: gift, alt: "", width: 160, height: 160, className: "mx-auto size-[8.313rem] grayscale" }), _jsx("p", { className: "text-text-tertiary-600 mx-auto mt-1 max-w-[20rem] text-center text-sm", children: "No Bonuses are available at the moment. Please check back later!" })] })), collection.items.length > 0 && (_jsx(Select.ItemGroup, { children: collection.items.map((promo) => (_jsxs(Select.Item, { item: promo, children: [_jsxs(Select.ItemText, { children: [_jsx("span", { className: "block font-medium", children: promo.name }), _jsx("span", { className: "text-text-warning-primary-600 line-clamp-1
|
|
28
|
+
}, children: "Clear" }) })) : (_jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })) })) })] }), _jsx(Select.Positioner, { children: _jsxs(Select.Content, { children: [collection.items.length <= 0 && (_jsxs("div", { className: "p-2", children: [_jsx(Image, { src: gift, alt: "", width: 160, height: 160, className: "mx-auto size-[8.313rem] grayscale" }), _jsx("p", { className: "text-text-tertiary-600 mx-auto mt-1 max-w-[20rem] text-center text-sm", children: "No Bonuses are available at the moment. Please check back later!" })] })), collection.items.length > 0 && (_jsx(Select.ItemGroup, { children: collection.items.map((promo) => (_jsxs(Select.Item, { item: promo, children: [_jsxs(Select.ItemText, { children: [_jsx("span", { className: "block font-medium", children: promo.name }), _jsx("span", { className: "text-text-warning-primary-600 line-clamp-1", dangerouslySetInnerHTML: {
|
|
29
29
|
__html: promo.description,
|
|
30
30
|
} })] }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, promo.id))) }))] }) })] }));
|
|
31
31
|
}
|
|
@@ -5,13 +5,17 @@ import { useEffect, useState } from 'react';
|
|
|
5
5
|
import { Controller, useForm } from 'react-hook-form';
|
|
6
6
|
import invariant from 'tiny-invariant';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
import {
|
|
8
|
+
import { useShallow } from 'zustand/shallow';
|
|
9
|
+
import { useAvailablePromosQuery, useCreateGCashDepositMutation, useDepositsCountQuery, useGlobalStore, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
|
|
9
10
|
import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, SpinnerIcon, XIcon, } from '../../../../icons/index.js';
|
|
10
11
|
import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
|
|
11
12
|
import { parseDecimal } from '../../../../utils/index.js';
|
|
12
13
|
import { AmountChoices } from '../../AmountChoices.js';
|
|
13
14
|
import { AvailablePromos } from '../AvailablePromos.js';
|
|
14
15
|
export function GCashDeposit() {
|
|
16
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
17
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
18
|
+
})));
|
|
15
19
|
const [status, setStatus] = useState('waiting');
|
|
16
20
|
const createDepositMutation = useCreateGCashDepositMutation({
|
|
17
21
|
onMutate() {
|
|
@@ -88,14 +92,14 @@ export function GCashDeposit() {
|
|
|
88
92
|
resolver: zodResolver(definition),
|
|
89
93
|
defaultValues: {
|
|
90
94
|
amount: '0',
|
|
91
|
-
promo: null,
|
|
95
|
+
promo: globalStore.depositWithdrawal.promo ?? null,
|
|
92
96
|
},
|
|
93
97
|
});
|
|
94
98
|
useEffect(() => {
|
|
95
99
|
if (minimumAmount) {
|
|
96
100
|
form.reset({
|
|
97
101
|
amount: minimumAmount.toString(),
|
|
98
|
-
promo: null,
|
|
102
|
+
promo: form.getValues('promo') ?? null,
|
|
99
103
|
});
|
|
100
104
|
}
|
|
101
105
|
}, [form, minimumAmount]);
|
|
@@ -116,7 +120,10 @@ export function GCashDeposit() {
|
|
|
116
120
|
shouldDirty: true,
|
|
117
121
|
shouldValidate: true,
|
|
118
122
|
});
|
|
119
|
-
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange:
|
|
123
|
+
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: (value) => {
|
|
124
|
+
o.field.onChange(value);
|
|
125
|
+
globalStore.depositWithdrawal.setPromo(null);
|
|
126
|
+
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: status !== 'waiting', onOpenChange: (details) => {
|
|
120
127
|
if (!details.open) {
|
|
121
128
|
setStatus('waiting');
|
|
122
129
|
}
|
|
@@ -4,13 +4,17 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
|
|
4
4
|
import { useEffect, useState } from 'react';
|
|
5
5
|
import { Controller, useForm } from 'react-hook-form';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import {
|
|
7
|
+
import { useShallow } from 'zustand/shallow';
|
|
8
|
+
import { useAvailablePromosQuery, useCreateMayaAppDepositMutation, useDepositsCountQuery, useGlobalStore, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
|
|
8
9
|
import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, SpinnerIcon, XIcon, } from '../../../../icons/index.js';
|
|
9
10
|
import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
|
|
10
11
|
import { parseDecimal } from '../../../../utils/index.js';
|
|
11
12
|
import { AmountChoices } from '../../AmountChoices.js';
|
|
12
13
|
import { AvailablePromos } from '../AvailablePromos.js';
|
|
13
14
|
export function MayaAppDeposit() {
|
|
15
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
16
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
17
|
+
})));
|
|
14
18
|
const [status, setStatus] = useState('waiting');
|
|
15
19
|
const createDepositMutation = useCreateMayaAppDepositMutation({
|
|
16
20
|
onMutate() {
|
|
@@ -85,14 +89,14 @@ export function MayaAppDeposit() {
|
|
|
85
89
|
resolver: zodResolver(definition),
|
|
86
90
|
defaultValues: {
|
|
87
91
|
amount: '0',
|
|
88
|
-
promo: null,
|
|
92
|
+
promo: globalStore.depositWithdrawal.promo ?? null,
|
|
89
93
|
},
|
|
90
94
|
});
|
|
91
95
|
useEffect(() => {
|
|
92
96
|
if (minimumAmount) {
|
|
93
97
|
form.reset({
|
|
94
98
|
amount: minimumAmount.toString(),
|
|
95
|
-
promo: null,
|
|
99
|
+
promo: form.getValues('promo') ?? null,
|
|
96
100
|
});
|
|
97
101
|
}
|
|
98
102
|
}, [form, minimumAmount]);
|
|
@@ -113,7 +117,10 @@ export function MayaAppDeposit() {
|
|
|
113
117
|
shouldDirty: true,
|
|
114
118
|
shouldValidate: true,
|
|
115
119
|
});
|
|
116
|
-
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange:
|
|
120
|
+
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: (value) => {
|
|
121
|
+
o.field.onChange(value);
|
|
122
|
+
globalStore.depositWithdrawal.setPromo(null);
|
|
123
|
+
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: status !== 'waiting', onOpenChange: (details) => {
|
|
117
124
|
if (!details.open) {
|
|
118
125
|
setStatus('waiting');
|
|
119
126
|
}
|
|
@@ -5,13 +5,17 @@ import { useEffect, useState } from 'react';
|
|
|
5
5
|
import { Controller, useForm } from 'react-hook-form';
|
|
6
6
|
import invariant from 'tiny-invariant';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
import {
|
|
8
|
+
import { useShallow } from 'zustand/shallow';
|
|
9
|
+
import { useAvailablePromosQuery, useCreateMayaDepositMutation, useDepositsCountQuery, useGlobalStore, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
|
|
9
10
|
import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, SpinnerIcon, XIcon, } from '../../../../icons/index.js';
|
|
10
11
|
import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
|
|
11
12
|
import { parseDecimal } from '../../../../utils/index.js';
|
|
12
13
|
import { AmountChoices } from '../../AmountChoices.js';
|
|
13
14
|
import { AvailablePromos } from '../AvailablePromos.js';
|
|
14
15
|
export function MayaDeposit() {
|
|
16
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
17
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
18
|
+
})));
|
|
15
19
|
const [status, setStatus] = useState('waiting');
|
|
16
20
|
const createDepositMutation = useCreateMayaDepositMutation({
|
|
17
21
|
onMutate() {
|
|
@@ -88,14 +92,14 @@ export function MayaDeposit() {
|
|
|
88
92
|
resolver: zodResolver(definition),
|
|
89
93
|
defaultValues: {
|
|
90
94
|
amount: '0',
|
|
91
|
-
promo: null,
|
|
95
|
+
promo: globalStore.depositWithdrawal.promo ?? null,
|
|
92
96
|
},
|
|
93
97
|
});
|
|
94
98
|
useEffect(() => {
|
|
95
99
|
if (minimumAmount) {
|
|
96
100
|
form.reset({
|
|
97
101
|
amount: minimumAmount.toString(),
|
|
98
|
-
promo: null,
|
|
102
|
+
promo: form.getValues('promo') ?? null,
|
|
99
103
|
});
|
|
100
104
|
}
|
|
101
105
|
}, [form, minimumAmount]);
|
|
@@ -116,7 +120,10 @@ export function MayaDeposit() {
|
|
|
116
120
|
shouldDirty: true,
|
|
117
121
|
shouldValidate: true,
|
|
118
122
|
});
|
|
119
|
-
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, {
|
|
123
|
+
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { onChange: (value) => {
|
|
124
|
+
o.field.onChange(value);
|
|
125
|
+
globalStore.depositWithdrawal.setPromo(null);
|
|
126
|
+
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: status !== 'waiting', onOpenChange: (details) => {
|
|
120
127
|
if (!details.open) {
|
|
121
128
|
setStatus('waiting');
|
|
122
129
|
}
|
package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositForm.js
CHANGED
|
@@ -4,7 +4,8 @@ import { noop } from 'lodash-es';
|
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
5
|
import { Controller, useForm } from 'react-hook-form';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import {
|
|
7
|
+
import { useShallow } from 'zustand/shallow';
|
|
8
|
+
import { useAvailablePromosQuery, useDepositsCountQuery, useGlobalStore, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
|
|
8
9
|
import { ChevronDownIcon, ChevronUpIcon } from '../../../../icons/index.js';
|
|
9
10
|
import { Button, Field, NumberInput } from '../../../../ui/index.js';
|
|
10
11
|
import { parseDecimal } from '../../../../utils/index.js';
|
|
@@ -12,6 +13,9 @@ import { AmountChoices } from '../../AmountChoices.js';
|
|
|
12
13
|
import { AvailablePromos } from '../AvailablePromos.js';
|
|
13
14
|
import { useOnlineBankDepositContext } from './OnlineBankDepositContext.js';
|
|
14
15
|
export function OnlineBankDepositForm() {
|
|
16
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
17
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
18
|
+
})));
|
|
15
19
|
const context = useOnlineBankDepositContext();
|
|
16
20
|
const depositsCountQuery = useDepositsCountQuery();
|
|
17
21
|
const depositsCount = depositsCountQuery.data ?? 0;
|
|
@@ -74,14 +78,14 @@ export function OnlineBankDepositForm() {
|
|
|
74
78
|
resolver: zodResolver(definition),
|
|
75
79
|
defaultValues: {
|
|
76
80
|
amount: '0',
|
|
77
|
-
promo: null,
|
|
81
|
+
promo: globalStore.depositWithdrawal.promo ?? null,
|
|
78
82
|
},
|
|
79
83
|
});
|
|
80
84
|
useEffect(() => {
|
|
81
85
|
if (minimumAmount) {
|
|
82
86
|
form.reset({
|
|
83
87
|
amount: minimumAmount.toString(),
|
|
84
|
-
promo: null,
|
|
88
|
+
promo: form.getValues('promo') ?? null,
|
|
85
89
|
});
|
|
86
90
|
}
|
|
87
91
|
}, [form, minimumAmount]);
|
|
@@ -98,5 +102,8 @@ export function OnlineBankDepositForm() {
|
|
|
98
102
|
shouldDirty: true,
|
|
99
103
|
shouldValidate: true,
|
|
100
104
|
});
|
|
101
|
-
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-3xl",
|
|
105
|
+
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-3xl", onChange: (value) => {
|
|
106
|
+
o.field.onChange(value);
|
|
107
|
+
globalStore.depositWithdrawal.setPromo(null);
|
|
108
|
+
} })) }), _jsx(Button, { type: "submit", className: "mt-3xl", children: "Deposit" }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] })] }));
|
|
102
109
|
}
|
|
@@ -3,7 +3,8 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
import { Controller, useForm } from 'react-hook-form';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import {
|
|
6
|
+
import { useShallow } from 'zustand/shallow';
|
|
7
|
+
import { useAvailablePromosQuery, useDepositsCountQuery, useGlobalStore, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
|
|
7
8
|
import { ChevronDownIcon, ChevronUpIcon } from '../../../../icons/index.js';
|
|
8
9
|
import { Button, Field, NumberInput } from '../../../../ui/index.js';
|
|
9
10
|
import { parseDecimal } from '../../../../utils/index.js';
|
|
@@ -11,6 +12,9 @@ import { AmountChoices } from '../../AmountChoices.js';
|
|
|
11
12
|
import { AvailablePromos } from '../AvailablePromos.js';
|
|
12
13
|
import { useQRPHDepositContext } from './QRPHDepositContext.js';
|
|
13
14
|
export function QRPHDepositForm() {
|
|
15
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
16
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
17
|
+
})));
|
|
14
18
|
const context = useQRPHDepositContext();
|
|
15
19
|
const depositsCountQuery = useDepositsCountQuery();
|
|
16
20
|
const depositsCount = depositsCountQuery.data ?? 0;
|
|
@@ -73,14 +77,14 @@ export function QRPHDepositForm() {
|
|
|
73
77
|
resolver: zodResolver(definition),
|
|
74
78
|
defaultValues: {
|
|
75
79
|
amount: '0',
|
|
76
|
-
promo: null,
|
|
80
|
+
promo: globalStore.depositWithdrawal.promo ?? null,
|
|
77
81
|
},
|
|
78
82
|
});
|
|
79
83
|
useEffect(() => {
|
|
80
84
|
if (minimumAmount) {
|
|
81
85
|
form.reset({
|
|
82
86
|
amount: minimumAmount.toString(),
|
|
83
|
-
promo: null,
|
|
87
|
+
promo: form.getValues('promo') ?? null,
|
|
84
88
|
});
|
|
85
89
|
}
|
|
86
90
|
}, [form, minimumAmount]);
|
|
@@ -97,5 +101,8 @@ export function QRPHDepositForm() {
|
|
|
97
101
|
shouldDirty: true,
|
|
98
102
|
shouldValidate: true,
|
|
99
103
|
});
|
|
100
|
-
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, {
|
|
104
|
+
}, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { onChange: (value) => {
|
|
105
|
+
o.field.onChange(value);
|
|
106
|
+
globalStore.depositWithdrawal.setPromo(null);
|
|
107
|
+
}, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", children: "Deposit" }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] })] }));
|
|
101
108
|
}
|
|
@@ -19,6 +19,9 @@ export function DepositWithdrawal() {
|
|
|
19
19
|
});
|
|
20
20
|
return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: globalStore.depositWithdrawal.open, onOpenChange: (details) => {
|
|
21
21
|
globalStore.depositWithdrawal.setOpen(details.open);
|
|
22
|
+
if (!details.open) {
|
|
23
|
+
globalStore.depositWithdrawal.setPromo(null);
|
|
24
|
+
}
|
|
22
25
|
}, 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)]", children: _jsxs(Dialog.Content, { className: "lg:min-h-auto mx-auto min-h-full w-full px-4 py-3xl lg:w-[480px] lg:rounded-xl", children: [_jsxs(Dialog.Header, { className: "flex items-center gap-xl", children: [_jsx("div", { className: "border-border-primary shadow-xs text-gray-700 text-text-secondary-700 flex size-10 items-center justify-center rounded-md border", children: _jsx(Wallet02Icon, { className: "size-5" }) }), _jsx(Dialog.Title, { className: "grow text-lg font-semibold", children: "Wallet" }), _jsx(Dialog.Context, { children: (api) => (_jsx(IconButton, { size: "sm", variant: "outline", colorScheme: "gray", onClick: () => api.setOpen(false), children: _jsx(XIcon, {}) })) })] }), _jsxs(Dialog.Body, { className: "mt-3xl", children: [_jsx("p", { className: "text-text-secondary-700 text-center text-sm", children: "Deposit Balance" }), _jsx("p", { className: "text-center text-3xl font-bold leading-tight tracking-tight", children: formatNumber(walletQuery.data?.balance, {
|
|
23
26
|
currency: localeInfo.currency.code,
|
|
24
27
|
minDecimalPlaces: 2,
|
|
@@ -3,8 +3,10 @@ export * from './prefetchAvailablePromosQuery';
|
|
|
3
3
|
export * from './prefetchAvailableQuestsCountQuery';
|
|
4
4
|
export * from './prefetchAvailableQuestsQuery';
|
|
5
5
|
export * from './prefetchBetRecordsQuery';
|
|
6
|
+
export * from './prefetchBonusesCountQuery';
|
|
6
7
|
export * from './prefetchBonusesQuery';
|
|
7
8
|
export * from './prefetchBonusQuery';
|
|
9
|
+
export * from './prefetchCashbackBonusesCountQuery';
|
|
8
10
|
export * from './prefetchCashbackBonusesQuery';
|
|
9
11
|
export * from './prefetchCashbackBonusQuery';
|
|
10
12
|
export * from './prefetchCashbackQuery';
|
|
@@ -3,8 +3,10 @@ export * from './prefetchAvailablePromosQuery.js';
|
|
|
3
3
|
export * from './prefetchAvailableQuestsCountQuery.js';
|
|
4
4
|
export * from './prefetchAvailableQuestsQuery.js';
|
|
5
5
|
export * from './prefetchBetRecordsQuery.js';
|
|
6
|
+
export * from './prefetchBonusesCountQuery.js';
|
|
6
7
|
export * from './prefetchBonusesQuery.js';
|
|
7
8
|
export * from './prefetchBonusQuery.js';
|
|
9
|
+
export * from './prefetchCashbackBonusesCountQuery.js';
|
|
8
10
|
export * from './prefetchCashbackBonusesQuery.js';
|
|
9
11
|
export * from './prefetchCashbackBonusQuery.js';
|
|
10
12
|
export * from './prefetchCashbackQuery.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const prefetchBonusesCountQuery: () => Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getBonusesCount } from '../../services/index.js';
|
|
2
|
+
import { getBonusesCountQueryKey, getQueryClient } from '../../utils/index.js';
|
|
3
|
+
import { getSession } from '../services/getSession.js';
|
|
4
|
+
export const prefetchBonusesCountQuery = async () => {
|
|
5
|
+
const session = await getSession();
|
|
6
|
+
if (session.status === 'unauthenticated')
|
|
7
|
+
return;
|
|
8
|
+
await getQueryClient().prefetchQuery({
|
|
9
|
+
queryKey: getBonusesCountQueryKey(),
|
|
10
|
+
queryFn: async ({ signal }) => {
|
|
11
|
+
return await getBonusesCount({
|
|
12
|
+
signal,
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${session.token}`,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const prefetchCashbackBonusesCountQuery: () => Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getCashbackBonusesCount } from '../../services/index.js';
|
|
2
|
+
import { getCashbackBonusesCountQueryKey, getQueryClient } from '../../utils/index.js';
|
|
3
|
+
import { getSession } from '../services/index.js';
|
|
4
|
+
export const prefetchCashbackBonusesCountQuery = async () => {
|
|
5
|
+
const session = await getSession();
|
|
6
|
+
if (session.status === 'unauthenticated')
|
|
7
|
+
return;
|
|
8
|
+
await getQueryClient().prefetchQuery({
|
|
9
|
+
queryKey: getCashbackBonusesCountQueryKey(),
|
|
10
|
+
queryFn: async ({ signal }) => {
|
|
11
|
+
return await getCashbackBonusesCount({
|
|
12
|
+
signal,
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${session.token}`,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -49,10 +49,12 @@ export declare const CASHBACKS = "\n \n \n fragment FileFragment on File {\n
|
|
|
49
49
|
export declare const CASHBACK = "\n \n \n fragment FileFragment on File {\n id\n url\n status\n }\n\n\n fragment CashbackFragment on Cashback {\n id\n name\n banner {\n ...FileFragment\n }\n minimumCashback\n maximumMonthlyCashback\n status\n description\n activationStartDateTime\n activationEndDateTime\n turnoverContributionPercentagePerGameProvider\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n query Cashback($id: ObjectId!) {\n node(id: $id) {\n ... on Cashback {\n ...CashbackFragment\n }\n }\n }\n";
|
|
50
50
|
export declare const BONUS_FRAGMENT = "\n \n \n fragment FileFragment on File {\n id\n url\n status\n }\n\n\n fragment PromoFragment on Promo {\n id\n type\n name\n banner {\n ...FileFragment\n }\n status\n description\n maximumBonusAmount\n minimumBonusAmount\n maximumDepositAmount\n minimumDepositAmount\n activationStartDateTime\n turnoverRequirementContributionPercentagePerGameProvider\n activationEndDateTime\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n fragment BonusFragment on Bonus {\n id\n promo {\n ...PromoFragment\n }\n deposit {\n type\n amount\n netAmount\n fee\n status\n reference\n dateTimeCreated\n dateTimeLastUpdated\n }\n amount\n balance\n turnoverRequirement\n currentTurnoverRequirementContribution\n currentTurnoverRequirementContributionPercentage\n turnoverRequirementContributionPercentagePerGameProvider\n enabledGameProviders\n expiration\n dateTimeCreated\n dateTimeLastUpdated\n }\n";
|
|
51
51
|
export declare const BONUSES = "\n \n \n \n fragment FileFragment on File {\n id\n url\n status\n }\n\n\n fragment PromoFragment on Promo {\n id\n type\n name\n banner {\n ...FileFragment\n }\n status\n description\n maximumBonusAmount\n minimumBonusAmount\n maximumDepositAmount\n minimumDepositAmount\n activationStartDateTime\n turnoverRequirementContributionPercentagePerGameProvider\n activationEndDateTime\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n fragment BonusFragment on Bonus {\n id\n promo {\n ...PromoFragment\n }\n deposit {\n type\n amount\n netAmount\n fee\n status\n reference\n dateTimeCreated\n dateTimeLastUpdated\n }\n amount\n balance\n turnoverRequirement\n currentTurnoverRequirementContribution\n currentTurnoverRequirementContributionPercentage\n turnoverRequirementContributionPercentagePerGameProvider\n enabledGameProviders\n expiration\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n query Bonuses {\n bonuses {\n ...BonusFragment\n }\n }\n";
|
|
52
|
+
export declare const BONUSES_IDS = "\n query BonusesIds {\n bonuses {\n id\n }\n }\n";
|
|
52
53
|
export declare const BONUS = "\n \n \n \n fragment FileFragment on File {\n id\n url\n status\n }\n\n\n fragment PromoFragment on Promo {\n id\n type\n name\n banner {\n ...FileFragment\n }\n status\n description\n maximumBonusAmount\n minimumBonusAmount\n maximumDepositAmount\n minimumDepositAmount\n activationStartDateTime\n turnoverRequirementContributionPercentagePerGameProvider\n activationEndDateTime\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n fragment BonusFragment on Bonus {\n id\n promo {\n ...PromoFragment\n }\n deposit {\n type\n amount\n netAmount\n fee\n status\n reference\n dateTimeCreated\n dateTimeLastUpdated\n }\n amount\n balance\n turnoverRequirement\n currentTurnoverRequirementContribution\n currentTurnoverRequirementContributionPercentage\n turnoverRequirementContributionPercentagePerGameProvider\n enabledGameProviders\n expiration\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n query Bonus($id: ObjectId!) {\n node(id: $id) {\n ... on Bonus {\n ...BonusFragment\n }\n }\n }\n";
|
|
53
54
|
export declare const CURRENT_BONUS = "\n \n \n \n fragment FileFragment on File {\n id\n url\n status\n }\n\n\n fragment PromoFragment on Promo {\n id\n type\n name\n banner {\n ...FileFragment\n }\n status\n description\n maximumBonusAmount\n minimumBonusAmount\n maximumDepositAmount\n minimumDepositAmount\n activationStartDateTime\n turnoverRequirementContributionPercentagePerGameProvider\n activationEndDateTime\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n fragment BonusFragment on Bonus {\n id\n promo {\n ...PromoFragment\n }\n deposit {\n type\n amount\n netAmount\n fee\n status\n reference\n dateTimeCreated\n dateTimeLastUpdated\n }\n amount\n balance\n turnoverRequirement\n currentTurnoverRequirementContribution\n currentTurnoverRequirementContributionPercentage\n turnoverRequirementContributionPercentagePerGameProvider\n enabledGameProviders\n expiration\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n query CurrentBonus {\n currentBonus: bonus {\n ...BonusFragment\n }\n }\n";
|
|
54
55
|
export declare const CASHBACK_BONUS_FRAGMENT = "\n \n \n fragment FileFragment on File {\n id\n url\n status\n }\n\n\n fragment CashbackFragment on Cashback {\n id\n name\n banner {\n ...FileFragment\n }\n minimumCashback\n maximumMonthlyCashback\n status\n description\n activationStartDateTime\n activationEndDateTime\n turnoverContributionPercentagePerGameProvider\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n fragment CashbackBonusFragment on CashbackBonus {\n id\n balance\n total\n cashback {\n ...CashbackFragment\n }\n dateTimeCreated\n dateTimeLastUpdated\n }\n";
|
|
55
56
|
export declare const CASHBACK_BONUSES = "\n \n \n \n fragment FileFragment on File {\n id\n url\n status\n }\n\n\n fragment CashbackFragment on Cashback {\n id\n name\n banner {\n ...FileFragment\n }\n minimumCashback\n maximumMonthlyCashback\n status\n description\n activationStartDateTime\n activationEndDateTime\n turnoverContributionPercentagePerGameProvider\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n fragment CashbackBonusFragment on CashbackBonus {\n id\n balance\n total\n cashback {\n ...CashbackFragment\n }\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n query CashbackBonuses {\n cashbackBonuses {\n ...CashbackBonusFragment\n }\n }\n";
|
|
57
|
+
export declare const CASHBACK_BONUSES_IDS = "\n query CashbackBonusesIds {\n cashbackBonuses {\n id\n }\n }\n";
|
|
56
58
|
export declare const CASHBACK_BONUS = "\n \n \n \n fragment FileFragment on File {\n id\n url\n status\n }\n\n\n fragment CashbackFragment on Cashback {\n id\n name\n banner {\n ...FileFragment\n }\n minimumCashback\n maximumMonthlyCashback\n status\n description\n activationStartDateTime\n activationEndDateTime\n turnoverContributionPercentagePerGameProvider\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n fragment CashbackBonusFragment on CashbackBonus {\n id\n balance\n total\n cashback {\n ...CashbackFragment\n }\n dateTimeCreated\n dateTimeLastUpdated\n }\n\n\n query CashbackBonus($id: ObjectId!) {\n node(id: $id) {\n ... on CashbackBonus {\n ...CashbackBonusFragment\n }\n }\n }\n";
|
|
57
59
|
export declare const CLAIM_CASHBACK_BONUS = "\n mutation ClaimCashbackBonus($input: ClaimCashbackBonusInput!) {\n claimCashbackBonus(input: $input) {\n ... on CashbackBonusDoesNotExistError {\n name: __typename\n message\n }\n }\n }\n";
|
|
58
60
|
export declare const MEMBER = "\n query Member {\n member {\n dateTimeLastActive\n }\n }\n";
|
package/dist/services/queries.js
CHANGED
|
@@ -1217,6 +1217,13 @@ export const BONUSES = /* GraphQL */ `
|
|
|
1217
1217
|
}
|
|
1218
1218
|
}
|
|
1219
1219
|
`;
|
|
1220
|
+
export const BONUSES_IDS = /* GraphQL */ `
|
|
1221
|
+
query BonusesIds {
|
|
1222
|
+
bonuses {
|
|
1223
|
+
id
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
`;
|
|
1220
1227
|
export const BONUS = /* GraphQL */ `
|
|
1221
1228
|
${BONUS_FRAGMENT}
|
|
1222
1229
|
|
|
@@ -1260,6 +1267,13 @@ export const CASHBACK_BONUSES = /* GraphQL */ `
|
|
|
1260
1267
|
}
|
|
1261
1268
|
}
|
|
1262
1269
|
`;
|
|
1270
|
+
export const CASHBACK_BONUSES_IDS = /* GraphQL */ `
|
|
1271
|
+
query CashbackBonusesIds {
|
|
1272
|
+
cashbackBonuses {
|
|
1273
|
+
id
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
`;
|
|
1263
1277
|
export const CASHBACK_BONUS = /* GraphQL */ `
|
|
1264
1278
|
${CASHBACK_BONUS_FRAGMENT}
|
|
1265
1279
|
|
|
@@ -34,9 +34,15 @@ export interface AvailablePromosQueryVariables {
|
|
|
34
34
|
}
|
|
35
35
|
export declare const getAvailablePromos: (input: AvailablePromosInput, options?: GraphQLRequestOptions) => Promise<Promo[]>;
|
|
36
36
|
export interface CashbackBonusesQuery {
|
|
37
|
-
cashbackBonuses
|
|
37
|
+
cashbackBonuses?: CashbackBonus[] | null;
|
|
38
38
|
}
|
|
39
39
|
export declare const getCashbackBonuses: (options?: GraphQLRequestOptions) => Promise<CashbackBonus[]>;
|
|
40
|
+
export interface CashbackBonusesIdsQuery {
|
|
41
|
+
cashbackBonuses?: {
|
|
42
|
+
id: string;
|
|
43
|
+
}[] | null;
|
|
44
|
+
}
|
|
45
|
+
export declare const getCashbackBonusesCount: (options?: GraphQLRequestOptions) => Promise<number>;
|
|
40
46
|
export type ClaimCashbackBonusError = {
|
|
41
47
|
name: 'CashbackBonusDoesNotExistError';
|
|
42
48
|
message: string;
|
|
@@ -404,6 +410,12 @@ export interface BonusesQuery {
|
|
|
404
410
|
bonuses?: Bonus[] | null;
|
|
405
411
|
}
|
|
406
412
|
export declare const getBonuses: (options?: GraphQLRequestOptions) => Promise<Bonus[]>;
|
|
413
|
+
export interface BonusesIdsQuery {
|
|
414
|
+
bonuses?: {
|
|
415
|
+
id: string;
|
|
416
|
+
}[] | null;
|
|
417
|
+
}
|
|
418
|
+
export declare const getBonusesCount: (options?: GraphQLRequestOptions) => Promise<number>;
|
|
407
419
|
export type ClaimSpotBonusError = {
|
|
408
420
|
name: 'InvalidPromoCodeError';
|
|
409
421
|
message: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cache } from 'react';
|
|
2
2
|
import { WALLET_GRAPHQL_ENDPOINT } from '../constants/index.js';
|
|
3
3
|
import { graphqlRequest } from './graphqlRequest.js';
|
|
4
|
-
import { AVAILABLE_PROMOS, BONUS, BONUSES, CASHBACK, CASHBACK_BONUS, CASHBACK_BONUSES, CASHBACKS, CLAIM_CASHBACK_BONUS, CLAIM_SPOT_BONUS, CREATE_AIO_INSTAPAY_WITHDRAWAL, CREATE_AIO_ONLINE_BANK_DEPOSIT, CREATE_AIO_QRPH_DEPOSIT, CREATE_BANK_WITHDRAWAL, CREATE_GAME_SESSION, CREATE_GCASH_DEPOSIT, CREATE_GCASH_DIRECT_WEBPAY_DEPOSIT, CREATE_GCASH_WITHDRAWAL, CREATE_MANUAL_BANK_DEPOSIT, CREATE_MANUAL_BANK_WITHDRAWAL, CREATE_MANUAL_UPI_DEPOSIT, CREATE_MANUAL_UPI_WITHDRAWAL, CREATE_MAYA_APP_DEPOSIT, CREATE_MAYA_APP_WITHDRAWAL, CREATE_MAYA_DEPOSIT, CREATE_MAYA_WITHDRAWAL, CURRENT_BONUS, DEPOSIT, END_GAME_SESSION, FAVORITE_GAMES, GAME_SESSION, INSTAPAY_BANK_LIST, MARK_GAME_AS_FAVORITE, MAYA_SESSION, POINTS_WALLET, PROMO, PROMOS, REDEEM_POINTS_TO_CASH, REMAINING_DAILY_WITHDRAWALS_COUNT, TOUCH_GCASH_DEPOSIT, TOUCH_QRPH_DEPOSIT, UNMARK_GAME_AS_FAVORITE, VALIDATE_MAYA_SESSION, WALLET, } from './queries.js';
|
|
4
|
+
import { AVAILABLE_PROMOS, BONUS, BONUSES, BONUSES_IDS, CASHBACK, CASHBACK_BONUS, CASHBACK_BONUSES, CASHBACK_BONUSES_IDS, CASHBACKS, CLAIM_CASHBACK_BONUS, CLAIM_SPOT_BONUS, CREATE_AIO_INSTAPAY_WITHDRAWAL, CREATE_AIO_ONLINE_BANK_DEPOSIT, CREATE_AIO_QRPH_DEPOSIT, CREATE_BANK_WITHDRAWAL, CREATE_GAME_SESSION, CREATE_GCASH_DEPOSIT, CREATE_GCASH_DIRECT_WEBPAY_DEPOSIT, CREATE_GCASH_WITHDRAWAL, CREATE_MANUAL_BANK_DEPOSIT, CREATE_MANUAL_BANK_WITHDRAWAL, CREATE_MANUAL_UPI_DEPOSIT, CREATE_MANUAL_UPI_WITHDRAWAL, CREATE_MAYA_APP_DEPOSIT, CREATE_MAYA_APP_WITHDRAWAL, CREATE_MAYA_DEPOSIT, CREATE_MAYA_WITHDRAWAL, CURRENT_BONUS, DEPOSIT, END_GAME_SESSION, FAVORITE_GAMES, GAME_SESSION, INSTAPAY_BANK_LIST, MARK_GAME_AS_FAVORITE, MAYA_SESSION, POINTS_WALLET, PROMO, PROMOS, REDEEM_POINTS_TO_CASH, REMAINING_DAILY_WITHDRAWALS_COUNT, TOUCH_GCASH_DEPOSIT, TOUCH_QRPH_DEPOSIT, UNMARK_GAME_AS_FAVORITE, VALIDATE_MAYA_SESSION, WALLET, } from './queries.js';
|
|
5
5
|
import { sha256 } from './sha256.js';
|
|
6
6
|
export const getPromos = cache(async (options) => {
|
|
7
7
|
const res = await graphqlRequest(WALLET_GRAPHQL_ENDPOINT, PROMOS, undefined, options);
|
|
@@ -25,7 +25,11 @@ export const getAvailablePromos = cache(async (input, options) => {
|
|
|
25
25
|
});
|
|
26
26
|
export const getCashbackBonuses = cache(async (options) => {
|
|
27
27
|
const res = await graphqlRequest(WALLET_GRAPHQL_ENDPOINT, CASHBACK_BONUSES, undefined, options);
|
|
28
|
-
return res.cashbackBonuses;
|
|
28
|
+
return res.cashbackBonuses ?? [];
|
|
29
|
+
});
|
|
30
|
+
export const getCashbackBonusesCount = cache(async (options) => {
|
|
31
|
+
const res = await graphqlRequest(WALLET_GRAPHQL_ENDPOINT, CASHBACK_BONUSES_IDS, undefined, options);
|
|
32
|
+
return res.cashbackBonuses?.length ?? 0;
|
|
29
33
|
});
|
|
30
34
|
export const claimCashbackBonus = async (id, options) => {
|
|
31
35
|
const res = await graphqlRequest(WALLET_GRAPHQL_ENDPOINT, CLAIM_CASHBACK_BONUS, { input: { id } }, options);
|
|
@@ -301,6 +305,10 @@ export const getBonuses = cache(async (options) => {
|
|
|
301
305
|
const res = await graphqlRequest(WALLET_GRAPHQL_ENDPOINT, BONUSES, undefined, options);
|
|
302
306
|
return res.bonuses ?? [];
|
|
303
307
|
});
|
|
308
|
+
export const getBonusesCount = cache(async (options) => {
|
|
309
|
+
const res = await graphqlRequest(WALLET_GRAPHQL_ENDPOINT, BONUSES_IDS, undefined, options);
|
|
310
|
+
return res.bonuses?.length ?? 0;
|
|
311
|
+
});
|
|
304
312
|
export const claimSpotBonus = async (code, options) => {
|
|
305
313
|
const res = await graphqlRequest(WALLET_GRAPHQL_ENDPOINT, CLAIM_SPOT_BONUS, { code }, options);
|
|
306
314
|
if (res.claimSpotBonus) {
|