@opexa/portal-components 0.0.121 → 0.0.122

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.
@@ -7,8 +7,11 @@ import { useSessionQuery } from './useSessionQuery.js';
7
7
  export const useBetRecordsQuery = (input, config) => {
8
8
  const sessionQuery = useSessionQuery();
9
9
  const query = useInfiniteQuery({
10
- enabled: sessionQuery.data?.status === 'authenticated',
10
+ staleTime: 1000 * 2,
11
11
  ...config,
12
+ enabled: config?.enabled === false
13
+ ? false
14
+ : sessionQuery.data?.status === 'authenticated',
12
15
  queryKey: getBetRecordsQueryKey(input),
13
16
  queryFn: async ({ pageParam, signal }) => {
14
17
  const session = await getSession();
@@ -7,6 +7,7 @@ import { useSessionQuery } from './useSessionQuery.js';
7
7
  export const useDepositRecordsQuery = (input, config) => {
8
8
  const sessionQuery = useSessionQuery();
9
9
  const query = useInfiniteQuery({
10
+ staleTime: 1000 * 2,
10
11
  ...config,
11
12
  enabled: config?.enabled === false
12
13
  ? false
@@ -52,6 +52,7 @@ interface DepositWithdrawalStore extends PopupStore {
52
52
  interface GlobalStore {
53
53
  signUp: PopupStore;
54
54
  signIn: PopupStore;
55
+ forgotPassword: PopupStore;
55
56
  disclaimer: PopupStore;
56
57
  depositWithdrawal: DepositWithdrawalStore;
57
58
  gameLaunch: GameLaunchStore;
@@ -221,4 +221,17 @@ export const useGlobalStore = create((set) => ({
221
221
  },
222
222
  '~touched': false,
223
223
  },
224
+ forgotPassword: {
225
+ open: false,
226
+ setOpen(open) {
227
+ set((prev) => ({
228
+ forgotPassword: {
229
+ ...prev.forgotPassword,
230
+ open,
231
+ '~touched': true,
232
+ },
233
+ }));
234
+ },
235
+ '~touched': false,
236
+ },
224
237
  }));
@@ -0,0 +1,3 @@
1
+ import { type ResetPasswordInput } from '../../services/account';
2
+ import type { Mutation } from '../../types';
3
+ export declare const useResetPasswordMutation: Mutation<void, ResetPasswordInput>;
@@ -0,0 +1,12 @@
1
+ import { useMutation } from '@tanstack/react-query';
2
+ import { resetPassword } from '../../services/account.js';
3
+ import { getResetPasswordMutationKey } from '../../utils/mutationKeys.js';
4
+ export const useResetPasswordMutation = (config) => {
5
+ return useMutation({
6
+ ...config,
7
+ mutationKey: getResetPasswordMutationKey(),
8
+ mutationFn: async (input) => {
9
+ await resetPassword(input);
10
+ },
11
+ });
12
+ };
@@ -7,6 +7,7 @@ import { useSessionQuery } from './useSessionQuery.js';
7
7
  export const useTransactionRecordsQuery = (input, config) => {
8
8
  const sessionQuery = useSessionQuery();
9
9
  const query = useInfiniteQuery({
10
+ staleTime: 1000 * 2,
10
11
  ...config,
11
12
  enabled: config?.enabled === false
12
13
  ? false
@@ -7,6 +7,7 @@ import { useSessionQuery } from './useSessionQuery.js';
7
7
  export const useWithdrawalRecordsQuery = (input, config) => {
8
8
  const sessionQuery = useSessionQuery();
9
9
  const query = useInfiniteQuery({
10
+ staleTime: 1000 * 2,
10
11
  ...config,
11
12
  enabled: config?.enabled === false
12
13
  ? false
@@ -0,0 +1,3 @@
1
+ import type { ForgotPasswordProps } from './ForgotPassword.lazy';
2
+ export declare function ForgotPassword(props: ForgotPasswordProps): import("react/jsx-runtime").JSX.Element | undefined;
3
+ export type { ForgotPasswordProps };
@@ -0,0 +1,14 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import dynamic from 'next/dynamic';
4
+ import { useShallow } from 'zustand/shallow';
5
+ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
6
+ const Component = dynamic(() => import('./ForgotPassword.lazy.js').then((m) => m.ForgotPassword), {
7
+ ssr: false,
8
+ loading: () => null,
9
+ });
10
+ export function ForgotPassword(props) {
11
+ const touched = useGlobalStore(useShallow((ctx) => ctx.forgotPassword['~touched']));
12
+ if (touched)
13
+ return _jsx(Component, { ...props });
14
+ }
@@ -0,0 +1,8 @@
1
+ import { type ImageProps } from 'next/image';
2
+ import { type ReactNode } from 'react';
3
+ export interface ForgotPasswordProps {
4
+ logo: ImageProps['src'];
5
+ children?: ReactNode;
6
+ className?: string;
7
+ }
8
+ export declare function ForgotPassword(props: ForgotPasswordProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import Image, {} from 'next/image';
4
+ import { Suspense } from 'react';
5
+ import { twMerge } from 'tailwind-merge';
6
+ import { useShallow } from 'zustand/shallow';
7
+ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
8
+ import { XIcon } from '../../icons/XIcon.js';
9
+ import { Dialog } from '../../ui/Dialog/index.js';
10
+ import { Portal } from '../../ui/Portal/index.js';
11
+ import { ForgotPasswordForm } from './ForgotPasswordForm.js';
12
+ export function ForgotPassword(props) {
13
+ const globalStore = useGlobalStore(useShallow((ctx) => ({
14
+ forgotPassword: ctx.forgotPassword,
15
+ })));
16
+ return (_jsx(Dialog.Root, { open: globalStore.forgotPassword.open, onOpenChange: (details) => {
17
+ globalStore.forgotPassword.setOpen(details.open);
18
+ }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsxs(Dialog.Content, { className: twMerge('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', props.className), 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(Suspense, { children: _jsx(ForgotPasswordForm, {}) })] }) })] }) }));
19
+ }
@@ -0,0 +1 @@
1
+ export declare function ForgotPasswordForm(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,136 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { zodResolver } from '@hookform/resolvers/zod';
4
+ import { useRef, useState } from 'react';
5
+ import { Controller, useForm } from 'react-hook-form';
6
+ import { z } from 'zod';
7
+ import { useShallow } from 'zustand/shallow';
8
+ import { useCooldown } from '../../client/hooks/useCooldown.js';
9
+ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
10
+ import { useLocaleInfo } from '../../client/hooks/useLocaleInfo.js';
11
+ import { useMobileNumberParser } from '../../client/hooks/useMobileNumberParser.js';
12
+ import { useResetPasswordMutation } from '../../client/hooks/useResetPasswordMutation.js';
13
+ import { useSendVerificationCodeMutation } from '../../client/hooks/useSendVerificationCodeMutation.js';
14
+ import { toaster } from '../../client/utils/toaster.js';
15
+ import { ArrowLeftIcon } from '../../icons/ArrowLeftIcon.js';
16
+ import { EyeIcon } from '../../icons/EyeIcon.js';
17
+ import { EyeOffIcon } from '../../icons/EyeOffIcon.js';
18
+ import { Button } from '../../ui/Button/index.js';
19
+ import { Field } from '../../ui/Field/index.js';
20
+ import { PasswordInput } from '../../ui/PasswordInput/index.js';
21
+ import { PinInput } from '../../ui/PinInput/index.js';
22
+ export function ForgotPasswordForm() {
23
+ const [step, setStep] = useState(1);
24
+ const mobileNumberParser = useMobileNumberParser();
25
+ const localeInfo = useLocaleInfo();
26
+ const globalStore = useGlobalStore(useShallow((ctx) => ({
27
+ signIn: ctx.signIn,
28
+ forgotPassword: ctx.forgotPassword,
29
+ })));
30
+ const sendVerificationCodeMutation = useSendVerificationCodeMutation();
31
+ const resetPasswordMutation = useResetPasswordMutation({
32
+ onSuccess() {
33
+ globalStore.forgotPassword.setOpen(false);
34
+ globalStore.signIn.setOpen(true);
35
+ step1Form.reset();
36
+ step2Form.reset();
37
+ toaster.success({
38
+ description: 'Your password has been updated.',
39
+ });
40
+ },
41
+ onError(error) {
42
+ toaster.error({
43
+ description: error.message,
44
+ });
45
+ },
46
+ });
47
+ const Step1Definition = z
48
+ .object({
49
+ mobileNumber: z.string().superRefine((v, ctx) => {
50
+ if (!mobileNumberParser.validate(v)) {
51
+ ctx.addIssue({
52
+ code: z.ZodIssueCode.custom,
53
+ message: 'Invalid mobile number',
54
+ });
55
+ }
56
+ }),
57
+ newPassword: z
58
+ .string()
59
+ .min(8, 'Password must be 8 or more characters')
60
+ .max(100, 'Password must not be more than 100 characters'),
61
+ confirmPassword: z.string().min(1, 'Confirm your password'),
62
+ })
63
+ .superRefine((val, ctx) => {
64
+ if (val.newPassword !== val.confirmPassword) {
65
+ ctx.addIssue({
66
+ path: ['confirmPassword'],
67
+ code: z.ZodIssueCode.custom,
68
+ message: 'Passwords do not match',
69
+ });
70
+ }
71
+ });
72
+ const Step2Definition = z.object({
73
+ verificationCode: z.array(z.string().min(1).max(1).trim()).min(6).max(6),
74
+ });
75
+ const step1Form = useForm({
76
+ mode: 'all',
77
+ resolver: zodResolver(Step1Definition),
78
+ defaultValues: {
79
+ mobileNumber: '',
80
+ confirmPassword: '',
81
+ newPassword: '',
82
+ },
83
+ });
84
+ const step2Form = useForm({
85
+ resolver: zodResolver(Step2Definition),
86
+ defaultValues: {
87
+ verificationCode: Array.from({ length: 6 }).fill(''),
88
+ },
89
+ });
90
+ const cooldown = useCooldown({
91
+ max: 60,
92
+ duration: 1000 * 60,
93
+ });
94
+ const form2Ref = useRef(null);
95
+ return (_jsxs(_Fragment, { children: [step === 1 && (_jsxs(_Fragment, { children: [_jsx("h2", { className: "mt-xl text-center text-lg font-semibold", children: "Forgot Password" }), _jsx("p", { className: "text-text-secondary-700 mt-xs text-center text-sm", children: "Your new password will be used to sign in." }), _jsxs("form", { className: "mt-3xl", onSubmit: step1Form.handleSubmit(async (data) => {
96
+ try {
97
+ await sendVerificationCodeMutation.mutateAsync({
98
+ channel: 'SMS',
99
+ recipient: mobileNumberParser.format(data.mobileNumber),
100
+ });
101
+ setStep(2);
102
+ cooldown.start();
103
+ }
104
+ catch (e) {
105
+ toaster.error({
106
+ description: e instanceof Error
107
+ ? e.message
108
+ : 'Failed to send verification code',
109
+ });
110
+ }
111
+ }), children: [_jsxs(Field.Root, { invalid: !!step1Form.formState.errors.mobileNumber, children: [_jsx(Field.Label, { children: "Mobile Number" }), _jsxs("div", { className: "relative", children: [_jsxs("div", { className: "absolute left-3.5 top-1/2 flex shrink-0 -translate-y-1/2 items-center gap-md", children: [_jsx(localeInfo.country.flag, { className: "size-5" }), _jsx("span", { className: "text-text-placeholder", children: localeInfo.mobileNumber.areaCode })] }), _jsx(Field.Input, { style: {
112
+ paddingLeft: `calc(2.75rem + ${localeInfo.mobileNumber.areaCode.length}ch)`,
113
+ }, ...step1Form.register('mobileNumber') })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.mobileNumber?.message })] }), _jsx(Field.Root, { invalid: !!step1Form.formState.errors.newPassword, className: "mt-xl", children: _jsxs(PasswordInput.Root, { children: [_jsx(PasswordInput.Label, { children: "New Password" }), _jsxs(PasswordInput.Control, { children: [_jsx(PasswordInput.Input, { placeholder: "Enter your new password", ...step1Form.register('newPassword') }), _jsx(PasswordInput.VisibilityTrigger, { children: _jsx(PasswordInput.Indicator, { fallback: _jsx(EyeOffIcon, {}), asChild: true, children: _jsx(EyeIcon, {}) }) })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.newPassword?.message })] }) }), _jsx(Field.Root, { invalid: !!step1Form.formState.errors.confirmPassword, className: "mt-xl", children: _jsxs(PasswordInput.Root, { children: [_jsx(PasswordInput.Label, { children: "Confirm Password" }), _jsxs(PasswordInput.Control, { children: [_jsx(PasswordInput.Input, { placeholder: "Confirm new password", ...step1Form.register('confirmPassword') }), _jsx(PasswordInput.VisibilityTrigger, { children: _jsx(PasswordInput.Indicator, { fallback: _jsx(EyeOffIcon, {}), asChild: true, children: _jsx(EyeIcon, {}) }) })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.confirmPassword?.message })] }) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: step1Form.formState.isSubmitting, children: "Continue" })] })] })), 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 }) => {
114
+ resetPasswordMutation.mutate({
115
+ mobileNumber: mobileNumberParser.format(step1Form.getValues('mobileNumber')),
116
+ newPassword: step1Form.getValues('newPassword'),
117
+ verificationCode: verificationCode.join(''),
118
+ });
119
+ }), 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) => {
120
+ o.field.onChange(details.value);
121
+ }, onValueComplete: () => {
122
+ form2Ref.current?.requestSubmit();
123
+ }, 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: resetPasswordMutation.isPending, children: "Verify" }), _jsxs("div", { className: "mt-3 flex w-full items-center justify-center gap-xs text-sm", children: [_jsx("span", { className: "text-text-secondary-700", children: "Didn't recieve the code?" }), _jsx("button", { type: "button", className: "text-button-secondary-fg font-semibold disabled:cursor-not-allowed disabled:opacity-75", disabled: cooldown.cooling, onClick: async () => {
124
+ await sendVerificationCodeMutation.mutateAsync({
125
+ channel: 'SMS',
126
+ recipient: mobileNumberParser.format(step1Form.getValues('mobileNumber')),
127
+ });
128
+ cooldown.start();
129
+ }, children: cooldown.cooling
130
+ ? `Resend in ${cooldown.countdown}s`
131
+ : '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: () => {
132
+ setStep(1);
133
+ step2Form.reset();
134
+ cooldown.stop();
135
+ }, children: [_jsx(ArrowLeftIcon, { className: "size-5" }), "Back"] })] })] }))] }));
136
+ }
@@ -0,0 +1,6 @@
1
+ import type { ComponentPropsWithRef } from 'react';
2
+ interface ForgotPasswordTriggerProps extends ComponentPropsWithRef<'button'> {
3
+ asChild?: boolean;
4
+ }
5
+ export declare function ForgotPasswordTrigger(props: ForgotPasswordTriggerProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,14 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { ark } from '@ark-ui/react/factory';
4
+ import { useShallow } from 'zustand/shallow';
5
+ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
6
+ export function ForgotPasswordTrigger(props) {
7
+ const globalStore = useGlobalStore(useShallow((ctx) => ({
8
+ forgotPassword: ctx.forgotPassword,
9
+ })));
10
+ return (_jsx(ark.button, { type: "button", "aria-label": "Reset Password", "data-state": globalStore.forgotPassword.open ? 'open' : 'closed', ...props, onClick: (e) => {
11
+ globalStore.forgotPassword.setOpen(!globalStore.forgotPassword.open);
12
+ return props.onClick?.(e);
13
+ } }));
14
+ }
@@ -0,0 +1,2 @@
1
+ export * from './ForgotPassword';
2
+ export * from './ForgotPasswordTrigger';
@@ -0,0 +1,2 @@
1
+ export * from './ForgotPassword.js';
2
+ export * from './ForgotPasswordTrigger.js';
@@ -24,7 +24,9 @@ import { useSignInContext } from './SignInContext.js';
24
24
  export function MobileNumberSignIn() {
25
25
  const context = useSignInContext();
26
26
  const dialog = useDialogContext();
27
- const signUpStore = useGlobalStore(useShallow((ctx) => ctx.signUp));
27
+ const globalStore = useGlobalStore(useShallow((ctx) => ({
28
+ signUp: ctx.signUp,
29
+ })));
28
30
  const signInMutation = useSignInMutation();
29
31
  const sendVerificationCodeMutation = useSendVerificationCodeMutation();
30
32
  const localeInfo = useLocaleInfo();
@@ -98,7 +100,7 @@ export function MobileNumberSignIn() {
98
100
  dialog.setOpen(false);
99
101
  }, 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: () => {
100
102
  dialog.setOpen(false);
101
- signUpStore.setOpen(true);
103
+ globalStore.signUp.setOpen(true);
102
104
  }, 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 }) => {
103
105
  const { mobileNumber } = step1Form.getValues();
104
106
  try {
@@ -25,6 +25,7 @@ export function NameAndPasswordSignIn() {
25
25
  const globalStore = useGlobalStore(useShallow((ctx) => ({
26
26
  signIn: ctx.signIn,
27
27
  signUp: ctx.signUp,
28
+ forgotPassword: ctx.forgotPassword,
28
29
  })));
29
30
  const signInMutation = useSignInMutation({
30
31
  onSuccess(authenticator) {
@@ -118,7 +119,10 @@ export function NameAndPasswordSignIn() {
118
119
  signInMutation.reset();
119
120
  form.setValue('secretAnswer', '');
120
121
  },
121
- }) }), _jsx(Field.ErrorText, { children: form.formState.errors.name?.message })] }), _jsx(Field.Root, { disabled: !!signInMutation.data, invalid: !!form.formState.errors.name, className: "mt-xl", children: _jsxs(PasswordInput.Root, { children: [_jsx(PasswordInput.Label, { children: "Password" }), _jsxs("div", { children: [_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(Field.ErrorText, { children: form.formState.errors.password?.message })] }), _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" }) })] }) }), 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(Field.Root, { invalid: o.fieldState.invalid, className: "mt-xl", children: [_jsxs(Checkbox.Root, { checked: o.field.value, onCheckedChange: (details) => {
122
+ }) }), _jsx(Field.ErrorText, { children: form.formState.errors.name?.message })] }), _jsx(Field.Root, { disabled: !!signInMutation.data, invalid: !!form.formState.errors.name, className: "mt-xl", children: _jsxs(PasswordInput.Root, { children: [_jsx(PasswordInput.Label, { children: "Password" }), _jsxs("div", { children: [_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(Field.ErrorText, { children: form.formState.errors.password?.message })] }), _jsx("div", { className: "mt-2 flex justify-end", children: _jsx("button", { type: "button", tabIndex: -1, className: "text-button-tertiary-fg text-sm font-semibold", onClick: () => {
123
+ globalStore.forgotPassword.setOpen(true);
124
+ dialog.setOpen(false);
125
+ }, children: "Forgot Password" }) })] }) }), 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(Field.Root, { invalid: o.fieldState.invalid, className: "mt-xl", children: [_jsxs(Checkbox.Root, { checked: o.field.value, onCheckedChange: (details) => {
122
126
  o.field.onChange(details.checked);
123
127
  }, 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, {})] }), _jsx(Field.ErrorText, { className: "ml-6 text-xs", children: o.fieldState.error?.message })] })) })] }), _jsxs("div", { className: "mt-6 flex items-center gap-2", children: [_jsx("div", { className: "bg-text-tertiary-600/50 h-px flex-grow" }), _jsx("span", { className: "text-text-tertiary-600 text-sm font-semibold", children: "Log in directly with" }), _jsx("div", { className: "bg-text-tertiary-600/50 h-px flex-grow" })] }), _jsxs("div", { className: "mt-6", children: [_jsxs(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
124
128
  dialog.setOpen(false);
@@ -0,0 +1,2 @@
1
+ export type KnownErrorName = '' | (string & {});
2
+ export declare function createErrorFromCode(name: KnownErrorName | (string & {}), message?: string): Error;
@@ -0,0 +1,11 @@
1
+ // ✏️ TODO
2
+ const ERROR_CODES_MAP = {
3
+ '': '',
4
+ };
5
+ export function createErrorFromCode(name, message) {
6
+ const error = new Error();
7
+ error.name = name;
8
+ error.message = ERROR_CODES_MAP[name] ?? message ?? 'Something went wrong';
9
+ Error.captureStackTrace?.(error, createErrorFromCode);
10
+ return error;
11
+ }
@@ -28,3 +28,4 @@ export declare const getSignUpMutationKey: () => MutationKey;
28
28
  export declare const getCompleteOnboardingMutationKey: () => MutationKey;
29
29
  export declare const getSkipOnboardingMutationKey: () => MutationKey;
30
30
  export declare const getUploadImageFileMutationKey: () => MutationKey;
31
+ export declare const getResetPasswordMutationKey: () => MutationKey;
@@ -106,3 +106,7 @@ export const getUploadImageFileMutationKey = () => [
106
106
  PARENT_KEY,
107
107
  'uploadImageFile',
108
108
  ];
109
+ export const getResetPasswordMutationKey = () => [
110
+ PARENT_KEY,
111
+ 'resetPassword',
112
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.121",
3
+ "version": "0.0.122",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",