Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor : merit Api querykey factor #874

Merged
merged 5 commits into from
Jan 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/api/meritApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import axios from 'axios';
import { PageAndSize, MeritLog, MeritType, MembersMerit } from './dto';

const meritKeys = {
meritLog: (param: PageAndSize & { meritType?: string }) => ['meritLog', param] as const,
meritType: (param: PageAndSize) => ['meritType', param] as const,
membersMerit: (param: PageAndSize) => ['membersMerit', param] as const,
memberMerit: (param: PageAndSize & { memberId: number }) => ['memberMerit', param] as const,
base: ['merits'] as const,
meritLog: (param: PageAndSize & { meritType?: string }) => [...meritKeys.base, param] as const,
meritType: (param: PageAndSize) => [...meritKeys.base, 'types', param] as const,
membersMerit: (param: PageAndSize) => [...meritKeys.base, 'members', param] as const,
memberMerit: (memberId: number, param: PageAndSize) => [...meritKeys.base, 'members', memberId, param] as const,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

param -> params
로 변경해주세요~!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다!


const useGetMeritLogQuery = ({ page, size = 10, meritType = 'ALL' }: PageAndSize & { meritType?: string }) => {
Expand Down Expand Up @@ -56,7 +57,7 @@ const useGetMemberMeritQuery = ({ page, size = 10, memberId }: PageAndSize & { m
})
.then(({ data }) => data);

return useQuery<MeritLog>(meritKeys.memberMerit({ page, size, memberId }), fetcher, {
return useQuery<MeritLog>(meritKeys.memberMerit(memberId, { page, size }), fetcher, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ page, size } -> params로 변수 따로 빼서 fetcher랑 같이 반영해줘도 좋을 것 같습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다

keepPreviousData: true,
});
};
Expand Down
Loading