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:
commit
0918891c28
3 changed files with 7 additions and 2 deletions
|
|
@ -1124,5 +1124,8 @@ export async function deleteMessagesFn(ids: string[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateMessageApi(data: Message) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import {
|
||||||
ColGroupDef,
|
ColGroupDef,
|
||||||
SelectionChangedEvent,
|
SelectionChangedEvent,
|
||||||
} from "ag-grid-community";
|
} from "ag-grid-community";
|
||||||
|
import { cloneDeep } from "lodash";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import TableComponent from "../../../../components/tableComponent";
|
import TableComponent from "../../../../components/tableComponent";
|
||||||
import useAlertStore from "../../../../stores/alertStore";
|
import useAlertStore from "../../../../stores/alertStore";
|
||||||
|
|
@ -37,7 +38,7 @@ export default function MessagesPage() {
|
||||||
function handleUpdateMessage(event: CellEditRequestEvent<any, string>) {
|
function handleUpdateMessage(event: CellEditRequestEvent<any, string>) {
|
||||||
const newValue = event.newValue;
|
const newValue = event.newValue;
|
||||||
const field = event.column.getColId();
|
const field = event.column.getColId();
|
||||||
const row = event.data;
|
const row = cloneDeep(event.data);
|
||||||
const data = {
|
const data = {
|
||||||
...row,
|
...row,
|
||||||
[field]: newValue,
|
[field]: newValue,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ type Message = {
|
||||||
sender_name: string;
|
sender_name: string;
|
||||||
session_id: string;
|
session_id: string;
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
|
files: Array<string>;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue