@mesob/auth-react 0.0.3 → 0.0.5

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 (62) hide show
  1. package/dist/components/auth/auth-card.js +11 -0
  2. package/dist/components/auth/auth-card.js.map +1 -0
  3. package/dist/components/{auth-page-layout.d.ts → auth/auth-page-layout.d.ts} +2 -1
  4. package/dist/components/{auth-page-layout.js → auth/auth-page-layout.js} +16 -3
  5. package/dist/components/auth/auth-page-layout.js.map +1 -0
  6. package/dist/components/{countdown.js → auth/countdown.js} +8 -4
  7. package/dist/components/auth/countdown.js.map +1 -0
  8. package/dist/components/{forgot-password.d.ts → auth/forgot-password.d.ts} +1 -1
  9. package/dist/components/{forgot-password.js → auth/forgot-password.js} +7 -4
  10. package/dist/components/auth/forgot-password.js.map +1 -0
  11. package/dist/components/{pages → auth/pages}/forgot-password-page.js +94 -28
  12. package/dist/components/auth/pages/forgot-password-page.js.map +1 -0
  13. package/dist/components/{pages → auth/pages}/reset-password-page.d.ts +2 -1
  14. package/dist/components/{pages → auth/pages}/reset-password-page.js +111 -42
  15. package/dist/components/auth/pages/reset-password-page.js.map +1 -0
  16. package/dist/components/{pages → auth/pages}/sign-in-page.js +130 -30
  17. package/dist/components/auth/pages/sign-in-page.js.map +1 -0
  18. package/dist/components/{pages → auth/pages}/sign-up-page.d.ts +2 -1
  19. package/dist/components/{pages → auth/pages}/sign-up-page.js +93 -29
  20. package/dist/components/auth/pages/sign-up-page.js.map +1 -0
  21. package/dist/components/{pages → auth/pages}/verify-email-page.d.ts +2 -1
  22. package/dist/components/{pages → auth/pages}/verify-email-page.js +131 -61
  23. package/dist/components/auth/pages/verify-email-page.js.map +1 -0
  24. package/dist/components/{pages → auth/pages}/verify-phone-page.d.ts +2 -1
  25. package/dist/components/{pages → auth/pages}/verify-phone-page.js +136 -63
  26. package/dist/components/auth/pages/verify-phone-page.js.map +1 -0
  27. package/dist/components/{reset-password-form.d.ts → auth/reset-password-form.d.ts} +3 -2
  28. package/dist/components/{reset-password-form.js → auth/reset-password-form.js} +17 -15
  29. package/dist/components/auth/reset-password-form.js.map +1 -0
  30. package/dist/components/{sign-in.js → auth/sign-in.js} +43 -6
  31. package/dist/components/auth/sign-in.js.map +1 -0
  32. package/dist/components/{sign-up.js → auth/sign-up.js} +4 -4
  33. package/dist/components/auth/sign-up.js.map +1 -0
  34. package/dist/components/{verification-form.d.ts → auth/verification-form.d.ts} +2 -1
  35. package/dist/components/{verification-form.js → auth/verification-form.js} +33 -33
  36. package/dist/components/auth/verification-form.js.map +1 -0
  37. package/dist/handle-error-H0iqQxJ5.d.ts +6 -0
  38. package/dist/index.d.ts +49 -15
  39. package/dist/index.js +304 -142
  40. package/dist/index.js.map +1 -1
  41. package/package.json +3 -3
  42. package/dist/components/auth-card.js +0 -11
  43. package/dist/components/auth-card.js.map +0 -1
  44. package/dist/components/auth-page-layout.js.map +0 -1
  45. package/dist/components/countdown.js.map +0 -1
  46. package/dist/components/forgot-password.js.map +0 -1
  47. package/dist/components/pages/forgot-password-page.js.map +0 -1
  48. package/dist/components/pages/reset-password-page.js.map +0 -1
  49. package/dist/components/pages/sign-in-page.js.map +0 -1
  50. package/dist/components/pages/sign-up-page.js.map +0 -1
  51. package/dist/components/pages/verify-email-page.js.map +0 -1
  52. package/dist/components/pages/verify-phone-page.js.map +0 -1
  53. package/dist/components/reset-password-form.js.map +0 -1
  54. package/dist/components/sign-in.js.map +0 -1
  55. package/dist/components/sign-up.js.map +0 -1
  56. package/dist/components/verification-form.js.map +0 -1
  57. /package/dist/components/{auth-card.d.ts → auth/auth-card.d.ts} +0 -0
  58. /package/dist/components/{countdown.d.ts → auth/countdown.d.ts} +0 -0
  59. /package/dist/components/{pages → auth/pages}/forgot-password-page.d.ts +0 -0
  60. /package/dist/components/{pages → auth/pages}/sign-in-page.d.ts +0 -0
  61. /package/dist/components/{sign-in.d.ts → auth/sign-in.d.ts} +0 -0
  62. /package/dist/components/{sign-up.d.ts → auth/sign-up.d.ts} +0 -0
