2024-06-01 15:47:53 +03:00
|
|
|
import { makeGetRequest, makePostRequest } from "./api";
|
2024-06-01 21:36:06 +03:00
|
|
|
import { AnswerType } from "./question";
|
2024-06-01 15:47:53 +03:00
|
|
|
|
|
|
|
export type Session = {
|
|
|
|
id: number;
|
|
|
|
right: number;
|
|
|
|
wrong: number;
|
|
|
|
total: number;
|
|
|
|
// user: string;
|
|
|
|
}
|
|
|
|
|
2024-06-01 17:40:01 +03:00
|
|
|
export type SessionState = {
|
|
|
|
answered: number;
|
|
|
|
wrong: number;
|
|
|
|
right: number;
|
|
|
|
category: string;
|
2024-06-01 21:36:06 +03:00
|
|
|
opened: boolean[];
|
|
|
|
answer: AnswerType[];
|
2024-06-01 23:42:20 +03:00
|
|
|
index: number;
|
2024-06-01 17:40:01 +03:00
|
|
|
}
|
|
|
|
|
2024-06-01 15:47:53 +03:00
|
|
|
export const getSession = async (id: number): Promise<Session> => {
|
|
|
|
return makeGetRequest( `sessions/${id}/` );
|
|
|
|
}
|
|
|
|
|
|
|
|
export const postSession = async (session: Session): Promise<Session> => {
|
|
|
|
return makePostRequest( `sessions`, session );
|
|
|
|
}
|