fix(frontend): make the widget stateful

This commit is contained in:
yassinedorbozgithub 2024-10-08 06:33:41 +01:00
parent 402bdb872c
commit 72d24498ac
2 changed files with 4 additions and 4 deletions

View File

@ -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}`;

View File

@ -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<LayoutProps> = ({
sxContent,
...rest
}) => {
const pathname = usePathname();
const [isSideBarOpen, setIsSideBarOpen] = useState(false);
return (
@ -46,7 +44,7 @@ export const Layout: React.FC<LayoutProps> = ({
<Content sx={sxContent} {...rest}>
{children}
</Content>
<ChatWidget pathname={pathname} />
<ChatWidget />
</Grid>
);
};