mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
refactor: add key generation based on selected settings by specific field(s)
This commit is contained in:
@@ -8,8 +8,12 @@
|
||||
|
||||
import { Avatar, Box } from "@mui/material";
|
||||
import UiChatWidget from "hexabot-chat-widget/src/UiChatWidget";
|
||||
import {
|
||||
extractSettingValues,
|
||||
generateUUIDFromString,
|
||||
} from "hexabot-chat-widget/src/utils/text";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useMemo } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { getAvatarSrc } from "@/components/inbox/helpers/mapMessages";
|
||||
import { useLoadSettings } from "@/hooks/entities/auth-hooks";
|
||||
@@ -26,15 +30,24 @@ export const ChatWidget = () => {
|
||||
const { isAuthenticated } = useAuth();
|
||||
const isVisualEditor = pathname === `/${RouterType.VISUAL_EDITOR}`;
|
||||
const { data: settings } = useLoadSettings();
|
||||
const key = useMemo(
|
||||
() =>
|
||||
JSON.stringify(
|
||||
settings?.["console_channel"]?.find(
|
||||
(s) => s.label === "allowed_domains",
|
||||
)?.value,
|
||||
),
|
||||
[settings],
|
||||
);
|
||||
const [key, setKey] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
const settingValues = extractSettingValues(settings, [
|
||||
{
|
||||
group: "console_channel",
|
||||
label: "allowed_domains",
|
||||
selectedField: "value",
|
||||
},
|
||||
{
|
||||
group: "console_channel",
|
||||
label: "theme_color",
|
||||
selectedField: "value",
|
||||
},
|
||||
]);
|
||||
|
||||
setKey(generateUUIDFromString(settingValues.join()));
|
||||
}, [settings]);
|
||||
|
||||
return isAuthenticated ? (
|
||||
<Box
|
||||
|
||||
Reference in New Issue
Block a user