@opexa/portal-components 0.0.60 → 0.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/client/hooks/useGlobalStore.d.ts +2 -0
  2. package/dist/client/hooks/useGlobalStore.js +9 -0
  3. package/dist/components/Cashback/Cashback.client.d.ts +2 -0
  4. package/dist/components/Cashback/Cashback.client.js +9 -0
  5. package/dist/components/Cashback/Cashback.d.ts +10 -0
  6. package/dist/components/Cashback/Cashback.js +5 -0
  7. package/dist/components/Cashback/index.d.ts +1 -0
  8. package/dist/components/Cashback/index.js +1 -0
  9. package/dist/components/Promo/Promo.client.js +19 -1
  10. package/dist/components/Promo/Promo.js +11 -4
  11. package/dist/components/Promos/PromoItem.d.ts +1 -1
  12. package/dist/components/Promos/PromoItem.js +12 -6
  13. package/dist/components/Rewards/Rewards.client.d.ts +2 -0
  14. package/dist/components/Rewards/Rewards.client.js +25 -0
  15. package/dist/components/Rewards/Rewards.d.ts +15 -0
  16. package/dist/components/Rewards/Rewards.js +7 -0
  17. package/dist/components/Rewards/index.d.ts +1 -0
  18. package/dist/components/Rewards/index.js +1 -0
  19. package/dist/components/SignIn/MobileNumberSignIn.d.ts +1 -0
  20. package/dist/components/SignIn/MobileNumberSignIn.js +117 -0
  21. package/dist/components/SignIn/NameAndPasswordSignIn.d.ts +1 -0
  22. package/dist/components/SignIn/NameAndPasswordSignIn.js +53 -0
  23. package/dist/components/SignIn/SignIn.js +1 -1
  24. package/dist/components/SignIn/SignInContext.d.ts +12 -0
  25. package/dist/components/SignIn/SignInContext.js +18 -0
  26. package/dist/components/SignIn/SignInForm.js +7 -115
  27. package/dist/components/SignIn/SignInMethod.d.ts +1 -0
  28. package/dist/components/SignIn/SignInMethod.js +19 -0
  29. package/dist/components/index.d.ts +2 -1
  30. package/dist/components/index.js +2 -1
  31. package/dist/types/index.d.ts +1 -0
  32. package/dist/ui/AlertDialog/AlertDialog.d.ts +154 -154
  33. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +14 -14
  34. package/dist/ui/Badge/Badge.d.ts +12 -12
  35. package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
  36. package/dist/ui/Badge/badge.anatomy.js +1 -1
  37. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  38. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  39. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  40. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  41. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  42. package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
  43. package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
  44. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  45. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  46. package/dist/ui/DatePicker/DatePicker.d.ts +192 -192
  47. package/dist/ui/DatePicker/datePicker.recipe.d.ts +8 -8
  48. package/dist/ui/Dialog/Dialog.d.ts +154 -154
  49. package/dist/ui/Dialog/dialog.recipe.d.ts +14 -14
  50. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  51. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  52. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  53. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  54. package/dist/ui/Popover/Popover.d.ts +88 -88
  55. package/dist/ui/Popover/popover.recipe.d.ts +8 -8
  56. package/dist/ui/Select/Select.d.ts +45 -45
  57. package/dist/ui/Select/select.recipe.d.ts +3 -3
  58. package/dist/ui/Table/Table.d.ts +21 -21
  59. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  60. package/dist/ui/Table/table.anatomy.js +1 -1
  61. package/dist/ui/Table/table.recipe.d.ts +3 -3
  62. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  63. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  64. package/dist/utils/anatomyToRecipeSlots.d.ts +1 -1
  65. package/dist/utils/anatomyToRecipeSlots.js +3 -1
  66. package/package.json +8 -8
@@ -43,6 +43,8 @@ interface MessagesStore extends PopupStore {
43
43
  interface DepositWithdrawalStore extends PopupStore {
44
44
  tab: DepositWithdrawalTab;
45
45
  setTab: (tab: DepositWithdrawalTab) => void;
46
+ promo: string | null;
47
+ setPromo: (promo: string | null) => void;
46
48
  }
47
49
  interface GlobalStore {
48
50
  signUp: PopupStore;
@@ -52,6 +52,15 @@ export const useGlobalStore = create((set) => ({
52
52
  },
53
53
  }));
54
54
  },
55
+ promo: null,
56
+ setPromo(promo) {
57
+ set((prev) => ({
58
+ depositWithdrawal: {
59
+ ...prev.depositWithdrawal,
60
+ promo,
61
+ },
62
+ }));
63
+ },
55
64
  },
