@opexa/portal-components 0.0.62 → 0.0.64
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 +8 -2
- package/dist/client/hooks/index.js +8 -2
- package/dist/client/hooks/useBonusQuery.d.ts +3 -0
- package/dist/client/hooks/useBonusQuery.js +34 -0
- package/dist/client/hooks/useCashbackBonusQuery.d.ts +3 -0
- package/dist/client/hooks/useCashbackBonusQuery.js +34 -0
- package/dist/client/hooks/useCashbackBonusesQuery.d.ts +3 -0
- package/dist/client/hooks/useCashbackBonusesQuery.js +32 -0
- package/dist/client/hooks/useCashbackQuery.d.ts +3 -0
- package/dist/client/hooks/useCashbackQuery.js +20 -0
- package/dist/client/hooks/useClaimCashbackBonusMutation.d.ts +2 -0
- package/dist/client/hooks/useClaimCashbackBonusMutation.js +28 -0
- package/dist/client/hooks/useClaimSpotBonusMutation.d.ts +2 -0
- package/dist/client/hooks/useClaimSpotBonusMutation.js +28 -0
- package/dist/client/utils/createContext.d.ts +9 -0
- package/dist/client/utils/createContext.js +14 -0
- package/dist/client/utils/index.d.ts +1 -0
- package/dist/client/utils/index.js +1 -0
- package/dist/components/Bonuses/Bonuses.client.d.ts +2 -0
- package/dist/components/Bonuses/Bonuses.client.js +87 -0
- package/dist/components/Bonuses/Bonuses.d.ts +3 -3
- package/dist/components/Bonuses/Bonuses.js +6 -14
- package/dist/components/Bonuses/money-on-hand.png +0 -0
- package/dist/components/Bonuses/piggy-bank.png +0 -0
- package/dist/components/Cashback/Cashback.client.d.ts +1 -1
- package/dist/components/Cashback/Cashback.client.js +21 -3
- package/dist/components/Cashback/Cashback.d.ts +2 -5
- package/dist/components/Cashback/Cashback.js +11 -1
- package/dist/components/CashbackBonus/CashbackBonus.client.d.ts +2 -0
- package/dist/components/CashbackBonus/CashbackBonus.client.js +9 -0
- package/dist/components/CashbackBonus/CashbackBonus.d.ts +10 -0
- package/dist/components/CashbackBonus/CashbackBonus.js +5 -0
- package/dist/components/CashbackBonus/index.d.ts +1 -0
- package/dist/components/CashbackBonus/index.js +1 -0
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.d.ts +1 -2
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.js +2 -8
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositContext.d.ts +1 -2
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositContext.js +2 -8
- package/dist/components/Empty.d.ts +1 -0
- package/dist/components/Empty.js +1 -1
- package/dist/components/Games/GameContext.d.ts +1 -2
- package/dist/components/Games/GameContext.js +2 -8
- package/dist/components/KYC/KYCContext.d.ts +1 -2
- package/dist/components/KYC/KYCContext.js +2 -8
- package/dist/components/Messages/MessageItem.js +3 -2
- package/dist/components/Messages/MessagePopup.js +1 -0
- package/dist/components/Messages/MessageTrigger.d.ts +8 -0
- package/dist/components/Messages/MessageTrigger.js +18 -0
- package/dist/components/Messages/index.d.ts +2 -0
- package/dist/components/Messages/index.js +2 -0
- package/dist/components/PortalProvider/WebVitals.js +2 -2
- package/dist/components/Promo/Promo.client.d.ts +1 -1
- package/dist/components/Promo/Promo.client.js +3 -3
- package/dist/components/Promos/Cashback.d.ts +7 -0
- package/dist/components/Promos/Cashback.js +17 -0
- package/dist/components/Promos/Promo.d.ts +7 -0
- package/dist/components/Promos/Promo.js +17 -0
- package/dist/components/Promos/Promos.d.ts +4 -0
- package/dist/components/Promos/Promos.js +6 -6
- package/dist/components/Promos/PromosCarousel.d.ts +2 -0
- package/dist/components/Promos/{PromoCarousel.js → PromosCarousel.js} +9 -5
- package/dist/components/Promos/PromosGrid.d.ts +2 -0
- package/dist/components/Promos/PromosGrid.js +16 -0
- package/dist/components/SignIn/MobileNumberSignIn.js +5 -1
- package/dist/components/SignIn/NameAndPasswordSignIn.js +83 -20
- package/dist/components/SignIn/SignIn.js +6 -3
- package/dist/components/SignIn/SignInContext.d.ts +2 -12
- package/dist/components/SignIn/SignInContext.js +2 -18
- package/dist/components/SignIn/SignInForm.js +3 -3
- package/dist/components/SignIn/useSignIn.d.ts +10 -0
- package/dist/components/SignIn/useSignIn.js +11 -0
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +2 -1
- package/dist/constants/index.d.ts +4 -2
- package/dist/constants/index.js +24 -0
- package/dist/server/utils/index.d.ts +4 -0
- package/dist/server/utils/index.js +4 -0
- package/dist/server/utils/prefetchBonusQuery.d.ts +1 -0
- package/dist/server/utils/prefetchBonusQuery.js +22 -0
- package/dist/server/utils/prefetchCashbackBonusQuery.d.ts +1 -0
- package/dist/server/utils/prefetchCashbackBonusQuery.js +22 -0
- package/dist/server/utils/prefetchCashbackBonusesQuery.d.ts +1 -0
- package/dist/server/utils/prefetchCashbackBonusesQuery.js +22 -0
- package/dist/server/utils/prefetchCashbackQuery.d.ts +1 -0
- package/dist/server/utils/prefetchCashbackQuery.js +17 -0
- package/dist/ui/Badge/Badge.d.ts +12 -0
- package/dist/ui/Badge/badge.recipe.d.ts +3 -0
- package/dist/ui/Badge/badge.recipe.js +11 -0
- package/dist/ui/Progress/progress.recipe.js +1 -1
- package/dist/utils/queryKeys.d.ts +6 -0
- package/dist/utils/queryKeys.js +18 -0
- package/package.json +3 -3
- package/dist/components/AccountPaymentMethods/AccountPaymentMethods.d.ts +0 -1
- package/dist/components/AccountPaymentMethods/AccountPaymentMethods.js +0 -3
- package/dist/components/AccountPaymentMethods/index.d.ts +0 -1
- package/dist/components/AccountPaymentMethods/index.js +0 -1
- package/dist/components/AccountVerification/AccountVerificationContext.d.ts +0 -14
- package/dist/components/AccountVerification/AccountVerificationContext.js +0 -27
- package/dist/components/AccountVerification/VerificationCapture.d.ts +0 -1
- package/dist/components/AccountVerification/VerificationCapture.js +0 -28
- package/dist/components/AccountVerification/VerificationComplete.d.ts +0 -1
- package/dist/components/AccountVerification/VerificationComplete.js +0 -9
- package/dist/components/AccountVerification/VerificationDetails.d.ts +0 -1
- package/dist/components/AccountVerification/VerificationDetails.js +0 -38
- package/dist/components/GamesSearch/GamesSearchTrigger.d.ts +0 -5
- package/dist/components/GamesSearch/GamesSearchTrigger.js +0 -14
- package/dist/components/KYC/AccountVerificationContext.d.ts +0 -14
- package/dist/components/KYC/AccountVerificationContext.js +0 -27
- package/dist/components/KYC/VerificationCapture.d.ts +0 -1
- package/dist/components/KYC/VerificationCapture.js +0 -28
- package/dist/components/KYC/VerificationComplete.d.ts +0 -1
- package/dist/components/KYC/VerificationComplete.js +0 -9
- package/dist/components/KYC/VerificationDetails.d.ts +0 -1
- package/dist/components/KYC/VerificationDetails.js +0 -38
- package/dist/components/Promo/PromoContent.d.ts +0 -2
- package/dist/components/Promo/PromoContent.js +0 -9
- package/dist/components/Promos/PromoCarousel.d.ts +0 -2
- package/dist/components/Promos/PromoGrid.d.ts +0 -2
- package/dist/components/Promos/PromoGrid.js +0 -11
- package/dist/components/Promos/PromoItem.d.ts +0 -7
- package/dist/components/Promos/PromoItem.js +0 -17
- package/dist/components/Rewards/Rewards.client.d.ts +0 -2
- package/dist/components/Rewards/Rewards.client.js +0 -25
- package/dist/components/Rewards/Rewards.d.ts +0 -15
- package/dist/components/Rewards/Rewards.js +0 -7
- package/dist/components/Rewards/index.d.ts +0 -1
- package/dist/components/Rewards/index.js +0 -1
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import { createContext
|
|
2
|
-
|
|
3
|
-
export const QRPHDepositContext = createContext(null);
|
|
4
|
-
export const useQRPHDepositContext = () => {
|
|
5
|
-
const context = useContext(QRPHDepositContext);
|
|
6
|
-
invariant(context);
|
|
7
|
-
return context;
|
|
8
|
-
};
|
|
1
|
+
import { createContext } from '../../../../client/utils/index.js';
|
|
2
|
+
export const [QRPHDepositContext, useQRPHDepositContext] = createContext();
|
package/dist/components/Empty.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
export function Empty(props) {
|
|
3
|
-
return (_jsxs("div", { role: "alert", "aria-live": "polite", className: props.className, children: [_jsxs("div", { className: "relative mx-auto w-[9.5rem] pt-4", children: [_jsx("div", { className: "bg-utility-gray-200 absolute left-1/2 top-0 size-[6.5rem] -translate-x-1/2 rounded-full" }), _jsx(CloudIcon, { className: "relative h-auto w-full shrink-0" }), _jsx("div", { className: "bg-utility-gray-200/40 absolute bottom-2 left-1/2 flex size-12 -translate-x-1/2 items-center justify-center rounded-full backdrop-blur-sm", children: _jsx(props.icon, { className: "size-6 text-white" }) }), _jsx("div", { className: "bg-utility-gray-200 absolute left-4 top-3.5 size-2.5 rounded-full" }), _jsx("div", { className: "bg-utility-gray-200 absolute bottom-0.5 left-3 size-3.5 rounded-full" }), _jsx("div", { className: "bg-utility-gray-200 absolute right-3.5 top-1 size-2 rounded-full" }), _jsx("div", { className: "bg-utility-gray-200 absolute right-0 top-6.5 size-3.5 rounded-full" })] }), _jsx("h2", { className: "mt-xl text-center font-semibold", children: props.title }), _jsx("p", { className: "text-text-tertiary-600 mx-auto mt-xs max-w-[25rem] text-center text-sm", children: props.message })] }));
|
|
3
|
+
return (_jsxs("div", { role: "alert", "aria-live": "polite", style: props.style, className: props.className, children: [_jsxs("div", { className: "relative mx-auto w-[9.5rem] pt-4", children: [_jsx("div", { className: "bg-utility-gray-200 absolute left-1/2 top-0 size-[6.5rem] -translate-x-1/2 rounded-full" }), _jsx(CloudIcon, { className: "relative h-auto w-full shrink-0" }), _jsx("div", { className: "bg-utility-gray-200/40 absolute bottom-2 left-1/2 flex size-12 -translate-x-1/2 items-center justify-center rounded-full backdrop-blur-sm", children: _jsx(props.icon, { className: "size-6 text-white" }) }), _jsx("div", { className: "bg-utility-gray-200 absolute left-4 top-3.5 size-2.5 rounded-full" }), _jsx("div", { className: "bg-utility-gray-200 absolute bottom-0.5 left-3 size-3.5 rounded-full" }), _jsx("div", { className: "bg-utility-gray-200 absolute right-3.5 top-1 size-2 rounded-full" }), _jsx("div", { className: "bg-utility-gray-200 absolute right-0 top-6.5 size-3.5 rounded-full" })] }), _jsx("h2", { className: "mt-xl text-center font-semibold", children: props.title }), _jsx("p", { className: "text-text-tertiary-600 mx-auto mt-xs max-w-[25rem] text-center text-sm", children: props.message })] }));
|
|
4
4
|
}
|
|
5
5
|
function CloudIcon(props) {
|
|
6
6
|
return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 152 104", fill: "none", ...props, children: [_jsxs("g", { filter: "url(#filter0_dd_2719_19242)", children: [_jsx("path", { d: "M77.6 0C66.8273 0 57.2978 5.32329 51.4987 13.4829C49.605 13.0363 47.6301 12.8 45.6 12.8C31.4615 12.8 20 24.2615 20 38.4C20 52.5385 31.4615 64 45.6 64L109.6 64C121.971 64 132 53.9712 132 41.6C132 29.2288 121.971 19.2 109.6 19.2C108.721 19.2 107.854 19.2506 107.002 19.349C102.098 7.9677 90.7797 0 77.6 0Z", fill: "#F9FAFB" }), _jsx("ellipse", { cx: "45.6", cy: "38.4008", rx: "25.6", ry: "25.6", fill: "url(#paint0_linear_2719_19242)" }), _jsx("circle", { cx: "77.6", cy: "32", r: "32", fill: "url(#paint1_linear_2719_19242)" }), _jsx("ellipse", { cx: "109.6", cy: "41.5992", rx: "22.4", ry: "22.4", fill: "url(#paint2_linear_2719_19242)" })] }), _jsxs("defs", { children: [_jsxs("filter", { id: "filter0_dd_2719_19242", x: "0", y: "0", width: "152", height: "104", filterUnits: "userSpaceOnUse", colorInterpolationFilters: "sRGB", children: [_jsx("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }), _jsx("feColorMatrix", { in: "SourceAlpha", type: "matrix", values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0", result: "hardAlpha" }), _jsx("feMorphology", { radius: "4", operator: "erode", in: "SourceAlpha", result: "effect1_dropShadow_2719_19242" }), _jsx("feOffset", { dy: "8" }), _jsx("feGaussianBlur", { stdDeviation: "4" }), _jsx("feComposite", { in2: "hardAlpha", operator: "out" }), _jsx("feColorMatrix", { type: "matrix", values: "0 0 0 0 0.0627451 0 0 0 0 0.0941176 0 0 0 0 0.156863 0 0 0 0.03 0" }), _jsx("feBlend", { mode: "normal", in2: "BackgroundImageFix", result: "effect1_dropShadow_2719_19242" }), _jsx("feColorMatrix", { in: "SourceAlpha", type: "matrix", values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0", result: "hardAlpha" }), _jsx("feMorphology", { radius: "4", operator: "erode", in: "SourceAlpha", result: "effect2_dropShadow_2719_19242" }), _jsx("feOffset", { dy: "20" }), _jsx("feGaussianBlur", { stdDeviation: "12" }), _jsx("feComposite", { in2: "hardAlpha", operator: "out" }), _jsx("feColorMatrix", { type: "matrix", values: "0 0 0 0 0.0627451 0 0 0 0 0.0941176 0 0 0 0 0.156863 0 0 0 0.08 0" }), _jsx("feBlend", { mode: "normal", in2: "effect1_dropShadow_2719_19242", result: "effect2_dropShadow_2719_19242" }), _jsx("feBlend", { mode: "normal", in: "SourceGraphic", in2: "effect2_dropShadow_2719_19242", result: "shape" })] }), _jsxs("linearGradient", { id: "paint0_linear_2719_19242", x1: "25.9429", y1: "21.4865", x2: "71.2", y2: "64.0007", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { stopColor: "#D0D5DD" }), _jsx("stop", { offset: "0.350715", stopColor: "white", stopOpacity: "0" })] }), _jsxs("linearGradient", { id: "paint1_linear_2719_19242", x1: "53.0286", y1: "10.8571", x2: "109.6", y2: "64", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { stopColor: "#D0D5DD" }), _jsx("stop", { offset: "0.350715", stopColor: "white", stopOpacity: "0" })] }), _jsxs("linearGradient", { id: "paint2_linear_2719_19242", x1: "92.4", y1: "26.7992", x2: "132", y2: "63.9992", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { stopColor: "#D0D5DD" }), _jsx("stop", { offset: "0.350715", stopColor: "white", stopOpacity: "0" })] })] })] }));
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import { createContext
|
|
2
|
-
|
|
3
|
-
export const GameContext = createContext(null);
|
|
4
|
-
export const useGameContext = () => {
|
|
5
|
-
const context = useContext(GameContext);
|
|
6
|
-
invariant(context);
|
|
7
|
-
return context;
|
|
8
|
-
};
|
|
1
|
+
import { createContext } from '../../client/utils/index.js';
|
|
2
|
+
export const [GameContext, useGameContext] = createContext();
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { UseKYCReturn } from './useKYC';
|
|
2
|
-
export declare const KYCContext: import("react").Context<UseKYCReturn
|
|
3
|
-
export declare const useKYCContext: () => UseKYCReturn;
|
|
2
|
+
export declare const KYCContext: import("react").Context<UseKYCReturn>, useKYCContext: () => UseKYCReturn;
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import { createContext
|
|
2
|
-
|
|
3
|
-
export const KYCContext = createContext(null);
|
|
4
|
-
export const useKYCContext = () => {
|
|
5
|
-
const context = useContext(KYCContext);
|
|
6
|
-
invariant(context);
|
|
7
|
-
return context;
|
|
8
|
-
};
|
|
1
|
+
import { createContext } from '../../client/utils/index.js';
|
|
2
|
+
export const [KYCContext, useKYCContext] = createContext();
|
|
@@ -14,13 +14,14 @@ export function MessageItem({ message }) {
|
|
|
14
14
|
message: ctx.message,
|
|
15
15
|
messages: ctx.messages,
|
|
16
16
|
})));
|
|
17
|
-
const
|
|
17
|
+
const markMessageAsReadMutation = useMarkMessageAsReadMutation();
|
|
18
18
|
const Icon = getMessageIcon(icon);
|
|
19
19
|
const handleViewMessage = async () => {
|
|
20
|
-
mutate(id);
|
|
21
20
|
globalStore.message.setData(message);
|
|
22
21
|
globalStore.message.setOpen(true);
|
|
23
22
|
globalStore.messages.setOpen(false);
|
|
23
|
+
if (!markedAsRead)
|
|
24
|
+
markMessageAsReadMutation.mutate(id);
|
|
24
25
|
};
|
|
25
26
|
const handleActionClick = (e) => {
|
|
26
27
|
e.stopPropagation();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Message } from '@opexa/portal-sdk-core';
|
|
2
|
+
import type { ComponentPropsWithRef } from 'react';
|
|
3
|
+
interface MessageTriggerProps extends ComponentPropsWithRef<'button'> {
|
|
4
|
+
message: Message;
|
|
5
|
+
asChild?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function MessageTrigger(props: MessageTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ark } from '@ark-ui/react';
|
|
4
|
+
import { useShallow } from 'zustand/shallow';
|
|
5
|
+
import { useGlobalStore, useMarkMessageAsReadMutation, } from '../../client/hooks/index.js';
|
|
6
|
+
export function MessageTrigger(props) {
|
|
7
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
8
|
+
message: ctx.message,
|
|
9
|
+
})));
|
|
10
|
+
const markMessageAsReadMutation = useMarkMessageAsReadMutation();
|
|
11
|
+
return (_jsx(ark.button, { type: "button", "aria-label": "View message", "data-state": globalStore.message.open ? 'open' : 'closed', ...props, onClick: (e) => {
|
|
12
|
+
globalStore.message.setData(props.message);
|
|
13
|
+
globalStore.message.setOpen(true);
|
|
14
|
+
if (!props.message.markedAsRead)
|
|
15
|
+
markMessageAsReadMutation.mutate(props.message.id);
|
|
16
|
+
return props.onClick?.(e);
|
|
17
|
+
} }));
|
|
18
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { PromoProps } from './Promo';
|
|
2
|
-
export declare function Promo__client(props: PromoProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function Promo__client(props: PromoProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -4,7 +4,6 @@ import { tz } from '@date-fns/tz';
|
|
|
4
4
|
import { format } from 'date-fns';
|
|
5
5
|
import Image from 'next/image';
|
|
6
6
|
import Link from 'next/link';
|
|
7
|
-
import invariant from 'tiny-invariant';
|
|
8
7
|
import { useShallow } from 'zustand/shallow';
|
|
9
8
|
import { useGlobalStore, useLocaleInfo, usePromoQuery, } from '../../client/hooks/index.js';
|
|
10
9
|
import { ChevronLeftIcon } from '../../icons/index.js';
|
|
@@ -16,10 +15,11 @@ export function Promo__client(props) {
|
|
|
16
15
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
17
16
|
depositWithdrawal: ctx.depositWithdrawal,
|
|
18
17
|
})));
|
|
19
|
-
|
|
18
|
+
if (!promo)
|
|
19
|
+
return null;
|
|
20
20
|
return (_jsxs("div", { className: props.className, children: [_jsxs(Link, { href: props.viewAllPromosUrl ?? '/promos', className: "text-button-tertiary-fg flex w-fit items-center gap-lg text-lg font-semibold", children: [_jsx(ChevronLeftIcon, { className: "size-6" }), "Back to all Promotions"] }), promo.banner.url && (_jsx(Image, { src: promo.banner.url, alt: "", width: 1024, height: 600, className: "mt-xl h-auto w-full rounded-xl lg:mt-6" })), _jsx(Button, { className: "mt-xl lg:mt-6", onClick: () => {
|
|
21
21
|
globalStore.depositWithdrawal.setOpen(true);
|
|
22
|
-
}, children: "Deposit Now" }), _jsx("h1", { className: "mt-xl text-2xl font-semibold lg:mt-6 lg:text-3xl", children: promo.name }), _jsxs("p", { className: "text-text-secondary-700 mt-xl lg:mt-6", children: ["Ends", ' ', format(promo.activationEndDateTime, 'MM/dd/yyy hh:mm:ss
|
|
22
|
+
}, children: "Deposit Now" }), _jsx("h1", { className: "mt-xl text-2xl font-semibold lg:mt-6 lg:text-3xl", children: promo.name }), _jsxs("p", { className: "text-text-secondary-700 mt-xl lg:mt-6", children: ["Ends", ' ', format(promo.activationEndDateTime, 'MM/dd/yyy hh:mm:ss', {
|
|
23
23
|
in: tz(localeInfo.timezone),
|
|
24
24
|
})] }), _jsx(Prose, { className: "mt-2xl lg:mt-6", dangerouslySetInnerHTML: {
|
|
25
25
|
__html: promo.description,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Cashback as TCashback } from '@opexa/portal-sdk-core';
|
|
2
|
+
interface CashbackProps {
|
|
3
|
+
data: TCashback;
|
|
4
|
+
viewDetailsUrl: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function Cashback({ data, viewDetailsUrl, }: CashbackProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { useShallow } from 'zustand/shallow';
|
|
5
|
+
import { useAvailablePromosQuery, useGlobalStore } from '../../client/hooks/index.js';
|
|
6
|
+
import { Button } from '../../ui/index.js';
|
|
7
|
+
export function Cashback({ data, viewDetailsUrl = '/promos/cashback', }) {
|
|
8
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
9
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
10
|
+
})));
|
|
11
|
+
const claimablePromos = useAvailablePromosQuery().data ?? [];
|
|
12
|
+
const claimable = claimablePromos.find((availablePromo) => availablePromo.id === data.id);
|
|
13
|
+
return (_jsxs("div", { className: "border-border-secondary bg-accent-50 bg-bg-primary-alt relative flex h-full flex-col overflow-hidden rounded-2xl border", children: [data.banner.url && (_jsx(Image, { src: data.banner.url, alt: data.name, width: 1200, height: 500, priority: true, className: "block aspect-[365/180] w-full object-cover" })), _jsxs("div", { className: "flex flex-grow flex-col px-4 pb-3xl pt-2xl", children: [_jsx("div", { className: "w-full grow text-center text-xl font-semibold", children: data.name }), _jsxs("div", { className: "mt-auto flex flex-col gap-3 pt-4 lg:flex-row", children: [claimable && (_jsx(Button, { size: "sm", onClick: () => {
|
|
14
|
+
globalStore.depositWithdrawal.setOpen(true);
|
|
15
|
+
globalStore.depositWithdrawal.setPromo(data.id);
|
|
16
|
+
}, children: "Get bonus" })), _jsx(Button, { size: "sm", variant: "outline", asChild: true, children: _jsx(Link, { href: `${viewDetailsUrl}/${data.id}`, children: "Read more" }) })] })] })] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { useShallow } from 'zustand/shallow';
|
|
5
|
+
import { useAvailablePromosQuery, useGlobalStore } from '../../client/hooks/index.js';
|
|
6
|
+
import { Button } from '../../ui/index.js';
|
|
7
|
+
export function Promo({ data, viewDetailsUrl = '/promos' }) {
|
|
8
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
9
|
+
depositWithdrawal: ctx.depositWithdrawal,
|
|
10
|
+
})));
|
|
11
|
+
const claimablePromos = useAvailablePromosQuery().data ?? [];
|
|
12
|
+
const claimable = claimablePromos.find((availablePromo) => availablePromo.id === data.id);
|
|
13
|
+
return (_jsxs("div", { className: "border-border-secondary bg-accent-50 bg-bg-primary-alt relative flex h-full flex-col overflow-hidden rounded-2xl border", children: [data.banner.url && (_jsx(Image, { src: data.banner.url, alt: data.name, width: 1200, height: 500, priority: true, className: "block aspect-[365/180] w-full object-cover" })), _jsxs("div", { className: "flex flex-grow flex-col px-4 pb-3xl pt-2xl", children: [_jsx("div", { className: "w-full grow text-center text-xl font-semibold", children: data.name }), _jsxs("div", { className: "mt-auto flex flex-col gap-3 pt-4 lg:flex-row", children: [claimable && (_jsx(Button, { size: "sm", onClick: () => {
|
|
14
|
+
globalStore.depositWithdrawal.setOpen(true);
|
|
15
|
+
globalStore.depositWithdrawal.setPromo(data.id);
|
|
16
|
+
}, children: "Get bonus" })), _jsx(Button, { size: "sm", variant: "outline", asChild: true, children: _jsx(Link, { href: `${viewDetailsUrl}/${data.id}`, children: "Read more" }) })] })] })] }));
|
|
17
|
+
}
|
|
@@ -3,6 +3,10 @@ export interface PromosProps {
|
|
|
3
3
|
heading?: string;
|
|
4
4
|
/** @default "/promos" */
|
|
5
5
|
viewAllUrl?: string;
|
|
6
|
+
/** @default "/promos" */
|
|
7
|
+
viewPromoDetailsUrl?: string;
|
|
8
|
+
/** @default "/promos/cashback" */
|
|
9
|
+
viewCashbackDetailsUrl?: string;
|
|
6
10
|
/** @default 1 */
|
|
7
11
|
className?: string;
|
|
8
12
|
/** @default 'carousel' */
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { prefetchPromosQuery } from '../../server/utils/index.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { prefetchCashbacksQuery, prefetchPromosQuery, } from '../../server/utils/index.js';
|
|
3
|
+
import { PromosCarousel } from './PromosCarousel.js';
|
|
4
|
+
import { PromosGrid } from './PromosGrid.js';
|
|
5
5
|
export async function Promos(props) {
|
|
6
|
-
await prefetchPromosQuery();
|
|
6
|
+
await Promise.all([prefetchPromosQuery(), prefetchCashbacksQuery()]);
|
|
7
7
|
if (props.layout === 'grid') {
|
|
8
|
-
return _jsx(
|
|
8
|
+
return _jsx(PromosGrid, { ...props });
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
11
|
-
return _jsx(
|
|
11
|
+
return _jsx(PromosCarousel, { ...props });
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import useEmblaCarousel, {} from 'embla-carousel-react';
|
|
4
4
|
import Link from 'next/link';
|
|
5
5
|
import { useCallback, useEffect, useState } from 'react';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
|
-
import { usePromosQuery } from '../../client/hooks/index.js';
|
|
7
|
+
import { useCashbacksQuery, usePromosQuery } from '../../client/hooks/index.js';
|
|
8
8
|
import { ArrowLeftIcon, ArrowRightIcon, ChevronRightIcon, Gift01Icon, } from '../../icons/index.js';
|
|
9
9
|
import { Button } from '../../ui/index.js';
|
|
10
10
|
import { Empty } from '../Empty.js';
|
|
11
|
-
import {
|
|
12
|
-
|
|
11
|
+
import { Cashback } from './Cashback.js';
|
|
12
|
+
import { Promo } from './Promo.js';
|
|
13
|
+
export function PromosCarousel(props) {
|
|
13
14
|
const promosQuery = usePromosQuery();
|
|
15
|
+
const cashbacksQuery = useCashbacksQuery();
|
|
14
16
|
const promos = promosQuery.data ?? [];
|
|
17
|
+
const cashbacks = cashbacksQuery.data ?? [];
|
|
18
|
+
const empty = promos.length <= 0 && cashbacks.length <= 0;
|
|
15
19
|
const [emblaRef, emblaApi] = useEmblaCarousel({
|
|
16
20
|
align: 'start',
|
|
17
21
|
slidesToScroll: 1,
|
|
@@ -37,5 +41,5 @@ export function PromoCarousel(props) {
|
|
|
37
41
|
onSelect(emblaApi);
|
|
38
42
|
emblaApi.on('reInit', onSelect).on('select', onSelect);
|
|
39
43
|
}, [emblaApi, onSelect]);
|
|
40
|
-
return (_jsxs("div", { className: props.className, children: [_jsxs("div", { className: "flex items-center", children: [_jsx("h2", { className: "text-lg font-semibold", children: props.heading ?? 'Promotions' }), _jsx("div", { className: "grow" }), _jsxs("div", { className: "flex items-center justify-center gap-xl", children: [_jsxs(Link, { href: props.viewAllUrl ?? '/promos', className: "text-button-tertiary-fg flex gap-sm text-sm font-semibold", children: ["See All", _jsx(ChevronRightIcon, { className: "size-5 lg:hidden" })] }), _jsxs("div", { className: "hidden lg:flex", children: [_jsx(Button, { variant: "outline", colorScheme: "gray", className: "rounded-r-none border-r-0", onClick: onPrevButtonClick, disabled: prevBtnDisabled, "aria-label": "Previous", children: _jsx(ArrowLeftIcon, { className: "size-5" }) }), _jsx(Button, { variant: "outline", colorScheme: "gray", className: "rounded-l-none", onClick: onNextButtonClick, disabled: nextBtnDisabled, "aria-label": "Next", children: _jsx(ArrowRightIcon, { className: "size-5" }) })] })] })] }),
|
|
44
|
+
return (_jsxs("div", { className: props.className, children: [_jsxs("div", { className: "flex items-center", children: [_jsx("h2", { className: "text-lg font-semibold", children: props.heading ?? 'Promotions' }), _jsx("div", { className: "grow" }), _jsxs("div", { className: "flex items-center justify-center gap-xl", children: [_jsxs(Link, { href: props.viewAllUrl ?? '/promos', className: "text-button-tertiary-fg flex gap-sm text-sm font-semibold", children: ["See All", _jsx(ChevronRightIcon, { className: "size-5 lg:hidden" })] }), _jsxs("div", { className: "hidden lg:flex", children: [_jsx(Button, { variant: "outline", colorScheme: "gray", className: "rounded-r-none border-r-0", onClick: onPrevButtonClick, disabled: prevBtnDisabled, "aria-label": "Previous", children: _jsx(ArrowLeftIcon, { className: "size-5" }) }), _jsx(Button, { variant: "outline", colorScheme: "gray", className: "rounded-l-none", onClick: onNextButtonClick, disabled: nextBtnDisabled, "aria-label": "Next", children: _jsx(ArrowRightIcon, { className: "size-5" }) })] })] })] }), empty && (_jsx(Empty, { icon: Gift01Icon, title: "No Promos", message: "No promo is currently available.", className: "mt-8" })), !empty && (_jsx(_Fragment, { children: _jsx("div", { ref: emblaRef, className: "relative mt-lg lg:overflow-hidden", children: _jsxs("div", { className: twMerge('grid auto-cols-[100%] grid-flow-col gap-1.5 lg:auto-cols-[calc((100%-(1.25rem*2))/3)] lg:gap-2xl'), children: [promos.map((promo) => (_jsx(Promo, { data: promo, viewDetailsUrl: props.viewPromoDetailsUrl ?? '/promos' }, promo.id))), cashbacks.map((cashback) => (_jsx(Cashback, { data: cashback, viewDetailsUrl: props.viewCashbackDetailsUrl ?? '/promos/cashback' }, cashback.id)))] }) }) }))] }));
|
|
41
45
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCashbacksQuery, usePromosQuery } from '../../client/hooks/index.js';
|
|
4
|
+
import { Cashback } from './Cashback.js';
|
|
5
|
+
import { Promo } from './Promo.js';
|
|
6
|
+
export function PromosGrid(props) {
|
|
7
|
+
const promosQuery = usePromosQuery();
|
|
8
|
+
const cashbacksQuery = useCashbacksQuery();
|
|
9
|
+
const promos = promosQuery.data ?? [];
|
|
10
|
+
const cashbacks = cashbacksQuery.data ?? [];
|
|
11
|
+
const empty = promos.length <= 0 && cashbacks.length <= 0;
|
|
12
|
+
if (empty) {
|
|
13
|
+
return (_jsx("div", { className: props.className, children: _jsxs("div", { className: "flex items-center", children: [_jsx("h2", { className: "text-lg font-semibold", children: props.heading ?? 'Promos' }), _jsx("div", { className: "grow" })] }) }));
|
|
14
|
+
}
|
|
15
|
+
return (_jsxs("div", { className: props.className, children: [_jsxs("div", { className: "flex items-center", children: [_jsx("h2", { className: "text-lg font-semibold", children: props.heading ?? 'Promos' }), _jsx("div", { className: "grow" })] }), _jsx("div", { className: "relative mt-lg lg:overflow-hidden", children: _jsxs("div", { className: "grid gap-3xl lg:grid-cols-3 lg:gap-2xl", children: [promos.map((promo) => (_jsx(Promo, { data: promo, viewDetailsUrl: props.viewPromoDetailsUrl ?? '/promos' }, promo.id))), cashbacks.map((cashback) => (_jsx(Cashback, { data: cashback, viewDetailsUrl: props.viewCashbackDetailsUrl ?? '/promos/cashback' }, cashback.id)))] }) })] }));
|
|
16
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useDialogContext } from '@ark-ui/react';
|
|
3
3
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
4
|
+
import { useRef } from 'react';
|
|
4
5
|
import { Controller, useForm } from 'react-hook-form';
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
import { useShallow } from 'zustand/shallow';
|
|
@@ -55,6 +56,7 @@ export function MobileNumberSignIn() {
|
|
|
55
56
|
max: 60,
|
|
56
57
|
duration: 1000 * 60,
|
|
57
58
|
});
|
|
59
|
+
const form2Ref = useRef(null);
|
|
58
60
|
return (_jsxs(_Fragment, { children: [context.step === 1 && (_jsxs(_Fragment, { children: [_jsxs("form", { className: "mt-3xl", onSubmit: step1Form.handleSubmit(async (data) => {
|
|
59
61
|
try {
|
|
60
62
|
await sendVerificationCodeMutation.mutateAsync({
|
|
@@ -81,7 +83,7 @@ export function MobileNumberSignIn() {
|
|
|
81
83
|
}, className: "border-border-primary bg-bg-primary text-text-secondary-700 mt-lg", children: [_jsx(FacebookIcon, { className: "size-6" }), "Continue with Facebook"] })] }), _jsxs("div", { className: "mt-6 flex w-full items-center justify-center gap-xs text-sm", children: [_jsx("span", { className: "text-text-tertiary-600", children: "Don't have an account?" }), _jsx("button", { type: "submit", className: "text-button-tertiary-fg font-semibold", onClick: () => {
|
|
82
84
|
dialog.setOpen(false);
|
|
83
85
|
signUpStore.setOpen(true);
|
|
84
|
-
}, children: "Sign up" })] })] })), context.step === 2 && (_jsxs(_Fragment, { children: [_jsx("h2", { className: "mt-xl text-center text-lg font-semibold", children: "Check your Phone" }), _jsxs("p", { className: "text-text-secondary-700 mt-xs text-center text-sm", children: ["We\u2019ve sent a verification code to your mobile number", ' ', _jsx("span", { className: "font-semibold", children: mobileNumberParser.format(step1Form.getValues('mobileNumber')) }), ' ', "via text"] }), _jsxs("form", { className: "mt-5", onSubmit: step2Form.handleSubmit(async ({ verificationCode }) => {
|
|
86
|
+
}, children: "Sign up" })] })] })), context.step === 2 && (_jsxs(_Fragment, { children: [_jsx("h2", { className: "mt-xl text-center text-lg font-semibold", children: "Check your Phone" }), _jsxs("p", { className: "text-text-secondary-700 mt-xs text-center text-sm", children: ["We\u2019ve sent a verification code to your mobile number", ' ', _jsx("span", { className: "font-semibold", children: mobileNumberParser.format(step1Form.getValues('mobileNumber')) }), ' ', "via text"] }), _jsxs("form", { ref: form2Ref, className: "mt-5", onSubmit: step2Form.handleSubmit(async ({ verificationCode }) => {
|
|
85
87
|
const { mobileNumber } = step1Form.getValues();
|
|
86
88
|
try {
|
|
87
89
|
await signInMutation.mutateAsync({
|
|
@@ -101,6 +103,8 @@ export function MobileNumberSignIn() {
|
|
|
101
103
|
}
|
|
102
104
|
}), children: [_jsx(Controller, { name: "verificationCode", control: step2Form.control, render: (o) => (_jsxs(PinInput.Root, { placeholder: "0", invalid: o.fieldState.invalid, value: o.field.value, onValueChange: (details) => {
|
|
103
105
|
o.field.onChange(details.value);
|
|
106
|
+
}, otp: true, onValueComplete: () => {
|
|
107
|
+
form2Ref.current?.requestSubmit();
|
|
104
108
|
}, children: [_jsxs(PinInput.Control, { className: "grid-cols-[1fr_1fr_1fr_auto_1fr_1fr_1fr] items-center gap-md", children: [_jsx(PinInput.Input, { index: 0 }), _jsx(PinInput.Input, { index: 1 }), _jsx(PinInput.Input, { index: 2 }), _jsx("span", { className: "text-text-placeholder-subtle text-2xl font-medium", children: "\u2013" }), _jsx(PinInput.Input, { index: 3 }), _jsx(PinInput.Input, { index: 4 }), _jsx(PinInput.Input, { index: 5 })] }), _jsx(PinInput.HiddenInput, {})] })) }), _jsx(Button, { type: "submit", className: "mt-4xl", disabled: step2Form.formState.isSubmitting, children: "Verify" }), _jsxs("div", { className: "mt-3 flex w-full items-center justify-center gap-xs text-sm", children: [_jsx("span", { className: "text-text-secondary-700", children: "Didn't recieve the code?" }), _jsx("button", { type: "button", className: "text-button-secondary-fg font-semibold", disabled: cooldown.cooling, onClick: async () => {
|
|
105
109
|
await sendVerificationCodeMutation.mutateAsync({
|
|
106
110
|
channel: 'SMS',
|
|
@@ -4,24 +4,67 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
|
|
4
4
|
import { Controller, useForm } from 'react-hook-form';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { useShallow } from 'zustand/shallow';
|
|
7
|
-
import { useGlobalStore, useSignInMutation } from '../../client/hooks/index.js';
|
|
7
|
+
import { useAuthenticateMutation, useGlobalStore, useSignInMutation, } from '../../client/hooks/index.js';
|
|
8
8
|
import { toaster } from '../../client/utils/index.js';
|
|
9
|
+
import { SECRET_QUESTIONS, SECRET_QUESTIONS_MAP } from '../../constants/index.js';
|
|
9
10
|
import { CheckIcon, EyeIcon, EyeOffIcon, FacebookIcon, GoogleIcon, } from '../../icons/index.js';
|
|
10
11
|
import { Button, Checkbox, Field, PasswordInput } from '../../ui/index.js';
|
|
11
12
|
import { useSignInContext } from './SignInContext.js';
|
|
12
|
-
const Definition = z.object({
|
|
13
|
-
name: z.string(),
|
|
14
|
-
password: z.string(),
|
|
15
|
-
secretAnswer: z.string(),
|
|
16
|
-
termsAccepted: z.boolean().refine((val) => val, {
|
|
17
|
-
message: 'You must accept the terms and conditions',
|
|
18
|
-
}),
|
|
19
|
-
});
|
|
20
13
|
export function NameAndPasswordSignIn() {
|
|
21
14
|
const context = useSignInContext();
|
|
22
15
|
const dialog = useDialogContext();
|
|
23
|
-
const
|
|
24
|
-
|
|
16
|
+
const globalStore = useGlobalStore(useShallow((popups) => ({
|
|
17
|
+
signIn: popups.signIn,
|
|
18
|
+
signUp: popups.signUp,
|
|
19
|
+
})));
|
|
20
|
+
const signInMutation = useSignInMutation({
|
|
21
|
+
onSuccess(authenticator) {
|
|
22
|
+
if (authenticator) {
|
|
23
|
+
context.setStep(2);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
globalStore.signIn.setOpen(false);
|
|
27
|
+
authenticateMutation.reset();
|
|
28
|
+
signInMutation.reset();
|
|
29
|
+
context.setStep(0);
|
|
30
|
+
form.reset();
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
onError() {
|
|
34
|
+
toaster.error({
|
|
35
|
+
description: 'Invalid username or password',
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const authenticateMutation = useAuthenticateMutation({
|
|
40
|
+
onSuccess() {
|
|
41
|
+
globalStore.signIn.setOpen(false);
|
|
42
|
+
authenticateMutation.reset();
|
|
43
|
+
signInMutation.reset();
|
|
44
|
+
context.setStep(0);
|
|
45
|
+
form.reset();
|
|
46
|
+
},
|
|
47
|
+
onError() {
|
|
48
|
+
toaster.error({
|
|
49
|
+
description: 'Incorrect secret answer',
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
const Definition = z.object({
|
|
54
|
+
name: z.string().min(1, 'Username is required').trim(),
|
|
55
|
+
password: z.string().min(1, 'Password is required'),
|
|
56
|
+
secretAnswer: z.string().superRefine((val, ctx) => {
|
|
57
|
+
if (signInMutation.data && val.trim().length === 0) {
|
|
58
|
+
ctx.addIssue({
|
|
59
|
+
code: z.ZodIssueCode.custom,
|
|
60
|
+
message: 'Secret answer is required',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
64
|
+
termsAccepted: z.boolean().refine((val) => val, {
|
|
65
|
+
message: 'You must accept the terms and conditions',
|
|
66
|
+
}),
|
|
67
|
+
});
|
|
25
68
|
const form = useForm({
|
|
26
69
|
resolver: zodResolver(Definition),
|
|
27
70
|
defaultValues: {
|
|
@@ -30,17 +73,37 @@ export function NameAndPasswordSignIn() {
|
|
|
30
73
|
secretAnswer: '',
|
|
31
74
|
},
|
|
32
75
|
});
|
|
33
|
-
|
|
34
|
-
|
|
76
|
+
const secretQuestion = signInMutation.data
|
|
77
|
+
? z
|
|
78
|
+
.union([
|
|
79
|
+
z.enum(SECRET_QUESTIONS).transform((v) => {
|
|
80
|
+
return SECRET_QUESTIONS_MAP[v];
|
|
81
|
+
}),
|
|
82
|
+
z.string(),
|
|
83
|
+
])
|
|
84
|
+
.parse(signInMutation.data.secretQuestion)
|
|
85
|
+
: null;
|
|
86
|
+
return (_jsxs(_Fragment, { children: [_jsxs("form", { className: "mt-3xl", onSubmit: form.handleSubmit((data) => {
|
|
87
|
+
if (!signInMutation.data) {
|
|
88
|
+
signInMutation.mutate({
|
|
89
|
+
type: 'NAME_AND_PASSWORD',
|
|
90
|
+
name: data.name,
|
|
91
|
+
password: data.password,
|
|
92
|
+
});
|
|
35
93
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
94
|
+
else {
|
|
95
|
+
authenticateMutation.mutate({
|
|
96
|
+
type: 'SECURITY_QUESTION',
|
|
97
|
+
token: signInMutation.data.token,
|
|
98
|
+
secretAnswer: data.secretAnswer,
|
|
41
99
|
});
|
|
42
100
|
}
|
|
43
|
-
}), children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.name, children: [_jsx(Field.Label, { children: "Name" }), _jsx(Field.Input, { placeholder: "Enter your name", ...form.register('name'
|
|
101
|
+
}), children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.name, children: [_jsx(Field.Label, { children: "Name" }), _jsx(Field.Input, { placeholder: "Enter your name", ...form.register('name', {
|
|
102
|
+
onChange() {
|
|
103
|
+
signInMutation.reset();
|
|
104
|
+
form.setValue('secretAnswer', '');
|
|
105
|
+
},
|
|
106
|
+
}) }), _jsx(Field.ErrorText, { children: form.formState.errors.name?.message })] }), _jsxs(Field.Root, { disabled: !!signInMutation.data, invalid: !!form.formState.errors.name, className: "mt-xl", children: [_jsxs(PasswordInput.Root, { children: [_jsx(PasswordInput.Label, { children: "Password" }), _jsxs(PasswordInput.Control, { children: [_jsx(PasswordInput.Input, { placeholder: "Enter your password", ...form.register('password') }), _jsx(PasswordInput.VisibilityTrigger, { children: _jsx(PasswordInput.Indicator, { fallback: _jsx(EyeOffIcon, {}), asChild: true, children: _jsx(EyeIcon, {}) }) })] }), _jsx("div", { className: "mt-2 flex justify-end", children: _jsx("button", { type: "button", tabIndex: -1, className: "text-button-tertiary-fg text-sm font-semibold", children: "Forgot Password" }) })] }), _jsx(Field.ErrorText, { children: form.formState.errors.password?.message })] }), signInMutation.data && (_jsxs(Field.Root, { invalid: !!form.formState.errors.secretAnswer, className: "mt-xl", children: [_jsx(Field.Label, { children: secretQuestion }), _jsx(Field.Input, { placeholder: "Answer the security question", ...form.register('secretAnswer') }), _jsx(Field.ErrorText, { children: form.formState.errors.secretAnswer?.message })] })), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: signInMutation.isPending || authenticateMutation.isPending, children: "Log In" }), _jsx(Controller, { control: form.control, name: "termsAccepted", render: (o) => (_jsxs(Checkbox.Root, { className: "mt-xl", invalid: o.fieldState.invalid, checked: o.field.value, onCheckedChange: (details) => {
|
|
44
107
|
o.field.onChange(details.checked);
|
|
45
108
|
}, children: [_jsx(Checkbox.Control, { children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsxs(Checkbox.Label, { children: ["I am at least 21 years of age and I accept the", ' ', _jsx("span", { className: "text-brand-400 whitespace-nowrap underline underline-offset-2", children: "Terms and Conditions." })] }), _jsx(Checkbox.HiddenInput, {})] })) })] }), _jsxs("div", { className: "relative mt-6 text-center", children: [_jsx("hr", { className: "-translte-y-1/2 text-text-tertiary-600/50 absolute top-1/2 w-full" }), _jsx("span", { className: "text-text-tertiary-600 bg-bg-primary-alt relative px-md text-center text-sm font-semibold", children: "Log in directly with" })] }), _jsxs("div", { className: "mt-6", children: [_jsxs(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
|
|
46
109
|
dialog.setOpen(false);
|
|
@@ -48,6 +111,6 @@ export function NameAndPasswordSignIn() {
|
|
|
48
111
|
dialog.setOpen(false);
|
|
49
112
|
}, className: "border-border-primary bg-bg-primary text-text-secondary-700 mt-lg", children: [_jsx(FacebookIcon, { className: "size-6" }), "Continue with Facebook"] })] }), _jsxs("div", { className: "mt-6 flex w-full items-center justify-center gap-xs text-sm", children: [_jsx("span", { className: "text-text-tertiary-600", children: "Don't have an account?" }), _jsx("button", { type: "submit", className: "text-button-tertiary-fg font-semibold", onClick: () => {
|
|
50
113
|
dialog.setOpen(false);
|
|
51
|
-
|
|
114
|
+
globalStore.signUp.setOpen(true);
|
|
52
115
|
}, children: "Sign up" })] })] }));
|
|
53
116
|
}
|
|
@@ -6,10 +6,13 @@ import { useShallow } from 'zustand/shallow';
|
|
|
6
6
|
import { useGlobalStore } from '../../client/hooks/index.js';
|
|
7
7
|
import { XIcon } from '../../icons/index.js';
|
|
8
8
|
import { Dialog } from '../../ui/index.js';
|
|
9
|
+
import { SignInContext } from './SignInContext.js';
|
|
9
10
|
import { SignInForm } from './SignInForm.js';
|
|
11
|
+
import { useSignIn } from './useSignIn.js';
|
|
10
12
|
export function SignIn(props) {
|
|
13
|
+
const signIn = useSignIn();
|
|
11
14
|
const signInStore = useGlobalStore(useShallow((popups) => popups.signIn));
|
|
12
|
-
return (_jsx(Dialog.Root, { open: signInStore.open, onOpenChange: (details) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
return (_jsx(SignInContext, { value: signIn, children: _jsx(Dialog.Root, { open: signInStore.open, onOpenChange: (details) => {
|
|
16
|
+
signInStore.setOpen(details.open);
|
|
17
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsxs(Dialog.Content, { className: "bg-bg-primary-alt mx-auto h-full w-full items-start p-3xl pb-4xl lg:h-auto lg:w-[400px] lg:rounded-xl", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsx(Image, { src: props.logo, alt: "", width: 200, height: 100, className: "mx-auto h-7.5 w-auto", draggable: false }), _jsx(SignInForm, {})] }) })] }) }) }));
|
|
15
18
|
}
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
export interface UseSignInReturn {
|
|
4
|
-
step: SignInStep;
|
|
5
|
-
setStep: (step: SignInStep) => void;
|
|
6
|
-
type: SignInType;
|
|
7
|
-
setType: (type: SignInType) => void;
|
|
8
|
-
}
|
|
9
|
-
export declare function useSignIn(): UseSignInReturn;
|
|
10
|
-
export declare const SignInContext: import("react").Context<UseSignInReturn | null>;
|
|
11
|
-
export declare const useSignInContext: () => UseSignInReturn;
|
|
12
|
-
export {};
|
|
1
|
+
import type { UseSignInReturn } from './useSignIn';
|
|
2
|
+
export declare const SignInContext: import("react").Context<UseSignInReturn>, useSignInContext: () => UseSignInReturn;
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
import { createContext
|
|
2
|
-
|
|
3
|
-
export function useSignIn() {
|
|
4
|
-
const [step, setStep] = useState(1);
|
|
5
|
-
const [type, setType] = useState('MOBILE_NUMBER');
|
|
6
|
-
return {
|
|
7
|
-
step,
|
|
8
|
-
setStep,
|
|
9
|
-
type,
|
|
10
|
-
setType,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export const SignInContext = createContext(null);
|
|
14
|
-
export const useSignInContext = () => {
|
|
15
|
-
const context = useContext(SignInContext);
|
|
16
|
-
invariant(context);
|
|
17
|
-
return context;
|
|
18
|
-
};
|
|
1
|
+
import { createContext } from '../../client/utils/index.js';
|
|
2
|
+
export const [SignInContext, useSignInContext] = createContext();
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { MobileNumberSignIn } from './MobileNumberSignIn.js';
|
|
4
4
|
import { NameAndPasswordSignIn } from './NameAndPasswordSignIn.js';
|
|
5
|
-
import {
|
|
5
|
+
import { useSignInContext } from './SignInContext.js';
|
|
6
6
|
import { SignInMethod } from './SignInMethod.js';
|
|
7
7
|
export function SignInForm() {
|
|
8
|
-
const context =
|
|
9
|
-
return (_jsxs(
|
|
8
|
+
const context = useSignInContext();
|
|
9
|
+
return (_jsxs(_Fragment, { children: [context.step === 1 && (_jsxs(_Fragment, { children: [_jsx("h2", { className: "mt-xl text-center text-lg font-semibold", children: "Log in to your account" }), _jsx("p", { className: "text-text-secondary-700 mt-xs text-center text-sm", children: "Welcome back! Please enter your details." })] })), _jsx(SignInMethod, {}), context.type === 'MOBILE_NUMBER' && _jsx(MobileNumberSignIn, {}), context.type === 'NAME_AND_PASSWORD' && _jsx(NameAndPasswordSignIn, {})] }));
|
|
10
10
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type SignInStep = 1 | 2 | (number & {});
|
|
2
|
+
type SignInType = 'NAME_AND_PASSWORD' | 'MOBILE_NUMBER';
|
|
3
|
+
export interface UseSignInReturn {
|
|
4
|
+
step: SignInStep;
|
|
5
|
+
setStep: (step: SignInStep) => void;
|
|
6
|
+
type: SignInType;
|
|
7
|
+
setType: (type: SignInType) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function useSignIn(): UseSignInReturn;
|
|
10
|
+
export {};
|