add cards table and pagination

This commit is contained in:
2023-10-07 23:44:20 +02:00
parent 450d664f34
commit 33f3fc6137
21 changed files with 635 additions and 52 deletions

View File

@@ -1,4 +1,4 @@
import { DecksResponse } from './decks.types'
import { CardsResponse, DeckResponse, DecksResponse } from './decks.types'
import { baseApi } from '@/services'
@@ -7,7 +7,13 @@ const decksService = baseApi.injectEndpoints({
getDecks: builder.query<DecksResponse, void>({
query: () => `v1/decks`,
}),
getDeckById: builder.query<DeckResponse, { id: string }>({
query: ({ id }) => `v1/decks/${id}`,
}),
getDeckCards: builder.query<CardsResponse, { id: string }>({
query: ({ id }) => `v1/decks/${id}/cards`,
}),
}),
})
export const { useGetDecksQuery } = decksService
export const { useGetDecksQuery, useGetDeckByIdQuery, useGetDeckCardsQuery } = decksService

View File

@@ -31,3 +31,24 @@ export type DecksResponse = {
pagination: Pagination
items: Deck[]
}
export type DeckResponse = Deck
export type CardsResponse = {
pagination: Pagination
items: Card[]
}
export type Card = {
id: string
question: string
answer: string
deckId: string
questionImg?: string | null
answerImg?: string | null
created: string
updated: string
shots: number
grade: number
userId: string
}

View File

@@ -1 +1,2 @@
export * from './base-api'
export * from './decks'