36 lines
998 B
TypeScript
36 lines
998 B
TypeScript
import { http } from "@/shared/api/httpClient";
|
|
import {
|
|
CreateSessionResponseSchema,
|
|
ICreateSessionRequest,
|
|
ICreateSessionResponse,
|
|
IUpdateSessionRequest,
|
|
IUpdateSessionResponse,
|
|
UpdateSessionResponseSchema,
|
|
} from "./types";
|
|
import { API_ROUTES } from "@/shared/constants/api-routes";
|
|
|
|
export const createSession = async (
|
|
payload: ICreateSessionRequest
|
|
): Promise<ICreateSessionResponse> => {
|
|
return http.post<ICreateSessionResponse>(API_ROUTES.session(), payload, {
|
|
tags: ["session", "create"],
|
|
schema: CreateSessionResponseSchema,
|
|
revalidate: 0,
|
|
});
|
|
};
|
|
|
|
export const updateSession = async (
|
|
payload: IUpdateSessionRequest
|
|
): Promise<IUpdateSessionResponse> => {
|
|
// Отправляем только data без вложенности
|
|
return http.patch<IUpdateSessionResponse>(
|
|
API_ROUTES.session(payload.sessionId),
|
|
payload.data,
|
|
{
|
|
tags: ["session", "update"],
|
|
schema: UpdateSessionResponseSchema,
|
|
revalidate: 0,
|
|
}
|
|
);
|
|
};
|