diff --git a/src/api/dto.ts b/src/api/dto.ts index 06508b18..1c88ad9b 100644 --- a/src/api/dto.ts +++ b/src/api/dto.ts @@ -20,6 +20,11 @@ export type borrowStatus = '대출대기' | '반납대기' | '대출반려' | ' export type MemberType = '비회원' | '정회원' | '휴면회원' | '졸업' | '탈퇴'; +export interface PageAndSize { + page?: number; + size?: number; +} + export interface MemberInfo { memberId: number; loginId: number; @@ -94,11 +99,9 @@ export interface PageBlockInfo { subtitleImages: Array; } -export interface BookListSearch { +export interface BookListSearch extends PageAndSize { searchType?: 'title' | 'author' | 'all'; search?: string; - page?: number; - size?: number; } export interface BorrowInfoListSearch { @@ -405,11 +408,6 @@ export interface TrendingPostInfo { registerTime: string; } -export interface PageAndSize { - page?: number; - size?: number; -} - export interface AttendRankInfo { rank: number; thumbnailPath?: string | null; diff --git a/src/api/libraryApi.ts b/src/api/libraryApi.ts index 428b02ee..ff21af7b 100644 --- a/src/api/libraryApi.ts +++ b/src/api/libraryApi.ts @@ -1,6 +1,6 @@ import { useQuery, useMutation, useQueryClient } from 'react-query'; import axios from 'axios'; -import { BookInfo, BorrowedBookInfo, BookListSearch } from './dto'; +import { BookInfo, BorrowedBookInfo, BookListSearch, PageAndSize } from './dto'; const libraryKeys = { bookList: (params: BookListSearch) => ['bookList', params] as const, @@ -23,7 +23,7 @@ const useGetBookListQuery = ({ page, size = 6, searchType, search }: BookListSea ); }; -const useGetBorrowedBookListQuery = ({ page, size }: { page: number; size: number }) => { +const useGetBorrowedBookListQuery = ({ page, size }: PageAndSize) => { const fetcher = () => axios.get(`/books/book-borrows`, { params: { page, size } }).then(({ data }) => { return { content: data.content, totalElement: data.totalElements };