From 33bd269e375dd44b18a098dda7d9fee4f18c46a9 Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sat, 9 Dec 2023 10:39:46 +0900 Subject: [PATCH 1/4] =?UTF-8?q?Fix=20:=20=EC=83=88=EB=A1=9C=EC=9A=B4=20Axi?= =?UTF-8?q?os=20=EC=9D=B8=EC=8A=A4=ED=84=B4=EC=8A=A4=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/queries/attach/useNewAttachMutation.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/queries/attach/useNewAttachMutation.ts b/client/src/queries/attach/useNewAttachMutation.ts index 56c526f..8023490 100644 --- a/client/src/queries/attach/useNewAttachMutation.ts +++ b/client/src/queries/attach/useNewAttachMutation.ts @@ -5,8 +5,9 @@ import { getPostListInfiniteQueryKey } from "./../post/useGetPostListInfiniteQue import { postDetailQueryKey } from "../post/useGetPostDetailQuery"; import { MyInfoQueryKeys } from "../auth/useMyInfoQuery"; import { UserInfoQueryKey } from "../user/useUserInfoQuery"; -import useAxiosPrivate from "@/hooks/useAxiosPrivate"; import { ImageSize } from "@/types/attach/attachInterface"; +import axios from "axios"; +import getTokenFromLocalStorage from "@/utils/getTokenFromLocalStorage"; export const useNewAttachMutation = () => { const errorHandler = useErrorHandler(); @@ -64,17 +65,17 @@ export const postImageFn = async ( { type, pk }: NewAttatchRequestUrl, size?: ImageSize ) => { - const axiosPrivate = useAxiosPrivate(); const formData = new FormData(); formData.append("image", file); - const { data } = await axiosPrivate.post<{ attachNo: number }>( + const { data } = await axios.post<{ attachNo: number }>( ATTACH_FILE(type, pk), formData, { params: size, headers: { "Content-Type": "multipart/form-data", + Authorization: getTokenFromLocalStorage(), }, transformRequest: [ function () { From 99d5abadf75ee4ffe21051eb70b625c966140eee Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sat, 9 Dec 2023 10:40:25 +0900 Subject: [PATCH 2/4] =?UTF-8?q?Refactor=20:=20=EC=BF=BC=EB=A6=AC=20enable?= =?UTF-8?q?=20=EC=98=B5=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/queries/alcohol/useGetAlcoholListQuery.tsx | 6 ++---- client/src/queries/auth/useMyInfoQuery.tsx | 6 +----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/client/src/queries/alcohol/useGetAlcoholListQuery.tsx b/client/src/queries/alcohol/useGetAlcoholListQuery.tsx index b2556e5..d5d8a94 100644 --- a/client/src/queries/alcohol/useGetAlcoholListQuery.tsx +++ b/client/src/queries/alcohol/useGetAlcoholListQuery.tsx @@ -7,13 +7,11 @@ const useGetAlcoholListQuery = (keyword?: string) => { return useQuery({ queryKey: AlcohilListQueryKey.byKeyword(keyword), queryFn: async () => await getAlcoholListByKeyword(keyword), + enabled: keyword!=undefined, }); }; export const getAlcoholListByKeyword = async (keyword?: string) => { - if (keyword === "") { - return { list: [], totalCount: 0 }; - } const { data } = await axios.get<{ list: AlcoholDetailInterface[]; totalCount: number; @@ -23,7 +21,7 @@ export const getAlcoholListByKeyword = async (keyword?: string) => { size: 5, searchKeyword: keyword, }, - }); + }); return data; }; diff --git a/client/src/queries/auth/useMyInfoQuery.tsx b/client/src/queries/auth/useMyInfoQuery.tsx index 4630e86..a12697d 100644 --- a/client/src/queries/auth/useMyInfoQuery.tsx +++ b/client/src/queries/auth/useMyInfoQuery.tsx @@ -27,15 +27,11 @@ export const useMyInfoQuery = () => { throw Error(); } }, + enabled: !!getTokenFromLocalStorage(), }); }; export const getMyInfoByLocalStorage = async () => { - const accessToken = getTokenFromLocalStorage(); - - if (!accessToken) { - return null; - } const axiosPrivate = useAxiosPrivate(); const { data } = await axiosPrivate.get(MY_INFO); return data; From b7f3f5784b386c0f2b69fbd833170e8e0c2185a4 Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sat, 9 Dec 2023 10:40:36 +0900 Subject: [PATCH 3/4] =?UTF-8?q?Refactor=20:=20=EC=BF=BC=EB=A6=AC=20enable?= =?UTF-8?q?=20=EC=98=B5=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/newpost/SearchAlcoholInput.tsx | 6 +++--- client/src/components/wiki/AlcoholPagination.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/components/newpost/SearchAlcoholInput.tsx b/client/src/components/newpost/SearchAlcoholInput.tsx index e7fecdd..1d2ceb1 100644 --- a/client/src/components/newpost/SearchAlcoholInput.tsx +++ b/client/src/components/newpost/SearchAlcoholInput.tsx @@ -24,7 +24,7 @@ interface SearchAlcoholInputInterface { } const SearchAlcoholInput = ({ setAlcoholNo }: SearchAlcoholInputInterface) => { // 유저가 검색한 키워드 - const [searchKeyword, setSearchKeyword] = useState(""); + const [searchKeyword, setSearchKeyword] = useState(); // 검색한 키워드의 Debounced 값 const debouncedValue = useDebounce(searchKeyword, 300); const [isSearchingAlcohol, setIsSearchingAlCohol] = useState(false); @@ -36,7 +36,7 @@ const SearchAlcoholInput = ({ setAlcoholNo }: SearchAlcoholInputInterface) => { useState(); useEffect(() => { - setSearchKeyword(selectedAlcohol?.alcoholName ?? ""); + setSearchKeyword(selectedAlcohol?.alcoholName); setAlcoholNo(selectedAlcohol?.alcoholNo); }, [selectedAlcohol]); @@ -68,7 +68,7 @@ const SearchAlcoholInput = ({ setAlcoholNo }: SearchAlcoholInputInterface) => { autoComplete="off" /> {/* FIXME List 컴포넌트로 분리 */} - {isSearchingAlcohol && ( + {isSearchingAlcohol && data && ( {isSuccess && diff --git a/client/src/components/wiki/AlcoholPagination.tsx b/client/src/components/wiki/AlcoholPagination.tsx index 967e9f3..885a65b 100644 --- a/client/src/components/wiki/AlcoholPagination.tsx +++ b/client/src/components/wiki/AlcoholPagination.tsx @@ -5,7 +5,7 @@ import { Pagination, Stack } from "@mui/material"; import usePushToWikiDetail from "@/hooks/wiki/usePushToWikiDetail"; const AlcoholPagenation = () => { - const { data: alcohols } = useGetAlcoholListQuery(); + const { data: alcohols } = useGetAlcoholListQuery(""); const onClickElementHandler = usePushToWikiDetail(); return ( From 08c710b10dafbacc253d7cdf58941e17db2570ec Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sat, 9 Dec 2023 10:40:43 +0900 Subject: [PATCH 4/4] =?UTF-8?q?Minor=20:=20=EC=8A=A4=ED=83=80=EC=9D=BC=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/wiki/WikiAlcoholSelectorBtn.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/wiki/WikiAlcoholSelectorBtn.tsx b/client/src/components/wiki/WikiAlcoholSelectorBtn.tsx index 482d6cb..458d589 100644 --- a/client/src/components/wiki/WikiAlcoholSelectorBtn.tsx +++ b/client/src/components/wiki/WikiAlcoholSelectorBtn.tsx @@ -31,7 +31,7 @@ const WikiAlcoholSelectorBtn = ({ > {iconComponent} - {title} + {title} );