@@ -0,0 +1,11 @@
1
+ "use client";
2
+
3
+ // src/components/auth/auth-card.tsx
4
+ import { jsx } from "react/jsx-runtime";
5
+ var AuthCard = ({ children }) => {
6
+ return /* @__PURE__ */ jsx("div", { className: "flex min-h-screen p-4 items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "w-full max-w-md", children: /* @__PURE__ */ jsx("div", { className: "rounded-xl border bg-card p-8 shadow-lg", children }) }) });
7
+ };
8
+ export {
9
+ AuthCard
10
+ };
11
+ //# sourceMappingURL=auth-card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/auth/auth-card.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\n\ntype AuthCardProps = {\n children: ReactNode;\n};\n\nexport const AuthCard = ({ children }: AuthCardProps) => {\n return (\n <div className=\"flex min-h-screen p-4 items-center justify-center\">\n <div className=\"w-full max-w-md\">\n <div className=\"rounded-xl border bg-card p-8 shadow-lg\">\n {children}\n </div>\n </div>\n </div>\n );\n};\n"],"mappings":";;;AAYQ;AAJD,IAAM,WAAW,CAAC,EAAE,SAAS,MAAqB;AACvD,SACE,oBAAC,SAAI,WAAU,qDACb,8BAAC,SAAI,WAAU,mBACb,8BAAC,SAAI,WAAU,2CACZ,UACH,GACF,GACF;AAEJ;","names":[]}
@@ -1,11 +1,12 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
+ import { A as AuthErrorContent } from '../../handle-error-H0iqQxJ5.js';
3
4
 
4
5
  type AuthPageLayoutProps = {
5
6
  title: string;
6
7
  description?: string;
7
8
  children: ReactNode;
8
- error?: string | null;
9
+ error?: AuthErrorContent | string | null;
9
10
  footer?: ReactNode;
10
11
  logoImage?: string;
11
12
  };
@@ -1,7 +1,12 @@
1
1
  "use client";
2
2
 
3
- // src/components/auth-page-layout.tsx
4
- import { Alert, AlertDescription } from "@mesob/ui/components/alert";
3
+ // src/components/auth/auth-page-layout.tsx
4
+ import {
5
+ Alert,
6
+ AlertDescription,
7
+ AlertTitle
8
+ } from "@mesob/ui/components/alert";
9
+ import { IconAlertCircle } from "@tabler/icons-react";
5
10
  import { jsx, jsxs } from "react/jsx-runtime";
6
11
  var AuthPageLayout = ({
7
12
  title,
@@ -11,6 +16,10 @@ var AuthPageLayout = ({
11
16
  footer,
12
17
  logoImage
13
18
  }) => {
19
+ const errorContent = error ? (
20
+ // biome-ignore lint/style/noNestedTernary: <explanation>
21
+ typeof error === "string" ? { title: "Error", description: error } : error
22
+ ) : null;
14
23
  return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
15
24
  /* @__PURE__ */ jsx("div", { className: "flex size-8 mb-6 w-full items-center justify-center rounded-md", children: /* @__PURE__ */ jsx("img", { src: logoImage || "", alt: "Jiret", width: 42, height: 42 }) }),
16
25
  /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
@@ -18,7 +27,11 @@ var AuthPageLayout = ({
18
27
  description && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: description })
19
28
  ] }),
20
29
  children,
21
- error && /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsx(AlertDescription, { children: error }) }),
30
+ errorContent && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
31
+ /* @__PURE__ */ jsx(IconAlertCircle, { className: "h-4 w-4" }),
32
+ /* @__PURE__ */ jsx(AlertTitle, { children: errorContent.title }),
33
+ /* @__PURE__ */ jsx(AlertDescription, { children: errorContent.description })
34
+ ] }),
22
35
  /* @__PURE__ */ jsx("div", { className: "mt-2 w-full", children: footer && /* @__PURE__ */ jsx("div", { className: "w-full text-center text-sm text-muted-foreground", children: footer }) })
23
36
  ] });
