@0xchain/header 1.1.0-beta.9 → 1.1.0-beta.90

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.
@@ -1,56 +1,64 @@
1
1
  'use client';
2
- import { jsxs as r, jsx as e } from "react/jsx-runtime";
3
- import { useLocale as h, useTranslations as d } from "next-intl";
4
- import { useSearchParams as p, usePathname as x } from "next/navigation";
5
- import { Accordion as b, AccordionItem as w, AccordionTrigger as y, AccordionContent as N } from "@0xchain/ui/accordion";
6
- import { twMerge as j } from "tailwind-merge";
7
- import { useCallback as v } from "react";
8
- import k from "@0xchain/link";
9
- import $ from "@0xchain/theme-toggle";
10
- function U({ onClick: f = () => {
11
- } }) {
12
- var i;
13
- const a = h(), l = p(), t = d("lang"), s = d("setting"), o = [
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import { useLocale, useTranslations } from "@0xchain/i18n/react";
4
+ import { useSearchParams, usePathname } from "next/navigation";
5
+ import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "@0xchain/ui/accordion";
6
+ import { twMerge } from "tailwind-merge";
7
+ import { useCallback } from "react";
8
+ import LinkBar from "@0xchain/link";
9
+ import ThemeToggle from "@0xchain/theme-toggle";
10
+ function SettingBody({ onClick = () => void 0 }) {
11
+ const locale = useLocale();
12
+ const params = useSearchParams();
13
+ const t = useTranslations("lang");
14
+ const tSetting = useTranslations("setting");
15
+ const supportedLanguages = [
14
16
  { name: t("en"), lang: "en" },
15
17
  { name: t("ja"), lang: "ja" },
16
18
  { name: t("ko"), lang: "ko" },
17
19
  { name: t("zh-hant"), lang: "zh-hant" },
18
20
  { name: t("zh-hans"), lang: "zh-hans" }
19
- ], c = x(), u = v(
20
- (n) => {
21
- const m = c.replace(new RegExp(`/${a}(/|$)`), `/${n}$1`), g = l.toString();
22
- return g ? `${m}?${g}` : m;
21
+ ];
22
+ const pathname = usePathname();
23
+ const generateLanguageUrl = useCallback(
24
+ (newLang) => {
25
+ const newUrl = pathname.replace(new RegExp(`/${locale}(/|$)`), `/${newLang}$1`);
26
+ const search = params.toString();
27
+ if (search) {
28
+ return `${newUrl}?${search}`;
29
+ }
30
+ return newUrl;
23
31
  },
24
- [c, a, l]
32
+ [pathname, locale, params]
25
33
  );
26
- return /* @__PURE__ */ r("div", { className: "text-sm gap-2 flex flex-col justify-start items-start md:py-2", children: [
27
- /* @__PURE__ */ e("div", { className: "flex w-full justify-between items-center", children: /* @__PURE__ */ e(b, { type: "single", className: "flex-1", collapsible: !0, children: /* @__PURE__ */ r(w, { value: a, className: "border-0", children: [
28
- /* @__PURE__ */ e(y, { className: "p-2 bg-background rounded-lg h-11 md:h-auto text-gray-500 w-full flex py-2 justify-between items-center hover:no-underline focus-visible:ring-0 focus-visible:ring-offset-0", children: /* @__PURE__ */ r("div", { className: "flex w-full justify-between items-center", children: [
29
- /* @__PURE__ */ e("span", { className: "text-foreground", children: s("language") }),
30
- /* @__PURE__ */ e("span", { className: "text-foreground", children: (i = o.find((n) => n.lang === a)) == null ? void 0 : i.name })
34
+ return /* @__PURE__ */ jsxs("div", { className: "text-sm gap-2 flex flex-col justify-start items-start md:py-2", children: [
35
+ /* @__PURE__ */ jsx("div", { className: "flex w-full justify-between items-center", children: /* @__PURE__ */ jsx(Accordion, { type: "single", className: "flex-1", collapsible: true, children: /* @__PURE__ */ jsxs(AccordionItem, { value: locale, className: "border-0", children: [
36
+ /* @__PURE__ */ jsx(AccordionTrigger, { className: "p-2 bg-background rounded-lg h-11 md:h-auto text-gray-500 w-full flex py-2 justify-between items-center hover:no-underline focus-visible:ring-0 focus-visible:ring-offset-0", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full justify-between items-center", children: [
37
+ /* @__PURE__ */ jsx("span", { className: "text-foreground", children: tSetting("language") }),
38
+ /* @__PURE__ */ jsx("span", { className: "text-foreground", children: supportedLanguages.find((item) => item.lang === locale)?.name })
31
39
  ] }) }),
32
- /* @__PURE__ */ e(N, { className: "bg-background mt-3 rounded-lg flex flex-col gap-2", children: o.map((n) => /* @__PURE__ */ e(
33
- k,
40
+ /* @__PURE__ */ jsx(AccordionContent, { className: "bg-background mt-3 rounded-lg flex flex-col gap-2", children: supportedLanguages.map((item) => /* @__PURE__ */ jsx(
41
+ LinkBar,
34
42
  {
35
- prefetch: !1,
36
- withLocale: !1,
37
- className: j(
43
+ prefetch: false,
44
+ withLocale: false,
45
+ className: twMerge(
38
46
  "p-2 rounded-lg flex w-full justify-between items-center",
39
- a === n.lang ? "text-primary" : ""
47
+ locale === item.lang ? "text-primary" : ""
40
48
  ),
41
- href: u(n.lang),
42
- onClick: f,
43
- children: n.name
49
+ href: generateLanguageUrl(item.lang),
50
+ onClick,
51
+ children: item.name
44
52
  },
45
- n.lang
53
+ item.lang
46
54
  )) })
47
55
  ] }) }) }),
48
- /* @__PURE__ */ r("div", { className: "bg-background p-2 rounded-lg h-11 md:h-auto flex w-full justify-between items-center", children: [
49
- /* @__PURE__ */ e("div", { children: s("theme") }),
50
- /* @__PURE__ */ e($, {})
56
+ /* @__PURE__ */ jsxs("div", { className: "bg-background p-2 rounded-lg h-11 md:h-auto flex w-full justify-between items-center", children: [
57
+ /* @__PURE__ */ jsx("div", { children: tSetting("theme") }),
58
+ /* @__PURE__ */ jsx(ThemeToggle, {})
51
59
  ] })
52
60
  ] });
53
61
  }
54
62
  export {
55
- U as default
63
+ SettingBody as default
56
64
  };
@@ -1,45 +1,49 @@
1
1
  'use client';
2
- import { jsxs as o, jsx as e } from "react/jsx-runtime";
3
- import t from "@0xchain/iconfont";
4
- import n from "@0xchain/tooltip";
5
- import r from "./SettingBody.js";
6
- import { useIsChaindigg as c } from "../context.js";
7
- function p({ onClick: d = () => {
8
- } }) {
9
- const i = c(), a = (s) => {
10
- document.querySelectorAll("iframe").forEach((l) => {
11
- l.style.pointerEvents = s ? "none" : "auto";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import IconFont from "@0xchain/iconfont";
4
+ import Tooltip from "@0xchain/tooltip";
5
+ import SettingBody from "./SettingBody.js";
6
+ import { useIsChaindigg } from "../context.js";
7
+ function Setting({ onClick = () => void 0 }) {
8
+ const isChaindigg = useIsChaindigg();
9
+ const onChange = (open) => {
10
+ const iframes = document.querySelectorAll("iframe");
11
+ iframes.forEach((iframe) => {
12
+ iframe.style.pointerEvents = open ? "none" : "auto";
12
13
  });
13
14
  };
14
- return i ? /* @__PURE__ */ o("div", { className: "w-full md:w-auto order-3 md:order-0", children: [
15
- /* @__PURE__ */ e("div", { className: "hidden md:flex items-center bg-card rounded-lg p-1.5 cursor-pointer", children: /* @__PURE__ */ e(
16
- n,
15
+ if (isChaindigg) {
16
+ return /* @__PURE__ */ jsxs("div", { className: "w-full md:w-auto order-3 md:order-0", children: [
17
+ /* @__PURE__ */ jsx("div", { className: "hidden md:flex items-center bg-card rounded-lg p-1.5 cursor-pointer", children: /* @__PURE__ */ jsx(
18
+ Tooltip,
19
+ {
20
+ side: "bottom",
21
+ needClick: true,
22
+ contentClassName: "w-70 rounded-lg bg-card shadow-lg text-foreground border-transparent outline-none",
23
+ trigger: /* @__PURE__ */ jsx(IconFont, { type: "icon-setting", className: "text-2xl border border-transparent hover:border-border" }),
24
+ arrowClassName: "fill-module",
25
+ children: /* @__PURE__ */ jsx(SettingBody, { onClick })
26
+ }
27
+ ) }),
28
+ /* @__PURE__ */ jsx("div", { className: "md:hidden", children: /* @__PURE__ */ jsx(SettingBody, {}) })
29
+ ] });
30
+ }
31
+ return /* @__PURE__ */ jsxs("div", { className: "w-full md:w-auto order-3 md:order-0", children: [
32
+ /* @__PURE__ */ jsx("div", { className: "hidden md:flex items-center bg-card hover:bg-border rounded-lg p-1.5 cursor-pointer", children: /* @__PURE__ */ jsx(
33
+ Tooltip,
17
34
  {
18
35
  side: "bottom",
19
- needClick: !0,
20
- contentClassName: "w-70 rounded-lg bg-card shadow-lg text-foreground border-transparent outline-none",
21
- trigger: /* @__PURE__ */ e(t, { type: "icon-setting", className: "text-2xl border border-transparent hover:border-border" }),
22
- arrowClassName: "fill-module",
23
- children: /* @__PURE__ */ e(r, { onClick: d })
24
- }
25
- ) }),
26
- /* @__PURE__ */ e("div", { className: "md:hidden", children: /* @__PURE__ */ e(r, {}) })
27
- ] }) : /* @__PURE__ */ o("div", { className: "w-full md:w-auto order-3 md:order-0", children: [
28
- /* @__PURE__ */ e("div", { className: "hidden md:flex items-center bg-card hover:bg-border rounded-lg p-1.5 cursor-pointer", children: /* @__PURE__ */ e(
29
- n,
30
- {
31
- side: "bottom",
32
- onChange: a,
33
- needClick: !0,
36
+ onChange,
37
+ needClick: true,
34
38
  contentClassName: "bg-card w-70 rounded-lg bg-card text-foreground border border-border",
35
- trigger: /* @__PURE__ */ e(t, { type: "icon-centersetup", className: "text-2xl" }),
39
+ trigger: /* @__PURE__ */ jsx(IconFont, { type: "icon-centersetup", className: "text-2xl" }),
36
40
  arrowClassName: "fill-card",
37
- children: /* @__PURE__ */ e(r, { onClick: d })
41
+ children: /* @__PURE__ */ jsx(SettingBody, { onClick })
38
42
  }
39
43
  ) }),
40
- /* @__PURE__ */ e("div", { className: "md:hidden", children: /* @__PURE__ */ e(r, {}) })
44
+ /* @__PURE__ */ jsx("div", { className: "md:hidden", children: /* @__PURE__ */ jsx(SettingBody, {}) })
41
45
  ] });
42
46
  }
43
47
  export {
44
- p as default
48
+ Setting as default
45
49
  };
@@ -1,22 +1,22 @@
1
1
  'use client';
2
- import { jsx as o } from "react/jsx-runtime";
3
- import { logout as a } from "@0xchain/auth";
4
- import { useCallback as e } from "react";
5
- import { twMerge as n } from "tailwind-merge";
6
- import l from "@0xchain/translation";
7
- function p({ className: t }) {
8
- const r = e(async () => {
9
- await a();
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { logout } from "@0xchain/auth";
4
+ import { useCallback } from "react";
5
+ import { twMerge } from "tailwind-merge";
6
+ import Translation from "@0xchain/translation";
7
+ function Logout({ className }) {
8
+ const logoutHandler = useCallback(async () => {
9
+ await logout();
10
10
  }, []);
11
- return /* @__PURE__ */ o(
11
+ return /* @__PURE__ */ jsx(
12
12
  "button",
13
13
  {
14
- onClick: r,
15
- className: n("cursor-pointer relative", t),
16
- children: /* @__PURE__ */ o(l, { value: "logout", parentKey: "account" })
14
+ onClick: logoutHandler,
15
+ className: twMerge("cursor-pointer relative", className),
16
+ children: /* @__PURE__ */ jsx(Translation, { value: "logout", parentKey: "account" })
17
17
  }
18
18
  );
19
19
  }
20
20
  export {
21
- p as default
21
+ Logout as default
22
22
  };
@@ -1,34 +1,44 @@
1
1
  'use client';
2
- import { jsx as t } from "react/jsx-runtime";
3
- import { useState as m, useMemo as c, useEffect as p } from "react";
4
- import s from "@0xchain/link";
5
- import l from "@0xchain/translation";
6
- import u from "@0xchain/better-link";
7
- import { useLocale as f } from "next-intl";
8
- import g from "@0xchain/avatar";
9
- function v({
10
- userInfo: r
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useState, useMemo, useEffect } from "react";
4
+ import LinkBar from "@0xchain/link";
5
+ import Translation from "@0xchain/translation";
6
+ import BetterLink from "@0xchain/better-link";
7
+ import { useLocale } from "@0xchain/i18n/react";
8
+ import Avatar from "@0xchain/avatar";
9
+ import { hasProfileIdentity } from "../authProfile.js";
10
+ function MainTrigger({
11
+ userInfo
11
12
  }) {
12
- const { gotoLogin: e } = u(), [i, n] = m(""), o = f(), a = c(() => r == null ? void 0 : r.id, [r]);
13
- return p(() => {
14
- n(e({
15
- locale: o,
13
+ const { gotoLogin } = BetterLink();
14
+ const [link, setLink] = useState("");
15
+ const locale = useLocale();
16
+ const isLogin = useMemo(() => {
17
+ return hasProfileIdentity(userInfo);
18
+ }, [userInfo]);
19
+ useEffect(() => {
20
+ setLink(gotoLogin({
21
+ locale,
16
22
  redirect: window.location.href
17
23
  }));
18
- }, [o, e]), a ? (
19
- // userInfo?.profileUrl
20
- // https://images.ichatgo.ai/user-profile/100000201.png
21
- /* @__PURE__ */ t(g, { userInfo: r, className: "w-8 h-8 cursor-pointer" })
22
- ) : /* @__PURE__ */ t(
23
- s,
24
+ }, [locale, gotoLogin]);
25
+ if (isLogin) {
26
+ return (
27
+ // userInfo?.profileUrl
28
+ // https://images.ichatgo.ai/user-profile/100000201.png
29
+ /* @__PURE__ */ jsx(Avatar, { userInfo, className: "w-8 h-8 cursor-pointer" })
30
+ );
31
+ }
32
+ return /* @__PURE__ */ jsx(
33
+ LinkBar,
24
34
  {
25
- href: i,
35
+ href: link,
26
36
  className: "cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
27
- replace: !0,
28
- children: /* @__PURE__ */ t(l, { value: "signIn", parentKey: "account" })
37
+ replace: true,
38
+ children: /* @__PURE__ */ jsx(Translation, { value: "signIn", parentKey: "account" })
29
39
  }
30
40
  );
31
41
  }
32
42
  export {
33
- v as default
43
+ MainTrigger as default
34
44
  };
@@ -1,41 +1,41 @@
1
1
  'use client';
2
- import { jsx as e, jsxs as r } from "react/jsx-runtime";
3
- import i from "@0xchain/link";
4
- import { Accordion as d, AccordionItem as m, AccordionTrigger as n, AccordionContent as s } from "@0xchain/ui/accordion";
5
- import o from "@0xchain/translation";
6
- import p from "@0xchain/avatar";
7
- function u({
8
- list: c,
9
- userInfo: l,
10
- onClick: t
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import LinkBar from "@0xchain/link";
4
+ import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "@0xchain/ui/accordion";
5
+ import Translation from "@0xchain/translation";
6
+ import Avatar from "@0xchain/avatar";
7
+ function Mobile({
8
+ list,
9
+ userInfo,
10
+ onClick
11
11
  }) {
12
- return /* @__PURE__ */ e(
13
- d,
12
+ return /* @__PURE__ */ jsx(
13
+ Accordion,
14
14
  {
15
15
  type: "single",
16
- collapsible: !0,
16
+ collapsible: true,
17
17
  className: "w-full",
18
18
  defaultValue: "",
19
- children: /* @__PURE__ */ r(m, { value: "item-1", className: "p-0 w-full border border-none", children: [
20
- /* @__PURE__ */ e(n, { className: "w-full bg-background p-3 flex items-center justify-between", children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-3 w-full overflow-hidden", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
21
- /* @__PURE__ */ e(p, { userInfo: l, className: "w-8 h-8 shrink-0" }),
22
- /* @__PURE__ */ r("div", { className: "flex flex-col overflow-hidden", children: [
23
- /* @__PURE__ */ e("div", { className: "text-sm font-medium", children: l == null ? void 0 : l.username }),
24
- /* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground w-full truncate", children: (l == null ? void 0 : l.email) || (l == null ? void 0 : l.walletAddress) })
19
+ children: /* @__PURE__ */ jsxs(AccordionItem, { value: "item-1", className: "p-0 w-full border border-none", children: [
20
+ /* @__PURE__ */ jsx(AccordionTrigger, { className: "w-full bg-background p-3 flex items-center justify-between", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3 w-full overflow-hidden", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
21
+ /* @__PURE__ */ jsx(Avatar, { userInfo, className: "w-8 h-8 shrink-0" }),
22
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col overflow-hidden", children: [
23
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-medium", children: userInfo?.username }),
24
+ /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground w-full truncate", children: userInfo?.email || userInfo?.walletAddress })
25
25
  ] })
26
26
  ] }) }) }),
27
- /* @__PURE__ */ e(s, { className: "flex text-sm flex-col text-balance bg-background rounded-lg p-3 gap-3 mt-[10px]", children: /* @__PURE__ */ e("ul", { children: c.map((a) => /* @__PURE__ */ e(
27
+ /* @__PURE__ */ jsx(AccordionContent, { className: "flex text-sm flex-col text-balance bg-background rounded-lg p-3 gap-3 mt-[10px]", children: /* @__PURE__ */ jsx("ul", { children: list.map((item) => /* @__PURE__ */ jsx(
28
28
  "li",
29
29
  {
30
30
  className: "flex justify-start items-center gap-2 py-2",
31
- children: /* @__PURE__ */ e(i, { href: `/${a.href}`, className: "flex-1 py-2", onClick: t, suppressHydrationWarning: !0, baseUrl: process.env.NEXT_PUBLIC_AUTH_URL, children: /* @__PURE__ */ e(o, { value: a.name, parentKey: "account" }) })
31
+ children: /* @__PURE__ */ jsx(LinkBar, { href: `/${item.href}`, className: "flex-1 py-2", onClick, suppressHydrationWarning: true, baseUrl: process.env.NEXT_PUBLIC_AUTH_URL, children: /* @__PURE__ */ jsx(Translation, { value: item.name, parentKey: "account" }) })
32
32
  },
33
- a.name
33
+ item.name
34
34
  )) }) })
35
35
  ] })
36
36
  }
37
37
  );
38
38
  }
39
39
  export {
40
- u as default
40
+ Mobile as default
41
41
  };
@@ -1,31 +1,33 @@
1
1
  'use client';
2
- import { jsx as l, jsxs as a } from "react/jsx-runtime";
3
- import d from "@0xchain/link";
4
- import c from "@0xchain/translation";
5
- import n from "./MainTrigger.js";
6
- import m from "./Logout.js";
7
- import s from "@0xchain/avatar";
8
- import p from "@0xchain/tooltip";
9
- function y({
10
- list: o,
11
- userInfo: e,
12
- onClick: t
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import LinkBar from "@0xchain/link";
4
+ import Translation from "@0xchain/translation";
5
+ import MainTrigger from "./MainTrigger.js";
6
+ import Logout from "./Logout.js";
7
+ import Avatar from "@0xchain/avatar";
8
+ import Tooltip from "@0xchain/tooltip";
9
+ function PC({
10
+ list,
11
+ userInfo,
12
+ onClick
13
13
  }) {
14
- return /* @__PURE__ */ l(p, { onChange: (r) => {
15
- document.querySelectorAll("iframe").forEach((i) => {
16
- i.style.pointerEvents = r ? "none" : "auto";
14
+ const onChange = (open) => {
15
+ const iframes = document.querySelectorAll("iframe");
16
+ iframes.forEach((iframe) => {
17
+ iframe.style.pointerEvents = open ? "none" : "auto";
17
18
  });
18
- }, trigger: /* @__PURE__ */ l(n, { userInfo: e }), arrowClassName: "fill-card", contentClassName: "text-foreground w-75 p-0 border-transparent outline-none ", children: /* @__PURE__ */ a("div", { className: "flex flex-col gap-2 p-3 bg-card rounded-md", children: [
19
- /* @__PURE__ */ l("div", { className: "flex flex-col gap-3 w-full bg-background rounded-lg p-2", children: /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
20
- /* @__PURE__ */ l(s, { userInfo: e, className: "w-8 h-8" }),
21
- /* @__PURE__ */ a("div", { className: "flex flex-col overflow-hidden", children: [
22
- /* @__PURE__ */ l("div", { className: "text-sm font-medium", children: (e == null ? void 0 : e.username) || "--" }),
23
- /* @__PURE__ */ l("div", { className: "text-xs text-muted-foreground w-full truncate", children: (e == null ? void 0 : e.email) || (e == null ? void 0 : e.walletAddress) })
19
+ };
20
+ return /* @__PURE__ */ jsx(Tooltip, { onChange, trigger: /* @__PURE__ */ jsx(MainTrigger, { userInfo }), arrowClassName: "fill-card", contentClassName: "text-foreground w-75 p-0 border-transparent outline-none ", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 p-3 bg-card rounded-md", children: [
21
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3 w-full bg-background rounded-lg p-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
22
+ /* @__PURE__ */ jsx(Avatar, { userInfo, className: "w-8 h-8" }),
23
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col overflow-hidden", children: [
24
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-medium", children: userInfo?.username || "--" }),
25
+ /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground w-full truncate", children: userInfo?.email || userInfo?.walletAddress })
24
26
  ] })
25
27
  ] }) }),
26
- o.map((r) => /* @__PURE__ */ l("div", { className: "px-0 py-0 focus-visible:border-none focus-visible:outline-none", children: /* @__PURE__ */ l("div", { className: "flex items-center gap-2 w-full", children: r.name === "logout" ? /* @__PURE__ */ l(m, { className: "flex-1 flex py-3 border-t border-border w-full px-2 hover:bg-background" }) : /* @__PURE__ */ l(d, { href: `/${r.href}`, baseUrl: process.env.NEXT_PUBLIC_AUTH_URL, className: "flex-1 flex py-3 h-full w-full px-2 hover:bg-background hover:text-primary rounded-lg ", onClick: t, children: /* @__PURE__ */ l(c, { value: r.name, parentKey: "account" }) }) }) }, r.name))
28
+ list.map((item) => /* @__PURE__ */ jsx("div", { className: "px-0 py-0 focus-visible:border-none focus-visible:outline-none", children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 w-full", children: item.name === "logout" ? /* @__PURE__ */ jsx(Logout, { className: "flex-1 flex py-3 border-t border-border w-full px-2 hover:bg-background" }) : /* @__PURE__ */ jsx(LinkBar, { href: `/${item.href}`, baseUrl: process.env.NEXT_PUBLIC_AUTH_URL, className: "flex-1 flex py-3 h-full w-full px-2 hover:bg-background hover:text-primary rounded-lg ", onClick, children: /* @__PURE__ */ jsx(Translation, { value: item.name, parentKey: "account" }) }) }) }, item.name))
27
29
  ] }) });
28
30
  }
29
31
  export {
30
- y as default
32
+ PC as default
31
33
  };
@@ -1,25 +1,26 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import o from "@0xchain/translation";
3
- import { twMerge as i } from "tailwind-merge";
4
- import { useLogin as p, OpenLoginType as s } from "@0xchain/with-login";
5
- function g({ onClick: r = () => {
6
- }, className: t }) {
7
- const { openLogin: n } = p();
8
- return /* @__PURE__ */ e(
1
+ import { jsx } from "react/jsx-runtime";
2
+ import Translation from "@0xchain/translation";
3
+ import { twMerge } from "tailwind-merge";
4
+ import { useLogin, OpenLoginType } from "@0xchain/with-login";
5
+ function SignIn({ onClick = () => void 0, className }) {
6
+ const { openLogin } = useLogin();
7
+ const handleClick = () => {
8
+ onClick?.();
9
+ openLogin(OpenLoginType.LOGIN);
10
+ };
11
+ return /* @__PURE__ */ jsx(
9
12
  "div",
10
13
  {
11
- onClick: () => {
12
- r == null || r(), n(s.LOGIN);
13
- },
14
+ onClick: handleClick,
14
15
  style: { cursor: "pointer" },
15
- className: i(
16
+ className: twMerge(
16
17
  "cursor-pointer text-sm text-white! bg-primary! py-2 px-3 rounded-lg",
17
- t
18
+ className
18
19
  ),
19
- children: /* @__PURE__ */ e(o, { value: "signIn", parentKey: "account" })
20
+ children: /* @__PURE__ */ jsx(Translation, { value: "signIn", parentKey: "account" })
20
21
  }
21
22
  );
22
23
  }
23
24
  export {
24
- g as default
25
+ SignIn as default
25
26
  };
@@ -1,41 +1,52 @@
1
1
  'use client';
2
- import { jsx as r, jsxs as n, Fragment as o } from "react/jsx-runtime";
3
- import a from "./Pc.js";
4
- import c from "./Mobile.js";
5
- import { twMerge as i } from "tailwind-merge";
6
- import s from "./SignIn.js";
7
- const d = [
2
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
+ import PC from "./Pc.js";
4
+ import Mobile from "./Mobile.js";
5
+ import { twMerge } from "tailwind-merge";
6
+ import SignIn from "./SignIn.js";
7
+ import { hasProfileIdentity } from "../authProfile.js";
8
+ const list = [
8
9
  {
9
10
  name: "overview",
10
- href: "user-center"
11
+ href: `user-center`
12
+ },
13
+ {
14
+ name: "points",
15
+ href: `user-center/points`
11
16
  },
12
17
  {
13
18
  name: "collect",
14
- href: "user-center/collect"
19
+ href: `user-center/collect`
15
20
  },
16
21
  {
17
22
  name: "privateLabel",
18
- href: "user-center/private-label"
23
+ href: `user-center/private-label`
24
+ },
25
+ {
26
+ name: "monitor",
27
+ href: `user-center/monitor`
19
28
  },
20
29
  {
21
30
  name: "setting",
22
- href: "user-center/setting"
31
+ href: `user-center/setting`
23
32
  },
24
33
  {
25
34
  name: "logout",
26
35
  href: void 0
27
36
  }
28
37
  ];
29
- function x({ onClick: t = (l) => {
30
- }, className: m, userInfo: e }) {
31
- return e != null && e.id ? /* @__PURE__ */ n(o, { children: [
32
- /* @__PURE__ */ r("div", { className: i("hidden md:flex items-center", m), children: /* @__PURE__ */ r(a, { list: d, userInfo: e, onClick: t }) }),
33
- /* @__PURE__ */ r("div", { className: i("block md:hidden w-full", m), children: /* @__PURE__ */ r(c, { list: d.filter((l) => l.href), userInfo: e, onClick: t }) })
34
- ] }) : /* @__PURE__ */ r(s, { onClick: t, className: i(
35
- "hidden md:flex cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
36
- "order-3"
37
- ) });
38
+ function UserControl({ onClick = (e) => void 0, className, userInfo }) {
39
+ if (!hasProfileIdentity(userInfo)) {
40
+ return /* @__PURE__ */ jsx(SignIn, { onClick, className: twMerge(
41
+ "hidden md:flex cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
42
+ "order-3"
43
+ ) });
44
+ }
45
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
46
+ /* @__PURE__ */ jsx("div", { className: twMerge("hidden md:flex items-center", className), children: /* @__PURE__ */ jsx(PC, { list, userInfo, onClick }) }),
47
+ /* @__PURE__ */ jsx("div", { className: twMerge("block md:hidden w-full", className), children: /* @__PURE__ */ jsx(Mobile, { list: list.filter((item) => item.href), userInfo, onClick }) })
48
+ ] });
38
49
  }
39
50
  export {
40
- x as default
51
+ UserControl as default
41
52
  };
@@ -0,0 +1,34 @@
1
+ function hasProfileIdentity(userInfo) {
2
+ return Boolean(userInfo?.id || userInfo?.userId);
3
+ }
4
+ function getProfileUrls() {
5
+ const urls = ["/api/auth/profile"];
6
+ const appUrl = (process.env.NEXT_PUBLIC_APP_URL || "").replace(/\/$/, "");
7
+ if (appUrl) {
8
+ urls.push(`${appUrl}/api/auth/profile`);
9
+ }
10
+ return Array.from(new Set(urls));
11
+ }
12
+ async function fetchHeaderProfile(fetcher = fetch) {
13
+ let lastError = null;
14
+ for (const profileUrl of getProfileUrls()) {
15
+ try {
16
+ const response = await fetcher(profileUrl, {
17
+ credentials: "include",
18
+ cache: "no-store"
19
+ });
20
+ if (!response.ok) {
21
+ throw new Error(`Failed to load profile: ${response.status}`);
22
+ }
23
+ return await response.json();
24
+ } catch (error) {
25
+ lastError = error;
26
+ }
27
+ }
28
+ throw lastError instanceof Error ? lastError : new Error("Failed to load profile");
29
+ }
30
+ export {
31
+ fetchHeaderProfile,
32
+ getProfileUrls,
33
+ hasProfileIdentity
34
+ };
@@ -1,24 +1,24 @@
1
1
  'use client';
2
- import { jsx as n } from "react/jsx-runtime";
3
- import { createContext as o, useContext as i } from "react";
4
- const t = o({
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext } from "react";
4
+ const HeaderContext = createContext({
5
5
  brand: "iChatGo"
6
6
  });
7
- function C({
8
- children: e,
9
- brand: r = "iChatGo"
7
+ function HeaderProvider({
8
+ children,
9
+ brand = "iChatGo"
10
10
  }) {
11
- return /* @__PURE__ */ n(t.Provider, { value: { brand: r }, children: e });
11
+ return /* @__PURE__ */ jsx(HeaderContext.Provider, { value: { brand }, children });
12
12
  }
13
- function a() {
14
- return i(t);
13
+ function useHeaderContext() {
14
+ return useContext(HeaderContext);
15
15
  }
16
- function s() {
17
- const { brand: e } = a();
18
- return e === "CHAINDIGG";
16
+ function useIsChaindigg() {
17
+ const { brand } = useHeaderContext();
18
+ return brand === "CHAINDIGG";
19
19
  }
20
20
  export {
21
- C as HeaderProvider,
22
- a as useHeaderContext,
23
- s as useIsChaindigg
21
+ HeaderProvider,
22
+ useHeaderContext,
23
+ useIsChaindigg
24
24
  };