refactor: Add getSessions function to fetch available sessions in IOModal
This commit is contained in:
parent
895df8c050
commit
818696a661
2 changed files with 20 additions and 3 deletions
|
|
@ -1040,6 +1040,19 @@ export async function getMessagesTable(
|
||||||
return { rows: rows.data, columns };
|
return { rows: rows.data, columns };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getSessions(id?: string): Promise<Array<string>> {
|
||||||
|
const config = {};
|
||||||
|
if (id) {
|
||||||
|
config["params"] = { flow_id: id };
|
||||||
|
}
|
||||||
|
const rows = await api.get(`${BASE_URL_API}monitor/messages`, config);
|
||||||
|
const sessions = new Set<string>();
|
||||||
|
rows.data.forEach((row) => {
|
||||||
|
sessions.add(row.session_id);
|
||||||
|
});
|
||||||
|
return Array.from(sessions);
|
||||||
|
}
|
||||||
|
|
||||||
export async function deleteMessagesFn(ids: number[]) {
|
export async function deleteMessagesFn(ids: number[]) {
|
||||||
try {
|
try {
|
||||||
return await api.delete(`${BASE_URL_API}monitor/messages`, {
|
return await api.delete(`${BASE_URL_API}monitor/messages`, {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import { cn } from "../../utils/utils";
|
||||||
import BaseModal from "../baseModal";
|
import BaseModal from "../baseModal";
|
||||||
import IOFieldView from "./components/IOFieldView";
|
import IOFieldView from "./components/IOFieldView";
|
||||||
import ChatView from "./components/chatView";
|
import ChatView from "./components/chatView";
|
||||||
|
import { getSessions } from "../../controllers/API";
|
||||||
|
|
||||||
export default function IOModal({
|
export default function IOModal({
|
||||||
children,
|
children,
|
||||||
|
|
@ -78,6 +79,7 @@ export default function IOModal({
|
||||||
const isBuilding = useFlowStore((state) => state.isBuilding);
|
const isBuilding = useFlowStore((state) => state.isBuilding);
|
||||||
const currentFlow = useFlowsManagerStore((state) => state.currentFlow);
|
const currentFlow = useFlowsManagerStore((state) => state.currentFlow);
|
||||||
const setNode = useFlowStore((state) => state.setNode);
|
const setNode = useFlowStore((state) => state.setNode);
|
||||||
|
const [sessions, setSessions] = useState<string[]>([]);
|
||||||
|
|
||||||
async function updateVertices() {
|
async function updateVertices() {
|
||||||
return updateVerticesOrder(currentFlow!.id, null);
|
return updateVerticesOrder(currentFlow!.id, null);
|
||||||
|
|
@ -113,9 +115,11 @@ export default function IOModal({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelectedViewField(startView());
|
setSelectedViewField(startView());
|
||||||
if (haveChat) {
|
// if (haveChat) {
|
||||||
//TODO: fetch avaliable Sessions
|
// getSessions().then((sessions) => {
|
||||||
}
|
// setSessions(sessions);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue