Skip to content

Commit

Permalink
refactor : about api querykey factor
Browse files Browse the repository at this point in the history
  • Loading branch information
jasper200207 committed Jan 16, 2024
1 parent 1ce9890 commit 026bce5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/api/aboutApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import axios from 'axios';
import { PageBlockInfo } from './dto';

const aboutKeys = {
titleType: ['titleType'] as const,
blockList: (params: { type: string }) => ['blockList', params] as const,
base: ['about'] as const,
titleType: () => [...aboutKeys.base, 'titleType'] as const,
blockList: (params: { type: string }) => [...aboutKeys.base, 'blockList', params] 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 }) => {
Expand Down

0 comments on commit 026bce5

Please sign in to comment.