refactor: introduce repositories and expose study api client
This commit is contained in:
16
memora-web/src/services/api/study.ts
Normal file
16
memora-web/src/services/api/study.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { http } from '../http'
|
||||
import type { ReviewMode, ReviewResult, Word } from './types'
|
||||
|
||||
export async function createStudySession(limit = 10) {
|
||||
const res = await http.post<{ data: Word[] }>('/study/sessions', { limit })
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function submitStudyAnswer(payload: { wordId: number; answer: string; mode: ReviewMode }) {
|
||||
const res = await http.post<{ data: ReviewResult }>('/study/answers', {
|
||||
word_id: payload.wordId,
|
||||
answer: payload.answer,
|
||||
mode: payload.mode
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
Reference in New Issue
Block a user