ikoncomponents 1.3.5 → 1.3.7
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/ikoncomponents/activity-sheet/index.js +2 -2
- package/dist/ikoncomponents/app-breadcrumb/BreadcrumbProvider.d.ts +2 -0
- package/dist/ikoncomponents/app-breadcrumb/BreadcrumbProvider.js +12 -1
- package/dist/ikoncomponents/main-layout/SidebarNavContext.d.ts +6 -0
- package/dist/ikoncomponents/main-layout/SidebarNavContext.js +12 -0
- package/dist/ikoncomponents/main-layout/app-sidebar.js +3 -3
- package/dist/ikoncomponents/main-layout/header.d.ts +3 -1
- package/dist/ikoncomponents/main-layout/header.js +2 -2
- package/dist/ikoncomponents/main-layout/index.d.ts +2 -1
- package/dist/ikoncomponents/main-layout/index.js +2 -2
- package/dist/ikoncomponents/main-layout/main-sidebar.d.ts +2 -1
- package/dist/ikoncomponents/main-layout/main-sidebar.js +49 -9
- package/dist/ikoncomponents/main-layout/nav-main.d.ts +4 -1
- package/dist/ikoncomponents/main-layout/nav-main.js +6 -4
- package/dist/ikoncomponents/provider-wrapper/index.d.ts +2 -1
- package/dist/ikoncomponents/provider-wrapper/index.js +2 -2
- package/dist/ikoncomponents/tabs/index.d.ts +1 -1
- package/dist/ikoncomponents/tabs/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/shadcn/table.js +1 -1
- package/dist/styles.css +0 -3
- package/dist/utils/token-management/index.d.ts +5 -4
- package/dist/utils/token-management/index.js +10 -10
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { AlignJustify } from "lucide-react";
|
|
4
|
-
import {
|
|
4
|
+
import { CustomTabs } from "../tabs";
|
|
5
5
|
import { NoDataComponent } from "../no-data";
|
|
6
6
|
import { UploadTab } from "../upload-tab";
|
|
7
7
|
import { SheetComponent } from "../sheet";
|
|
@@ -19,5 +19,5 @@ export function ActivitySheet({ activityLogs = [] }) {
|
|
|
19
19
|
tabContent: _jsx(UploadTab, {})
|
|
20
20
|
}
|
|
21
21
|
];
|
|
22
|
-
return (_jsx(SheetComponent, { buttonText: "", buttonIcon: _jsx(AlignJustify, {}), sheetTitle: "", sheetContent: _jsx(
|
|
22
|
+
return (_jsx(SheetComponent, { buttonText: "", buttonIcon: _jsx(AlignJustify, {}), sheetTitle: "", sheetContent: _jsx(CustomTabs, { tabArray: tabArray, tabListClass: '' }), closeButton: true }));
|
|
23
23
|
}
|
|
@@ -8,6 +8,8 @@ interface BreadcrumbContextType {
|
|
|
8
8
|
breadcrumbItems: BreadcrumbItemProps[];
|
|
9
9
|
addBreadcrumb: (item: BreadcrumbItemProps) => void;
|
|
10
10
|
backBreadcrumb: (item: BreadcrumbItemProps) => void;
|
|
11
|
+
addBreadcrumbItems: (items: BreadcrumbItemProps[], isReplace?: boolean) => void;
|
|
12
|
+
clearBreadcrumb: () => void;
|
|
11
13
|
}
|
|
12
14
|
export declare function BreadcrumbProvider({ children }: {
|
|
13
15
|
children: ReactNode;
|
|
@@ -13,6 +13,14 @@ export function BreadcrumbProvider({ children }) {
|
|
|
13
13
|
return [...filterState, item];
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
+
const addBreadcrumbItems = (items, isReplace) => {
|
|
17
|
+
if (isReplace) {
|
|
18
|
+
setBreadcrumbItems(items);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
setBreadcrumbItems((prevItems) => [...prevItems, ...items]);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
16
24
|
// Function to go back in the breadcrumb
|
|
17
25
|
const backBreadcrumb = (item) => {
|
|
18
26
|
setBreadcrumbItems((prevItems) => {
|
|
@@ -20,7 +28,10 @@ export function BreadcrumbProvider({ children }) {
|
|
|
20
28
|
return [...filterState];
|
|
21
29
|
});
|
|
22
30
|
};
|
|
23
|
-
|
|
31
|
+
const clearBreadcrumb = () => {
|
|
32
|
+
setBreadcrumbItems([]);
|
|
33
|
+
};
|
|
34
|
+
return (_jsx(BreadcrumbContext.Provider, { value: { breadcrumbItems, addBreadcrumb, backBreadcrumb, addBreadcrumbItems, clearBreadcrumb }, children: children }));
|
|
24
35
|
}
|
|
25
36
|
// Custom hook to use the BreadcrumbContext
|
|
26
37
|
export function useBreadcrumb() {
|
|
@@ -12,14 +12,20 @@ export interface SidebarNavItem {
|
|
|
12
12
|
isActive?: boolean;
|
|
13
13
|
default?: boolean;
|
|
14
14
|
items?: SidebarNavSubItem[];
|
|
15
|
+
header?: ReactNode;
|
|
16
|
+
footer?: ReactNode;
|
|
15
17
|
}
|
|
16
18
|
export interface SidebarNavContextType {
|
|
17
19
|
navItems: SidebarNavItem[];
|
|
20
|
+
header: ReactNode | null;
|
|
21
|
+
footer: ReactNode | null;
|
|
18
22
|
setNavItems: (items: SidebarNavItem[]) => void;
|
|
19
23
|
addNavItem: (item: SidebarNavItem) => void;
|
|
20
24
|
removeNavItem: (title: string) => void;
|
|
21
25
|
updateNavItem: (title: string, updates: Partial<SidebarNavItem>) => void;
|
|
22
26
|
clearNavItems: () => void;
|
|
27
|
+
setSidebarHeader: (header: ReactNode) => void;
|
|
28
|
+
setSidebarFooter: (footer: ReactNode) => void;
|
|
23
29
|
}
|
|
24
30
|
export declare function SidebarNavProvider({ children }: {
|
|
25
31
|
children: ReactNode;
|
|
@@ -4,6 +4,8 @@ import { createContext, useContext, useState } from 'react';
|
|
|
4
4
|
const SidebarNavContext = createContext(undefined);
|
|
5
5
|
export function SidebarNavProvider({ children }) {
|
|
6
6
|
const [navItems, setNavItems] = useState([]);
|
|
7
|
+
const [header, setHeader] = useState(null);
|
|
8
|
+
const [footer, setFooter] = useState(null);
|
|
7
9
|
const addNavItem = (item) => {
|
|
8
10
|
setNavItems((prevItems) => {
|
|
9
11
|
const exists = prevItems.some((navItem) => navItem.title === item.title);
|
|
@@ -19,16 +21,26 @@ export function SidebarNavProvider({ children }) {
|
|
|
19
21
|
const updateNavItem = (title, updates) => {
|
|
20
22
|
setNavItems((prevItems) => prevItems.map((item) => item.title === title ? Object.assign(Object.assign({}, item), updates) : item));
|
|
21
23
|
};
|
|
24
|
+
const setSidebarHeader = (header) => {
|
|
25
|
+
setHeader(header);
|
|
26
|
+
};
|
|
27
|
+
const setSidebarFooter = (footer) => {
|
|
28
|
+
setFooter(footer);
|
|
29
|
+
};
|
|
22
30
|
const clearNavItems = () => {
|
|
23
31
|
setNavItems([]);
|
|
24
32
|
};
|
|
25
33
|
return (_jsx(SidebarNavContext.Provider, { value: {
|
|
26
34
|
navItems,
|
|
35
|
+
header,
|
|
36
|
+
footer,
|
|
27
37
|
setNavItems,
|
|
28
38
|
addNavItem,
|
|
29
39
|
removeNavItem,
|
|
30
40
|
updateNavItem,
|
|
31
41
|
clearNavItems,
|
|
42
|
+
setSidebarHeader,
|
|
43
|
+
setSidebarFooter,
|
|
32
44
|
}, children: children }));
|
|
33
45
|
}
|
|
34
46
|
export function useSidebarNav() {
|
|
@@ -11,14 +11,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { Sidebar, SidebarContent, SidebarFooter, SidebarRail, } from "../../shadcn/sidebar";
|
|
14
|
+
import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarRail, } from "../../shadcn/sidebar";
|
|
15
15
|
import { NavMain } from "./nav-main";
|
|
16
16
|
import { useSidebarNav } from "./SidebarNavContext";
|
|
17
17
|
export function AppSidebar(_a) {
|
|
18
18
|
var props = __rest(_a, []);
|
|
19
|
-
const { navItems } = useSidebarNav();
|
|
19
|
+
const { navItems, header, footer } = useSidebarNav();
|
|
20
20
|
if (!navItems || navItems.length === 0) {
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
|
-
return (_jsxs(Sidebar, Object.assign({ className: "ml-12", collapsible: "offcanvas" }, props, { children: [_jsx(SidebarContent, { children: _jsx(NavMain, {}) }), _jsx(SidebarFooter, {}), _jsx(SidebarRail, {})] })));
|
|
23
|
+
return (_jsxs(Sidebar, Object.assign({ className: "ml-12", collapsible: "offcanvas" }, props, { children: [header && _jsx(SidebarHeader, { children: header }), _jsx(SidebarContent, { children: _jsx(NavMain, {}) }), footer && _jsx(SidebarFooter, { children: footer }), _jsx(SidebarRail, {})] })));
|
|
24
24
|
}
|
|
@@ -7,9 +7,9 @@ import { Bell, Play } from "lucide-react";
|
|
|
7
7
|
import { IconButtonWithTooltip, IconTextButton } from "../buttons";
|
|
8
8
|
import { useSidebarNav } from "./SidebarNavContext";
|
|
9
9
|
import Link from "next/link";
|
|
10
|
-
export function Header() {
|
|
10
|
+
export function Header({ platformUrl }) {
|
|
11
11
|
const { navItems } = useSidebarNav();
|
|
12
12
|
return (_jsx("header", { className: "ml-12 flex h-12 border-b shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12", children: _jsxs("div", { className: "flex items-center justify-between gap-2 px-4 w-full", children: [_jsxs("div", { className: "flex items-center gap-2", children: [(!navItems || navItems.length === 0) ? _jsx("div", {}) : _jsx(SidebarTrigger, { className: "-ml-1" }), (!navItems || navItems.length === 0) ?
|
|
13
13
|
_jsx("div", {}) :
|
|
14
|
-
_jsx(Separator, { orientation: "vertical", className: "mr-2 data-[orientation=vertical]:h-4" }), _jsx(AppBreadcrumb, {})] }), _jsxs("div", { className: "ml-auto flex gap-4", children: [_jsx(IconButtonWithTooltip, { className: "px-2!", tooltipContent: "Notifications", children: _jsx(Bell, {}) }), _jsx(ThemeToggleBtn, {}), _jsx(Link, { href:
|
|
14
|
+
_jsx(Separator, { orientation: "vertical", className: "mr-2 data-[orientation=vertical]:h-4" }), _jsx(AppBreadcrumb, {})] }), _jsxs("div", { className: "ml-auto flex gap-4", children: [_jsx(IconButtonWithTooltip, { className: "px-2!", tooltipContent: "Notifications", children: _jsx(Bell, {}) }), _jsx(ThemeToggleBtn, {}), _jsx(Link, { href: `${platformUrl}/app-store`, children: _jsxs(IconTextButton, { variant: "default", children: [_jsx(Play, {}), "App Store"] }) })] })] }) }));
|
|
15
15
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
export declare function MainLayout({ children, baseUrl }: {
|
|
2
|
+
export declare function MainLayout({ children, baseUrl, platformUrl }: {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
baseUrl: string;
|
|
5
|
+
platformUrl: string;
|
|
5
6
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,6 +6,6 @@ import { AppSidebar } from './app-sidebar';
|
|
|
6
6
|
import { Header } from './header';
|
|
7
7
|
import { Footer } from './footer';
|
|
8
8
|
import { SidebarNavProvider } from './SidebarNavContext';
|
|
9
|
-
export function MainLayout({ children, baseUrl }) {
|
|
10
|
-
return (_jsxs(_Fragment, { children: [_jsx(MainSidebar, { baseUrl: baseUrl }), _jsx(SidebarProvider, { children: _jsx(DialogProvider, { children: _jsxs(SidebarNavProvider, { children: [_jsx(AppSidebar, {}), _jsxs(SidebarInset, { className: "flex flex-col h-screen", children: [_jsx(Header, {}), _jsx("div", { className: "flex flex-col gap-4 p-4 pt-0 ml-12 grow overflow-auto scrollbar-hidden", children: children }), _jsx(Footer, {})] })] }) }) })] }));
|
|
9
|
+
export function MainLayout({ children, baseUrl, platformUrl }) {
|
|
10
|
+
return (_jsxs(_Fragment, { children: [_jsx(MainSidebar, { baseUrl: baseUrl, platformUrl: platformUrl }), _jsx(SidebarProvider, { children: _jsx(DialogProvider, { children: _jsxs(SidebarNavProvider, { children: [_jsx(AppSidebar, {}), _jsxs(SidebarInset, { className: "flex flex-col h-screen", children: [_jsx(Header, { platformUrl: platformUrl }), _jsx("div", { className: "flex flex-col gap-4 p-4 pt-0 ml-12 grow overflow-auto scrollbar-hidden", children: children }), _jsx(Footer, {})] })] }) }) })] }));
|
|
11
11
|
}
|
|
@@ -49,6 +49,7 @@ export interface DecodedAccessToken {
|
|
|
49
49
|
iat: number;
|
|
50
50
|
exp: number;
|
|
51
51
|
}
|
|
52
|
-
export declare const MainSidebar: ({ baseUrl }: {
|
|
52
|
+
export declare const MainSidebar: ({ baseUrl, platformUrl }: {
|
|
53
53
|
baseUrl: string;
|
|
54
|
+
platformUrl: string;
|
|
54
55
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,7 +12,7 @@ import { redirect } from 'next/navigation';
|
|
|
12
12
|
import Link from 'next/link';
|
|
13
13
|
import { jwtDecode } from "jwt-decode";
|
|
14
14
|
import { Icon } from '../icon';
|
|
15
|
-
export const MainSidebar = ({ baseUrl }) => {
|
|
15
|
+
export const MainSidebar = ({ baseUrl, platformUrl }) => {
|
|
16
16
|
const [user, setUser] = React.useState();
|
|
17
17
|
const [accounts, setAccounts] = React.useState([]);
|
|
18
18
|
const [selectedAccount, setSelectedAccount] = React.useState();
|
|
@@ -34,7 +34,10 @@ export const MainSidebar = ({ baseUrl }) => {
|
|
|
34
34
|
React.useEffect(() => {
|
|
35
35
|
const fetchUser = async () => {
|
|
36
36
|
try {
|
|
37
|
-
const accessToken = await getValidAccessToken(
|
|
37
|
+
const accessToken = await getValidAccessToken(baseUrl, {
|
|
38
|
+
platformUrl: platformUrl,
|
|
39
|
+
isSetToken: true
|
|
40
|
+
});
|
|
38
41
|
const decoded = jwtDecode(accessToken !== null && accessToken !== void 0 ? accessToken : '');
|
|
39
42
|
const response = await axios.get(`${baseUrl}/platform/user/${decoded.sub}`, {
|
|
40
43
|
headers: {
|
|
@@ -49,7 +52,10 @@ export const MainSidebar = ({ baseUrl }) => {
|
|
|
49
52
|
};
|
|
50
53
|
const fetchAccounts = async () => {
|
|
51
54
|
try {
|
|
52
|
-
const accessToken = await getValidAccessToken(
|
|
55
|
+
const accessToken = await getValidAccessToken(baseUrl, {
|
|
56
|
+
platformUrl: platformUrl,
|
|
57
|
+
isSetToken: true
|
|
58
|
+
});
|
|
53
59
|
const response = await axios.get(`${baseUrl}/platform/account/all`, {
|
|
54
60
|
headers: {
|
|
55
61
|
Authorization: `Bearer ${accessToken}`,
|
|
@@ -64,7 +70,10 @@ export const MainSidebar = ({ baseUrl }) => {
|
|
|
64
70
|
};
|
|
65
71
|
const fetchSubscribedSoftwares = async () => {
|
|
66
72
|
try {
|
|
67
|
-
const accessToken = await getValidAccessToken(
|
|
73
|
+
const accessToken = await getValidAccessToken(baseUrl, {
|
|
74
|
+
platformUrl: platformUrl,
|
|
75
|
+
isSetToken: true
|
|
76
|
+
});
|
|
68
77
|
const response = await axios.get(`${baseUrl}/platform/software/accessible/user`, {
|
|
69
78
|
headers: {
|
|
70
79
|
Authorization: `Bearer ${accessToken}`,
|
|
@@ -80,14 +89,45 @@ export const MainSidebar = ({ baseUrl }) => {
|
|
|
80
89
|
fetchSubscribedSoftwares();
|
|
81
90
|
fetchUser();
|
|
82
91
|
}, []);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
const switchAccount = async (accountId, baseUrl) => {
|
|
93
|
+
try {
|
|
94
|
+
const accessToken = await getValidAccessToken(baseUrl, {
|
|
95
|
+
platformUrl: platformUrl,
|
|
96
|
+
isSetToken: true
|
|
97
|
+
});
|
|
98
|
+
const response = await axios.post(`${baseUrl}/platform/auth/switch-account`, {
|
|
99
|
+
targetAccountId: accountId,
|
|
100
|
+
}, {
|
|
101
|
+
headers: {
|
|
102
|
+
Authorization: `Bearer ${accessToken}`,
|
|
103
|
+
},
|
|
104
|
+
withCredentials: true,
|
|
105
|
+
});
|
|
106
|
+
console.log(response);
|
|
107
|
+
return response.data;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
console.error(error);
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return (_jsx(TooltipProvider, { delayDuration: 0, children: _jsxs("aside", { className: "fixed left-0 top-0 z-20 h-screen w-12 border-r border-border bg-sidebar text-sidebar-foreground flex flex-col items-center py-4 ", children: [_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "default", className: "mb-4 h-8 w-8 rounded-lg p-0", disabled: !selectedAccount, children: _jsx("span", { className: "text-base font-medium text-accent-foreground", children: selectedAccount ? getInitials(selectedAccount.accountName) : '...' }) }) }), _jsxs(DropdownMenuContent, { className: "w-55", side: "right", sideOffset: 8, align: "start", children: [_jsx("div", { className: "px-2 py-1.5 text-xs font-semibold text-foreground", children: "Accounts" }), accounts.map((account) => (_jsxs(DropdownMenuItem, { className: "flex items-center justify-between cursor-pointer", onClick: async () => {
|
|
115
|
+
try {
|
|
116
|
+
setSelectedAccount(account);
|
|
117
|
+
console.log(account.accountId);
|
|
118
|
+
const res = await switchAccount(account.accountId, baseUrl); // Pass baseUrl
|
|
119
|
+
console.log(res);
|
|
120
|
+
window.location.reload(); // Reload to apply new account context
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
console.error("Switch account failed", error);
|
|
124
|
+
}
|
|
125
|
+
}, children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "h-6 w-6 rounded bg-primary/10 flex items-center justify-center", children: _jsx("span", { className: "text-xs font-medium text-primary", children: getInitials(account.accountName) }) }), _jsx("span", { className: "text-sm", children: account.accountName })] }), (selectedAccount === null || selectedAccount === void 0 ? void 0 : selectedAccount.accountId) === account.accountId && (_jsx(Check, { className: "h-4 w-4 text-primary" }))] }, account.accountId)))] })] }), _jsx("nav", { className: "flex flex-col gap-1", children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: 'h-8 w-8', children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href: `${platformUrl}/home`, children: [_jsx(Home, { className: "h-8 w-8" }), _jsx("span", { className: "sr-only", children: "Home" })] }) }) }), _jsx(TooltipContent, { side: "right", sideOffset: 5, children: "Home" })] }, "home") }), _jsx("nav", { className: "flex flex-col gap-1 flex-1", children: softwares.map((software) => {
|
|
86
126
|
var _a, _b;
|
|
87
127
|
const hasIcon = Boolean(software.icon && software.icon.trim() !== "");
|
|
88
128
|
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: "h-8 w-8", children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href: (_a = software.url) !== null && _a !== void 0 ? _a : "#", children: [hasIcon ? (_jsx(Icon, { name: toPascalCase((_b = software.icon) !== null && _b !== void 0 ? _b : ''), className: "h-8 w-8" })) : (_jsx(FolderCode, { className: "h-8 w-8" })), _jsx("span", { className: "sr-only", children: software.softwareName })] }) }) }), _jsx(TooltipContent, { side: "right", sideOffset: 5, children: software.softwareName })] }, software.softwareName));
|
|
89
|
-
}) }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: 'h-8 w-8', children: _jsx(Button, { variant: "ghost", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href:
|
|
129
|
+
}) }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: 'h-8 w-8', children: _jsx(Button, { variant: "ghost", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href: `${platformUrl}/settings`, children: [_jsx(Settings, { className: "h-8 w-8" }), _jsx("span", { className: "sr-only", children: "Settings" })] }) }) }), _jsx(TooltipContent, { side: "right", sideOffset: 5, children: "Settings" })] }, "settings"), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-10 w-10", children: _jsx(CircleUserRound, { className: "h-8 w-8" }) }) }), _jsxs(DropdownMenuContent, { className: "w-55 p-0", side: 'right', sideOffset: 8, children: [_jsxs("div", { className: "flex items-start gap-3 p-4 bg-card", children: [_jsx(CircleUserRound, { className: "h-8 w-8" }), _jsxs("div", { className: "flex flex-col gap-0.5 flex-1 min-w-0", children: [_jsx("p", { className: "text-sm font-bold text-foreground blue-dark:text-muted-foreground truncate", children: user === null || user === void 0 ? void 0 : user.userName }), _jsx("p", { className: "text-xs text-muted-foreground truncate", children: user === null || user === void 0 ? void 0 : user.userEmail }), _jsx("p", { className: "text-sm text-muted-foreground font-semibold", children: selectedAccount === null || selectedAccount === void 0 ? void 0 : selectedAccount.accountName })] })] }), _jsx(DropdownMenuSeparator, { className: "my-0" }), _jsxs(DropdownMenuItem, { onClick: async () => {
|
|
90
130
|
await clearAllCookieSession();
|
|
91
|
-
redirect(
|
|
131
|
+
redirect(`${platformUrl}/login.html`);
|
|
92
132
|
}, className: "flex items-center gap-2 px-4 py-3 cursor-pointer focus:bg-destructive dark:focus:bg-destructive blue-dark:focus:bg-destructive", children: [_jsx(LogOut, { className: "h-4 w-4 text-foreground" }), _jsx("span", { children: "Log out" })] })] })] })] }) }));
|
|
93
133
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
import { SidebarNavItem } from "./SidebarNavContext";
|
|
2
3
|
export declare function NavMain(): import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
export declare function RenderSidebarNav({ items }: {
|
|
4
|
+
export declare function RenderSidebarNav({ items, sidebarHeader, sidebarFooter }: {
|
|
4
5
|
items: SidebarNavItem[];
|
|
6
|
+
sidebarHeader?: ReactNode;
|
|
7
|
+
sidebarFooter?: ReactNode;
|
|
5
8
|
}): null;
|
|
6
9
|
export declare function AddSidebarNav({ item }: {
|
|
7
10
|
item: SidebarNavItem;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect } from "react";
|
|
3
|
+
import { useEffect, } from "react";
|
|
4
4
|
import { ChevronRight } from "lucide-react";
|
|
5
5
|
import { SidebarGroup, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem } from "../../shadcn/sidebar";
|
|
6
6
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../../shadcn/collapsible";
|
|
@@ -14,11 +14,13 @@ export function NavMain() {
|
|
|
14
14
|
return (_jsx(SidebarGroup, { children: _jsx(SidebarMenu, { children: navItems.map((item) => item.items && item.items.length > 0 ? (_jsx(Collapsible, { asChild: true, defaultOpen: item.isActive, className: "group/collapsible", children: _jsxs(SidebarMenuItem, { children: [_jsx(CollapsibleTrigger, { asChild: true, children: _jsxs(SidebarMenuButton, { tooltip: item.title, children: [item.icon && _jsx(item.icon, {}), _jsx("span", { children: item.title }), _jsx(ChevronRight, { className: "ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })] }) }), _jsx(CollapsibleContent, { children: _jsx(SidebarMenuSub, { children: item.items.map((subItem) => (_jsx(SidebarMenuSubItem, { children: _jsx(SidebarMenuSubButton, { asChild: true, children: _jsx(Link, { href: subItem.url, children: _jsx("span", { children: subItem.title }) }) }) }, subItem.title))) }) })] }) }, item.title)) : (_jsx(SidebarMenuItem, { children: _jsx(SidebarMenuButton, { asChild: true, tooltip: item.title, children: _jsxs(Link, { href: item.url, className: "flex items-center gap-2 w-full", children: [item.icon && _jsx(item.icon, {}), _jsx("span", { children: item.title })] }) }) }, item.title))) }) }));
|
|
15
15
|
}
|
|
16
16
|
// Helper component to set nav items from pages
|
|
17
|
-
export function RenderSidebarNav({ items }) {
|
|
18
|
-
const { setNavItems } = useSidebarNav();
|
|
17
|
+
export function RenderSidebarNav({ items, sidebarHeader, sidebarFooter }) {
|
|
18
|
+
const { setNavItems, setSidebarHeader, setSidebarFooter } = useSidebarNav();
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
setNavItems(items);
|
|
21
|
-
|
|
21
|
+
setSidebarHeader(sidebarHeader);
|
|
22
|
+
setSidebarFooter(sidebarFooter);
|
|
23
|
+
}, [items, sidebarHeader, sidebarFooter, setNavItems, setSidebarHeader, setSidebarFooter]);
|
|
22
24
|
return null;
|
|
23
25
|
}
|
|
24
26
|
// Helper component to add a single nav item
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare function ProviderWrapper({ children, baseUrl }: {
|
|
2
|
+
export declare function ProviderWrapper({ children, baseUrl, platformUrl }: {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
baseUrl: string;
|
|
5
|
+
platformUrl: string;
|
|
5
6
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,6 +5,6 @@ import { FontProvider } from "../../utils/font-provider";
|
|
|
5
5
|
import { RadiusProvider } from "../../utils/border-radius-provider";
|
|
6
6
|
import { BreadcrumbProvider } from "../app-breadcrumb/BreadcrumbProvider";
|
|
7
7
|
import { MainLayout } from "../main-layout";
|
|
8
|
-
export function ProviderWrapper({ children, baseUrl }) {
|
|
9
|
-
return (_jsx(ThemeProvider, { attribute: "class", defaultTheme: "system", enableSystem: true, children: _jsx(FontProvider, { children: _jsx(RadiusProvider, { children: _jsx(BreadcrumbProvider, { children: _jsx(MainLayout, { baseUrl: baseUrl, children: children }) }) }) }) }));
|
|
8
|
+
export function ProviderWrapper({ children, baseUrl, platformUrl }) {
|
|
9
|
+
return (_jsx(ThemeProvider, { attribute: "class", defaultTheme: "system", enableSystem: true, children: _jsx(FontProvider, { children: _jsx(RadiusProvider, { children: _jsx(BreadcrumbProvider, { children: _jsx(MainLayout, { baseUrl: baseUrl, platformUrl: platformUrl, children: children }) }) }) }) }));
|
|
10
10
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TabProps } from "./type";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function CustomTabs({ children, tabArray, pathName, tabListClass, tabListInnerClass, tabListButtonClass, tabContentClass, headerEndComponent, onTabChange, isSeperatePage, }: TabProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,7 +7,7 @@ import { TextButton } from "../buttons";
|
|
|
7
7
|
import { Card } from "../../shadcn/card";
|
|
8
8
|
import { useEffect, useState } from "react";
|
|
9
9
|
import { useIsMobile } from "../../hooks/use-mobile";
|
|
10
|
-
export function
|
|
10
|
+
export function CustomTabs({ children, tabArray, pathName, tabListClass = "", tabListInnerClass = "", tabListButtonClass = "", tabContentClass = "", headerEndComponent, onTabChange, isSeperatePage = false, }) {
|
|
11
11
|
var _a, _b;
|
|
12
12
|
// const pathName = usePathname();
|
|
13
13
|
const [itemToDisplay, setItemToDisplay] = useState(5);
|
package/dist/index.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export { PhoneInput } from "./ikoncomponents/phone-input";
|
|
|
74
74
|
export { SearchInput } from "./ikoncomponents/search-input";
|
|
75
75
|
export { SheetComponent } from "./ikoncomponents/sheet";
|
|
76
76
|
export { SimpleWidget } from "./ikoncomponents/simple-widget";
|
|
77
|
-
export {
|
|
77
|
+
export { CustomTabs } from "./ikoncomponents/tabs";
|
|
78
78
|
export type { TabArray, TabProps } from "./ikoncomponents/tabs/type";
|
|
79
79
|
export { ThemeToggleBtn } from "./ikoncomponents/theme-toggle-btn";
|
|
80
80
|
export { TitleProgress } from "./ikoncomponents/title-progress";
|
package/dist/index.js
CHANGED
|
@@ -68,7 +68,7 @@ export { PhoneInput } from "./ikoncomponents/phone-input";
|
|
|
68
68
|
export { SearchInput } from "./ikoncomponents/search-input";
|
|
69
69
|
export { SheetComponent } from "./ikoncomponents/sheet";
|
|
70
70
|
export { SimpleWidget } from "./ikoncomponents/simple-widget";
|
|
71
|
-
export {
|
|
71
|
+
export { CustomTabs } from "./ikoncomponents/tabs";
|
|
72
72
|
export { ThemeToggleBtn } from "./ikoncomponents/theme-toggle-btn";
|
|
73
73
|
export { TitleProgress } from "./ikoncomponents/title-progress";
|
|
74
74
|
export { TooltipComponent } from "./ikoncomponents/tooltip";
|
package/dist/shadcn/table.js
CHANGED
|
@@ -14,7 +14,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
import { cn } from "../utils/cn";
|
|
15
15
|
function Table(_a) {
|
|
16
16
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
17
|
-
return (_jsx("div", { "data-slot": "table-container", className: "relative w-full overflow-
|
|
17
|
+
return (_jsx("div", { "data-slot": "table-container", className: "h-full relative w-full overflow-auto", children: _jsx("table", Object.assign({ "data-slot": "table", className: cn("w-full caption-bottom text-sm", className) }, props)) }));
|
|
18
18
|
}
|
|
19
19
|
function TableHeader(_a) {
|
|
20
20
|
var { className } = _a, props = __rest(_a, ["className"]);
|
package/dist/styles.css
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
interface AccessTokenOptionsProps {
|
|
2
2
|
isNotLogOutWhenExpire?: boolean;
|
|
3
|
+
platformUrl?: string;
|
|
3
4
|
isSetToken?: boolean;
|
|
4
5
|
}
|
|
5
|
-
export declare function getValidAccessToken(options?: AccessTokenOptionsProps): Promise<string | null>;
|
|
6
|
-
export declare function refreshAccessToken(refreshToken: string, isSetToken?: boolean): Promise<string | null>;
|
|
7
|
-
export declare function decodeAccessToken(): Promise<import("jwt-decode").JwtPayload | null>;
|
|
8
|
-
export declare function logOut(): Promise<void>;
|
|
6
|
+
export declare function getValidAccessToken(baseUrl: string, options?: AccessTokenOptionsProps): Promise<string | null>;
|
|
7
|
+
export declare function refreshAccessToken(refreshToken: string, baseUrl: string, isSetToken?: boolean): Promise<string | null>;
|
|
8
|
+
export declare function decodeAccessToken(baseUrl: string): Promise<import("jwt-decode").JwtPayload | null>;
|
|
9
|
+
export declare function logOut(platformUrl: string): Promise<void>;
|
|
9
10
|
export {};
|
|
@@ -4,7 +4,7 @@ import { clearAllCookieSession, getCookieSession, setCookieSession, } from "../s
|
|
|
4
4
|
import { jwtDecode } from "jwt-decode";
|
|
5
5
|
// Prevent multiple refresh calls at once
|
|
6
6
|
let refreshPromise = null;
|
|
7
|
-
export async function getValidAccessToken(options) {
|
|
7
|
+
export async function getValidAccessToken(baseUrl, options) {
|
|
8
8
|
const accessToken = await getCookieSession("accessToken");
|
|
9
9
|
console.log("Access Token....:");
|
|
10
10
|
const refreshToken = await getCookieSession("refreshToken");
|
|
@@ -16,20 +16,20 @@ export async function getValidAccessToken(options) {
|
|
|
16
16
|
if (refreshToken) {
|
|
17
17
|
console.log("Refreshing access token using refresh token...", refreshToken);
|
|
18
18
|
if (!refreshPromise) {
|
|
19
|
-
refreshPromise = refreshAccessToken(refreshToken,
|
|
19
|
+
refreshPromise = refreshAccessToken(refreshToken, baseUrl, options === null || options === void 0 ? void 0 : options.isSetToken);
|
|
20
20
|
refreshPromise.finally(() => (refreshPromise = null));
|
|
21
21
|
}
|
|
22
22
|
return await refreshPromise;
|
|
23
23
|
}
|
|
24
|
-
if (!(options === null || options === void 0 ? void 0 : options.isNotLogOutWhenExpire)) {
|
|
25
|
-
await logOut();
|
|
24
|
+
if (!(options === null || options === void 0 ? void 0 : options.isNotLogOutWhenExpire) && (options === null || options === void 0 ? void 0 : options.platformUrl)) {
|
|
25
|
+
await logOut(options === null || options === void 0 ? void 0 : options.platformUrl);
|
|
26
26
|
}
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
|
-
export async function refreshAccessToken(refreshToken, isSetToken) {
|
|
29
|
+
export async function refreshAccessToken(refreshToken, baseUrl, isSetToken) {
|
|
30
30
|
try {
|
|
31
31
|
console.log("Refreshing access token...");
|
|
32
|
-
const response = await fetch(
|
|
32
|
+
const response = await fetch(`${baseUrl}/platform/auth/refresh-token`, {
|
|
33
33
|
method: "POST",
|
|
34
34
|
credentials: "include",
|
|
35
35
|
headers: { "Content-Type": "application/json" },
|
|
@@ -58,12 +58,12 @@ export async function refreshAccessToken(refreshToken, isSetToken) {
|
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
export async function decodeAccessToken() {
|
|
62
|
-
const accessToken = await getValidAccessToken();
|
|
61
|
+
export async function decodeAccessToken(baseUrl) {
|
|
62
|
+
const accessToken = await getValidAccessToken(baseUrl);
|
|
63
63
|
return accessToken ? jwtDecode(accessToken) : null;
|
|
64
64
|
}
|
|
65
|
-
export async function logOut() {
|
|
65
|
+
export async function logOut(platformUrl) {
|
|
66
66
|
await clearAllCookieSession();
|
|
67
67
|
console.log("Logging out...");
|
|
68
|
-
redirect(
|
|
68
|
+
redirect(`${platformUrl}/login.html`);
|
|
69
69
|
}
|