fix edit method on messages (#2435)

fix bug where messages couldn't be edited.
Change post to put on frontend
This commit is contained in:
anovazzi1 2024-06-28 20:30:07 +00:00 committed by GitHub
commit 0918891c28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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

@ -4,6 +4,7 @@ import {
ColGroupDef,
SelectionChangedEvent,
} from "ag-grid-community";
import { cloneDeep } from "lodash";
import { useState } from "react";
import TableComponent from "../../../../components/tableComponent";
import useAlertStore from "../../../../stores/alertStore";
@ -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;
};