Skip to content

Commit

Permalink
refactor: lotusQueryOptions query 파일로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
ATeals committed Nov 25, 2024
1 parent 76a75b3 commit 01c1a73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
6 changes: 0 additions & 6 deletions apps/frontend/src/feature/lotus/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { LotusType } from './type';
import { CodeViewValue } from '@/feature/codeView';
import { api } from '@/shared/common/api';
import { createQueryOptions } from '@/shared/createQueryOptions';
import { PageType } from '@/shared/pagination';

export const getLotusList = async ({ page = 1 }: { page: number }) => {
Expand Down Expand Up @@ -77,8 +76,3 @@ export const createLotus = async ({

return data;
};

export const lotusQueryOptions = createQueryOptions('lotus', {
list: getLotusList,
detail: getLotusDetail
});
24 changes: 6 additions & 18 deletions apps/frontend/src/feature/lotus/query.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
import { useMutation, useSuspenseQuery } from '@tanstack/react-query';
import { useMutation } from '@tanstack/react-query';
import { createLotus, deleteLotus, getLotusDetail, getLotusList, updateLotus } from './api';
import { createQueryOptions } from '@/shared/createQueryOptions';

export const useLotusListSuspenseQuery = ({ page = 1 }: { page?: number } = {}) => {
const query = useSuspenseQuery({
queryKey: ['lotus', page],
queryFn: async () => getLotusList({ page })
});

return query;
};

export const useLotusSuspenseQuery = ({ id }: { id: string }) => {
const query = useSuspenseQuery({
queryKey: ['lotus', 'detail', id],
queryFn: async () => getLotusDetail({ id })
});

return query;
};
export const lotusQueryOptions = createQueryOptions('lotus', {
list: getLotusList,
detail: getLotusDetail
});

export const useLotusDeleteMutation = () => {
const mutation = useMutation({
Expand Down

0 comments on commit 01c1a73

Please sign in to comment.