mirror of
https://github.com/ershisan99/flashcards-example-project.git
synced 2026-01-03 20:52:12 +00:00
add cards table and pagination
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export * from './base-api'
|
||||
export * from './decks'
|
||||
|
||||
Reference in New Issue
Block a user