Skip to content

Commit

Permalink
Merge pull request #872 from KEEPER31337/feature/aboutApi_쿼리키_포맷_통일_#864
Browse files Browse the repository at this point in the history
refactor : about api 쿼리키 포멧 통일
  • Loading branch information
jasper200207 authored Jan 18, 2024
2 parents c51de75 + dd34d56 commit 2c2edbb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/api/aboutApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ import axios from 'axios';
import { PageBlockInfo } from './dto';

const aboutKeys = {
titleType: ['titleType'] as const,
blockList: ['blockList'] as const,
base: ['about'] as const,
titleType: () => [...aboutKeys.base, 'titles', 'types'] as const,
blockList: (type: string) => [...aboutKeys.base, 'titles', 'types', type] as const,
};

const useGetTitleTypesQuery = () => {
const fetcher = () => axios.get(`/about/titles/types`).then(({ data }) => data.list);

return useQuery<string[]>(aboutKeys.titleType, fetcher);
return useQuery<string[]>(aboutKeys.titleType(), fetcher);
};

const useGetBlockListQuery = ({ type }: { type: string }) => {
const fetcher = () => axios.get(`/about/titles/types/${type}`).then(({ data }) => data);

return useQuery<PageBlockInfo>([aboutKeys.blockList, type], fetcher);
return useQuery<PageBlockInfo>(aboutKeys.blockList(type), fetcher);
};

export { useGetTitleTypesQuery, useGetBlockListQuery };

0 comments on commit 2c2edbb

Please sign in to comment.