fix edit method on messages

This commit is contained in:
anovazzi1 2024-06-28 15:34:38 -03:00 committed by Gabriel Luiz Freitas Almeida
commit 5cbe19934e
3 changed files with 7 additions and 2 deletions

View file

@ -1124,5 +1124,8 @@ export async function deleteMessagesFn(ids: string[]) {
}
export async function updateMessageApi(data: Message) {
return await api.post(`${BASE_URL_API}monitor/messages/${data.id}`, data);
if(data.files && typeof data.files === 'string'){
data.files = JSON.parse(data.files);
}
return await api.put(`${BASE_URL_API}monitor/messages/${data.id}`, data);
}

View file

@ -13,6 +13,7 @@ import HeaderMessagesComponent from "./components/headerMessages";
import useMessagesTable from "./hooks/use-messages-table";
import useRemoveMessages from "./hooks/use-remove-messages";
import useUpdateMessage from "./hooks/use-updateMessage";
import { cloneDeep } from "lodash";
export default function MessagesPage() {
const [columns, setColumns] = useState<Array<ColDef | ColGroupDef>>([]);
@ -37,7 +38,7 @@ export default function MessagesPage() {
function handleUpdateMessage(event: CellEditRequestEvent<any, string>) {
const newValue = event.newValue;
const field = event.column.getColId();
const row = event.data;
const row = cloneDeep(event.data);
const data = {
...row,
[field]: newValue,

View file

@ -6,6 +6,7 @@ type Message = {
sender_name: string;
session_id: string;
timestamp: string;
files:Array<string>;
id: string;
};