Skip to content

Commit

Permalink
refactor : type PageAndSize 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
pipisebastian committed Dec 28, 2023
1 parent 808b49d commit a7c7b91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions src/api/dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export type borrowStatus = '대출대기' | '반납대기' | '대출반려' | '

export type MemberType = '비회원' | '정회원' | '휴면회원' | '졸업' | '탈퇴';

export interface PageAndSize {
page?: number;
size?: number;
}

export interface MemberInfo {
memberId: number;
loginId: number;
Expand Down Expand Up @@ -94,11 +99,9 @@ export interface PageBlockInfo {
subtitleImages: Array<SubTitleImagesInfo>;
}

export interface BookListSearch {
export interface BookListSearch extends PageAndSize {
searchType?: 'title' | 'author' | 'all';
search?: string;
page?: number;
size?: number;
}

export interface BorrowInfoListSearch {
Expand Down Expand Up @@ -405,11 +408,6 @@ export interface TrendingPostInfo {
registerTime: string;
}

export interface PageAndSize {
page?: number;
size?: number;
}

export interface AttendRankInfo {
rank: number;
thumbnailPath?: string | null;
Expand Down
4 changes: 2 additions & 2 deletions src/api/libraryApi.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 };
Expand Down

0 comments on commit a7c7b91

Please sign in to comment.