mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(frontend): make the widget stateful
This commit is contained in:
parent
402bdb872c
commit
72d24498ac
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import { Avatar, Box } from "@mui/material";
|
import { Avatar, Box } from "@mui/material";
|
||||||
import UiChatWidget from "hexabot-widget/src/UiChatWidget";
|
import UiChatWidget from "hexabot-widget/src/UiChatWidget";
|
||||||
|
import { usePathname } from "next/navigation";
|
||||||
|
|
||||||
import { getAvatarSrc } from "@/components/inbox/helpers/mapMessages";
|
import { getAvatarSrc } from "@/components/inbox/helpers/mapMessages";
|
||||||
import { useConfig } from "@/hooks/useConfig";
|
import { useConfig } from "@/hooks/useConfig";
|
||||||
@ -16,7 +17,8 @@ import { EntityType, RouterType } from "@/services/types";
|
|||||||
|
|
||||||
import { ChatWidgetHeader } from "./ChatWidgetHeader";
|
import { ChatWidgetHeader } from "./ChatWidgetHeader";
|
||||||
|
|
||||||
export const ChatWidget = ({ pathname }: { pathname: string }) => {
|
export const ChatWidget = () => {
|
||||||
|
const pathname = usePathname();
|
||||||
const { apiUrl } = useConfig();
|
const { apiUrl } = useConfig();
|
||||||
const isVisualEditor = pathname === `/${RouterType.VISUAL_EDITOR}`;
|
const isVisualEditor = pathname === `/${RouterType.VISUAL_EDITOR}`;
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { BoxProps, Grid } from "@mui/material";
|
import { BoxProps, Grid } from "@mui/material";
|
||||||
import { usePathname } from "next/navigation";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
import { ChatWidget } from "@/app-components/widget/ChatWidget";
|
import { ChatWidget } from "@/app-components/widget/ChatWidget";
|
||||||
@ -29,7 +28,6 @@ export const Layout: React.FC<LayoutProps> = ({
|
|||||||
sxContent,
|
sxContent,
|
||||||
...rest
|
...rest
|
||||||
}) => {
|
}) => {
|
||||||
const pathname = usePathname();
|
|
||||||
const [isSideBarOpen, setIsSideBarOpen] = useState(false);
|
const [isSideBarOpen, setIsSideBarOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -46,7 +44,7 @@ export const Layout: React.FC<LayoutProps> = ({
|
|||||||
<Content sx={sxContent} {...rest}>
|
<Content sx={sxContent} {...rest}>
|
||||||
{children}
|
{children}
|
||||||
</Content>
|
</Content>
|
||||||
<ChatWidget pathname={pathname} />
|
<ChatWidget />
|
||||||
</Grid>
|
</Grid>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user