📝 (chatView/index.tsx): clean up import statements and improve code readability by removing unnecessary imports and reformatting code

📝 (chatView/index.tsx): refactor code to improve readability and maintainability by restructuring the filter and map functions
📝 (chatView/index.tsx): fix destructuring assignment to correctly access properties from output data
📝 (apiModal/views/index.tsx): remove unnecessary console.log statement to clean up code and improve code quality
This commit is contained in:
ogabrielluiz 2024-06-05 11:18:08 -03:00
commit 454ddcdc54
2 changed files with 8 additions and 12 deletions

View file

@ -9,11 +9,7 @@ import useAlertStore from "../../../../stores/alertStore";
import useFlowStore from "../../../../stores/flowStore"; import useFlowStore from "../../../../stores/flowStore";
import useFlowsManagerStore from "../../../../stores/flowsManagerStore"; import useFlowsManagerStore from "../../../../stores/flowsManagerStore";
import { VertexBuildTypeAPI, sendAllProps } from "../../../../types/api"; import { VertexBuildTypeAPI, sendAllProps } from "../../../../types/api";
import { import { ChatMessageType, ChatOutputType } from "../../../../types/chat";
ChatMessageType,
ChatOutputType,
FlowPoolObjectType,
} from "../../../../types/chat";
import { chatViewProps } from "../../../../types/components"; import { chatViewProps } from "../../../../types/components";
import { classNames } from "../../../../utils/utils"; import { classNames } from "../../../../utils/utils";
import ChatInput from "./chatInput"; import ChatInput from "./chatInput";
@ -64,12 +60,13 @@ export default function ChatView({
const chatMessages: ChatMessageType[] = chatOutputResponses const chatMessages: ChatMessageType[] = chatOutputResponses
.sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp)) .sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp))
// //
.filter((output) => output.data.messages && output.data.messages.length > 0) .filter(
(output) => output.data.messages && output.data.messages.length > 0
)
.map((output, index) => { .map((output, index) => {
try { try {
const { sender, message, sender_name, stream_url,files } = output.data const { sender, message, sender_name, stream_url, files } = output
.messages[0] as ChatOutputType; .data.messages[0] as ChatOutputType;
const is_ai = sender === "Machine" || sender === null; const is_ai = sender === "Machine" || sender === null;
return { return {
isSend: !is_ai, isSend: !is_ai,
@ -77,8 +74,7 @@ export default function ChatView({
sender_name, sender_name,
componentId: output.id, componentId: output.id,
stream_url: stream_url, stream_url: stream_url,
files files,
}; };
} catch (e) { } catch (e) {
console.error(e); console.error(e);

View file

@ -60,7 +60,7 @@ const ApiModal = forwardRef(
); );
const pythonCode = getPythonCode(flow?.name, tweak); const pythonCode = getPythonCode(flow?.name, tweak);
const widgetCode = getWidgetCode(flow?.id, flow?.name, autoLogin); const widgetCode = getWidgetCode(flow?.id, flow?.name, autoLogin);
console.log("flow", flow);
const includeWebhook = flow.webhook; const includeWebhook = flow.webhook;
const tweaksCode = buildTweaks(flow); const tweaksCode = buildTweaks(flow);
const codesArray = [ const codesArray = [