ikoncomponents 1.3.6 → 1.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +36 -36
  2. package/dist/ikoncomponents/app-breadcrumb/BreadcrumbProvider.d.ts +2 -0
  3. package/dist/ikoncomponents/app-breadcrumb/BreadcrumbProvider.js +12 -1
  4. package/dist/ikoncomponents/fileUpload/index.js +2 -2
  5. package/dist/ikoncomponents/form-fields/date-input/index.js +1 -1
  6. package/dist/ikoncomponents/image-cropper-upload/components/newImageUploadForm.js +2 -2
  7. package/dist/ikoncomponents/main-layout/RefreshContext.d.ts +10 -0
  8. package/dist/ikoncomponents/main-layout/RefreshContext.js +17 -0
  9. package/dist/ikoncomponents/main-layout/SidebarNavContext.d.ts +6 -0
  10. package/dist/ikoncomponents/main-layout/SidebarNavContext.js +12 -0
  11. package/dist/ikoncomponents/main-layout/app-sidebar.js +3 -3
  12. package/dist/ikoncomponents/main-layout/header.d.ts +3 -1
  13. package/dist/ikoncomponents/main-layout/header.js +2 -2
  14. package/dist/ikoncomponents/main-layout/index.d.ts +2 -1
  15. package/dist/ikoncomponents/main-layout/index.js +2 -2
  16. package/dist/ikoncomponents/main-layout/main-sidebar.d.ts +7 -1
  17. package/dist/ikoncomponents/main-layout/main-sidebar.js +89 -63
  18. package/dist/ikoncomponents/main-layout/nav-main.d.ts +4 -1
  19. package/dist/ikoncomponents/main-layout/nav-main.js +6 -4
  20. package/dist/ikoncomponents/provider-wrapper/index.d.ts +2 -1
  21. package/dist/ikoncomponents/provider-wrapper/index.js +2 -2
  22. package/dist/index.d.ts +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/shadcn/table.js +1 -1
  25. package/dist/styles.css +29 -32
  26. package/dist/utils/token-management/index.d.ts +5 -4
  27. package/dist/utils/token-management/index.js +10 -10
  28. package/package.json +103 -103
