diff --git a/frontend/src/components/inbox/hooks/ChatContext.tsx b/frontend/src/components/inbox/hooks/ChatContext.tsx index b7559de2..ff69d316 100644 --- a/frontend/src/components/inbox/hooks/ChatContext.tsx +++ b/frontend/src/components/inbox/hooks/ChatContext.tsx @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. @@ -7,17 +7,16 @@ */ import { + Dispatch, PropsWithChildren, createContext, - useState, - Dispatch, useContext, + useState, } from "react"; import { useGet } from "@/hooks/crud/useGet"; import { EntityType, Format } from "@/services/types"; import { ISubscriber } from "@/types/subscriber.types"; -import { useSocketGetQuery } from "@/websocket/socket-hooks"; import { noop } from "../helpers/noop"; @@ -49,10 +48,6 @@ export const ChatProvider = ({ children }: PropsWithChildren) => { setSubscriberId, }; - useSocketGetQuery("/message/subscribe/"); - - useSocketGetQuery("/subscriber/subscribe/"); - return ( {children} ); diff --git a/frontend/src/layout/AnonymousLayout.tsx b/frontend/src/layout/AnonymousLayout.tsx new file mode 100644 index 00000000..f9a276e6 --- /dev/null +++ b/frontend/src/layout/AnonymousLayout.tsx @@ -0,0 +1,30 @@ +/* + * Copyright © 2025 Hexastack. All rights reserved. + * + * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: + * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. + * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). + */ + +import { Grid } from "@mui/material"; + +import { LayoutProps } from "."; + +import { ChatWidget } from "@/app-components/widget/ChatWidget"; + +import { Content } from "./content"; +import { Header } from "./Header"; + +export const AnonymousLayout: React.FC = ({ + children, + sxContent, + ...rest +}) => ( + +
+ + {children} + + + +); diff --git a/frontend/src/layout/AuthenticatedLayout.tsx b/frontend/src/layout/AuthenticatedLayout.tsx new file mode 100644 index 00000000..8a5e5e9f --- /dev/null +++ b/frontend/src/layout/AuthenticatedLayout.tsx @@ -0,0 +1,49 @@ +/* + * Copyright © 2025 Hexastack. All rights reserved. + * + * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: + * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. + * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). + */ + +import { Grid } from "@mui/material"; +import { useState } from "react"; + +import { LayoutProps } from "."; + +import { ChatWidget } from "@/app-components/widget/ChatWidget"; +import { useSocketGetQuery } from "@/websocket/socket-hooks"; + +import { Content } from "./content"; +import { Header } from "./Header"; +import { VerticalMenu } from "./VerticalMenu"; + +export const AuthenticatedLayout: React.FC = ({ + children, + sxContent, + ...rest +}) => { + const [isSideBarOpen, setIsSideBarOpen] = useState(false); + + useSocketGetQuery("/message/subscribe/"); + + useSocketGetQuery("/subscriber/subscribe/"); + + return ( + +
setIsSideBarOpen(true)} + /> + setIsSideBarOpen(true)} + onToggleOut={() => setIsSideBarOpen(false)} + /> + + {children} + + + + ); +}; diff --git a/frontend/src/layout/Header.tsx b/frontend/src/layout/Header.tsx index 6f773062..50a487f6 100644 --- a/frontend/src/layout/Header.tsx +++ b/frontend/src/layout/Header.tsx @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. @@ -69,8 +69,8 @@ const StyledAppBar = styled(AppBar)(() => ({ })); export type HeaderProps = { - isSideBarOpen: boolean; - onToggleSidebar: () => void; + isSideBarOpen?: boolean; + onToggleSidebar?: () => void; }; export const Header: FC = ({ isSideBarOpen, onToggleSidebar }) => { const { apiUrl, ssoEnabled } = useConfig(); diff --git a/frontend/src/layout/index.tsx b/frontend/src/layout/index.tsx index 2619bc34..8ad6b330 100644 --- a/frontend/src/layout/index.tsx +++ b/frontend/src/layout/index.tsx @@ -1,19 +1,17 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). */ -import { BoxProps, Grid } from "@mui/material"; -import { useState } from "react"; +import { BoxProps } from "@mui/material"; -import { ChatWidget } from "@/app-components/widget/ChatWidget"; +import { useAuth } from "@/hooks/useAuth"; -import { Content } from "./content"; -import { Header } from "./Header"; -import { VerticalMenu } from "./VerticalMenu"; +import { AnonymousLayout } from "./AnonymousLayout"; +import { AuthenticatedLayout } from "./AuthenticatedLayout"; export interface IContentPaddingProps { hasNoPadding?: boolean; @@ -23,28 +21,12 @@ export type LayoutProps = IContentPaddingProps & { children: JSX.Element; sxContent?: BoxProps; }; -export const Layout: React.FC = ({ - children, - sxContent, - ...rest -}) => { - const [isSideBarOpen, setIsSideBarOpen] = useState(false); +export const Layout: React.FC = ({ children, ...rest }) => { + const { isAuthenticated } = useAuth(); - return ( - -
setIsSideBarOpen(true)} - /> - setIsSideBarOpen(true)} - onToggleOut={() => setIsSideBarOpen(false)} - /> - - {children} - - - + return isAuthenticated ? ( + {children} + ) : ( + {children} ); };