📝 (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 useFlowsManagerStore from "../../../../stores/flowsManagerStore";
import { VertexBuildTypeAPI, sendAllProps } from "../../../../types/api";
import {
ChatMessageType,
ChatOutputType,
FlowPoolObjectType,
} from "../../../../types/chat";
import { ChatMessageType, ChatOutputType } from "../../../../types/chat";
import { chatViewProps } from "../../../../types/components";
import { classNames } from "../../../../utils/utils";
import ChatInput from "./chatInput";
@ -64,12 +60,13 @@ export default function ChatView({
const chatMessages: ChatMessageType[] = chatOutputResponses
.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) => {
try {
const { sender, message, sender_name, stream_url,files } = output.data
.messages[0] as ChatOutputType;
const { sender, message, sender_name, stream_url, files } = output
.data.messages[0] as ChatOutputType;
const is_ai = sender === "Machine" || sender === null;
return {
isSend: !is_ai,
@ -77,8 +74,7 @@ export default function ChatView({
sender_name,
componentId: output.id,
stream_url: stream_url,
files
files,
};
} catch (e) {
console.error(e);

View file

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