24
37
  };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/auth/auth-page-layout.tsx"],"sourcesContent":["'use client';\n\nimport {\n Alert,\n AlertDescription,\n AlertTitle,\n} from '@mesob/ui/components/alert';\nimport { IconAlertCircle } from '@tabler/icons-react';\nimport type { ReactNode } from 'react';\nimport type { AuthErrorContent } from '../../utils/handle-error';\n\ntype AuthPageLayoutProps = {\n title: string;\n description?: string;\n children: ReactNode;\n error?: AuthErrorContent | string | null;\n footer?: ReactNode;\n logoImage?: string;\n};\n\nexport const AuthPageLayout = ({\n title,\n description,\n children,\n error,\n footer,\n logoImage,\n}: AuthPageLayoutProps) => {\n const errorContent: AuthErrorContent | null = error\n ? // biome-ignore lint/style/noNestedTernary: <explanation>\n typeof error === 'string'\n ? { title: 'Error', description: error }\n : error\n : null;\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex size-8 mb-6 w-full items-center justify-center rounded-md\">\n {/** biome-ignore lint/performance/noImgElement: logo image */}\n <img src={logoImage || ''} alt=\"Jiret\" width={42} height={42} />\n </div>\n <div className=\"text-center\">\n <h1 className=\"text-2xl font-bold tracking-tight\">{title}</h1>\n {description && (\n <p className=\"mt-2 text-sm text-muted-foreground\">{description}</p>\n )}\n </div>\n\n {children}\n\n {errorContent && (\n <Alert variant=\"destructive\">\n <IconAlertCircle className=\"h-4 w-4\" />\n <AlertTitle>{errorContent.title}</AlertTitle>\n <AlertDescription>{errorContent.description}</AlertDescription>\n </Alert>\n )}\n <div className=\"mt-2 w-full\">\n {footer && (\n <div className=\"w-full text-center text-sm text-muted-foreground\">\n {footer}\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAgCxB,cAEF,YAFE;AAnBD,IAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA2B;AACzB,QAAM,eAAwC;AAAA;AAAA,IAE1C,OAAO,UAAU,WACf,EAAE,OAAO,SAAS,aAAa,MAAM,IACrC;AAAA,MACF;AAEJ,SACE,qBAAC,SAAI,WAAU,aACb;AAAA,wBAAC,SAAI,WAAU,kEAEb,8BAAC,SAAI,KAAK,aAAa,IAAI,KAAI,SAAQ,OAAO,IAAI,QAAQ,IAAI,GAChE;AAAA,IACA,qBAAC,SAAI,WAAU,eACb;AAAA,0BAAC,QAAG,WAAU,qCAAqC,iBAAM;AAAA,MACxD,eACC,oBAAC,OAAE,WAAU,sCAAsC,uBAAY;AAAA,OAEnE;AAAA,IAEC;AAAA,IAEA,gBACC,qBAAC,SAAM,SAAQ,eACb;AAAA,0BAAC,mBAAgB,WAAU,WAAU;AAAA,MACrC,oBAAC,cAAY,uBAAa,OAAM;AAAA,MAChC,oBAAC,oBAAkB,uBAAa,aAAY;AAAA,OAC9C;AAAA,IAEF,oBAAC,SAAI,WAAU,eACZ,oBACC,oBAAC,SAAI,WAAU,oDACZ,kBACH,GAEJ;AAAA,KACF;AAEJ;","names":[]}
@@ -1,10 +1,11 @@
1
1
  "use client";
2
2
 
3
- // src/components/countdown.tsx
3
+ // src/components/auth/countdown.tsx
4
4
  import { Button } from "@mesob/ui/components/button";
5
+ import { Spinner } from "@mesob/ui/components/spinner";
5
6
  import { useTranslations } from "next-intl";
6
7
  import { useEffect, useState } from "react";
7
- import { jsx } from "react/jsx-runtime";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
8
9
  var Countdown = ({
9
10
  initialSeconds = 60,
10
11
  onResend,
@@ -41,13 +42,16 @@ var Countdown = ({
41
42
  if (seconds > 0) {
42
43
  return /* @__PURE__ */ jsx(Button, { variant: "ghost", disabled: true, children: t("resendIn", { seconds }) });
43
44
  }
44
- return /* @__PURE__ */ jsx(
45
+ return /* @__PURE__ */ jsxs(
45
46
  Button,
46
47
  {
47
48
  variant: "ghost",
48
49
  onClick: handleResend,
49
50
  disabled: isResending || resending,
50
- children: isResending || resending ? t("resending") : t("resend")
51
+ children: [
52
+ isResending || resending && /* @__PURE__ */ jsx(Spinner, {}),
53
+ t("resend")
54
+ ]
51
55
  }
52
56
  );
53
57
  };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/auth/countdown.tsx"],"sourcesContent":["'use client';\n\nimport { Button } from '@mesob/ui/components/button';\nimport { Spinner } from '@mesob/ui/components/spinner';\nimport { useTranslations } from 'next-intl';\nimport { useEffect, useState } from 'react';\n\ntype CountdownProps = {\n initialSeconds?: number;\n onResend: () => Promise<void> | void;\n resending?: boolean;\n};\n\nexport const Countdown = ({\n initialSeconds = 60,\n onResend,\n resending = false,\n}: CountdownProps) => {\n const t = useTranslations('Common');\n const [seconds, setSeconds] = useState(initialSeconds);\n const [isResending, setIsResending] = useState(false);\n\n useEffect(() => {\n if (seconds <= 0) {\n return;\n }\n\n const timer = setInterval(() => {\n setSeconds((prev) => {\n if (prev <= 1) {\n clearInterval(timer);\n return 0;\n }\n return prev - 1;\n });\n }, 1000);\n\n return () => clearInterval(timer);\n }, [seconds]);\n\n const handleResend = async () => {\n setIsResending(true);\n try {\n await onResend();\n setSeconds(initialSeconds);\n } catch (_error) {\n // Error handling is done by parent\n } finally {\n setIsResending(false);\n }\n };\n\n if (seconds > 0) {\n return (\n <Button variant=\"ghost\" disabled>\n {t('resendIn', { seconds })}\n </Button>\n );\n }\n\n return (\n <Button\n variant=\"ghost\"\n onClick={handleResend}\n disabled={isResending || resending}\n >\n {isResending || (resending && <Spinner />)}\n {t('resend')}\n </Button>\n );\n};\n"],"mappings":";;;AAEA,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,SAAS,WAAW,gBAAgB;AAiD9B,cAOF,YAPE;AAzCC,IAAM,YAAY,CAAC;AAAA,EACxB,iBAAiB;AAAA,EACjB;AAAA,EACA,YAAY;AACd,MAAsB;AACpB,QAAM,IAAI,gBAAgB,QAAQ;AAClC,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,cAAc;AACrD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AAEpD,YAAU,MAAM;AACd,QAAI,WAAW,GAAG;AAChB;AAAA,IACF;AAEA,UAAM,QAAQ,YAAY,MAAM;AAC9B,iBAAW,CAAC,SAAS;AACnB,YAAI,QAAQ,GAAG;AACb,wBAAc,KAAK;AACnB,iBAAO;AAAA,QACT;AACA,eAAO,OAAO;AAAA,MAChB,CAAC;AAAA,IACH,GAAG,GAAI;AAEP,WAAO,MAAM,cAAc,KAAK;AAAA,EAClC,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,eAAe,YAAY;AAC/B,mBAAe,IAAI;AACnB,QAAI;AACF,YAAM,SAAS;AACf,iBAAW,cAAc;AAAA,IAC3B,SAAS,QAAQ;AAAA,IAEjB,UAAE;AACA,qBAAe,KAAK;AAAA,IACtB;AAAA,EACF;AAEA,MAAI,UAAU,GAAG;AACf,WACE,oBAAC,UAAO,SAAQ,SAAQ,UAAQ,MAC7B,YAAE,YAAY,EAAE,QAAQ,CAAC,GAC5B;AAAA,EAEJ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,SAAS;AAAA,MACT,UAAU,eAAe;AAAA,MAExB;AAAA,uBAAgB,aAAa,oBAAC,WAAQ;AAAA,QACtC,EAAE,QAAQ;AAAA;AAAA;AAAA,EACb;AAEJ;","names":[]}
@@ -8,6 +8,6 @@ type ForgotPasswordProps = {
8
8
  isLoading?: boolean;
9
9
  onBack?: () => void;
10
10
  };
11
- declare const ForgotPassword: ({ onSubmit, isLoading, onBack, }: ForgotPasswordProps) => react_jsx_runtime.JSX.Element;
11
+ declare const ForgotPassword: ({ onSubmit, isLoading, }: ForgotPasswordProps) => react_jsx_runtime.JSX.Element;
12
12
 
13
13
  export { ForgotPassword };
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- // src/components/forgot-password.tsx
3
+ // src/components/auth/forgot-password.tsx
4
4
  import { zodResolver } from "@hookform/resolvers/zod";
5
5
  import { Button } from "@mesob/ui/components/button";
6
6
  import {
@@ -12,6 +12,7 @@ import {
12
12
  FormMessage
13
13
  } from "@mesob/ui/components/form";
14
14
  import { Input } from "@mesob/ui/components/input";
15
+ import { Spinner } from "@mesob/ui/components/spinner";
15
16
  import { useTranslations } from "next-intl";
16
17
  import { useMemo } from "react";
17
18
  import { useForm } from "react-hook-form";
@@ -19,8 +20,7 @@ import { z } from "zod";
19
20
  import { jsx, jsxs } from "react/jsx-runtime";
20
21
  var ForgotPassword = ({
21
22
  onSubmit,
22
- isLoading = false,
23
- onBack
23
+ isLoading = false
24
24
  }) => {
25
25
  const t = useTranslations("Auth.forgotPassword");
26
26
  const forgotPasswordSchema = useMemo(
@@ -58,7 +58,10 @@ var ForgotPassword = ({
58
58
  ] })
59
59
  }
60
60
  ),
61
- /* @__PURE__ */ jsx(Button, { type: "submit", className: "w-full", disabled: isLoading, children: isLoading ? t("form.submitting") : t("form.submit") })
61
+ /* @__PURE__ */ jsxs(Button, { type: "submit", className: "w-full", disabled: isLoading, children: [
62
+ isLoading && /* @__PURE__ */ jsx(Spinner, {}),
63
+ isLoading ? t("form.submitting") : t("form.submit")
64
+ ] })
62
65
  ] }) });
63
66
  };
64
67
  export {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/auth/forgot-password.tsx"],"sourcesContent":["'use client';\n\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { Button } from '@mesob/ui/components/button';\nimport {\n Form,\n FormControl,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '@mesob/ui/components/form';\nimport { Input } from '@mesob/ui/components/input';\nimport { Spinner } from '@mesob/ui/components/spinner';\nimport { useTranslations } from 'next-intl';\nimport { useMemo } from 'react';\nimport { useForm } from 'react-hook-form';\nimport { z } from 'zod';\n\ntype ForgotPasswordFormValues = {\n account: string;\n};\n\ntype ForgotPasswordProps = {\n onSubmit: (values: ForgotPasswordFormValues) => Promise<void> | void;\n isLoading?: boolean;\n onBack?: () => void;\n};\n\nexport const ForgotPassword = ({\n onSubmit,\n isLoading = false,\n}: ForgotPasswordProps) => {\n const t = useTranslations('Auth.forgotPassword');\n const forgotPasswordSchema = useMemo(\n () =>\n z.object({\n account: z.string().min(1, t('errors.accountRequired')),\n }),\n [t],\n );\n\n const form = useForm<ForgotPasswordFormValues>({\n resolver: zodResolver(forgotPasswordSchema),\n defaultValues: {\n account: '',\n },\n });\n\n const handleSubmit = form.handleSubmit(async (values) => {\n await onSubmit(values);\n });\n\n return (\n <Form {...form}>\n <form onSubmit={handleSubmit} className=\"space-y-5\">\n <FormField\n control={form.control}\n name=\"account\"\n render={({ field }) => (\n <FormItem>\n <FormLabel>{t('form.accountLabel')}</FormLabel>\n <FormControl>\n <Input\n type=\"text\"\n placeholder={t('form.accountPlaceholder')}\n {...field}\n />\n </FormControl>\n <FormMessage />\n </FormItem>\n )}\n />\n <Button type=\"submit\" className=\"w-full\" disabled={isLoading}>\n {isLoading && <Spinner />}\n {isLoading ? t('form.submitting') : t('form.submit')}\n </Button>\n </form>\n </Form>\n );\n};\n"],"mappings":";;;AAEA,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,SAAS;AA2CN,SACE,KADF;AA/BL,IAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA,YAAY;AACd,MAA2B;AACzB,QAAM,IAAI,gBAAgB,qBAAqB;AAC/C,QAAM,uBAAuB;AAAA,IAC3B,MACE,EAAE,OAAO;AAAA,MACP,SAAS,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,wBAAwB,CAAC;AAAA,IACxD,CAAC;AAAA,IACH,CAAC,CAAC;AAAA,EACJ;AAEA,QAAM,OAAO,QAAkC;AAAA,IAC7C,UAAU,YAAY,oBAAoB;AAAA,IAC1C,eAAe;AAAA,MACb,SAAS;AAAA,IACX;AAAA,EACF,CAAC;AAED,QAAM,eAAe,KAAK,aAAa,OAAO,WAAW;AACvD,UAAM,SAAS,MAAM;AAAA,EACvB,CAAC;AAED,SACE,oBAAC,QAAM,GAAG,MACR,+BAAC,UAAK,UAAU,cAAc,WAAU,aACtC;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,SAAS,KAAK;AAAA,QACd,MAAK;AAAA,QACL,QAAQ,CAAC,EAAE,MAAM,MACf,qBAAC,YACC;AAAA,8BAAC,aAAW,YAAE,mBAAmB,GAAE;AAAA,UACnC,oBAAC,eACC;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,aAAa,EAAE,yBAAyB;AAAA,cACvC,GAAG;AAAA;AAAA,UACN,GACF;AAAA,UACA,oBAAC,eAAY;AAAA,WACf;AAAA;AAAA,IAEJ;AAAA,IACA,qBAAC,UAAO,MAAK,UAAS,WAAU,UAAS,UAAU,WAChD;AAAA,mBAAa,oBAAC,WAAQ;AAAA,MACtB,YAAY,EAAE,iBAAiB,IAAI,EAAE,aAAa;AAAA,OACrD;AAAA,KACF,GACF;AAEJ;","names":[]}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- // src/components/pages/forgot-password-page.tsx
3
+ // src/components/auth/pages/forgot-password-page.tsx
4
4
  import { useTranslations as useTranslations2 } from "next-intl";
5
5
  import { useState as useState2 } from "react";
6
6
 
@@ -37,40 +37,95 @@ var AuthError = class extends Error {
37
37
  };
38
38
 
39
39
  // src/constants/auth.error.codes.ts
40
- var validCodes = [
41
- "USER_NOT_FOUND",
42
- "INVALID_PASSWORD",
43
- "USER_EXISTS",
44
- "VERIFICATION_EXPIRED",
45
- "VERIFICATION_MISMATCH",
46
- "VERIFICATION_NOT_FOUND",
47
- "TOO_MANY_ATTEMPTS",
48
- "REQUIRES_VERIFICATION",
49
- "UNAUTHORIZED",
50
- "ACCESS_DENIED",
51
- "HAS_NO_PASSWORD"
52
- ];
40
+ var AUTH_ERROR_MAPPING = {
41
+ USER_NOT_FOUND: {
42
+ title: "Account Not Found",
43
+ description: "We could not find an account with that identifier. Please check your spelling or sign up."
44
+ },
45
+ INVALID_PASSWORD: {
46
+ title: "Invalid Password",
47
+ description: "The password you entered is incorrect. Please try again."
48
+ },
49
+ USER_EXISTS: {
50
+ title: "Account Already Exists",
51
+ description: "An account with this identifier already exists. Please sign in instead."
52
+ },
53
+ VERIFICATION_EXPIRED: {
54
+ title: "Verification Expired",
55
+ description: "The verification code or link has expired. Please request a new one."
56
+ },
57
+ VERIFICATION_MISMATCH: {
58
+ title: "Invalid Code",
59
+ description: "The verification code you entered is invalid. Please double-check and try again."
60
+ },
61
+ VERIFICATION_NOT_FOUND: {
62
+ title: "Verification Not Found",
63
+ description: "We could not find a pending verification request. Please restart the process."
64
+ },
65
+ TOO_MANY_ATTEMPTS: {
66
+ title: "Too Many Attempts",
67
+ description: "You have made too many requests recently. Please wait a moment before trying again."
68
+ },
69
+ REQUIRES_VERIFICATION: {
70
+ title: "Verification Required",
71
+ description: "You need to verify your account before you can continue. Please check your email or phone."
72
+ },
73
+ UNAUTHORIZED: {
74
+ title: "Unauthorized",
75
+ description: "You are not authorized to perform this action. Please sign in again."
76
+ },
77
+ ACCESS_DENIED: {
78
+ title: "Access Denied",
79
+ description: "You do not have permission to access this resource. Please contact support if you believe this is an error."
80
+ },
81
+ HAS_NO_PASSWORD: {
82
+ title: "No Password Set",
83
+ description: "Your account does not have a password set (e.g. social login). Please sign in with your provider or reset your password."
84
+ }
85
+ };
86
+ var validCodes = Object.keys(AUTH_ERROR_MAPPING);
53
87
 
54
88
  // src/utils/handle-error.ts
55
89
  var handleError = (err, setError, t) => {
56
90
  if (err instanceof AuthError) {
57
- let errorKey = "errors.fallback";
58
- if (err.code) {
59
- errorKey = `errors.${err.code.toLowerCase()}`;
91
+ let errorCode = "";
92
+ if (err.code && validCodes.includes(err.code)) {
93
+ errorCode = err.code;
60
94
  } else if (err.message) {
61
95
  const messageUpper = err.message.toUpperCase().trim();
62
96
  if (validCodes.includes(messageUpper)) {
63
- errorKey = `errors.${messageUpper.toLowerCase()}`;
97
+ errorCode = messageUpper;
64
98
  }
65
99
  }
66
- setError(t(errorKey, { defaultValue: err.message }));
100
+ if (errorCode && AUTH_ERROR_MAPPING[errorCode]) {
101
+ const mapping = AUTH_ERROR_MAPPING[errorCode];
102
+ setError({
103
+ title: mapping.title,
104
+ description: mapping.description
105
+ });
106
+ return;
107
+ }
108
+ setError({
109
+ title: t("errors.fallback"),
110
+ // or 'Error'
111
+ description: err.message || t("errors.fallback")
112
+ });
67
113
  } else {
68
- setError(err instanceof Error ? err.message : t("errors.fallback"));
114
+ const message = err instanceof Error ? err.message : t("errors.fallback");
115
+ setError({
116
+ title: "Error",
117
+ description: message
118
+ });
69
119
  }
70
120
  };
71
121
 
72
- // src/components/auth-page-layout.tsx
73
- import { Alert, AlertDescription } from "@mesob/ui/components/alert";
122
+ // src/components/auth/auth-page-layout.tsx
123
+ import {
124
+ Alert,
125
+ AlertDescription,
126
+ AlertTitle
127
+ } from "@mesob/ui/components/alert";
128
+ import { IconAlertCircle } from "@tabler/icons-react";
74
129
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
75
130
  var AuthPageLayout = ({
76
131
  title,
@@ -80,6 +135,10 @@ var AuthPageLayout = ({
80
135
  footer,
81
136
  logoImage
82
137
  }) => {
138
+ const errorContent = error ? (
139
+ // biome-ignore lint/style/noNestedTernary: <explanation>
140
+ typeof error === "string" ? { title: "Error", description: error } : error
141
+ ) : null;
83
142
  return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
84
143
  /* @__PURE__ */ jsx2("div", { className: "flex size-8 mb-6 w-full items-center justify-center rounded-md", children: /* @__PURE__ */ jsx2("img", { src: logoImage || "", alt: "Jiret", width: 42, height: 42 }) }),
85
144
  /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
@@ -87,12 +146,16 @@ var AuthPageLayout = ({
87
146
  description && /* @__PURE__ */ jsx2("p", { className: "mt-2 text-sm text-muted-foreground", children: description })
88
147
  ] }),
89
148
  children,
90
- error && /* @__PURE__ */ jsx2(Alert, { variant: "destructive", children: /* @__PURE__ */ jsx2(AlertDescription, { children: error }) }),
149
+ errorContent && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
150
+ /* @__PURE__ */ jsx2(IconAlertCircle, { className: "h-4 w-4" }),
151
+ /* @__PURE__ */ jsx2(AlertTitle, { children: errorContent.title }),
152
+ /* @__PURE__ */ jsx2(AlertDescription, { children: errorContent.description })
153
+ ] }),
91
154
  /* @__PURE__ */ jsx2("div", { className: "mt-2 w-full", children: footer && /* @__PURE__ */ jsx2("div", { className: "w-full text-center text-sm text-muted-foreground", children: footer }) })
92
155
  ] });
93
156
  };
