@greatapps/common 1.1.302 → 1.1.304
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/layouts/NavBar.mjs +40 -21
- package/dist/components/layouts/NavBar.mjs.map +1 -1
- package/dist/modules/whitelabel/services/whitelabel.service.mjs +14 -1
- package/dist/modules/whitelabel/services/whitelabel.service.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/layouts/NavBar.tsx +47 -22
- package/src/modules/whitelabel/services/whitelabel.service.ts +15 -3
|
@@ -5,6 +5,7 @@ import { IconChevronRight } from "@tabler/icons-react";
|
|
|
5
5
|
import { Separator } from "../ui/data-display/Separator";
|
|
6
6
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/overlay/Tooltip";
|
|
7
7
|
import { useDesktopSidebarStore } from "../../store/useDesktopSidebarStore";
|
|
8
|
+
import { useWhitelabel } from "../../providers/whitelabel.provider";
|
|
8
9
|
import { cn } from "../../infra/utils/clsx";
|
|
9
10
|
function NavBar({
|
|
10
11
|
onLogoClick,
|
|
@@ -16,6 +17,9 @@ function NavBar({
|
|
|
16
17
|
className
|
|
17
18
|
}) {
|
|
18
19
|
const { isExpanded: isDesktopExpanded, toggle: toggleDesktop } = useDesktopSidebarStore();
|
|
20
|
+
const { whitelabel } = useWhitelabel();
|
|
21
|
+
const isDefaultWl = !whitelabel || whitelabel.id === 1;
|
|
22
|
+
const primaryColor = whitelabel?.general?.primary_color;
|
|
19
23
|
return /* @__PURE__ */ jsxs(
|
|
20
24
|
"div",
|
|
21
25
|
{
|
|
@@ -33,7 +37,7 @@ function NavBar({
|
|
|
33
37
|
className: "cursor-pointer",
|
|
34
38
|
asChild: true,
|
|
35
39
|
onClick: onLogoClick,
|
|
36
|
-
children: /* @__PURE__ */ jsx(
|
|
40
|
+
children: isDefaultWl ? /* @__PURE__ */ jsx(
|
|
37
41
|
Image,
|
|
38
42
|
{
|
|
39
43
|
src: "/icons/great-icon.svg",
|
|
@@ -41,7 +45,12 @@ function NavBar({
|
|
|
41
45
|
width: 28,
|
|
42
46
|
height: 28
|
|
43
47
|
}
|
|
44
|
-
)
|
|
48
|
+
) : /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", stroke: primaryColor || "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
49
|
+
/* @__PURE__ */ jsx("path", { d: "M4 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" }),
|
|
50
|
+
/* @__PURE__ */ jsx("path", { d: "M14 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" }),
|
|
51
|
+
/* @__PURE__ */ jsx("path", { d: "M4 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" }),
|
|
52
|
+
/* @__PURE__ */ jsx("path", { d: "M14 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" })
|
|
53
|
+
] })
|
|
45
54
|
}
|
|
46
55
|
),
|
|
47
56
|
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: "Great" })
|
|
@@ -50,9 +59,11 @@ function NavBar({
|
|
|
50
59
|
"div",
|
|
51
60
|
{
|
|
52
61
|
className: cn(
|
|
53
|
-
"absolute -left-[22px] top-1/2 -translate-y-1/2 z-10 w-[3px] h-5
|
|
62
|
+
"absolute -left-[22px] top-1/2 -translate-y-1/2 z-10 w-[3px] h-5 rounded-r-xl transition-opacity duration-300",
|
|
63
|
+
isDefaultWl ? "bg-gray-950" : "",
|
|
54
64
|
activeApp === "gapps" ? "opacity-100" : "opacity-0"
|
|
55
|
-
)
|
|
65
|
+
),
|
|
66
|
+
style: !isDefaultWl ? { backgroundColor: primaryColor } : void 0
|
|
56
67
|
}
|
|
57
68
|
)
|
|
58
69
|
] }),
|
|
@@ -83,32 +94,40 @@ function NavBar({
|
|
|
83
94
|
] }),
|
|
84
95
|
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
85
96
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
86
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, onClick: onAppIconClick, children:
|
|
87
|
-
|
|
97
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, onClick: onAppIconClick, children: /* @__PURE__ */ jsx(
|
|
98
|
+
"div",
|
|
88
99
|
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
className: cn(
|
|
101
|
+
"size-10 rounded-lg cursor-pointer flex items-center justify-center border-2 ring-2 transition-colors duration-300",
|
|
102
|
+
activeApp === "gpages" ? isDefaultWl ? "bg-cyan-100 border-white ring-cyan-300" : "border-white" : "hover:bg-gray-100 border-transparent ring-transparent"
|
|
103
|
+
),
|
|
104
|
+
style: activeApp === "gpages" && !isDefaultWl ? { backgroundColor: `${primaryColor}20`, boxShadow: `0 0 0 2px ${primaryColor}` } : void 0,
|
|
105
|
+
children: isDefaultWl ? /* @__PURE__ */ jsx(
|
|
106
|
+
Image,
|
|
107
|
+
{
|
|
108
|
+
src: "/icons/icon-navbar.svg",
|
|
109
|
+
alt: "GreatPages",
|
|
110
|
+
width: 24,
|
|
111
|
+
height: 24
|
|
112
|
+
}
|
|
113
|
+
) : /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: primaryColor || "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
114
|
+
/* @__PURE__ */ jsx("path", { d: "M4 8h16" }),
|
|
115
|
+
/* @__PURE__ */ jsx("path", { d: "M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12" }),
|
|
116
|
+
/* @__PURE__ */ jsx("path", { d: "M8 4v4" })
|
|
117
|
+
] })
|
|
101
118
|
}
|
|
102
|
-
) })
|
|
119
|
+
) }),
|
|
103
120
|
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: "GreatPages" })
|
|
104
121
|
] }),
|
|
105
122
|
/* @__PURE__ */ jsx(
|
|
106
123
|
"div",
|
|
107
124
|
{
|
|
108
125
|
className: cn(
|
|
109
|
-
"absolute -left-4 top-1/2 -translate-y-1/2 z-10 w-[3px] h-5
|
|
126
|
+
"absolute -left-4 top-1/2 -translate-y-1/2 z-10 w-[3px] h-5 rounded-r-xl transition-opacity duration-300",
|
|
127
|
+
isDefaultWl ? "bg-cyan-300" : "",
|
|
110
128
|
activeApp === "gpages" ? "opacity-100" : "opacity-0"
|
|
111
|
-
)
|
|
129
|
+
),
|
|
130
|
+
style: !isDefaultWl ? { backgroundColor: primaryColor } : void 0
|
|
112
131
|
}
|
|
113
132
|
)
|
|
114
133
|
] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/layouts/NavBar.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport Image from \"next/image\";\nimport { IconChevronRight } from \"@tabler/icons-react\";\nimport { Separator } from \"../ui/data-display/Separator\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"../ui/overlay/Tooltip\";\nimport { useDesktopSidebarStore } from \"../../store/useDesktopSidebarStore\";\nimport { cn } from \"../../infra/utils/clsx\";\n\ntype NavBarProps = {\n onLogoClick: () => void;\n onAppIconClick?: () => void;\n activeApp?: \"gapps\" | \"gpages\";\n showExpandButton?: boolean;\n onExpandClick?: () => void;\n children?: React.ReactNode;\n className?: string;\n};\n\nfunction NavBar({\n onLogoClick,\n onAppIconClick,\n activeApp,\n showExpandButton = false,\n onExpandClick,\n children,\n className,\n}: NavBarProps) {\n const { isExpanded: isDesktopExpanded, toggle: toggleDesktop } =
|
|
1
|
+
{"version":3,"sources":["../../../src/components/layouts/NavBar.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport Image from \"next/image\";\nimport { IconChevronRight } from \"@tabler/icons-react\";\nimport { Separator } from \"../ui/data-display/Separator\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"../ui/overlay/Tooltip\";\nimport { useDesktopSidebarStore } from \"../../store/useDesktopSidebarStore\";\nimport { useWhitelabel } from \"../../providers/whitelabel.provider\";\nimport { cn } from \"../../infra/utils/clsx\";\n\ntype NavBarProps = {\n onLogoClick: () => void;\n onAppIconClick?: () => void;\n activeApp?: \"gapps\" | \"gpages\";\n showExpandButton?: boolean;\n onExpandClick?: () => void;\n children?: React.ReactNode;\n className?: string;\n};\n\nfunction NavBar({\n onLogoClick,\n onAppIconClick,\n activeApp,\n showExpandButton = false,\n onExpandClick,\n children,\n className,\n}: NavBarProps) {\n const { isExpanded: isDesktopExpanded, toggle: toggleDesktop } =\n useDesktopSidebarStore();\n const { whitelabel } = useWhitelabel();\n const isDefaultWl = !whitelabel || whitelabel.id === 1;\n const primaryColor = whitelabel?.general?.primary_color;\n\n return (\n <div\n className={cn(\n \"hidden md:flex flex-col justify-between h-screen p-4 border-r border-gray-200 overflow-visible z-40 bg-white\",\n className,\n )}\n >\n <div className=\"flex flex-col gap-4 items-center mt-[6.5px]\">\n {/* GreatApps logo */}\n <div className=\"relative\">\n <Tooltip>\n <TooltipTrigger\n className=\"cursor-pointer\"\n asChild\n onClick={onLogoClick}\n >\n {isDefaultWl ? (\n <Image\n src=\"/icons/great-icon.svg\"\n alt=\"Great Icon\"\n width={28}\n height={28}\n />\n ) : (\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"28\" height=\"28\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={primaryColor || 'currentColor'} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M4 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4\" />\n <path d=\"M14 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4\" />\n <path d=\"M4 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4\" />\n <path d=\"M14 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4\" />\n </svg>\n )}\n </TooltipTrigger>\n <TooltipContent side=\"right\">Great</TooltipContent>\n </Tooltip>\n <div\n className={cn(\n \"absolute -left-[22px] top-1/2 -translate-y-1/2 z-10 w-[3px] h-5 rounded-r-xl transition-opacity duration-300\",\n isDefaultWl ? \"bg-gray-950\" : \"\",\n activeApp === \"gapps\" ? \"opacity-100\" : \"opacity-0\",\n )}\n style={!isDefaultWl ? { backgroundColor: primaryColor } : undefined}\n />\n </div>\n\n <div className=\"relative w-full mt-[7.5px]\">\n <Separator />\n {/* Md expand button */}\n {showExpandButton && (\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n onClick={onExpandClick}\n className=\"absolute top-1/2 -translate-y-1/2 right-0 translate-x-[calc(50%+1rem)] size-8 flex items-center justify-center rounded-full border border-gray-200 bg-white hover:bg-gray-100 cursor-pointer transition-colors z-10\"\n >\n <IconChevronRight size={16} className=\"text-gray-500\" />\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"right\">Expandir menu</TooltipContent>\n </Tooltip>\n )}\n {/* Desktop expand button */}\n {!isDesktopExpanded && (\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n onClick={toggleDesktop}\n className=\"hidden lg:flex absolute top-1/2 -translate-y-1/2 right-0 translate-x-[calc(50%+1rem)] size-8 items-center justify-center rounded-full border border-gray-200 bg-white hover:bg-gray-100 cursor-pointer transition-colors z-10\"\n >\n <IconChevronRight size={16} className=\"text-gray-500\" />\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"right\">Expandir menu</TooltipContent>\n </Tooltip>\n )}\n </div>\n\n {/* GreatPages icon */}\n <div className=\"relative\">\n <Tooltip>\n <TooltipTrigger asChild onClick={onAppIconClick}>\n <div\n className={cn(\n \"size-10 rounded-lg cursor-pointer flex items-center justify-center border-2 ring-2 transition-colors duration-300\",\n activeApp === \"gpages\"\n ? isDefaultWl\n ? \"bg-cyan-100 border-white ring-cyan-300\"\n : \"border-white\"\n : \"hover:bg-gray-100 border-transparent ring-transparent\",\n )}\n style={activeApp === \"gpages\" && !isDefaultWl ? { backgroundColor: `${primaryColor}20`, boxShadow: `0 0 0 2px ${primaryColor}` } : undefined}\n >\n {isDefaultWl ? (\n <Image\n src=\"/icons/icon-navbar.svg\"\n alt=\"GreatPages\"\n width={24}\n height={24}\n />\n ) : (\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={primaryColor || 'currentColor'} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M4 8h16\" />\n <path d=\"M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12\" />\n <path d=\"M8 4v4\" />\n </svg>\n )}\n </div>\n </TooltipTrigger>\n <TooltipContent side=\"right\">GreatPages</TooltipContent>\n </Tooltip>\n <div\n className={cn(\n \"absolute -left-4 top-1/2 -translate-y-1/2 z-10 w-[3px] h-5 rounded-r-xl transition-opacity duration-300\",\n isDefaultWl ? \"bg-cyan-300\" : \"\",\n activeApp === \"gpages\" ? \"opacity-100\" : \"opacity-0\",\n )}\n style={!isDefaultWl ? { backgroundColor: primaryColor } : undefined}\n />\n </div>\n </div>\n\n <div className=\"flex flex-col items-center gap-2\">{children}</div>\n </div>\n );\n}\n\nexport { NavBar };\nexport type { NavBarProps };\n"],"mappings":";AAqDgB,cAOA,YAPA;AAlDhB,OAAO,WAAW;AAClB,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,gBAAgB,sBAAsB;AACxD,SAAS,8BAA8B;AACvC,SAAS,qBAAqB;AAC9B,SAAS,UAAU;AAYnB,SAAS,OAAO;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AACF,GAAgB;AACd,QAAM,EAAE,YAAY,mBAAmB,QAAQ,cAAc,IAC3D,uBAAuB;AACzB,QAAM,EAAE,WAAW,IAAI,cAAc;AACrC,QAAM,cAAc,CAAC,cAAc,WAAW,OAAO;AACrD,QAAM,eAAe,YAAY,SAAS;AAE1C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MAEA;AAAA,6BAAC,SAAI,WAAU,+CAEb;AAAA,+BAAC,SAAI,WAAU,YACb;AAAA,iCAAC,WACC;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,WAAU;AAAA,kBACV,SAAO;AAAA,kBACP,SAAS;AAAA,kBAER,wBACC;AAAA,oBAAC;AAAA;AAAA,sBACC,KAAI;AAAA,sBACJ,KAAI;AAAA,sBACJ,OAAO;AAAA,sBACP,QAAQ;AAAA;AAAA,kBACV,IAEA,qBAAC,SAAI,OAAM,8BAA6B,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,QAAQ,gBAAgB,gBAAgB,aAAY,KAAI,eAAc,SAAQ,gBAAe,SAC1L;AAAA,wCAAC,UAAK,GAAE,gFAA+E;AAAA,oBACvF,oBAAC,UAAK,G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cAAc,EAAE,iBAAiB,GAAG,YAAY,MAAM,WAAW,aAAa,YAAY,GAAG,IAAI;AAAA,kBAElI,wBACC;AAAA,oBAAC;AAAA;AAAA,sBACC,KAAI;AAAA,sBACJ,KAAI;AAAA,sBACJ,OAAO;AAAA,sBACP,QAAQ;AAAA;AAAA,kBACV,IAEA,qBAAC,SAAI,OAAM,8BAA6B,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,QAAQ,gBAAgB,gBAAgB,aAAY,KAAI,eAAc,SAAQ,gBAAe,SAC1L;AAAA,wCAAC,UAAK,GAAE,WAAU;AAAA,oBAClB,oBAAC,UAAK,GAAE,oFAAmF;AAAA,oBAC3F,oBAAC,UAAK,GAAE,UAAS;AAAA,qBACnB;AAAA;AAAA,cAEJ,GACF;AAAA,cACA,oBAAC,kBAAe,MAAK,SAAQ,wBAAU;AAAA,eACzC;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,WAAW;AAAA,kBACT;AAAA,kBACA,cAAc,gBAAgB;AAAA,kBAC9B,cAAc,WAAW,gBAAgB;AAAA,gBAC3C;AAAA,gBACA,OAAO,CAAC,cAAc,EAAE,iBAAiB,aAAa,IAAI;AAAA;AAAA,YAC5D;AAAA,aACF;AAAA,WACF;AAAA,QAEA,oBAAC,SAAI,WAAU,oCAAoC,UAAS;AAAA;AAAA;AAAA,EAC9D;AAEJ;","names":[]}
|
|
@@ -64,9 +64,17 @@ class WhitelabelService {
|
|
|
64
64
|
}
|
|
65
65
|
async getTokenByDomain(hostname) {
|
|
66
66
|
hostname = `${normalizeHostname(process.env.WHITELABEL_DOMAIN || hostname)}`;
|
|
67
|
+
console.debug("[WhitelabelService] Getting token for domain", {
|
|
68
|
+
hostname,
|
|
69
|
+
byEnv: process.env.WHITELABEL_DOMAIN
|
|
70
|
+
});
|
|
67
71
|
const cache = this.createCache();
|
|
68
72
|
const cacheKey = this.getCacheKey(hostname);
|
|
69
73
|
const cachedData = await cache.select(cacheKey);
|
|
74
|
+
console.debug("[WhitelabelService] Cache lookup for domain", {
|
|
75
|
+
cacheKey,
|
|
76
|
+
cachedData
|
|
77
|
+
});
|
|
70
78
|
if (cachedData.status == 1 && "data" in cachedData && cachedData.data) {
|
|
71
79
|
console.log("[WhitelabelService] Cache hit for domain", { hostname });
|
|
72
80
|
return JSON.parse(cachedData.data);
|
|
@@ -112,10 +120,15 @@ class WhitelabelService {
|
|
|
112
120
|
}
|
|
113
121
|
async revalidateByDomain(hostname) {
|
|
114
122
|
hostname = `${normalizeHostname(process.env.WHITELABEL_DOMAIN || hostname)}`;
|
|
123
|
+
console.debug("[WhitelabelService] Getting token for domain", {
|
|
124
|
+
hostname,
|
|
125
|
+
byEnv: process.env.WHITELABEL_DOMAIN
|
|
126
|
+
});
|
|
115
127
|
const cache = this.createCache();
|
|
116
128
|
const cacheKey = this.getCacheKey(hostname);
|
|
117
129
|
console.log("[WhitelabelService] Revalidating cache for domain", {
|
|
118
|
-
hostname
|
|
130
|
+
hostname,
|
|
131
|
+
cacheKey
|
|
119
132
|
});
|
|
120
133
|
await cache.delete(cacheKey);
|
|
121
134
|
const data = await this.fetchFromApi(hostname);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/whitelabel/services/whitelabel.service.ts"],"sourcesContent":["import greatCache from \"@greatapps/cache\";\r\nimport { ApiError } from \"../../../infra/api/types\";\r\nimport { WhitelabelTokenApiResponse, WhitelabelTokenData } from \"../schema\";\r\nimport { normalizeHostname } from \"../utils/normalize-hostname\";\r\n\r\nclass WhitelabelService {\r\n private getApiUrl(): string {\r\n const apiUrl = process.env.GAPPS_R3_API_URL;\r\n if (!apiUrl) {\r\n throw new ApiError(\r\n \"GAPPS_R3_API_URL not configured\",\r\n \"CONFIG_ERROR\",\r\n 500,\r\n );\r\n }\r\n return apiUrl;\r\n }\r\n\r\n private getToken(): string {\r\n const token = process.env.WHITELABEL_TOKEN_MASTER;\r\n if (!token) {\r\n throw new ApiError(\r\n \"WHITELABEL_TOKEN_MASTER not configured\",\r\n \"CONFIG_ERROR\",\r\n 500,\r\n );\r\n }\r\n return token;\r\n }\r\n\r\n private createCache() {\r\n return new greatCache({\r\n service: \"whitelabel-service\",\r\n version: \"1.0\",\r\n domain: \"whitelabel-cache.greatapps.com.br\",\r\n ambient: process.env.NODE_ENV || \"development\",\r\n });\r\n }\r\n\r\n private getCacheKey(hostname: string): string {\r\n return `whitelabel-token-${hostname}`;\r\n }\r\n\r\n private async fetchFromApi(hostname: string): Promise<WhitelabelTokenData> {\r\n const apiUrl = this.getApiUrl();\r\n const whitelabelMasterToken = this.getToken();\r\n const url = `${apiUrl}/v1/pt-br/1/whitelabel/${hostname}/token`;\r\n\r\n console.log(\"[WhitelabelService] Fetching token for domain\", { url });\r\n\r\n const response = await fetch(url, {\r\n method: \"GET\",\r\n headers: {\r\n authorization: whitelabelMasterToken,\r\n },\r\n });\r\n\r\n if (!response.ok) {\r\n console.error(\"[WhitelabelService] Failed to fetch whitelabel token\", {\r\n response,\r\n });\r\n throw new ApiError(\r\n `Failed to fetch whitelabel token: ${response.status}`,\r\n \"FETCH_ERROR\",\r\n response.status,\r\n );\r\n }\r\n\r\n const result: WhitelabelTokenApiResponse = await response.json();\r\n\r\n if (result.status !== 1 || !result.data?.length) {\r\n throw new ApiError(\"Whitelabel token not found\", \"TOKEN_NOT_FOUND\", 404);\r\n }\r\n\r\n return result.data[0];\r\n }\r\n\r\n async getTokenByDomain(hostname: string): Promise<WhitelabelTokenData> {\r\n hostname = `${normalizeHostname(process.env.WHITELABEL_DOMAIN || hostname)}`;\r\n\r\n const cache = this.createCache();\r\n const cacheKey = this.getCacheKey(hostname);\r\n\r\n const cachedData = await cache.select(cacheKey);\r\n\r\n if (cachedData.status == 1 && \"data\" in cachedData && cachedData.data) {\r\n console.log(\"[WhitelabelService] Cache hit for domain\", { hostname });\r\n return JSON.parse(cachedData.data) as WhitelabelTokenData;\r\n }\r\n\r\n const data = await this.fetchFromApi(hostname);\r\n\r\n await cache.insert(cacheKey, JSON.stringify(data), 604800);\r\n\r\n return data;\r\n }\r\n\r\n async getTokenByWhitelabelId(idWl: number): Promise<string> {\r\n const apiUrl = this.getApiUrl();\r\n const masterToken = this.getToken();\r\n const url = `${apiUrl}/v1/pt-br/${idWl}/tokens?limit=1&page=1&sort=id:desc`;\r\n console.debug(\"[WhitelabelService] Fetching token by whitelabel ID\", {\r\n url,\r\n config: {\r\n method: \"GET\",\r\n headers: { authorization: masterToken },\r\n },\r\n });\r\n\r\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/whitelabel/services/whitelabel.service.ts"],"sourcesContent":["import greatCache from \"@greatapps/cache\";\r\nimport { ApiError } from \"../../../infra/api/types\";\r\nimport { WhitelabelTokenApiResponse, WhitelabelTokenData } from \"../schema\";\r\nimport { normalizeHostname } from \"../utils/normalize-hostname\";\r\n\r\nclass WhitelabelService {\r\n private getApiUrl(): string {\r\n const apiUrl = process.env.GAPPS_R3_API_URL;\r\n if (!apiUrl) {\r\n throw new ApiError(\r\n \"GAPPS_R3_API_URL not configured\",\r\n \"CONFIG_ERROR\",\r\n 500,\r\n );\r\n }\r\n return apiUrl;\r\n }\r\n\r\n private getToken(): string {\r\n const token = process.env.WHITELABEL_TOKEN_MASTER;\r\n if (!token) {\r\n throw new ApiError(\r\n \"WHITELABEL_TOKEN_MASTER not configured\",\r\n \"CONFIG_ERROR\",\r\n 500,\r\n );\r\n }\r\n return token;\r\n }\r\n\r\n private createCache() {\r\n return new greatCache({\r\n service: \"whitelabel-service\",\r\n version: \"1.0\",\r\n domain: \"whitelabel-cache.greatapps.com.br\",\r\n ambient: process.env.NODE_ENV || \"development\",\r\n });\r\n }\r\n\r\n private getCacheKey(hostname: string): string {\r\n return `whitelabel-token-${hostname}`;\r\n }\r\n\r\n private async fetchFromApi(hostname: string): Promise<WhitelabelTokenData> {\r\n const apiUrl = this.getApiUrl();\r\n const whitelabelMasterToken = this.getToken();\r\n const url = `${apiUrl}/v1/pt-br/1/whitelabel/${hostname}/token`;\r\n\r\n console.log(\"[WhitelabelService] Fetching token for domain\", { url });\r\n\r\n const response = await fetch(url, {\r\n method: \"GET\",\r\n headers: {\r\n authorization: whitelabelMasterToken,\r\n },\r\n });\r\n\r\n if (!response.ok) {\r\n console.error(\"[WhitelabelService] Failed to fetch whitelabel token\", {\r\n response,\r\n });\r\n throw new ApiError(\r\n `Failed to fetch whitelabel token: ${response.status}`,\r\n \"FETCH_ERROR\",\r\n response.status,\r\n );\r\n }\r\n\r\n const result: WhitelabelTokenApiResponse = await response.json();\r\n\r\n if (result.status !== 1 || !result.data?.length) {\r\n throw new ApiError(\"Whitelabel token not found\", \"TOKEN_NOT_FOUND\", 404);\r\n }\r\n\r\n return result.data[0];\r\n }\r\n\r\n async getTokenByDomain(hostname: string): Promise<WhitelabelTokenData> {\r\n hostname = `${normalizeHostname(process.env.WHITELABEL_DOMAIN || hostname)}`;\r\n console.debug(\"[WhitelabelService] Getting token for domain\", {\r\n hostname,\r\n byEnv: process.env.WHITELABEL_DOMAIN,\r\n });\r\n\r\n const cache = this.createCache();\r\n const cacheKey = this.getCacheKey(hostname);\r\n\r\n const cachedData = await cache.select(cacheKey);\r\n console.debug(\"[WhitelabelService] Cache lookup for domain\", {\r\n cacheKey,\r\n cachedData,\r\n });\r\n\r\n if (cachedData.status == 1 && \"data\" in cachedData && cachedData.data) {\r\n console.log(\"[WhitelabelService] Cache hit for domain\", { hostname });\r\n return JSON.parse(cachedData.data) as WhitelabelTokenData;\r\n }\r\n\r\n const data = await this.fetchFromApi(hostname);\r\n\r\n await cache.insert(cacheKey, JSON.stringify(data), 604800);\r\n\r\n return data;\r\n }\r\n\r\n async getTokenByWhitelabelId(idWl: number): Promise<string> {\r\n const apiUrl = this.getApiUrl();\r\n const masterToken = this.getToken();\r\n const url = `${apiUrl}/v1/pt-br/${idWl}/tokens?limit=1&page=1&sort=id:desc`;\r\n console.debug(\"[WhitelabelService] Fetching token by whitelabel ID\", {\r\n url,\r\n config: {\r\n method: \"GET\",\r\n headers: { authorization: masterToken },\r\n },\r\n });\r\n\r\n const response = await fetch(url, {\r\n method: \"GET\",\r\n headers: { authorization: masterToken },\r\n });\r\n\r\n console.debug(\"[WhitelabelService] Response received for whitelabel ID\", {\r\n response,\r\n });\r\n\r\n if (!response.ok) {\r\n throw new ApiError(\r\n `Failed to fetch whitelabel token: ${response.status}`,\r\n \"WL_TOKEN_NOT_FOUND\",\r\n response.status,\r\n );\r\n }\r\n\r\n const result: WhitelabelTokenApiResponse = await response.json();\r\n\r\n if (result.status !== 1 || !result.data?.length) {\r\n throw new ApiError(\r\n \"Token do whitelabel não encontrado\",\r\n \"WL_TOKEN_NOT_FOUND\",\r\n 404,\r\n );\r\n }\r\n\r\n return result.data[0].token;\r\n }\r\n\r\n async revalidateByDomain(hostname: string): Promise<WhitelabelTokenData> {\r\n hostname = `${normalizeHostname(process.env.WHITELABEL_DOMAIN || hostname)}`;\r\n console.debug(\"[WhitelabelService] Getting token for domain\", {\r\n hostname,\r\n byEnv: process.env.WHITELABEL_DOMAIN,\r\n });\r\n\r\n const cache = this.createCache();\r\n const cacheKey = this.getCacheKey(hostname);\r\n\r\n console.log(\"[WhitelabelService] Revalidating cache for domain\", {\r\n hostname,\r\n cacheKey,\r\n });\r\n \r\n await cache.delete(cacheKey);\r\n\r\n const data = await this.fetchFromApi(hostname);\r\n\r\n await cache.insert(cacheKey, JSON.stringify(data), 604800);\r\n\r\n console.log(\"[WhitelabelService] Cache revalidated for domain\", {\r\n hostname,\r\n });\r\n\r\n return data;\r\n }\r\n}\r\n\r\nexport const whitelabelService = new WhitelabelService();\r\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,SAAS,gBAAgB;AAEzB,SAAS,yBAAyB;AAElC,MAAM,kBAAkB;AAAA,EACd,YAAoB;AAC1B,UAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,QACA;AA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;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,OAAO,KAAK,CAAC,EAAE;AAAA,EACxB;AAAA,EAEA,MAAM,mBAAmB,UAAgD;AACvE,eAAW,GAAG,kBAAkB,QAAQ,IAAI,qBAAqB,QAAQ,CAAC;AAC1E,YAAQ,MAAM,gDAAgD;AAAA,MAC5D;AAAA,MACA,OAAO,QAAQ,IAAI;AAAA,IACrB,CAAC;AAED,UAAM,QAAQ,KAAK,YAAY;AAC/B,UAAM,WAAW,KAAK,YAAY,QAAQ;AAE1C,YAAQ,IAAI,qDAAqD;AAAA,MAC/D;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,MAAM,OAAO,QAAQ;AAE3B,UAAM,OAAO,MAAM,KAAK,aAAa,QAAQ;AAE7C,UAAM,MAAM,OAAO,UAAU,KAAK,UAAU,IAAI,GAAG,MAAM;AAEzD,YAAQ,IAAI,oDAAoD;AAAA,MAC9D;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;AAEO,MAAM,oBAAoB,IAAI,kBAAkB;","names":[]}
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import { IconChevronRight } from "@tabler/icons-react";
|
|
|
6
6
|
import { Separator } from "../ui/data-display/Separator";
|
|
7
7
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/overlay/Tooltip";
|
|
8
8
|
import { useDesktopSidebarStore } from "../../store/useDesktopSidebarStore";
|
|
9
|
+
import { useWhitelabel } from "../../providers/whitelabel.provider";
|
|
9
10
|
import { cn } from "../../infra/utils/clsx";
|
|
10
11
|
|
|
11
12
|
type NavBarProps = {
|
|
@@ -27,7 +28,11 @@ function NavBar({
|
|
|
27
28
|
children,
|
|
28
29
|
className,
|
|
29
30
|
}: NavBarProps) {
|
|
30
|
-
const { isExpanded: isDesktopExpanded, toggle: toggleDesktop } =
|
|
31
|
+
const { isExpanded: isDesktopExpanded, toggle: toggleDesktop } =
|
|
32
|
+
useDesktopSidebarStore();
|
|
33
|
+
const { whitelabel } = useWhitelabel();
|
|
34
|
+
const isDefaultWl = !whitelabel || whitelabel.id === 1;
|
|
35
|
+
const primaryColor = whitelabel?.general?.primary_color;
|
|
31
36
|
|
|
32
37
|
return (
|
|
33
38
|
<div
|
|
@@ -45,20 +50,31 @@ function NavBar({
|
|
|
45
50
|
asChild
|
|
46
51
|
onClick={onLogoClick}
|
|
47
52
|
>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
{isDefaultWl ? (
|
|
54
|
+
<Image
|
|
55
|
+
src="/icons/great-icon.svg"
|
|
56
|
+
alt="Great Icon"
|
|
57
|
+
width={28}
|
|
58
|
+
height={28}
|
|
59
|
+
/>
|
|
60
|
+
) : (
|
|
61
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke={primaryColor || 'currentColor'} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
62
|
+
<path d="M4 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" />
|
|
63
|
+
<path d="M14 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" />
|
|
64
|
+
<path d="M4 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" />
|
|
65
|
+
<path d="M14 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" />
|
|
66
|
+
</svg>
|
|
67
|
+
)}
|
|
54
68
|
</TooltipTrigger>
|
|
55
69
|
<TooltipContent side="right">Great</TooltipContent>
|
|
56
70
|
</Tooltip>
|
|
57
71
|
<div
|
|
58
72
|
className={cn(
|
|
59
|
-
"absolute -left-[22px] top-1/2 -translate-y-1/2 z-10 w-[3px] h-5
|
|
73
|
+
"absolute -left-[22px] top-1/2 -translate-y-1/2 z-10 w-[3px] h-5 rounded-r-xl transition-opacity duration-300",
|
|
74
|
+
isDefaultWl ? "bg-gray-950" : "",
|
|
60
75
|
activeApp === "gapps" ? "opacity-100" : "opacity-0",
|
|
61
76
|
)}
|
|
77
|
+
style={!isDefaultWl ? { backgroundColor: primaryColor } : undefined}
|
|
62
78
|
/>
|
|
63
79
|
</div>
|
|
64
80
|
|
|
@@ -98,33 +114,42 @@ function NavBar({
|
|
|
98
114
|
<div className="relative">
|
|
99
115
|
<Tooltip>
|
|
100
116
|
<TooltipTrigger asChild onClick={onAppIconClick}>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
<div
|
|
118
|
+
className={cn(
|
|
119
|
+
"size-10 rounded-lg cursor-pointer flex items-center justify-center border-2 ring-2 transition-colors duration-300",
|
|
120
|
+
activeApp === "gpages"
|
|
121
|
+
? isDefaultWl
|
|
122
|
+
? "bg-cyan-100 border-white ring-cyan-300"
|
|
123
|
+
: "border-white"
|
|
124
|
+
: "hover:bg-gray-100 border-transparent ring-transparent",
|
|
125
|
+
)}
|
|
126
|
+
style={activeApp === "gpages" && !isDefaultWl ? { backgroundColor: `${primaryColor}20`, boxShadow: `0 0 0 2px ${primaryColor}` } : undefined}
|
|
127
|
+
>
|
|
128
|
+
{isDefaultWl ? (
|
|
112
129
|
<Image
|
|
113
130
|
src="/icons/icon-navbar.svg"
|
|
114
131
|
alt="GreatPages"
|
|
115
132
|
width={24}
|
|
116
133
|
height={24}
|
|
117
134
|
/>
|
|
118
|
-
|
|
119
|
-
|
|
135
|
+
) : (
|
|
136
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke={primaryColor || 'currentColor'} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
137
|
+
<path d="M4 8h16" />
|
|
138
|
+
<path d="M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12" />
|
|
139
|
+
<path d="M8 4v4" />
|
|
140
|
+
</svg>
|
|
141
|
+
)}
|
|
142
|
+
</div>
|
|
120
143
|
</TooltipTrigger>
|
|
121
144
|
<TooltipContent side="right">GreatPages</TooltipContent>
|
|
122
145
|
</Tooltip>
|
|
123
146
|
<div
|
|
124
147
|
className={cn(
|
|
125
|
-
"absolute -left-4 top-1/2 -translate-y-1/2 z-10 w-[3px] h-5
|
|
148
|
+
"absolute -left-4 top-1/2 -translate-y-1/2 z-10 w-[3px] h-5 rounded-r-xl transition-opacity duration-300",
|
|
149
|
+
isDefaultWl ? "bg-cyan-300" : "",
|
|
126
150
|
activeApp === "gpages" ? "opacity-100" : "opacity-0",
|
|
127
151
|
)}
|
|
152
|
+
style={!isDefaultWl ? { backgroundColor: primaryColor } : undefined}
|
|
128
153
|
/>
|
|
129
154
|
</div>
|
|
130
155
|
</div>
|
|
@@ -77,11 +77,19 @@ class WhitelabelService {
|
|
|
77
77
|
|
|
78
78
|
async getTokenByDomain(hostname: string): Promise<WhitelabelTokenData> {
|
|
79
79
|
hostname = `${normalizeHostname(process.env.WHITELABEL_DOMAIN || hostname)}`;
|
|
80
|
+
console.debug("[WhitelabelService] Getting token for domain", {
|
|
81
|
+
hostname,
|
|
82
|
+
byEnv: process.env.WHITELABEL_DOMAIN,
|
|
83
|
+
});
|
|
80
84
|
|
|
81
85
|
const cache = this.createCache();
|
|
82
86
|
const cacheKey = this.getCacheKey(hostname);
|
|
83
87
|
|
|
84
88
|
const cachedData = await cache.select(cacheKey);
|
|
89
|
+
console.debug("[WhitelabelService] Cache lookup for domain", {
|
|
90
|
+
cacheKey,
|
|
91
|
+
cachedData,
|
|
92
|
+
});
|
|
85
93
|
|
|
86
94
|
if (cachedData.status == 1 && "data" in cachedData && cachedData.data) {
|
|
87
95
|
console.log("[WhitelabelService] Cache hit for domain", { hostname });
|
|
@@ -107,14 +115,13 @@ class WhitelabelService {
|
|
|
107
115
|
},
|
|
108
116
|
});
|
|
109
117
|
|
|
110
|
-
|
|
111
118
|
const response = await fetch(url, {
|
|
112
119
|
method: "GET",
|
|
113
120
|
headers: { authorization: masterToken },
|
|
114
121
|
});
|
|
115
122
|
|
|
116
123
|
console.debug("[WhitelabelService] Response received for whitelabel ID", {
|
|
117
|
-
response
|
|
124
|
+
response,
|
|
118
125
|
});
|
|
119
126
|
|
|
120
127
|
if (!response.ok) {
|
|
@@ -140,14 +147,19 @@ class WhitelabelService {
|
|
|
140
147
|
|
|
141
148
|
async revalidateByDomain(hostname: string): Promise<WhitelabelTokenData> {
|
|
142
149
|
hostname = `${normalizeHostname(process.env.WHITELABEL_DOMAIN || hostname)}`;
|
|
150
|
+
console.debug("[WhitelabelService] Getting token for domain", {
|
|
151
|
+
hostname,
|
|
152
|
+
byEnv: process.env.WHITELABEL_DOMAIN,
|
|
153
|
+
});
|
|
143
154
|
|
|
144
155
|
const cache = this.createCache();
|
|
145
156
|
const cacheKey = this.getCacheKey(hostname);
|
|
146
157
|
|
|
147
158
|
console.log("[WhitelabelService] Revalidating cache for domain", {
|
|
148
159
|
hostname,
|
|
160
|
+
cacheKey,
|
|
149
161
|
});
|
|
150
|
-
|
|
162
|
+
|
|
151
163
|
await cache.delete(cacheKey);
|
|
152
164
|
|
|
153
165
|
const data = await this.fetchFromApi(hostname);
|