78 lines
1.6 KiB
TypeScript
78 lines
1.6 KiB
TypeScript
import {
|
|
httpGetInterceptor,
|
|
httpPostInterceptor,
|
|
} from "./http-config/http-interceptor-services";
|
|
|
|
export interface ScheduleData {
|
|
title: string;
|
|
description: string;
|
|
summary: string;
|
|
scheduled_at: string;
|
|
duration: number;
|
|
chat_session_id: number;
|
|
}
|
|
|
|
export interface ScheduleChatSessionData {
|
|
name: string;
|
|
type: string;
|
|
userIds: number[];
|
|
}
|
|
|
|
export interface ScheduleResponse {
|
|
error: boolean;
|
|
message: string;
|
|
data: {
|
|
id: number;
|
|
title: string;
|
|
description: string;
|
|
summary: string;
|
|
scheduled_at: string;
|
|
duration: number;
|
|
};
|
|
}
|
|
|
|
// Create schedule
|
|
export async function createSchedule(
|
|
scheduleData: ScheduleData
|
|
): Promise<ScheduleResponse> {
|
|
const response = await httpPostInterceptor("/chat/schedules", scheduleData);
|
|
return response?.data;
|
|
}
|
|
|
|
// Upload schedule files
|
|
export async function uploadScheduleFiles(
|
|
scheduleId: number,
|
|
files: File[]
|
|
): Promise<any> {
|
|
const formData = new FormData();
|
|
|
|
files.forEach((file) => {
|
|
formData.append("files", file);
|
|
});
|
|
|
|
const response = await httpPostInterceptor(
|
|
`/chat/schedule-files/${scheduleId}`,
|
|
formData,
|
|
{
|
|
"Content-Type": "multipart/form-data",
|
|
}
|
|
);
|
|
|
|
return response;
|
|
}
|
|
|
|
export async function createChatSessionId(
|
|
scheduleChatData: ScheduleChatSessionData
|
|
) {
|
|
const response = await httpPostInterceptor(
|
|
"/chat/sessions",
|
|
scheduleChatData
|
|
);
|
|
return response?.data;
|
|
}
|
|
|
|
export async function getSchedulesData(schedule: any) {
|
|
const response = await httpGetInterceptor("/chat/schedules");
|
|
return response?.data;
|
|
}
|