56
65
  gameLaunch: {
57
66
  details: { status: 'WAITING' },
@@ -0,0 +1,2 @@
1
+ import type { CashbackProps } from './Cashback';
2
+ export declare function Cashback__client(props: CashbackProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import Image from 'next/image';
4
+ import Link from 'next/link';
5
+ import { ChevronLeftIcon, ChevronRightIcon, StopWatchIcon } from '../../icons/index.js';
6
+ import { Badge, Collapsible, Progress, Prose } from '../../ui/index.js';
7
+ export function Cashback__client(props) {
8
+ return (_jsxs("div", { className: props.className, children: [_jsxs(Link, { href: props.viewAllUrl ?? '/rewards', className: "text-button-tertiary-fg flex items-center gap-lg text-lg font-semibold", children: [_jsx(ChevronLeftIcon, { className: "size-6" }), "Back to Rewards"] }), _jsx(Image, { src: "https://s3.ap-east-1.amazonaws.com/opexa-assets.opexasystem.com/assets/BSxIXEsa59_zzMAR27-ALLDAYREBATE06-STATIC-WEB-HB-1920x1080.png", alt: "", width: 1024, height: 600, className: "mt-3xl h-auto w-full rounded-xl" }), _jsxs(Badge.Root, { size: "lg", round: false, colorScheme: "brand", className: "mt-xl lg:mt-6", children: [_jsx(Badge.Icon, { children: _jsx(StopWatchIcon, {}) }), _jsx(Badge.Label, { children: "9d:10h:11m" })] }), _jsx("h1", { className: "text-text-primary-900 mt-xl text-2xl font-semibold lg:mt-6 lg:text-3xl", children: "50 PHP First Deposit Bonus" }), _jsx("p", { className: "text-text-primary-brand mt-xl text-base lg:mt-6 lg:text-lg", children: "Complete the wagering before time runs out to convert your bonus balance into real money!" }), _jsxs("div", { className: "border-border-primary bg-bg-tertiary text-text-secondary-700 mt-xl flex items-center justify-between rounded-md border px-3.5 py-xl lg:mt-6", children: [_jsx("p", { children: "Your bonus" }), _jsxs("p", { children: [_jsx("span", { className: "text-text-primary-900", children: "20.00" }), " / 50.00 PHP"] })] }), _jsxs("div", { className: "border-border-primary bg-bg-tertiary text-text-secondary-700 mt-xl flex items-center justify-between rounded-md border px-3.5 py-xl lg:mt-6", children: [_jsx("p", { children: "Required Turnover" }), _jsx("p", { children: "5x" })] }), _jsxs("div", { className: "border-border-primary bg-bg-tertiary text-text-secondary-700 mt-xl rounded-md border px-3.5 py-xl lg:mt-6", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("p", { children: "Wagering" }), _jsx("p", { children: "400/1000" })] }), _jsx(Progress.Root, { defaultValue: 42, className: "mt-2", children: _jsx(Progress.Track, { children: _jsx(Progress.Range, {}) }) })] }), _jsxs(Collapsible.Root, { className: "mt-xl lg:mt-6", children: [_jsxs(Collapsible.Trigger, { className: "text-button-tertiary-fg flex w-fit items-center justify-center gap-sm text-sm font-semibold lg:mx-auto", children: ["Game Provider Contribution", _jsx(Collapsible.Indicator, { asChild: true, children: _jsx(ChevronRightIcon, { className: "size-5" }) })] }), _jsxs(Collapsible.Content, { className: "border-border-primary bg-bg-tertiary text-text-secondary-700 mt-xl space-y-1.5 rounded-md border px-3.5 py-xl lg:mt-6", children: [_jsxs("div", { className: "flex items-center justify-between gap-md", children: [_jsx("p", { className: "w-[11.25rem] shrink-0", children: "Playson" }), _jsx(Progress.Root, { defaultValue: 42, className: "mt-2 grow", children: _jsx(Progress.Track, { children: _jsx(Progress.Range, {}) }) }), _jsx("p", { children: "25%" })] }), _jsxs("div", { className: "flex items-center justify-between gap-md", children: [_jsx("p", { className: "w-[11.25rem] shrink-0", children: "Betsoft Gaming" }), _jsx(Progress.Root, { defaultValue: 42, className: "mt-2 grow", children: _jsx(Progress.Track, { children: _jsx(Progress.Range, {}) }) }), _jsx("p", { children: "13%" })] }), _jsxs("div", { className: "flex items-center justify-between gap-md", children: [_jsx("p", { className: "w-[11.25rem] shrink-0", children: "Microgaming" }), _jsx(Progress.Root, { defaultValue: 42, className: "mt-2 grow", children: _jsx(Progress.Track, { children: _jsx(Progress.Range, {}) }) }), _jsx("p", { children: "50%" })] }), _jsxs("div", { className: "flex items-center justify-between gap-md", children: [_jsx("p", { className: "w-[11.25rem] shrink-0", children: "Realtime Gaming" }), _jsx(Progress.Root, { defaultValue: 42, className: "mt-2 grow", children: _jsx(Progress.Track, { children: _jsx(Progress.Range, {}) }) }), _jsx("p", { children: "10%" })] })] })] }), _jsxs(Prose, { className: "mt-xl lg:mt-6", children: [_jsx("h3", { children: "How to get bonus" }), _jsxs("ol", { children: [_jsx("li", { children: "All OFWin members are eligible for this program." }), _jsx("li", { children: "50 PHP of game credit will be automatically credited to the new member account upon completion of first deposit Auctor vel in vitae placerat." }), _jsx("li", { children: "Member must reach a 5x turnover requirement before a withdrawal can be made. Attempting to make a withdrawal before this turnover requirement is completed could cause your bonus to be voided." }), _jsx("li", { children: "Players will have 10 days from the date the bonus is awarded to complete the rollover requirement." }), _jsx("li", { children: "Bets used to meet other bonus rollover requirements will not count toward this promotion." })] }), _jsx("h3", { children: "Terms and Conditions" }), _jsxs("ul", { children: [_jsx("li", { children: "Only one account per player is allowed. No same IP address/bank account name allowed. Players who have multiple or fraudulent accounts will not be qualified for the promotion." }), _jsx("li", { children: "Players that are found to have any duplicate accounts or those who participate in fraudulent activities may have their funds forfeited and their accounts closed." }), _jsx("li", { children: "OFWin reserves the right to amend or cancel this Referral Program at any time. OFWin General Terms and Conditions apply." })] })] })] }));
9
+ }
@@ -0,0 +1,10 @@
1
+ export interface CashbackProps {
2
+ id: string;
3
+ className?: string;
4
+ /**
5
+ * @description URL for the bonuses details page
6
+ * @default "/rewards"
7
+ */
8
+ viewAllUrl?: string;
9
+ }
10
+ export declare function Cashback(props: CashbackProps): Promise<import("react/jsx-runtime").JSX.Element>;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Cashback__client } from './Cashback.client.js';
3
+ export async function Cashback(props) {
4
+ return _jsx(Cashback__client, { ...props });
5
+ }
@@ -0,0 +1 @@
1
+ export * from './Cashback';
@@ -0,0 +1 @@
1
+ export * from './Cashback.js';
@@ -1,9 +1,27 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { tz } from '@date-fns/tz';
4
+ import { format } from 'date-fns';
3
5
  import Image from 'next/image';
4
6
  import Link from 'next/link';
7
+ import invariant from 'tiny-invariant';
8
+ import { useShallow } from 'zustand/shallow';
9
+ import { useGlobalStore, useLocaleInfo, usePromoQuery, } from '../../client/hooks/index.js';
5
10
  import { ChevronLeftIcon } from '../../icons/index.js';
6
11
  import { Button, Prose } from '../../ui/index.js';
7
12
  export function Promo__client(props) {
8
- 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"] }), _jsx(Image, { src: "https://s3.ap-east-1.amazonaws.com/opexa-assets.opexasystem.com/assets/BSxIXEsa59_zzMAR27-ALLDAYREBATE06-STATIC-WEB-HB-1920x1080.png", 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", children: "Deposit Now" }), _jsx("h1", { className: "mt-xl text-2xl font-semibold lg:mt-6 lg:text-3xl", children: "Welcome Bonus 100% up to $500 + 10 Free Spins" }), _jsx("p", { className: "text-text-secondary-700 mt-xl lg:mt-6", children: "Ends 5/26/2025, 1:59:59 AM" }), _jsxs(Prose, { className: "mt-2xl lg:mt-6", children: [_jsx("p", { children: "Mi tincidunt elit, id quisque ligula ac diam, amet. Vel etiam suspendisse morbi eleifend faucibus eget vestibulum felis. Dictum quis montes, sit sit. Tellus aliquam enim urna, etiam. Mauris posuere vulputate arcu amet, vitae nisi, tellus tincidunt. At feugiat sapien varius id." }), _jsx("p", { children: "Eget quis mi enim, leo lacinia pharetra, semper. Eget in volutpat mollis at volutpat lectus velit, sed auctor. Porttitor fames arcu quis fusce augue enim. Quis at habitant diam at. Suscipit tristique risus, at donec. In turpis vel et quam imperdiet. Ipsum molestie aliquet sodales id est ac volutpat." }), _jsx("p", { children: "Ipsum sit mattis nulla quam nulla. Gravida id gravida ac enim mauris id. Non pellentesque congue eget consectetur turpis. Sapien, dictum molestie sem tempor. Diam elit, orci, tincidunt aenean tempus. Quis velit eget ut tortor tellus. Sed vel, congue felis elit erat nam nibh orci." }), _jsx("p", { children: "Dolor enim eu tortor urna sed duis nulla. Aliquam vestibulum, nulla odio nisl vitae. In aliquet pellentesque aenean hac vestibulum turpis mi bibendum diam. Tempor integer aliquam in vitae malesuada fringilla." }), _jsx("p", { children: "Elit nisi in eleifend sed nisi. Pulvinar at orci, proin imperdiet commodo consectetur convallis risus. Sed condimentum enim dignissim adipiscing faucibus consequat, urna. Viverra purus et erat auctor aliquam. Risus, volutpat vulputate posuere purus sit congue convallis aliquet. Arcu id augue ut feugiat donec porttitor neque. Mauris, neque ultricies eu vestibulum, bibendum quam lorem id. Dolor lacus, eget nunc lectus in tellus, pharetra, porttitor." }), _jsx("p", { children: "Ipsum sit mattis nulla quam nulla. Gravida id gravida ac enim mauris id. Non pellentesque congue eget consectetur turpis. Sapien, dictum molestie sem tempor. Diam elit, orci, tincidunt aenean tempus. Quis velit eget ut tortor tellus. Sed vel, congue felis elit erat nam nibh orci." }), _jsx("h5", { children: "General Conditions:" }), _jsx("p", { children: "Mi tincidunt elit, id quisque ligula ac diam, amet. Vel etiam suspendisse morbi eleifend faucibus eget vestibulum felis. Dictum quis montes, sit sit. Tellus aliquam enim urna, etiam. Mauris posuere vulputate arcu amet, vitae nisi, tellus tincidunt. At feugiat sapien varius id." }), _jsx("p", { children: "Eget quis mi enim, leo lacinia pharetra, semper. Eget in volutpat mollis at volutpat lectus velit, sed auctor. Porttitor fames arcu quis fusce augue enim. Quis at habitant diam at. Suscipit tristique risus, at donec. In turpis vel et quam imperdiet. Ipsum molestie aliquet sodales id est ac volutpat." })] }), _jsxs(Prose, { className: "bg-bg-secondary mt-xl rounded-2xl p-2xl lg:mt-16 lg:p-4xl", children: [_jsx("h2", { children: "Conclusion" }), _jsx("p", { children: "Morbi sed imperdiet in ipsum, adipiscing elit dui lectus. Tellus id scelerisque est ultricies ultricies. Duis est sit sed leo nisl, blandit elit sagittis. Quisque tristique consequat quam sed. Nisl at scelerisque amet nulla purus habitasse." }), _jsx("p", { children: "Nunc sed faucibus bibendum feugiat sed interdum. Ipsum egestas condimentum mi massa. In tincidunt pharetra consectetur sed duis facilisis metus. Etiam egestas in nec sed et. Quis lobortis at sit dictum eget nibh tortor commodo cursus." }), _jsx("p", { children: "Odio felis sagittis, morbi feugiat tortor vitae feugiat fusce aliquet. Nam elementum urna nisi aliquet erat dolor enim. Ornare id morbi eget ipsum. Aliquam senectus neque ut id eget consectetur dictum. Donec posuere pharetra odio consequat scelerisque et, nunc tortor." })] })] }));
13
+ const localeInfo = useLocaleInfo();
14
+ const promoQuery = usePromoQuery(props.id);
15
+ const promo = promoQuery.data;
16
+ const globalStore = useGlobalStore(useShallow((ctx) => ({
17
+ depositWithdrawal: ctx.depositWithdrawal,
18
+ })));
19
+ invariant(promo);
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
+ 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 A', {
23
+ in: tz(localeInfo.timezone),
24
+ })] }), _jsx(Prose, { className: "mt-2xl lg:mt-6", dangerouslySetInnerHTML: {
25
+ __html: promo.description,
26
+ } }), _jsxs(Prose, { className: "bg-bg-secondary mt-xl rounded-2xl p-2xl lg:mt-16 lg:p-4xl", children: [_jsx("h2", { children: "Conclusion" }), _jsx("p", { children: "Morbi sed imperdiet in ipsum, adipiscing elit dui lectus. Tellus id scelerisque est ultricies ultricies. Duis est sit sed leo nisl, blandit elit sagittis. Quisque tristique consequat quam sed. Nisl at scelerisque amet nulla purus habitasse." }), _jsx("p", { children: "Nunc sed faucibus bibendum feugiat sed interdum. Ipsum egestas condimentum mi massa. In tincidunt pharetra consectetur sed duis facilisis metus. Etiam egestas in nec sed et. Quis lobortis at sit dictum eget nibh tortor commodo cursus." }), _jsx("p", { children: "Odio felis sagittis, morbi feugiat tortor vitae feugiat fusce aliquet. Nam elementum urna nisi aliquet erat dolor enim. Ornare id morbi eget ipsum. Aliquam senectus neque ut id eget consectetur dictum. Donec posuere pharetra odio consequat scelerisque et, nunc tortor." })] })] }));
9
27
  }
