Skip to content

Commit

Permalink
FIX : 쿼리키 변경 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jobkaeHenry committed Dec 5, 2023
1 parent 5f69086 commit 1b48ece
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions client/src/app/(logoutOnly)/auth/signup/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type layoutProps = {
children: ReactNode;
};

const layout = ({ children }: layoutProps) => {
const SignupLayout = ({ children }: layoutProps) => {
const [disableBtn, setDisableBtn] = useState(false);
const [formData, setFormData] = useState<SignupRequirement>({
id: "",
Expand All @@ -35,4 +35,4 @@ const layout = ({ children }: layoutProps) => {
);
};

export default layout;
export default SignupLayout;
2 changes: 1 addition & 1 deletion client/src/queries/attach/useNewAttachMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const useNewAttachMutation = () => {
});
queryClient.invalidateQueries({
queryKey: getPostListInfiniteQueryKey.byKeyword({
userNo: String(context?.url.pk),
searchUserNos: String(context?.url.pk),
}),
});
case "ALCOHOL":
Expand Down
15 changes: 9 additions & 6 deletions client/src/queries/post/updator/useOptimisticUpdatePostList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { AugmentedGetPostListResponse } from "../useGetPostListInfiniteQuery";
type QueryKey = readonly [
"posts",
{
readonly keyword: string | undefined;
readonly userNo: string | undefined;
readonly searchKeyword: string | undefined;
readonly searchUserNos: string | undefined;
readonly sort: string | undefined;
}
];

Expand All @@ -15,9 +16,11 @@ type QueryKey = readonly [
* @param 'like' | 'unlike'
* @returns queryKey와 postId 를 인자로 받아 무한스크롤포스트 리스트를 업데이트하는 함수
*/
export const useOptimisticUpdatePostList = (
{type = "like"}: {type:"like" | "unlike"}
) => {
export const useOptimisticUpdatePostList = ({
type = "like",
}: {
type: "like" | "unlike";
}) => {
const queryClient = useQueryClient();
/**
* queryKey와 postId 를 인자로 받아 무한스크롤포스트 리스트를 업데이트하는 함수
Expand All @@ -36,7 +39,7 @@ export const useOptimisticUpdatePostList = (
...prev,
pages: prev.pages.map((page) => ({
...page,
list: page.list.map((post) => {
content: page.content.map((post) => {
if (post.postNo === Number(id)) {
return {
...post,
Expand Down
11 changes: 6 additions & 5 deletions client/src/queries/post/useGetPostListInfiniteQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const useGetPostListInfiniteQuery = ({
queryKey: getPostListInfiniteQueryKey.byKeyword({
searchKeyword,
searchUserNos,
sort
sort,
}),

queryFn: async ({ pageParam = 0 }) =>
Expand Down Expand Up @@ -102,10 +102,11 @@ export const getPostListQueryFn = async ({
};
};

// export interface PostListInfiniteQueryKey {
// keyword?: string;
// userNo?: string;
// }
export interface PostListInfiniteQueryKey {
keyword?: string;
userNo?: string;
sort?: string;
}

export const getPostListInfiniteQueryKey = {
all: ["posts"] as const,
Expand Down
4 changes: 2 additions & 2 deletions client/src/queries/post/useLikePostMutation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const useLikePostMutation = (context?: PostcardContextInterface) => {
const postDetailUpdator = useOptimisticUpdatePostDetail({ type: "like" });

const listQueryKey = getPostListInfiniteQueryKey.byKeyword({
keyword: context?.searchKeyword,
userNo: context?.searchUserNos,
searchKeyword: context?.searchKeyword,
searchUserNos: context?.searchUserNos,
});
return useMutation({
mutationFn: (id: PostInterface["postNo"]) => useLikePostMutationFn(id),
Expand Down
4 changes: 2 additions & 2 deletions client/src/queries/post/useUnLikePostMutation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const useLikePostMutation = (context?: PostcardContextInterface) => {
const postDetailUpdator = useOptimisticUpdatePostDetail({ type: "unlike" });

const listQueryKey = getPostListInfiniteQueryKey.byKeyword({
keyword: context?.searchKeyword,
userNo: context?.searchUserNos,
searchKeyword: context?.searchKeyword,
searchUserNos: context?.searchUserNos,
});
return useMutation({
mutationFn: (id: PostInterface["postNo"]) => useLikePostMutationFn(id),
Expand Down

0 comments on commit 1b48ece

Please sign in to comment.