94
157
 
95
- // src/components/forgot-password.tsx
158
+ // src/components/auth/forgot-password.tsx
96
159
  import { zodResolver } from "@hookform/resolvers/zod";
97
160
  import { Button } from "@mesob/ui/components/button";
98
161
  import {
@@ -104,6 +167,7 @@ import {
104
167
  FormMessage
105
168
  } from "@mesob/ui/components/form";
106
169
  import { Input } from "@mesob/ui/components/input";
170
+ import { Spinner } from "@mesob/ui/components/spinner";
107
171
  import { useTranslations } from "next-intl";
108
172
  import { useMemo } from "react";
109
173
  import { useForm } from "react-hook-form";
@@ -111,8 +175,7 @@ import { z } from "zod";
111
175
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
112
176
  var ForgotPassword = ({
113
177
  onSubmit,
114
- isLoading = false,
115
- onBack
178
+ isLoading = false
116
179
  }) => {
117
180
  const t = useTranslations("Auth.forgotPassword");
118
181
  const forgotPasswordSchema = useMemo(
@@ -150,11 +213,14 @@ var ForgotPassword = ({
150
213
  ] })
151
214
  }
152
215
  ),
153
- /* @__PURE__ */ jsx3(Button, { type: "submit", className: "w-full", disabled: isLoading, children: isLoading ? t("form.submitting") : t("form.submit") })
216
+ /* @__PURE__ */ jsxs2(Button, { type: "submit", className: "w-full", disabled: isLoading, children: [
217
+ isLoading && /* @__PURE__ */ jsx3(Spinner, {}),
218
+ isLoading ? t("form.submitting") : t("form.submit")
219
+ ] })
154
220
  ] }) });
