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

FIX-파일첨부-url-변경 #79

Merged
merged 4 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions client/src/components/newpost/SearchAlcoholInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface SearchAlcoholInputInterface {
}
const SearchAlcoholInput = ({ setAlcoholNo }: SearchAlcoholInputInterface) => {
// 유저가 검색한 키워드
const [searchKeyword, setSearchKeyword] = useState("");
const [searchKeyword, setSearchKeyword] = useState<string>();
// 검색한 키워드의 Debounced 값
const debouncedValue = useDebounce(searchKeyword, 300);
const [isSearchingAlcohol, setIsSearchingAlCohol] = useState(false);
Expand All @@ -36,7 +36,7 @@ const SearchAlcoholInput = ({ setAlcoholNo }: SearchAlcoholInputInterface) => {
useState<AlcoholDetailInterface>();

useEffect(() => {
setSearchKeyword(selectedAlcohol?.alcoholName ?? "");
setSearchKeyword(selectedAlcohol?.alcoholName);
setAlcoholNo(selectedAlcohol?.alcoholNo);
}, [selectedAlcohol]);

Expand Down Expand Up @@ -68,7 +68,7 @@ const SearchAlcoholInput = ({ setAlcoholNo }: SearchAlcoholInputInterface) => {
autoComplete="off"
/>
{/* FIXME List 컴포넌트로 분리 */}
{isSearchingAlcohol && (
{isSearchingAlcohol && data && (
<Box sx={WrapperStyle}>
<List sx={ListStyle}>
{isSuccess &&
jobkaeHenry marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/wiki/AlcoholPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Stack alignItems="center" gap={2}>
jobkaeHenry marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/wiki/WikiAlcoholSelectorBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const WikiAlcoholSelectorBtn = ({
>
{iconComponent}
</Stack>
<Typography sx={{ p: 1 }}>{title}</Typography>
<Typography sx={{ py: 1 }}>{title}</Typography>
</Stack>
</ButtonBase>
);
jobkaeHenry marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
6 changes: 2 additions & 4 deletions client/src/queries/alcohol/useGetAlcoholListQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,7 +21,7 @@ export const getAlcoholListByKeyword = async (keyword?: string) => {
size: 5,
searchKeyword: keyword,
},
});
});
return data;
};

jobkaeHenry marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
7 changes: 4 additions & 3 deletions client/src/queries/attach/useNewAttachMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 () {
jobkaeHenry marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
6 changes: 1 addition & 5 deletions client/src/queries/auth/useMyInfoQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<MyInfoInterface>(MY_INFO);
return data;
jobkaeHenry marked this conversation as resolved.
Show resolved Hide resolved
Expand Down