@@ -1,8 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { notFound } from 'next/navigation';
3
+ import { prefetchPromoQuery } from '../../server/utils/index.js';
4
+ import { getPromoQueryKey, getQueryClient } from '../../utils/index.js';
2
5
  import { Promo__client } from './Promo.client.js';
3
6
  export async function Promo(props) {
4
- /**
5
- * await prefetchPromoQuery(props.id);
6
- */
7
- return _jsx(Promo__client, { ...props });
7
+ await prefetchPromoQuery(props.id);
8
+ const promo = getQueryClient().getQueryData(getPromoQueryKey(props.id));
9
+ if (promo) {
10
+ return _jsx(Promo__client, { ...props });
11
+ }
12
+ else {
13
+ return notFound();
14
+ }
8
15
  }
@@ -3,5 +3,5 @@ interface PromosItemProps {
3
3
  promo: Promo;
4
4
  redirectUrl?: string;
5
5
  }
6
- export declare function PromosItem(props: PromosItemProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function PromosItem({ promo, redirectUrl, }: PromosItemProps): import("react/jsx-runtime").JSX.Element;
7
7
  export {};
@@ -1,11 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import Image from 'next/image';
3
3
  import Link from 'next/link';
4
+ import { useShallow } from 'zustand/shallow';
5
+ import { useAvailablePromosQuery, useGlobalStore } from '../../client/hooks/index.js';
4
6
  import { Button } from '../../ui/index.js';
5
- export function PromosItem(props) {
6
- const { promo } = props;
7
- return (_jsxs(Link, { href: `${props.redirectUrl ?? '/promos'}/${promo.id}`, className: "border-border-secondary bg-accent-50 bg-bg-primary-alt relative flex h-full flex-col overflow-hidden rounded-2xl border", children: [promo.banner.url && (_jsx(Image, { src: promo.banner.url, alt: promo.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: promo.name }), _jsx("div", { className: "mt-auto pt-4", children: _jsx(Button, { size: "sm", asChild: true, children: _jsx("div", { role: "button", onClick: (e) => {
8
- e.preventDefault();
9
- e.stopPropagation();
10
- }, children: "Get bonus" }) }) })] })] }));
7
+ export function PromosItem({ promo, redirectUrl = '/promos', }) {
8
+ const globalStore = useGlobalStore(useShallow((ctx) => ({
9
+ depositWithdrawal: ctx.depositWithdrawal,
10
+ })));
11
+ const availablePromos = useAvailablePromosQuery().data ?? [];
12
+ const claimablePromo = availablePromos.find((availablePromo) => availablePromo.id === promo.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: [promo.banner.url && (_jsx(Image, { src: promo.banner.url, alt: promo.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: promo.name }), _jsxs("div", { className: "mt-auto flex flex-col gap-3 pt-4 lg:flex-row", children: [claimablePromo && (_jsx(Button, { size: "sm", onClick: () => {
14
+ globalStore.depositWithdrawal.setOpen(true);
15
+ globalStore.depositWithdrawal.setPromo(promo.id);
16
+ }, children: "Get bonus" })), _jsx(Button, { size: "sm", variant: "outline", asChild: true, children: _jsx(Link, { href: `${redirectUrl}/${promo.id}`, children: "Read more" }) })] })] })] }));
11
17
  }