155
221
  };
156
222
 
157
- // src/components/pages/forgot-password-page.tsx
223
+ // src/components/auth/pages/forgot-password-page.tsx
158
224
  import { jsx as jsx4 } from "react/jsx-runtime";
159
225
  var ForgotPasswordPage = ({
160
226
  onNavigate,
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/auth/pages/forgot-password-page.tsx","../../../../src/context/auth-provider.tsx","../../../../src/client.ts","../../../../src/constants/auth.error.codes.ts","../../../../src/utils/handle-error.ts","../../../../src/components/auth/auth-page-layout.tsx","../../../../src/components/auth/forgot-password.tsx"],"sourcesContent":["'use client';\n\nimport { useTranslations } from 'next-intl';\nimport type { ComponentProps } from 'react';\nimport { useState } from 'react';\nimport { useAuth } from '../../../context/auth-provider';\nimport type { AuthErrorContent } from '../../../utils/handle-error';\nimport { handleError } from '../../../utils/handle-error';\n\nimport { AuthPageLayout } from '../auth-page-layout';\nimport { ForgotPassword } from '../forgot-password';\n\ntype ForgotPasswordPageProps = {\n locale?: string;\n onNavigate: (path: string) => void;\n linkComponent?: React.ComponentType<ComponentProps<'a'> & { href: string }>;\n links?: {\n signIn?: string;\n };\n logoImage?: string;\n};\n\nexport const ForgotPasswordPage = ({\n onNavigate,\n linkComponent: Link,\n links,\n logoImage,\n}: ForgotPasswordPageProps) => {\n const t = useTranslations('Auth.forgotPassword');\n const { client } = useAuth();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<AuthErrorContent | null>(null);\n\n const signInLink = links?.signIn || '/auth/sign-in';\n\n const handleSubmit = async (values: { account: string }) => {\n setIsLoading(true);\n setError(null);\n\n try {\n const res = await client.forgotPassword({ identifier: values.account });\n\n if ('verificationId' in res && res.verificationId) {\n onNavigate(`/auth/reset-password?verificationId=${res.verificationId}`);\n } else {\n onNavigate(\n `/auth/reset-password?identifier=${encodeURIComponent(values.account)}`,\n );\n }\n } catch (err) {\n handleError(err, setError, t);\n } finally {\n setIsLoading(false);\n }\n };\n\n const handleBack = () => {\n onNavigate(signInLink);\n };\n\n return (\n <AuthPageLayout\n title={t('title')}\n description={t('description')}\n error={error}\n logoImage={logoImage}\n footer={\n Link ? (\n <Link href={signInLink} className=\"text-primary hover:underline\">\n {t('footer.backToSignIn')}\n </Link>\n ) : (\n <a\n href={signInLink}\n onClick={(e) => {\n e.preventDefault();\n onNavigate(signInLink);\n }}\n className=\"text-primary hover:underline\"\n >\n {t('footer.backToSignIn')}\n </a>\n )\n }\n >\n <ForgotPassword\n onSubmit={handleSubmit}\n isLoading={isLoading}\n onBack={handleBack}\n />\n </AuthPageLayout>\n );\n};\n","'use client';\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport type { AuthClient } from '../client';\nimport type { AuthResponse, Session, User } from '../types';\n\ntype AuthContextValue = {\n user: User | null;\n session: Session | null;\n loading: boolean;\n error: Error | null;\n client: AuthClient;\n refresh: () => Promise<void>;\n setAuth: (data: AuthResponse) => void;\n};\n\nconst AuthContext = createContext<AuthContextValue | null>(null);\n\nexport const useAuth = () => {\n const context = useContext(AuthContext);\n if (!context) {\n throw new Error('useAuth must be used within AuthProvider');\n }\n return context;\n};\n\ntype AuthProviderProps = {\n client: AuthClient;\n children: ReactNode;\n};\n\nexport const AuthProvider = ({ client, children }: AuthProviderProps) => {\n const [user, setUser] = useState<User | null>(null);\n const [session, setSession] = useState<Session | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const refresh = useCallback(async () => {\n try {\n setLoading(true);\n setError(null);\n const data = await client.getSession();\n setUser(data.user);\n setSession(data.session);\n } catch (err) {\n setError(\n err instanceof Error ? err : new Error('Failed to fetch session'),\n );\n setUser(null);\n setSession(null);\n } finally {\n setLoading(false);\n }\n }, [client]);\n\n const setAuth = useCallback((data: AuthResponse) => {\n setUser(data.user);\n setSession(data.session);\n setError(null);\n setLoading(false);\n }, []);\n\n useEffect(() => {\n refresh();\n }, [refresh]);\n\n return (\n <AuthContext.Provider\n value={{\n user,\n session,\n loading,\n error,\n client,\n refresh,\n setAuth,\n }}\n >\n {children}\n </AuthContext.Provider>\n );\n};\n","import type {\n AuthErrorCode,\n AuthErrorResponse,\n AuthResponse,\n PendingAccountChangeResponse,\n SessionResponse,\n User,\n VerificationResponse,\n} from './types';\n\n// Backend returns error code in 'error' field (AUTH_ERRORS values)\n// or in 'code' field, message in 'message' or 'error' field\nconst validErrorCodes: readonly AuthErrorCode[] = [\n 'USER_NOT_FOUND',\n 'INVALID_PASSWORD',\n 'USER_EXISTS',\n 'VERIFICATION_EXPIRED',\n 'VERIFICATION_MISMATCH',\n 'VERIFICATION_NOT_FOUND',\n 'TOO_MANY_ATTEMPTS',\n 'REQUIRES_VERIFICATION',\n 'UNAUTHORIZED',\n 'ACCESS_DENIED',\n 'HAS_NO_PASSWORD',\n] as const;\n\nexport class AuthError extends Error {\n code?: AuthErrorCode;\n status?: number;\n details?: Record<string, unknown>;\n\n constructor(\n message: string,\n code?: AuthErrorCode,\n status?: number,\n details?: Record<string, unknown>,\n ) {\n super(message);\n this.name = 'AuthError';\n this.code = code;\n this.status = status;\n this.details = details;\n }\n}\n\nexport type AuthClientConfig = {\n baseURL: string;\n};\n\nexport class AuthClient {\n private baseURL: string;\n\n constructor(config: AuthClientConfig) {\n this.baseURL = config.baseURL.replace(/\\/$/, '');\n }\n\n private async request<T>(\n endpoint: string,\n options: RequestInit = {},\n ): Promise<T> {\n const url = `${this.baseURL}${endpoint}`;\n const response = await fetch(url, {\n ...options,\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n if (!response.ok) {\n const text = await response.text();\n let errorData: AuthErrorResponse;\n try {\n errorData = JSON.parse(text);\n } catch {\n errorData = { error: 'Unknown error', message: text };\n }\n\n // Extract error code from code, error, or message field\n // Backend returns error codes in 'error' field (e.g., { error: 'INVALID_PASSWORD' })\n const potentialCode =\n errorData.code ||\n (typeof errorData.error === 'string' ? errorData.error : null) ||\n (typeof errorData.message === 'string' ? errorData.message : null);\n const upperCode = potentialCode?.toUpperCase().trim();\n const errorCode =\n upperCode && validErrorCodes.includes(upperCode as AuthErrorCode)\n ? (upperCode as AuthErrorCode)\n : undefined;\n const errorMessage =\n errorData.message || errorData.error || 'Request failed';\n\n throw new AuthError(\n errorMessage,\n errorCode as AuthErrorCode | undefined,\n response.status,\n errorData.details,\n );\n }\n\n const data = await response.json();\n return data;\n }\n\n signUpWithEmail(data: {\n email: string;\n password: string;\n fullName: string;\n handle?: string;\n }): Promise<AuthResponse | VerificationResponse> {\n return this.request<AuthResponse | VerificationResponse>('/sign-up', {\n method: 'POST',\n body: JSON.stringify({\n email: data.email,\n password: data.password,\n fullName: data.fullName,\n handle: data.handle,\n }),\n });\n }\n\n signUpWithPhone(data: {\n phone: string;\n password: string;\n fullName: string;\n handle?: string;\n }): Promise<AuthResponse | VerificationResponse> {\n return this.request<AuthResponse | VerificationResponse>('/sign-up', {\n method: 'POST',\n body: JSON.stringify({\n phone: data.phone,\n password: data.password,\n fullName: data.fullName,\n handle: data.handle,\n }),\n });\n }\n\n checkUser(data: { identifier: string }): Promise<{ exists: boolean }> {\n return this.request<{ exists: boolean }>('/check-user', {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n signInWithPassword(data: {\n identifier: string;\n password: string;\n }): Promise<AuthResponse | VerificationResponse> {\n return this.request<AuthResponse | VerificationResponse>('/sign-in', {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n signOut(): Promise<{ message: string }> {\n return this.request<{ message: string }>('/sign-out', {\n method: 'POST',\n });\n }\n\n requestEmailVerification(data?: {\n email?: string;\n }): Promise<{ verificationId: string }> {\n return this.request<{ verificationId: string }>(\n '/email/verification/request',\n {\n method: 'POST',\n body: JSON.stringify(data || {}),\n },\n );\n }\n\n verifyEmail(data: {\n verificationId: string;\n code: string;\n }): Promise<AuthResponse> {\n return this.request<AuthResponse>('/email/verification/confirm', {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n resendVerification(_verificationId: string): Promise<{\n verificationId: string;\n }> {\n // For email, request new verification\n return this.requestEmailVerification();\n }\n\n requestPhoneOtp(data: {\n phone: string;\n context: 'sign-up' | 'sign-in' | 'change-phone';\n }): Promise<{ verificationId: string }> {\n return this.request<{ verificationId: string }>(\n '/phone/verification/request',\n {\n method: 'POST',\n body: JSON.stringify(data),\n },\n );\n }\n\n verifyPhoneOtp(data: {\n verificationId: string;\n code: string;\n context: 'sign-up' | 'sign-in' | 'change-phone';\n }): Promise<\n AuthResponse | { user: User | null; session: null; verified: boolean }\n > {\n return this.request('/phone/verification/confirm', {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n forgotPassword(data: { identifier: string }): Promise<{\n message: string;\n }> {\n return this.request<{ message: string }>('/password/forgot', {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n resetPassword(data: {\n verificationId: string;\n code: string;\n password: string;\n }): Promise<AuthResponse> {\n return this.request<AuthResponse>('/password/reset', {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n verifyPassword(data: { password: string }): Promise<{ message: string }> {\n return this.request<{ message: string }>('/password/verify', {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n changePassword(data: {\n currentPassword: string;\n newPassword: string;\n }): Promise<{ message: string }> {\n return this.request<{ message: string }>('/password/change', {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n getSession(): Promise<SessionResponse> {\n return this.request<SessionResponse>('/session', {\n method: 'GET',\n });\n }\n\n getPendingAccountChange(): Promise<PendingAccountChangeResponse> {\n return this.request<PendingAccountChangeResponse>(\n '/account-change/pending',\n {\n method: 'GET',\n },\n );\n }\n\n updateProfile(data: { fullName?: string }): Promise<{ user: User }> {\n return this.request<{ user: User }>('/profile', {\n method: 'PUT',\n body: JSON.stringify(data),\n });\n }\n\n updateEmail(data: { email: string }): Promise<{ user: User }> {\n return this.request<{ user: User }>('/profile/email', {\n method: 'PUT',\n body: JSON.stringify(data),\n });\n }\n\n updatePhone(data: { phone: string }): Promise<{ user: User }> {\n return this.request<{ user: User }>('/profile/phone', {\n method: 'PUT',\n body: JSON.stringify(data),\n });\n }\n}\n","export const AUTH_ERROR_MAPPING: Record<\n string,\n { title: string; description: string }\n> = {\n USER_NOT_FOUND: {\n title: 'Account Not Found',\n description:\n 'We could not find an account with that identifier. Please check your spelling or sign up.',\n },\n INVALID_PASSWORD: {\n title: 'Invalid Password',\n description: 'The password you entered is incorrect. Please try again.',\n },\n USER_EXISTS: {\n title: 'Account Already Exists',\n description:\n 'An account with this identifier already exists. Please sign in instead.',\n },\n VERIFICATION_EXPIRED: {\n title: 'Verification Expired',\n description:\n 'The verification code or link has expired. Please request a new one.',\n },\n VERIFICATION_MISMATCH: {\n title: 'Invalid Code',\n description:\n 'The verification code you entered is invalid. Please double-check and try again.',\n },\n VERIFICATION_NOT_FOUND: {\n title: 'Verification Not Found',\n description:\n 'We could not find a pending verification request. Please restart the process.',\n },\n TOO_MANY_ATTEMPTS: {\n title: 'Too Many Attempts',\n description:\n 'You have made too many requests recently. Please wait a moment before trying again.',\n },\n REQUIRES_VERIFICATION: {\n title: 'Verification Required',\n description:\n 'You need to verify your account before you can continue. Please check your email or phone.',\n },\n UNAUTHORIZED: {\n title: 'Unauthorized',\n description:\n 'You are not authorized to perform this action. Please sign in again.',\n },\n ACCESS_DENIED: {\n title: 'Access Denied',\n description:\n 'You do not have permission to access this resource. Please contact support if you believe this is an error.',\n },\n HAS_NO_PASSWORD: {\n title: 'No Password Set',\n description:\n 'Your account does not have a password set (e.g. social login). Please sign in with your provider or reset your password.',\n },\n};\n\nexport const validCodes = Object.keys(AUTH_ERROR_MAPPING);\n","import type { _Translator } from 'next-intl';\nimport { AuthError } from '../client';\nimport { AUTH_ERROR_MAPPING, validCodes } from '../constants/auth.error.codes';\n\nexport type AuthErrorContent = {\n title: string;\n description: string;\n};\n\nexport const handleError = (\n err: any,\n setError: (error: AuthErrorContent | null) => void,\n t: _Translator<Record<string, any>, string>,\n) => {\n if (err instanceof AuthError) {\n let errorCode = '';\n\n if (err.code && validCodes.includes(err.code)) {\n errorCode = err.code;\n } else if (err.message) {\n const messageUpper = err.message.toUpperCase().trim();\n if (validCodes.includes(messageUpper)) {\n errorCode = messageUpper;\n }\n }\n\n if (errorCode && AUTH_ERROR_MAPPING[errorCode]) {\n const mapping = AUTH_ERROR_MAPPING[errorCode];\n // Try to translate the description if a key exists, otherwise use English fallback\n // Since mapping.description is English text, we might want to check if there is a translation key\n // But for now, let's use the provided English mapping or try to find a translation if the key matches 'errors.code'\n\n // We can try to lookup translation, if it returns the key (or fallback), we might prefer the mapping text (which is nice English).\n // However, usually we prefer translation.\n // Let's rely on the mapping text primarily as per the request to \"Generate a description and title...\".\n // But if we want i18n support, we should probably add keys.\n // Given the prompt \"Generate a description... for each error code... and display\",\n // I will prioritize the static mapping I just created, but allows future i18n improvement.\n\n setError({\n title: mapping.title,\n description: mapping.description,\n });\n return;\n }\n\n // Fallback for AuthError without known code\n setError({\n title: t('errors.fallback'), // or 'Error'\n description: err.message || t('errors.fallback'),\n });\n } else {\n // Generic error\n const message = err instanceof Error ? err.message : t('errors.fallback');\n setError({\n title: 'Error',\n description: message,\n });\n }\n};\n","'use client';\n\nimport {\n Alert,\n AlertDescription,\n AlertTitle,\n} from '@mesob/ui/components/alert';\nimport { IconAlertCircle } from '@tabler/icons-react';\nimport type { ReactNode } from 'react';\nimport type { AuthErrorContent } from '../../utils/handle-error';\n\ntype AuthPageLayoutProps = {\n title: string;\n description?: string;\n children: ReactNode;\n error?: AuthErrorContent | string | null;\n footer?: ReactNode;\n logoImage?: string;\n};\n\nexport const AuthPageLayout = ({\n title,\n description,\n children,\n error,\n footer,\n logoImage,\n}: AuthPageLayoutProps) => {\n const errorContent: AuthErrorContent | null = error\n ? // biome-ignore lint/style/noNestedTernary: <explanation>\n typeof error === 'string'\n ? { title: 'Error', description: error }\n : error\n : null;\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex size-8 mb-6 w-full items-center justify-center rounded-md\">\n {/** biome-ignore lint/performance/noImgElement: logo image */}\n <img src={logoImage || ''} alt=\"Jiret\" width={42} height={42} />\n </div>\n <div className=\"text-center\">\n <h1 className=\"text-2xl font-bold tracking-tight\">{title}</h1>\n {description && (\n <p className=\"mt-2 text-sm text-muted-foreground\">{description}</p>\n )}\n </div>\n\n {children}\n\n {errorContent && (\n <Alert variant=\"destructive\">\n <IconAlertCircle className=\"h-4 w-4\" />\n <AlertTitle>{errorContent.title}</AlertTitle>\n <AlertDescription>{errorContent.description}</AlertDescription>\n </Alert>\n )}\n <div className=\"mt-2 w-full\">\n {footer && (\n <div className=\"w-full text-center text-sm text-muted-foreground\">\n {footer}\n </div>\n )}\n </div>\n </div>\n );\n};\n","'use client';\n\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { Button } from '@mesob/ui/components/button';\nimport {\n Form,\n FormControl,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '@mesob/ui/components/form';\nimport { Input } from '@mesob/ui/components/input';\nimport { Spinner } from '@mesob/ui/components/spinner';\nimport { useTranslations } from 'next-intl';\nimport { useMemo } from 'react';\nimport { useForm } from 'react-hook-form';\nimport { z } from 'zod';\n\ntype ForgotPasswordFormValues = {\n account: string;\n};\n\ntype ForgotPasswordProps = {\n onSubmit: (values: ForgotPasswordFormValues) => Promise<void> | void;\n isLoading?: boolean;\n onBack?: () => void;\n};\n\nexport const ForgotPassword = ({\n onSubmit,\n isLoading = false,\n}: ForgotPasswordProps) => {\n const t = useTranslations('Auth.forgotPassword');\n const forgotPasswordSchema = useMemo(\n () =>\n z.object({\n account: z.string().min(1, t('errors.accountRequired')),\n }),\n [t],\n );\n\n const form = useForm<ForgotPasswordFormValues>({\n resolver: zodResolver(forgotPasswordSchema),\n defaultValues: {\n account: '',\n },\n });\n\n const handleSubmit = form.handleSubmit(async (values) => {\n await onSubmit(values);\n });\n\n return (\n <Form {...form}>\n <form onSubmit={handleSubmit} className=\"space-y-5\">\n <FormField\n control={form.control}\n name=\"account\"\n render={({ field }) => (\n <FormItem>\n <FormLabel>{t('form.accountLabel')}</FormLabel>\n <FormControl>\n <Input\n type=\"text\"\n placeholder={t('form.accountPlaceholder')}\n {...field}\n />\n </FormControl>\n <FormMessage />\n </FormItem>\n )}\n />\n <Button type=\"submit\" className=\"w-full\" disabled={isLoading}>\n {isLoading && <Spinner />}\n {isLoading ? t('form.submitting') : t('form.submit')}\n </Button>\n </form>\n </Form>\n );\n};\n"],"mappings":";;;AAEA,SAAS,mBAAAA,wBAAuB;AAEhC,SAAS,YAAAC,iBAAgB;;;ACFzB;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAiEH;AAnDJ,IAAM,cAAc,cAAuC,IAAI;AAExD,IAAM,UAAU,MAAM;AAC3B,QAAM,UAAU,WAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AACA,SAAO;AACT;;;ACLO,IAAM,YAAN,cAAwB,MAAM;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YACE,SACA,MACA,QACA,SACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,UAAU;AAAA,EACjB;AACF;;;AC3CO,IAAM,qBAGT;AAAA,EACF,gBAAgB;AAAA,IACd,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,kBAAkB;AAAA,IAChB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,aAAa;AAAA,IACX,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,sBAAsB;AAAA,IACpB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,uBAAuB;AAAA,IACrB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,wBAAwB;AAAA,IACtB,OAA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AAC,WAAW,YAAY,IAAIC,UAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAIA,UAAkC,IAAI;AAEhE,QAAM,aAAa,OAAO,UAAU;AAEpC,QAAM,eAAe,OAAO,WAAgC;AAC1D,iBAAa,IAAI;AACjB,aAAS,IAAI;AAEb,QAAI;AACF,YAAM,MAAM,MAAM,OAAO,eAAe,EAAE,YAAY,OAAO,QAAQ,CAAC;AAEtE,UAAI,oBAAoB,OAAO,IAAI,gBAAgB;AACjD,mBAAW,uCAAuC,IAAI,cAAc,EAAE;AAAA,MACxE,OAAO;AACL;AAAA,UACE,mCAAmC,mBAAmB,OAAO,OAAO,CAAC;AAAA,QACvE;AAAA,MACF;AAAA,IACF,SAAS,KAAK;AACZ,kBAAY,KAAK,UAAU,CAAC;AAAA,IAC9B,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,aAAa,MAAM;AACvB,eAAW,UAAU;AAAA,EACvB;AAEA,SACE,gBAAAF;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,EAAE,OAAO;AAAA,MAChB,aAAa,EAAE,aAAa;AAAA,MAC5B;AAAA,MACA;AAAA,MACA,QACE,OACE,gBAAAA,KAAC,QAAK,MAAM,YAAY,WAAU,gCAC/B,YAAE,qBAAqB,GAC1B,IAEA,gBAAAA;AAAA,QAAC;AAAA;AAAA,UACC,MAAM;AAAA,UACN,SAAS,CAAC,MAAM;AACd,cAAE,eAAe;AACjB,uBAAW,UAAU;AAAA,UACvB;AAAA,UACA,WAAU;AAAA,UAET,YAAE,qBAAqB;AAAA;AAAA,MAC1B;AAAA,MAIJ,0BAAAA;AAAA,QAAC;AAAA;AAAA,UACC,UAAU;AAAA,UACV;AAAA,UACA,QAAQ;AAAA;AAAA,MACV;AAAA;AAAA,EACF;AAEJ;","names":["useTranslations","useState","jsx","jsx","jsxs","jsx","useTranslations","useState"]}
@@ -13,7 +13,8 @@ type ResetPasswordPageProps = {
13
13
  forgotPassword?: string;
14
14
  };
15
15
  logoImage?: string;
16
+ redirectUrl?: string;
16
17
  };
17
- declare const ResetPasswordPage: ({ verificationId, onNavigate, linkComponent: Link, links, logoImage, }: ResetPasswordPageProps) => react_jsx_runtime.JSX.Element;
18
+ declare const ResetPasswordPage: ({ verificationId, onNavigate, linkComponent: Link, links, logoImage, redirectUrl, }: ResetPasswordPageProps) => react_jsx_runtime.JSX.Element;
18
19
 
19
20
  export { ResetPasswordPage };