add components

This commit is contained in:
andres
2023-09-09 17:03:16 +02:00
parent 4e301916f4
commit 450d664f34
35 changed files with 550 additions and 25 deletions

View File

@@ -9,13 +9,5 @@ export const baseApi = createApi({
headers.append('x-auth-skip', 'true')
},
}),
endpoints: builder => {
return {
getDecks: builder.query<any, void>({
query: () => `v1/decks`,
}),
}
},
endpoints: () => ({}),
})
export const { useGetDecksQuery } = baseApi

View File

@@ -0,0 +1,13 @@
import { DecksResponse } from './decks.types'
import { baseApi } from '@/services'
const decksService = baseApi.injectEndpoints({
endpoints: builder => ({
getDecks: builder.query<DecksResponse, void>({
query: () => `v1/decks`,
}),
}),
})
export const { useGetDecksQuery } = decksService

View File

@@ -0,0 +1,33 @@
export type Pagination = {
totalPages: number
currentPage: number
itemsPerPage: number
totalItems: number
}
export type Author = {
id: string
name: string
}
export type Deck = {
id: string
userId: string
name: string
isPrivate: boolean
shots: number
cover?: string | null
rating: number
isDeleted: boolean | null
isBlocked?: boolean | null
created: string
updated: string
cardsCount: number
author: Author
}
export type DecksResponse = {
maxCardsCount: number
pagination: Pagination
items: Deck[]
}

View File

@@ -0,0 +1,2 @@
export * from './decks.service'
export * from './decks.types'

1
src/services/index.ts Normal file
View File

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