From 72d24498ac7165001f8d8e4eca846ef47f1fff7e Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Tue, 8 Oct 2024 06:33:41 +0100 Subject: [PATCH] fix(frontend): make the widget stateful --- frontend/src/app-components/widget/ChatWidget.tsx | 4 +++- frontend/src/layout/index.tsx | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/app-components/widget/ChatWidget.tsx b/frontend/src/app-components/widget/ChatWidget.tsx index 1628611a..f5c541dd 100644 --- a/frontend/src/app-components/widget/ChatWidget.tsx +++ b/frontend/src/app-components/widget/ChatWidget.tsx @@ -8,6 +8,7 @@ import { Avatar, Box } from "@mui/material"; import UiChatWidget from "hexabot-widget/src/UiChatWidget"; +import { usePathname } from "next/navigation"; import { getAvatarSrc } from "@/components/inbox/helpers/mapMessages"; import { useConfig } from "@/hooks/useConfig"; @@ -16,7 +17,8 @@ import { EntityType, RouterType } from "@/services/types"; import { ChatWidgetHeader } from "./ChatWidgetHeader"; -export const ChatWidget = ({ pathname }: { pathname: string }) => { +export const ChatWidget = () => { + const pathname = usePathname(); const { apiUrl } = useConfig(); const isVisualEditor = pathname === `/${RouterType.VISUAL_EDITOR}`; diff --git a/frontend/src/layout/index.tsx b/frontend/src/layout/index.tsx index d18589f9..2619bc34 100644 --- a/frontend/src/layout/index.tsx +++ b/frontend/src/layout/index.tsx @@ -7,7 +7,6 @@ */ import { BoxProps, Grid } from "@mui/material"; -import { usePathname } from "next/navigation"; import { useState } from "react"; import { ChatWidget } from "@/app-components/widget/ChatWidget"; @@ -29,7 +28,6 @@ export const Layout: React.FC = ({ sxContent, ...rest }) => { - const pathname = usePathname(); const [isSideBarOpen, setIsSideBarOpen] = useState(false); return ( @@ -46,7 +44,7 @@ export const Layout: React.FC = ({ {children} - + ); };