@@ -0,0 +1,2 @@
1
+ import type { RewardsProps } from './Rewards';
2
+ export declare function Rewards__client(props: RewardsProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import Image from 'next/image';
4
+ import Link from 'next/link';
5
+ import { useBonusesQuery, useCashbacksQuery } from '../../client/hooks/index.js';
6
+ import { StopWatchIcon } from '../../icons/index.js';
7
+ import { Badge, Button, Progress, SegmentGroup } from '../../ui/index.js';
8
+ export function Rewards__client(props) {
9
+ const bonusesQuery = useBonusesQuery();
10
+ const cashbacksQuery = useCashbacksQuery();
11
+ const bonuses = bonusesQuery.data ?? [];
12
+ const cashbacks = cashbacksQuery.data ?? [];
13
+ console.log({
14
+ bonuses,
15
+ cashbacks,
16
+ });
17
+ return (_jsxs("div", { className: props.className, children: [_jsx("h2", { className: "text-lg font-semibold", children: props.heading ?? 'Rewards' }), _jsxs(SegmentGroup.Root, { defaultValue: "all", className: "mt-3 w-full lg:w-fit", children: [_jsxs(SegmentGroup.Item, { value: "all", className: "w-full lg:w-auto", children: [_jsx(SegmentGroup.ItemText, { children: "All" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "active", className: "w-full lg:w-auto", children: [_jsx(SegmentGroup.ItemText, { children: "Active" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "cashbacks", className: "w-full lg:w-auto", children: [_jsx(SegmentGroup.ItemText, { children: "Cashback" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsx(SegmentGroup.Indicator, {})] }), _jsxs("div", { className: "mt-3xl grid gap-3xl lg:grid-cols-3", children: [_jsx(Bonus, { viewDetailsUrl: props.viewBonusDetailsUrl ?? '/rewards/bonus' }), _jsx(Cashback, { viewDetailsUrl: props.viewCashbackDetailsUrl ?? '/rewards/cashback' })] })] }));
18
+ }
19
+ function Bonus(props) {
20
+ return (_jsxs("div", { className: "border-border-primary bg-bg-tertiary overflow-hidden rounded-2xl border", children: [_jsxs("div", { className: "relative", children: [_jsx(Image, { src: "https://images.pexels.com/photos/5868275/pexels-photo-5868275.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1", alt: "", width: 400, height: 200, className: "h-auto w-full" }), _jsxs(Badge.Root, { size: "lg", round: false, colorScheme: "brand", className: "absolute right-4 top-4", children: [_jsx(Badge.Icon, { children: _jsx(StopWatchIcon, {}) }), _jsx(Badge.Label, { children: "9d:10h:11m" })] })] }), _jsxs("div", { className: "px-xl py-3xl", children: [_jsx("h2", { className: "text-center text-xl font-semibold text-white", children: "50 PHP First Deposit Bonus" }), _jsxs("div", { className: "text-text-primary-brand mt-xl flex justify-between", children: [_jsx("p", { children: "Your bonus" }), _jsx("p", { children: "\u20B120.00" })] }), _jsxs("div", { className: "text-text-primary-brand mt-2 flex justify-between", children: [_jsx("p", { children: "Wagering 40%" }), _jsx("p", { children: "400/1000" })] }), _jsx(Progress.Root, { defaultValue: 42, className: "mt-2", children: _jsx(Progress.Track, { children: _jsx(Progress.Range, {}) }) }), _jsx(Button, { variant: "outline", className: "mt-6", asChild: true, children: _jsx(Link, { href: props.viewDetailsUrl, children: "See More" }) })] })] }));
21
+ }
22
+ function Cashback(props) {
23
+ console.log(props);
24
+ return (_jsxs("div", { className: "border-border-primary bg-bg-tertiary overflow-hidden rounded-2xl border", children: [_jsx(Image, { src: "https://images.pexels.com/photos/5868275/pexels-photo-5868275.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1", alt: "", width: 400, height: 200, className: "h-auto w-full" }), _jsxs("div", { className: "px-xl py-3xl", children: [_jsx("p", { className: "text-center text-xl font-semibold text-white", children: "Cashback" }), _jsx("h2", { className: "mt-2 text-center text-3xl font-semibold text-white", children: "\u20B120.48" }), _jsx("p", { className: "text-text-secondary-700 mt-2 text-center text-sm", children: "Claim your cashback reward and explore other exciting offers!" }), _jsx(Button, { className: "mt-6", children: "Claim" })] })] }));
25
+ }
@@ -0,0 +1,15 @@
1
+ export interface RewardsProps {
2
+ heading?: string;
3
+ className?: string;
4
+ /**
5
+ * @description base URL for the bonus details page
6
+ * @default "/rewards/bonus"
7
+ */
8
+ viewBonusDetailsUrl?: string;
9
+ /**
10
+ * @description base URL for the cashback details page
11
+ * @default "/rewards/cashback"
12
+ */
13
+ viewCashbackDetailsUrl?: string;
14
+ }
15
+ export declare function Rewards(props: RewardsProps): Promise<import("react/jsx-runtime").JSX.Element>;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { prefetchBonusesQuery, prefetchCashbacksQuery, } from '../../server/utils/index.js';
3
+ import { Rewards__client } from './Rewards.client.js';
4
+ export async function Rewards(props) {
5
+ await Promise.all([prefetchBonusesQuery(), prefetchCashbacksQuery()]);
6
+ return _jsx(Rewards__client, { ...props });
7
+ }
@@ -0,0 +1 @@
1
+ export * from './Rewards';
@@ -0,0 +1 @@
1
+ export * from './Rewards.js';
@@ -0,0 +1 @@
1
+ export declare function MobileNumberSignIn(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,117 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useDialogContext } from '@ark-ui/react';
3
+ import { zodResolver } from '@hookform/resolvers/zod';
4
+ import { Controller, useForm } from 'react-hook-form';
5
+ import { z } from 'zod';
6
+ import { useShallow } from 'zustand/shallow';
7
+ import { useCooldown, useGlobalStore, useLocaleInfo, useMobileNumberParser, useSendVerificationCodeMutation, useSignInMutation, } from '../../client/hooks/index.js';
8
+ import { toaster } from '../../client/utils/index.js';
9
+ import { ArrowLeftIcon, CheckIcon, FacebookIcon, GoogleIcon, } from '../../icons/index.js';
10
+ import { Button, Checkbox, Field, PinInput } from '../../ui/index.js';
11
+ import { useSignInContext } from './SignInContext.js';
12
+ export function MobileNumberSignIn() {
13
+ const context = useSignInContext();
14
+ const dialog = useDialogContext();
15
+ const signUpStore = useGlobalStore(useShallow((popups) => popups.signUp));
16
+ const signInMutation = useSignInMutation();
17
+ const sendVerificationCodeMutation = useSendVerificationCodeMutation();
18
+ const localeInfo = useLocaleInfo();
19
+ const mobileNumberParser = useMobileNumberParser();
20
+ const Step1Definition = z.object({
21
+ mobileNumber: z.string().superRefine((v, ctx) => {
22
+ if (!mobileNumberParser.validate(v)) {
23
+ ctx.addIssue({
24
+ code: z.ZodIssueCode.custom,
25
+ message: 'Invalid mobile number',
26
+ });
27
+ }
28
+ }),
29
+ termsAccepted: z.boolean().superRefine((v, ctx) => {
30
+ if (!v) {
31
+ ctx.addIssue({
32
+ code: z.ZodIssueCode.custom,
33
+ message: 'You must accept the terms and conditions',
34
+ });
35
+ }
36
+ }),
37
+ });
38
+ const Step2Definition = z.object({
39
+ verificationCode: z.array(z.string().min(1).max(1).trim()).min(6).max(6),
40
+ });
41
+ const step1Form = useForm({
42
+ resolver: zodResolver(Step1Definition),
43
+ defaultValues: {
44
+ mobileNumber: '',
45
+ termsAccepted: false,
46
+ },
47
+ });
48
+ const step2Form = useForm({
49
+ resolver: zodResolver(Step2Definition),
50
+ defaultValues: {
51
+ verificationCode: Array.from({ length: 6 }).fill(''),
52
+ },
53
+ });
54
+ const cooldown = useCooldown({
55
+ max: 60,
56
+ duration: 1000 * 60,
57
+ });
58
+ return (_jsxs(_Fragment, { children: [context.step === 1 && (_jsxs(_Fragment, { children: [_jsxs("form", { className: "mt-3xl", onSubmit: step1Form.handleSubmit(async (data) => {
59
+ try {
60
+ await sendVerificationCodeMutation.mutateAsync({
61
+ channel: 'SMS',
62
+ recipient: mobileNumberParser.format(data.mobileNumber),
63
+ strict: true,
64
+ });
65
+ context.setStep(2);
66
+ cooldown.start();
67
+ }
68
+ catch (e) {
69
+ toaster.error({
70
+ description: e instanceof Error
71
+ ? e.message
72
+ : 'Failed to send verification code',
73
+ });
74
+ }
75
+ }), children: [_jsxs(Field.Root, { invalid: !!step1Form.formState.errors.mobileNumber, children: [_jsx(Field.Label, { children: "Mobile Number" }), _jsxs("div", { className: "relative", children: [_jsx(localeInfo.country.flag, { className: "absolute left-3.5 top-1/2 size-5 shrink-0 -translate-y-1/2" }), _jsx(Field.Input, { className: "pl-11", placeholder: `${localeInfo.mobileNumber.areaCode}${localeInfo.mobileNumber.example}`, ...step1Form.register('mobileNumber') })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.mobileNumber?.message })] }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: step1Form.formState.isSubmitting, children: "Log In" }), _jsx(Controller, { control: step1Form.control, name: "termsAccepted", render: (o) => (_jsxs(Checkbox.Root, { className: "mt-xl", invalid: o.fieldState.invalid, checked: o.field.value, onCheckedChange: (details) => {
76
+ o.field.onChange(details.checked);
77
+ }, 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: () => {
78
+ dialog.setOpen(false);
79
+ }, className: "border-border-primary bg-bg-primary text-text-secondary-700", children: [_jsx(GoogleIcon, { className: "size-6" }), "Continue with Google"] }), _jsxs(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
80
+ dialog.setOpen(false);
81
+ }, 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
+ dialog.setOpen(false);
83
+ 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 }) => {
85
+ const { mobileNumber } = step1Form.getValues();
86
+ try {
87
+ await signInMutation.mutateAsync({
88
+ type: 'MOBILE_NUMBER',
89
+ mobileNumber: mobileNumberParser.format(mobileNumber),
90
+ verificationCode: verificationCode.join(''),
91
+ });
92
+ dialog.setOpen(false);
93
+ step1Form.reset();
94
+ step2Form.reset();
95
+ context.setStep(1);
96
+ }
97
+ catch {
98
+ toaster.error({
99
+ description: 'Invalid Verification Code',
100
+ });
101
+ }
102
+ }), 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
+ o.field.onChange(details.value);
104
+ }, 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
+ await sendVerificationCodeMutation.mutateAsync({
106
+ channel: 'SMS',
107
+ recipient: mobileNumberParser.format(step1Form.getValues('mobileNumber')),
108
+ });
109
+ cooldown.start();
110
+ }, children: cooldown.cooling
111
+ ? `Resend in ${cooldown.countdown}s`
112
+ : 'Resend' })] }), _jsxs("button", { type: "button", className: "text-text-tertiary-600 mx-auto mt-3xl flex w-fit items-center gap-1 text-sm font-semibold", onClick: () => {
113
+ context.setStep(1);
114
+ step2Form.reset();
115
+ cooldown.stop();
116
+ }, children: [_jsx(ArrowLeftIcon, { className: "size-5" }), "Back"] })] })] }))] }));
117
+ }
@@ -0,0 +1 @@
1
+ export declare function NameAndPasswordSignIn(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useDialogContext } from '@ark-ui/react';
3
+ import { zodResolver } from '@hookform/resolvers/zod';
4
+ import { Controller, useForm } from 'react-hook-form';
5
+ import { z } from 'zod';
6
+ import { useShallow } from 'zustand/shallow';
7
+ import { useGlobalStore, useSignInMutation } from '../../client/hooks/index.js';
8
+ import { toaster } from '../../client/utils/index.js';
9
+ import { CheckIcon, EyeIcon, EyeOffIcon, FacebookIcon, GoogleIcon, } from '../../icons/index.js';
10
+ import { Button, Checkbox, Field, PasswordInput } from '../../ui/index.js';
11
+ 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
+ export function NameAndPasswordSignIn() {
21
+ const context = useSignInContext();
22
+ const dialog = useDialogContext();
23
+ const signUpStore = useGlobalStore(useShallow((popups) => popups.signUp));
24
+ const signInMutation = useSignInMutation();
25
+ const form = useForm({
26
+ resolver: zodResolver(Definition),
27
+ defaultValues: {
28
+ name: '',
29
+ password: '',
30
+ secretAnswer: '',
31
+ },
32
+ });
33
+ return (_jsxs(_Fragment, { children: [_jsxs("form", { className: "mt-3xl", onSubmit: form.handleSubmit(async (data) => {
34
+ try {
35
+ }
36
+ catch (e) {
37
+ toaster.error({
38
+ description: e instanceof Error
39
+ ? e.message
40
+ : 'Failed to send verification code',
41
+ });
42
+ }
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') }), _jsx(Field.ErrorText, { children: form.formState.errors.name?.message })] }), _jsxs(Field.Root, { 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 })] }), _jsxs(Field.Root, { invalid: !!form.formState.errors.secretAnswer, className: "mt-xl", children: [_jsx(Field.Label, { children: "What was the name of your first pet?" }), _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: form.formState.isSubmitting, 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
+ o.field.onChange(details.checked);
45
+ }, 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
+ dialog.setOpen(false);
47
+ }, className: "border-border-primary bg-bg-primary text-text-secondary-700", children: [_jsx(GoogleIcon, { className: "size-6" }), "Continue with Google"] }), _jsxs(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
48
+ dialog.setOpen(false);
49
+ }, 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
+ dialog.setOpen(false);
51
+ signUpStore.setOpen(true);
52
+ }, children: "Sign up" })] })] }));
53
+ }
@@ -11,5 +11,5 @@ export function SignIn(props) {
11
11
  const signInStore = useGlobalStore(useShallow((popups) => popups.signIn));
12
12
  return (_jsx(Dialog.Root, { open: signInStore.open, onOpenChange: (details) => {
13
13
  signInStore.setOpen(details.open);
14
- }, 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-auto w-[120px]", draggable: false }), _jsx(SignInForm, {})] }) })] }) }));
14
+ }, 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
15
  }
@@ -0,0 +1,12 @@
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 declare const SignInContext: import("react").Context<UseSignInReturn | null>;
11
+ export declare const useSignInContext: () => UseSignInReturn;
12
+ export {};
@@ -0,0 +1,18 @@
1
+ import { createContext, useContext, useState } from 'react';
2
+ import invariant from 'tiny-invariant';
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,118 +1,10 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useDialogContext } from '@ark-ui/react';
4
- import { zodResolver } from '@hookform/resolvers/zod';
5
- import { useState } from 'react';
6
- import { Controller, useForm } from 'react-hook-form';
7
- import { z } from 'zod';
8
- import { useShallow } from 'zustand/shallow';
9
- import { useCooldown, useGlobalStore, useLocaleInfo, useMobileNumberParser, useSendVerificationCodeMutation, useSignInMutation, } from '../../client/hooks/index.js';
10
- import { toaster } from '../../client/utils/index.js';
11
- import { ArrowLeftIcon, CheckIcon, FacebookIcon, GoogleIcon, } from '../../icons/index.js';
12
- import { Button, Checkbox, Field, PinInput } from '../../ui/index.js';
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { MobileNumberSignIn } from './MobileNumberSignIn.js';
4
+ import { NameAndPasswordSignIn } from './NameAndPasswordSignIn.js';
5
+ import { SignInContext, useSignIn } from './SignInContext.js';
6
+ import { SignInMethod } from './SignInMethod.js';
13
7
  export function SignInForm() {
14
- const [step, setStep] = useState(1);
15
- const dialog = useDialogContext();
16
- const signUpStore = useGlobalStore(useShallow((popups) => popups.signUp));
17
- const signInMutation = useSignInMutation();
18
- const sendVerificationCodeMutation = useSendVerificationCodeMutation();
19
- const localeInfo = useLocaleInfo();
20
- const mobileNumberParser = useMobileNumberParser();
21
- const Step1Definition = z.object({
22
- mobileNumber: z.string().superRefine((v, ctx) => {
23
- if (!mobileNumberParser.validate(v)) {
24
- ctx.addIssue({
25
- code: z.ZodIssueCode.custom,
26
- message: 'Invalid mobile number',
27
- });
28
- }
29
- }),
30
- termsAccepted: z.boolean().superRefine((v, ctx) => {
31
- if (!v) {
32
- ctx.addIssue({
33
- code: z.ZodIssueCode.custom,
34
- message: 'You must accept the terms and conditions',
35
- });
36
- }
37
- }),
38
- });
39
- const Step2Definition = z.object({
40
- verificationCode: z.array(z.string().min(1).max(1).trim()).min(6).max(6),
41
- });
42
- const step1Form = useForm({
43
- resolver: zodResolver(Step1Definition),
44
- defaultValues: {
45
- mobileNumber: '',
46
- termsAccepted: false,
47
- },
48
- });
49
- const step2Form = useForm({
50
- resolver: zodResolver(Step2Definition),
51
- defaultValues: {
52
- verificationCode: Array.from({ length: 6 }).fill(''),
53
- },
54
- });
55
- const cooldown = useCooldown({
56
- max: 60,
57
- duration: 1000 * 60,
58
- });
59
- return (_jsxs(_Fragment, { children: [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." }), _jsxs("form", { className: "mt-3xl", onSubmit: step1Form.handleSubmit(async (data) => {
60
- try {
61
- await sendVerificationCodeMutation.mutateAsync({
62
- channel: 'SMS',
63
- recipient: mobileNumberParser.format(data.mobileNumber),
64
- strict: true,
65
- });
66
- setStep(2);
67
- cooldown.start();
68
- }
69
- catch (e) {
70
- toaster.error({
71
- description: e instanceof Error
72
- ? e.message
73
- : 'Failed to send verification code',
74
- });
75
- }
76
- }), children: [_jsxs(Field.Root, { invalid: !!step1Form.formState.errors.mobileNumber, children: [_jsx(Field.Label, { children: "Mobile Number" }), _jsxs("div", { className: "relative", children: [_jsx(localeInfo.country.flag, { className: "absolute left-3.5 top-1/2 size-5 shrink-0 -translate-y-1/2" }), _jsx(Field.Input, { className: "pl-11", placeholder: `${localeInfo.mobileNumber.areaCode}${localeInfo.mobileNumber.example}`, ...step1Form.register('mobileNumber') })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.mobileNumber?.message })] }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: step1Form.formState.isSubmitting, children: "Log In" }), _jsx(Controller, { control: step1Form.control, name: "termsAccepted", render: (o) => (_jsxs(Checkbox.Root, { className: "mt-xl", invalid: o.fieldState.invalid, checked: o.field.value, onCheckedChange: (details) => {
77
- o.field.onChange(details.checked);
78
- }, 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: () => {
79
- dialog.setOpen(false);
80
- }, className: "border-border-primary bg-bg-primary text-text-secondary-700", children: [_jsx(GoogleIcon, { className: "size-6" }), "Continue with Google"] }), _jsxs(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
81
- dialog.setOpen(false);
82
- }, 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: () => {
83
- dialog.setOpen(false);
84
- signUpStore.setOpen(true);
85
- }, children: "Sign up" })] })] })), 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
- const { mobileNumber } = step1Form.getValues();
87
- try {
88
- await signInMutation.mutateAsync({
89
- type: 'MOBILE_NUMBER',
90
- mobileNumber: mobileNumberParser.format(mobileNumber),
91
- verificationCode: verificationCode.join(''),
92
- });
93
- dialog.setOpen(false);
94
- step1Form.reset();
95
- step2Form.reset();
96
- setStep(1);
97
- }
98
- catch {
99
- toaster.error({
100
- description: 'Invalid Verification Code',
101
- });
102
- }
103
- }), 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) => {
104
- o.field.onChange(details.value);
105
- }, 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 () => {
106
- await sendVerificationCodeMutation.mutateAsync({
107
- channel: 'SMS',
108
- recipient: mobileNumberParser.format(step1Form.getValues('mobileNumber')),
109
- });
110
- cooldown.start();
111
- }, children: cooldown.cooling
112
- ? `Resend in ${cooldown.countdown}s`
113
- : 'Resend' })] }), _jsxs("button", { type: "button", className: "text-text-tertiary-600 mx-auto mt-3xl flex w-fit items-center gap-1 text-sm font-semibold", onClick: () => {
114
- setStep(1);
115
- step2Form.reset();
116
- cooldown.stop();
117
- }, children: [_jsx(ArrowLeftIcon, { className: "size-5" }), "Back"] })] })] }))] }));
8
+ const context = useSignIn();
9
+ return (_jsxs(SignInContext, { value: context, 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, {})] }));
118
10
  }
@@ -0,0 +1 @@
1
+ export declare function SignInMethod(): import("react/jsx-runtime").JSX.Element;