next-app/app/lib/session.ts

24 lines
517 B
TypeScript
Raw Normal View History

2024-06-01 15:47:53 +03:00
import { makeGetRequest, makePostRequest } from "./api";
export type Session = {
id: number;
right: number;
wrong: number;
total: number;
// user: string;
}
export type SessionState = {
answered: number;
wrong: number;
right: number;
category: string;
}
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 );
}