next-app/app/lib/session.ts
Alex Stan 1c6c5327c3 made the quiz functional
Signed-off-by: Alex Stan <alex.stan.2010@proton.me>

Fixed merge conflicts
2024-06-01 21:41:34 +03:00

27 lines
No EOL
603 B
TypeScript

import { makeGetRequest, makePostRequest } from "./api";
import { AnswerType } from "./question";
export type Session = {
id: number;
right: number;
wrong: number;
total: number;
// user: string;
}
export type SessionState = {
answered: number;
wrong: number;
right: number;
category: string;
opened: boolean[];
answer: AnswerType[];
}
export const getSession = async (id: number): Promise<Session> => {
return makeGetRequest( `sessions/${id}/` );
}
export const postSession = async (session: Session): Promise<Session> => {
return makePostRequest( `sessions`, session );
}