package/README.md CHANGED
@@ -1,36 +1,36 @@
1
- This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2
-
3
- ## Getting Started
4
-
5
- First, run the development server:
6
-
7
- ```bash
8
- npm run dev
9
- # or
10
- yarn dev
11
- # or
12
- pnpm dev
13
- # or
14
- bun dev
15
- ```
16
-
17
- Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18
-
19
- You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20
-
21
- This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22
-
23
- ## Learn More
24
-
25
- To learn more about Next.js, take a look at the following resources:
26
-
27
- - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28
- - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29
-
30
- You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31
-
32
- ## Deploy on Vercel
33
-
34
- The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35
-
36
- Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
1
+ This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2
+
3
+ ## Getting Started
4
+
5
+ First, run the development server:
6
+
7
+ ```bash
8
+ npm run dev
9
+ # or
10
+ yarn dev
11
+ # or
12
+ pnpm dev
13
+ # or
14
+ bun dev
15
+ ```
16
+
17
+ Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18
+
19
+ You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20
+
21
+ This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22
+
23
+ ## Learn More
24
+
25
+ To learn more about Next.js, take a look at the following resources:
26
+
27
+ - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28
+ - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29
+
30
+ You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31
+
32
+ ## Deploy on Vercel
33
+
34
+ The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35
+
36
+ Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
@@ -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
- return (_jsx(BreadcrumbContext.Provider, { value: { breadcrumbItems, addBreadcrumb, backBreadcrumb }, children: children }));
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() {
@@ -51,8 +51,8 @@ export function FileUploader({ label = "Upload File", isDrag = false, onFileSele
51
51
  if (file)
52
52
  handleFile(file);
53
53
  };
54
- return (_jsxs("div", { className: "flex flex-col gap-2 w-full", children: [_jsx("label", { className: "text-sm font-medium", children: label }), _jsx("input", { type: "file", id: "fileInput", className: "hidden", onChange: handleInputChange }), isDrag ? (_jsx("div", { className: `border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition
55
- ${isDragging ? "border-blue-600 bg-blue-50" : "border-gray-300"}
54
+ return (_jsxs("div", { className: "flex flex-col gap-2 w-full", children: [_jsx("label", { className: "text-sm font-medium", children: label }), _jsx("input", { type: "file", id: "fileInput", className: "hidden", onChange: handleInputChange }), isDrag ? (_jsx("div", { className: `border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition
55
+ ${isDragging ? "border-blue-600 bg-blue-50" : "border-gray-300"}
56
56
  `, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: () => { var _a; return (_a = document.getElementById("fileInput")) === null || _a === void 0 ? void 0 : _a.click(); }, children: _jsxs("div", { className: "flex flex-col items-center gap-3", children: [_jsx(UploadCloud, { className: "w-10 h-10 text-blue-600" }), _jsxs("p", { className: "text-gray-600", children: ["Drag & drop your file here or", " ", _jsx("span", { className: "text-blue-600 underline", children: "browse" })] })] }) })) : (
57
57
  // ----- SIMPLE UPLOAD BOX -----
58
58
  _jsxs("div", { className: "border rounded-lg p-4 flex flex-col items-center gap-2 cursor-pointer text-center", onClick: () => { var _a; return (_a = document.getElementById("fileInput")) === null || _a === void 0 ? void 0 : _a.click(); }, children: [_jsx(FileUp, { className: "w-8 h-8 text-blue-600" }), _jsx("span", { className: "text-blue-600 underline", children: "Browse File" })] }))] }));
@@ -7,7 +7,7 @@ import { format } from "date-fns";
7
7
  import { CalendarIcon } from "lucide-react";
8
8
  import { Calendar } from "../../../shadcn/calendar";
9
9
  export function FormDateInput({ formControl, name, label, placeholder, dateFormat, calendarDateDisabled, formDescription, disabled, }) {
10
- return (_jsx(_Fragment, { children: _jsx(FormField, { control: formControl, name: name, render: ({ field }) => (_jsxs(FormItem, { children: [label && (_jsx(_Fragment, { children: _jsx(FormLabel, { children: label }) })), _jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, className: "w-full", children: _jsx(FormControl, { children: _jsxs(Button, { variant: "outline", className: cn(!field.value && "text-foreground/50"), disabled: disabled, children: [field.value ? (format(field.value, dateFormat || "PPP")) : (_jsx("span", { children: placeholder || "Pick a date" })), _jsx(CalendarIcon, { className: "ml-auto h-4 w-4 opacity-50" })] }) }) }), _jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: _jsx(Calendar, { mode: "single", selected: field.value, onSelect: field.onChange, disabled: calendarDateDisabled,
10
+ return (_jsx(_Fragment, { children: _jsx(FormField, { control: formControl, name: name, render: ({ field }) => (_jsxs(FormItem, { children: [label && (_jsx(_Fragment, { children: _jsx(FormLabel, { children: label }) })), _jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, className: "w-full", children: _jsx(FormControl, { children: _jsxs(Button, { variant: "outline", className: cn(!field.value && "text-foreground/50"), disabled: disabled, children: [field.value ? (format(field.value, dateFormat || "PPP")) : (_jsx("span", { children: placeholder || "Pick a date" })), _jsx(CalendarIcon, { className: "ml-auto h-4 w-4 opacity-50" })] }) }) }), _jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: _jsx(Calendar, { mode: "single", selected: field.value, onSelect: field.onChange, disabled: calendarDateDisabled, captionLayout: "dropdown",
11
11
  // disabled={(date) =>
12
12
  // date > new Date() || date < new Date("1900-01-01")
13
13
  // }
@@ -90,12 +90,12 @@ const NewImageFormComponent = ({ open, setOpen, onImageSubmit, }) => {
90
90
  const getImagePreview = (state) => {
91
91
  const imgSource = croppedImage && activeState === state ? croppedImage : prevImages[state];
92
92
  // const imgSource = prevImages[state];
93
- return imgSource ? (_jsx("div", { className: `
93
+ return imgSource ? (_jsx("div", { className: `
94
94
  ${state === "first"
95
95
  ? "relative w-3/5 h-[200px] bg-slate-400"
96
96
  : state === "second"
97
97
  ? "relative w-1/2 h-[220px] bg-slate-400"
98
- : "relative w-1/3 h-[120px] bg-slate-400"}`, children: _jsx(Image, { src: imgSource || "", alt: `Preview ${state}`, layout: "fill", objectFit: "70vh" }) })) : (_jsx("div", { className: `
98
+ : "relative w-1/3 h-[120px] bg-slate-400"}`, children: _jsx(Image, { src: imgSource || "", alt: `Preview ${state}`, layout: "fill", objectFit: "70vh" }) })) : (_jsx("div", { className: `
99
99
  ${state === "first"
100
100
  ? "relative w-3/5 h-[200px] bg-slate-400"
101
101
  : state === "second"
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface RefreshContextType {
3
+ refresh: () => void;
4
+ refreshCounter: number;
5
+ }
6
+ export declare function RefreshProvider({ children }: {
7
+ children: React.ReactNode;
8
+ }): import("react/jsx-runtime").JSX.Element;
9
+ export declare function useRefresh(): RefreshContextType;
10
+ export {};
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useState, useCallback } from 'react';
3
+ const RefreshContext = createContext(undefined);
4
+ export function RefreshProvider({ children }) {
5
+ const [refreshCounter, setRefreshCounter] = useState(0);
6
+ const refresh = useCallback(() => {
7
+ setRefreshCounter((prev) => prev + 1);
8
+ }, []);
9
+ return (_jsx(RefreshContext.Provider, { value: { refresh, refreshCounter }, children: children }));
10
+ }
11
+ export function useRefresh() {
12
+ const context = useContext(RefreshContext);
13
+ if (context === undefined) {
14
+ throw new Error('useRefresh must be used within a RefreshProvider');
15
+ }
16
+ return context;
17
+ }
@@ -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
  }
@@ -1 +1,3 @@
1
- export declare function Header(): import("react/jsx-runtime").JSX.Element;
1
+ export declare function Header({ platformUrl }: {
2
+ platformUrl: string;
3
+ }): import("react/jsx-runtime").JSX.Element;
@@ -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: "/app-store", children: _jsxs(IconTextButton, { variant: "default", children: [_jsx(Play, {}), "App Store"] }) })] })] }) }));
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
  }
@@ -1,3 +1,8 @@
1
+ export interface AccountMembership {
2
+ accountId: string;
3
+ accountName: string;
4
+ primaryAccount?: boolean;
5
+ }
1
6
  export interface Account {
2
7
  accountId: string;
3
8
  accountName: string;
@@ -49,6 +54,7 @@ export interface DecodedAccessToken {
49
54
  iat: number;
50
55
  exp: number;
51
56
  }
52
- export declare const MainSidebar: ({ baseUrl }: {
57
+ export declare const MainSidebar: ({ baseUrl, platformUrl, }: {
53
58
  baseUrl: string;
59
+ platformUrl: string;
54
60
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,27 +1,29 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import * as React from 'react';
4
- import { Check, CircleUserRound, FolderCode, Home, LogOut, Settings } from 'lucide-react';
5
- import { Button } from '../../shadcn/button';
6
- import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../shadcn/tooltip';
7
- import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '../../shadcn/dropdown-menu';
8
- import { getValidAccessToken } from '../../utils/token-management';
9
- import { clearAllCookieSession } from '../../utils/session/cookieSession';
10
- import axios from 'axios';
11
- import { redirect } from 'next/navigation';
12
- import Link from 'next/link';
3
+ import * as React from "react";
4
+ import { Check, CircleUserRound, FolderCode, Home, LogOut, Settings, } from "lucide-react";
5
+ import { Button } from "../../shadcn/button";
6
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "../../shadcn/tooltip";
7
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "../../shadcn/dropdown-menu";
8
+ import { getValidAccessToken } from "../../utils/token-management";
9
+ import { clearAllCookieSession, setCookieSession } from "../../utils/session/cookieSession";
10
+ import axios from "axios";
11
+ import { redirect } from "next/navigation";
12
+ import Link from "next/link";
13
13
  import { jwtDecode } from "jwt-decode";
14
- import { Icon } from '../icon';
15
- export const MainSidebar = ({ baseUrl }) => {
14
+ import { Icon } from "../icon";
15
+ import { useRefresh } from "./RefreshContext";
16
+ export const MainSidebar = ({ baseUrl, platformUrl, }) => {
16
17
  const [user, setUser] = React.useState();
17
18
  const [accounts, setAccounts] = React.useState([]);
18
19
  const [selectedAccount, setSelectedAccount] = React.useState();
19
20
  const [softwares, setSoftwares] = React.useState([]);
21
+ const { refreshCounter } = useRefresh();
20
22
  const getInitials = (name) => {
21
23
  return name
22
- .split(' ')
23
- .map(word => word[0])
24
- .join('')
24
+ .split(" ")
25
+ .map((word) => word[0])
26
+ .join("")
25
27
  .toUpperCase()
26
28
  .slice(0, 2);
27
29
  };
@@ -31,63 +33,87 @@ export const MainSidebar = ({ baseUrl }) => {
31
33
  .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
32
34
  .join("");
33
35
  }
36
+ // Fetch all data
34
37
  React.useEffect(() => {
35
- const fetchUser = async () => {
38
+ const fetchAllData = async () => {
36
39
  try {
37
- const accessToken = await getValidAccessToken();
38
- const decoded = jwtDecode(accessToken !== null && accessToken !== void 0 ? accessToken : '');
39
- const response = await axios.get(`${baseUrl}/platform/user/${decoded.sub}`, {
40
- headers: {
41
- Authorization: `Bearer ${accessToken}`,
42
- },
40
+ const accessToken = await getValidAccessToken(baseUrl, {
41
+ platformUrl,
42
+ isSetToken: true,
43
43
  });
44
- setUser(response.data);
44
+ const decoded = jwtDecode(accessToken !== null && accessToken !== void 0 ? accessToken : "");
45
+ // Fetch all data in parallel
46
+ const [userResponse, accountsResponse, softwaresResponse] = await Promise.all([
47
+ axios.get(`${baseUrl}/platform/user/${decoded.sub}`, {
48
+ headers: { Authorization: `Bearer ${accessToken}` },
49
+ }),
50
+ axios.get(`${baseUrl}/platform/user/account-membership`, {
51
+ headers: { Authorization: `Bearer ${accessToken}` },
52
+ }),
53
+ axios.get(`${baseUrl}/platform/software/accessible/user`, {
54
+ headers: { Authorization: `Bearer ${accessToken}` },
55
+ }),
56
+ ]);
57
+ setUser(userResponse.data);
58
+ setAccounts(accountsResponse.data);
59
+ // const primaryAccount = accountsResponse.data.find(
60
+ // (account) => account.primaryAccount === true
61
+ // );
62
+ // if (primaryAccount) {
63
+ // setSelectedAccount(primaryAccount);
64
+ // }
65
+ const activeAccount = accountsResponse.data.find((account) => account.accountId === decoded.activeAccountId);
66
+ setSelectedAccount(activeAccount);
67
+ const visibleSoftwares = softwaresResponse.data.filter((item) => item.visible);
68
+ setSoftwares(visibleSoftwares);
45
69
  }
46
70
  catch (error) {
47
- console.error(error);
71
+ console.error("Failed to fetch data:", error);
48
72
  }
49
73
  };
50
- const fetchAccounts = async () => {
51
- try {
52
- const accessToken = await getValidAccessToken();
53
- const response = await axios.get(`${baseUrl}/platform/account/all`, {
54
- headers: {
55
- Authorization: `Bearer ${accessToken}`,
56
- },
57
- });
58
- setAccounts(response.data);
59
- setSelectedAccount(response.data[0]);
60
- }
61
- catch (error) {
62
- console.error(error);
63
- }
64
- };
65
- const fetchSubscribedSoftwares = async () => {
66
- try {
67
- const accessToken = await getValidAccessToken();
68
- const response = await axios.get(`${baseUrl}/platform/software/accessible/user`, {
69
- headers: {
70
- Authorization: `Bearer ${accessToken}`,
71
- },
72
- });
73
- setSoftwares(response.data);
74
- }
75
- catch (error) {
76
- console.error(error);
77
- }
78
- };
79
- fetchAccounts();
80
- fetchSubscribedSoftwares();
81
- fetchUser();
82
- }, []);
83
- 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: () => {
84
- setSelectedAccount(account);
85
- }, 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: "/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) => {
74
+ fetchAllData();
75
+ }, [baseUrl, platformUrl, refreshCounter]);
76
+ const switchAccount = async (accountId, baseUrl) => {
77
+ try {
78
+ const accessToken = await getValidAccessToken(baseUrl, {
79
+ platformUrl: platformUrl,
80
+ isSetToken: true,
81
+ });
82
+ const response = await axios.post(`${baseUrl}/platform/auth/switch-account`, {
83
+ targetAccountId: accountId,
84
+ }, {
85
+ headers: {
86
+ Authorization: `Bearer ${accessToken}`,
87
+ },
88
+ withCredentials: true,
89
+ });
90
+ console.log(response);
91
+ await setCookieSession("accessToken", response.data.accessToken);
92
+ await setCookieSession("refreshToken", response.data.refreshToken);
93
+ }
94
+ catch (error) {
95
+ console.error(error);
96
+ throw error;
97
+ }
98
+ };
99
+ 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
100
+ ? getInitials(selectedAccount.accountName)
101
+ : "..." }) }) }), _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 () => {
102
+ try {
103
+ setSelectedAccount(account);
104
+ console.log(account.accountId);
105
+ await switchAccount(account.accountId, baseUrl);
106
+ window.location.reload();
107
+ }
108
+ catch (error) {
109
+ console.error("Switch account failed", error);
110
+ }
111
+ }, 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
112
  var _a, _b;
87
113
  const hasIcon = Boolean(software.icon && software.icon.trim() !== "");
88
- 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: "/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 () => {
114
+ 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));
115
+ }) }), _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
116
  await clearAllCookieSession();
91
- redirect("/login.html");
117
+ redirect(`${platformUrl}/login.html`);
92
118
  }, 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
119
  };
@@ -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
- }, [items, setNavItems]);
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
  }
package/dist/index.d.ts CHANGED
@@ -135,3 +135,4 @@ export { setCookieSession, getCookieSession, clearCookieSession, clearAllCookieS
135
135
  export { getValidAccessToken, refreshAccessToken, decodeAccessToken, logOut, } from "./utils/token-management";
136
136
  export type { TokenResponse } from "./utils/token-management/types";
137
137
  export { useIsMobile } from "./hooks/use-mobile";
138
+ export { useRefresh } from "./ikoncomponents/main-layout/RefreshContext";
package/dist/index.js CHANGED
@@ -113,3 +113,4 @@ export { cn } from "./utils/cn";
113
113
  export { setCookieSession, getCookieSession, clearCookieSession, clearAllCookieSession, } from "./utils/session/cookieSession";
114
114
  export { getValidAccessToken, refreshAccessToken, decodeAccessToken, logOut, } from "./utils/token-management";
115
115
  export { useIsMobile } from "./hooks/use-mobile";
116
+ export { useRefresh } from "./ikoncomponents/main-layout/RefreshContext";
@@ -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-x-auto", children: _jsx("table", Object.assign({ "data-slot": "table", className: cn("w-full caption-bottom text-sm", className) }, props)) }));
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
@@ -1099,9 +1099,6 @@
1099
1099
  .overflow-hidden {
1100
1100
  overflow: hidden;
1101
1101
  }
1102
- .overflow-x-auto {
1103
- overflow-x: auto;
1104
- }
1105
1102
  .overflow-x-hidden {
1106
1103
  overflow-x: hidden;
1107
1104
  }
@@ -4983,9 +4980,9 @@
4983
4980
  .custom-buttons {
4984
4981
  font-size: 14px;
4985
4982
  }
4986
- .rbc-date-cell.rbc-now,
4987
- .rbc-time-slot.rbc-now,
4988
- .rbc-show-more,
4983
+ .rbc-date-cell.rbc-now,
4984
+ .rbc-time-slot.rbc-now,
4985
+ .rbc-show-more,
4989
4986
  .rbc-header {
4990
4987
  font-weight: normal !important;
4991
4988
  }
@@ -5031,13 +5028,13 @@
5031
5028
  .rbc-h-full {
5032
5029
  height: 100%;
5033
5030
  }
5034
- .rbc-calendar *,
5035
- .rbc-calendar *:before,
5031
+ .rbc-calendar *,
5032
+ .rbc-calendar *:before,
5036
5033
  .rbc-calendar *:after {
5037
5034
  -webkit-box-sizing: inherit;
5038
5035
  box-sizing: inherit;
5039
5036
  }
5040
- .rbc-abs-full,
5037
+ .rbc-abs-full,
5041
5038
  .rbc-row-bg {
5042
5039
  overflow: hidden;
5043
5040
  position: absolute;
@@ -5046,9 +5043,9 @@
5046
5043
  right: 0;
5047
5044
  bottom: 0;
5048
5045
  }
5049
- .rbc-ellipsis,
5050
- .rbc-show-more,
5051
- .rbc-row-segment .rbc-event-content,
5046
+ .rbc-ellipsis,
5047
+ .rbc-show-more,
5048
+ .rbc-row-segment .rbc-event-content,
5052
5049
  .rbc-event-label {
5053
5050
  display: block;
5054
5051
  overflow: hidden;
@@ -5087,8 +5084,8 @@
5087
5084
  border-left-width: 0;
5088
5085
  border-right: 1px solid hsl(var(--border));
5089
5086
  }
5090
- .rbc-header>a,
5091
- .rbc-header>a:active,
5087
+ .rbc-header>a,
5088
+ .rbc-header>a:active,
5092
5089
  .rbc-header>a:visited {
5093
5090
  color: inherit;
5094
5091
  text-decoration: none;
@@ -5172,7 +5169,7 @@
5172
5169
  line-height: normal;
5173
5170
  white-space: nowrap;
5174
5171
  }
5175
- .rbc-toolbar button:active,
5172
+ .rbc-toolbar button:active,
5176
5173
  .rbc-toolbar button.rbc-active {
5177
5174
  background-image: none;
5178
5175
  -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
@@ -5180,9 +5177,9 @@
5180
5177
  background-color: #e6e6e6;
5181
5178
  border-color: #adadad;
5182
5179
  }
5183
- .rbc-toolbar button:active:hover,
5184
- .rbc-toolbar button:active:focus,
5185
- .rbc-toolbar button.rbc-active:hover,
5180
+ .rbc-toolbar button:active:hover,
5181
+ .rbc-toolbar button:active:focus,
5182
+ .rbc-toolbar button.rbc-active:hover,
5186
5183
  .rbc-toolbar button.rbc-active:focus {
5187
5184
  color: #373a3c;
5188
5185
  background-color: #d4d4d4;
@@ -5230,7 +5227,7 @@
5230
5227
  margin-left: 0;
5231
5228
  margin-right: -1px;
5232
5229
  }
5233
- .rbc-btn-group+.rbc-btn-group,
5230
+ .rbc-btn-group+.rbc-btn-group,
5234
5231
  .rbc-btn-group+button {
5235
5232
  margin-left: 10px;
5236
5233
  }
@@ -5242,7 +5239,7 @@
5242
5239
  flex-direction: column;
5243
5240
  }
5244
5241
  }
5245
- .rbc-event,
5242
+ .rbc-event,
5246
5243
  .rbc-day-slot .rbc-background-event {
5247
5244
  border: none;
5248
5245
  -webkit-box-sizing: border-box;
@@ -5258,17 +5255,17 @@
5258
5255
  width: 100%;
5259
5256
  text-align: left;
5260
5257
  }
5261
- .rbc-slot-selecting .rbc-event,
5262
- .rbc-slot-selecting .rbc-day-slot .rbc-background-event,
5258
+ .rbc-slot-selecting .rbc-event,
5259
+ .rbc-slot-selecting .rbc-day-slot .rbc-background-event,
5263
5260
  .rbc-day-slot .rbc-slot-selecting .rbc-background-event {
5264
5261
  cursor: inherit;
5265
5262
  pointer-events: none;
5266
5263
  }
5267
- .rbc-event.rbc-selected,
5264
+ .rbc-event.rbc-selected,
5268
5265
  .rbc-day-slot .rbc-selected.rbc-background-event {
5269
5266
  background-color: #265985;
5270
5267
  }
5271
- .rbc-event:focus,
5268
+ .rbc-event:focus,
5272
5269
  .rbc-day-slot .rbc-background-event:focus {
5273
5270
  outline: 5px auto #3b99fc;
5274
5271
  }
@@ -5320,7 +5317,7 @@
5320
5317
  line-height: normal;
5321
5318
  color: hsl(var(--input));
5322
5319
  }
5323
- .rbc-show-more:hover,
5320
+ .rbc-show-more:hover,
5324
5321
  .rbc-show-more:focus {
5325
5322
  color: #265985;
5326
5323
  }
@@ -5384,8 +5381,8 @@
5384
5381
  .rbc-date-cell.rbc-now {
5385
5382
  font-weight: bold;
5386
5383
  }
5387
- .rbc-date-cell>a,
5388
- .rbc-date-cell>a:active,
5384
+ .rbc-date-cell>a,
5385
+ .rbc-date-cell>a:active,
5389
5386
  .rbc-date-cell>a:visited {
5390
5387
  color: inherit;
5391
5388
  text-decoration: none;
@@ -5488,7 +5485,7 @@
5488
5485
  .rbc-agenda-time-cell .rbc-continues-prior:before {
5489
5486
  content: "« ";
5490
5487
  }
5491
- .rbc-agenda-date-cell,
5488
+ .rbc-agenda-date-cell,
5492
5489
  .rbc-agenda-time-cell {
5493
5490
  white-space: nowrap;
5494
5491
  }
@@ -5521,7 +5518,7 @@
5521
5518
  -ms-flex-flow: column nowrap;
5522
5519
  flex-flow: column nowrap;
5523
5520
  }
5524
- .rbc-time-gutter,
5521
+ .rbc-time-gutter,
5525
5522
  .rbc-header-gutter {
5526
5523
  -webkit-box-flex: 0;
5527
5524
  -ms-flex: none;
@@ -5545,7 +5542,7 @@
5545
5542
  left: 10px;
5546
5543
  right: 0;
5547
5544
  }
5548
- .rbc-day-slot .rbc-event,
5545
+ .rbc-day-slot .rbc-event,
5549
5546
  .rbc-day-slot .rbc-background-event {
5550
5547
  border: 1px solid #265985;
5551
5548
  display: -webkit-box;
@@ -5586,7 +5583,7 @@
5586
5583
  .rbc-day-slot .rbc-time-slot {
5587
5584
  border-top: 1px solid hsl(var(--border));
5588
5585
  }
5589
- .rbc-time-view-resources .rbc-time-gutter,
5586
+ .rbc-time-view-resources .rbc-time-gutter,
5590
5587
  .rbc-time-view-resources .rbc-time-header-gutter {
5591
5588
  position: sticky;
5592
5589
  left: 0;
@@ -5612,7 +5609,7 @@
5612
5609
  .rbc-time-view-resources .rbc-day-slot {
5613
5610
  min-width: 140px;
5614
5611
  }
5615
- .rbc-time-view-resources .rbc-header,
5612
+ .rbc-time-view-resources .rbc-header,
5616
5613
  .rbc-time-view-resources .rbc-day-bg {
5617
5614
  width: 140px;
5618
5615
  -webkit-box-flex: 1;
@@ -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, true);
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(`https://ikoncloud-dev.keross.com/ikon-api/platform/auth/refresh-token`, {
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("/login.html");
68
+ redirect(`${platformUrl}/login.html`);
69
69
  }
package/package.json CHANGED
@@ -1,103 +1,103 @@
1
- {
2
- "name": "ikoncomponents",
3
- "version": "1.3.6",
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "css": "dist/styles.css",
7
- "files": [
8
- "dist"
9
- ],
10
- "scripts": {
11
- "build": "npm run build:js && npm run build:css",
12
- "build:js": "tsc -p tsconfig.json",
13
- "build:css": "postcss src/styles.css -o dist/styles.css --config postcss.config.mjs --minify",
14
- "clean": "rimraf dist",
15
- "prepublishOnly": "npm run build"
16
- },
17
- "dependencies": {
18
- "@radix-ui/react-accordion": "^1.2.12",
19
- "@radix-ui/react-alert-dialog": "^1.1.15",
20
- "@radix-ui/react-aspect-ratio": "^1.1.7",
21
- "@radix-ui/react-avatar": "^1.1.10",
22
- "@radix-ui/react-checkbox": "^1.3.3",
23
- "@radix-ui/react-dialog": "^1.1.15",
24
- "@radix-ui/react-dropdown-menu": "^2.1.16",
25
- "@radix-ui/react-hover-card": "^1.1.15",
26
- "@radix-ui/react-icons": "^1.3.0",
27
- "@radix-ui/react-label": "^2.1.7",
28
- "@radix-ui/react-navigation-menu": "^1.2.14",
29
- "@radix-ui/react-popover": "^1.1.15",
30
- "@radix-ui/react-progress": "^1.1.7",
31
- "@radix-ui/react-radio-group": "^1.3.8",
32
- "@radix-ui/react-scroll-area": "^1.2.10",
33
- "@radix-ui/react-select": "^2.2.6",
34
- "@radix-ui/react-separator": "^1.1.7",
35
- "@radix-ui/react-slider": "^1.3.6",
36
- "@radix-ui/react-slot": "^1.2.3",
37
- "@radix-ui/react-switch": "^1.2.6",
38
- "@radix-ui/react-tabs": "^1.1.13",
39
- "@radix-ui/react-toggle": "^1.1.10",
40
- "@radix-ui/react-toggle-group": "^1.1.11",
41
- "@radix-ui/react-tooltip": "^1.2.8",
42
- "@tanstack/react-table": "^8.21.3",
43
- "axios": "^1.13.1",
44
- "class-variance-authority": "^0.7.1",
45
- "clsx": "^2.1.1",
46
- "cmdk": "^1.1.1",
47
- "countries-list": "^3.1.1",
48
- "country-flag-icons": "^1.5.21",
49
- "crypto-js": "^4.2.0",
50
- "date-fns": "^4.1.0",
51
- "echarts": "^6.0.0",
52
- "eslint": "^9",
53
- "framer-motion": "^12.23.22",
54
- "input-otp": "^1.4.2",
55
- "jwt-decode": "^4.0.0",
56
- "lucide-react": "^0.552.0",
57
- "motion": "^12.23.22",
58
- "next": "16.0.0",
59
- "next-themes": "^0.4.6",
60
- "react": "^18.2.0",
61
- "react-big-calendar": "^1.19.4",
62
- "react-cropper": "^2.3.3",
63
- "react-day-picker": "^9.9.0",
64
- "react-dom": "^18.2.0",
65
- "react-hook-form": "^7.64.0",
66
- "shadcn": "^3.5.0",
67
- "sonner": "^2.0.7",
68
- "tailwind-merge": "^3.3.1",
69
- "tailwindcss-animate": "^1.0.7",
70
- "uuid": "^13.0.0",
71
- "vaul": "^1.1.2",
72
- "zxcvbn": "^4.4.2"
73
- },
74
- "devDependencies": {
75
- "@tailwindcss/postcss": "^4",
76
- "@types/crypto-js": "^4.2.2",
77
- "@types/node": "^20",
78
- "@types/react": "^19",
79
- "@types/react-big-calendar": "^1.16.3",
80
- "@types/react-dom": "^19",
81
- "@types/zxcvbn": "^4.4.5",
82
- "autoprefixer": "^10.4.21",
83
- "eslint": "^9",
84
- "eslint-config-next": "16.0.0",
85
- "next": "^14.0.0",
86
- "postcss": "^8.5.6",
87
- "postcss-cli": "^11.0.1",
88
- "postcss-import": "^16.1.1",
89
- "postcss-preset-env": "^10.4.0",
90
- "rimraf": "^6.0.1",
91
- "tailwindcss": "^4",
92
- "tw-animate-css": "^1.4.0",
93
- "typescript": "^5"
94
- },
95
- "peerDependencies": {
96
- "clsx": "^2.1.1",
97
- "next": "16.0.0",
98
- "next-themes": "^0.4.6",
99
- "react": "^18.2.0",
100
- "react-dom": "^18.2.0",
101
- "tailwind-merge": "^3.3.1"
102
- }
103
- }
1
+ {
2
+ "name": "ikoncomponents",
3
+ "version": "1.3.8",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "css": "dist/styles.css",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "npm run build:js && npm run build:css",
12
+ "build:js": "tsc -p tsconfig.json",
13
+ "build:css": "postcss src/styles.css -o dist/styles.css --config postcss.config.mjs --minify",
14
+ "clean": "rimraf dist",
15
+ "prepublishOnly": "npm run build"
16
+ },
17
+ "dependencies": {
18
+ "@radix-ui/react-accordion": "^1.2.12",
19
+ "@radix-ui/react-alert-dialog": "^1.1.15",
20
+ "@radix-ui/react-aspect-ratio": "^1.1.7",
21
+ "@radix-ui/react-avatar": "^1.1.10",
22
+ "@radix-ui/react-checkbox": "^1.3.3",
23
+ "@radix-ui/react-dialog": "^1.1.15",
24
+ "@radix-ui/react-dropdown-menu": "^2.1.16",
25
+ "@radix-ui/react-hover-card": "^1.1.15",
26
+ "@radix-ui/react-icons": "^1.3.0",
27
+ "@radix-ui/react-label": "^2.1.7",
28
+ "@radix-ui/react-navigation-menu": "^1.2.14",
29
+ "@radix-ui/react-popover": "^1.1.15",
30
+ "@radix-ui/react-progress": "^1.1.7",
31
+ "@radix-ui/react-radio-group": "^1.3.8",
32
+ "@radix-ui/react-scroll-area": "^1.2.10",
33
+ "@radix-ui/react-select": "^2.2.6",
34
+ "@radix-ui/react-separator": "^1.1.7",
35
+ "@radix-ui/react-slider": "^1.3.6",
36
+ "@radix-ui/react-slot": "^1.2.3",
37
+ "@radix-ui/react-switch": "^1.2.6",
38
+ "@radix-ui/react-tabs": "^1.1.13",
39
+ "@radix-ui/react-toggle": "^1.1.10",
40
+ "@radix-ui/react-toggle-group": "^1.1.11",
41
+ "@radix-ui/react-tooltip": "^1.2.8",
42
+ "@tanstack/react-table": "^8.21.3",
43
+ "axios": "^1.13.1",
44
+ "class-variance-authority": "^0.7.1",
45
+ "clsx": "^2.1.1",
46
+ "cmdk": "^1.1.1",
47
+ "countries-list": "^3.1.1",
48
+ "country-flag-icons": "^1.5.21",
49
+ "crypto-js": "^4.2.0",
50
+ "date-fns": "^4.1.0",
51
+ "echarts": "^6.0.0",
52
+ "eslint": "^9",
53
+ "framer-motion": "^12.23.22",
54
+ "input-otp": "^1.4.2",
55
+ "jwt-decode": "^4.0.0",
56
+ "lucide-react": "^0.552.0",
57
+ "motion": "^12.23.22",
58
+ "next": "16.0.0",
59
+ "next-themes": "^0.4.6",
60
+ "react": "^18.2.0",
61
+ "react-big-calendar": "^1.19.4",
62
+ "react-cropper": "^2.3.3",
63
+ "react-day-picker": "^9.9.0",
64
+ "react-dom": "^18.2.0",
65
+ "react-hook-form": "^7.64.0",
66
+ "shadcn": "^3.5.0",
67
+ "sonner": "^2.0.7",
68
+ "tailwind-merge": "^3.3.1",
69
+ "tailwindcss-animate": "^1.0.7",
70
+ "uuid": "^13.0.0",
71
+ "vaul": "^1.1.2",
72
+ "zxcvbn": "^4.4.2"
73
+ },
74
+ "devDependencies": {
75
+ "@tailwindcss/postcss": "^4",
76
+ "@types/crypto-js": "^4.2.2",
77
+ "@types/node": "^20",
78
+ "@types/react": "^19",
79
+ "@types/react-big-calendar": "^1.16.3",
80
+ "@types/react-dom": "^19",
81
+ "@types/zxcvbn": "^4.4.5",
82
+ "autoprefixer": "^10.4.21",
83
+ "eslint": "^9",
84
+ "eslint-config-next": "16.0.0",
85
+ "next": "^14.0.0",
86
+ "postcss": "^8.5.6",
87
+ "postcss-cli": "^11.0.1",
88
+ "postcss-import": "^16.1.1",
89
+ "postcss-preset-env": "^10.4.0",
90
+ "rimraf": "^6.0.1",
91
+ "tailwindcss": "^4",
92
+ "tw-animate-css": "^1.4.0",
93
+ "typescript": "^5"
94
+ },
95
+ "peerDependencies": {
96
+ "clsx": "^2.1.1",
97
+ "next": "16.0.0",
98
+ "next-themes": "^0.4.6",
99
+ "react": "^18.2.0",
100
+ "react-dom": "^18.2.0",
101
+ "tailwind-merge": "^3.3.1"
102
+ }
103
+ }