Skip to content

Commit

Permalink
fix: axios함수명 구분 및 getUrl 훅 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
lydiacho committed Oct 30, 2024
1 parent 5f9ec37 commit 16bdcce
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/pages/onboarding/apis/businesscardAxios.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { authAxios, axios } from '@utils/apis';

export const presignedUrlAxios = () => {
export const businessCardUrlAxios = () => {
return authAxios.get('/v1/image/businesscard');
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/onboarding/apis/profileImageAxios.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { authAxios, axios } from '@utils/apis';

export const presignedUrlAxios = () => {
export const profileUrlAxios = () => {
return authAxios.get('/v1/image/profile');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import useNicknameValid from '@pages/onboarding/hooks/useNicknameQuery';
import { useProfileQuery } from '@pages/onboarding/hooks/useProfileImgQuery';
import { useLocation, useNavigate, useOutletContext } from 'react-router-dom';
import { JoinContextType } from '@pages/onboarding/type';
import usePresignedUrl from '@pages/onboarding/hooks/usePresignedUrl';

import { isAxiosError } from 'axios';
import { useProfilePresignedUrl } from '@pages/onboarding/hooks/usePresignedUrl';

const Step개인정보입력 = () => {
const { data, setData } = useOutletContext<JoinContextType>();
Expand All @@ -29,7 +30,7 @@ const Step개인정보입력 = () => {
const startImgArr = [StartProfile1Img, StartProfile2Img];
const startImg = useMemo(() => startImgArr[Math.floor(Math.random() * 2)], []);

const { res } = usePresignedUrl();
const { res } = useProfilePresignedUrl();
const { mutate: imageUploadMutate } = useProfileQuery();

const handleChangeImage = (e: ChangeEvent<HTMLInputElement>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import { InputBox, TextBox } from '../TextBox';
import { useBusinessCardQuery } from '@pages/onboarding/hooks/useBusinessCardQuery';
import { BizInfoType, JoinContextType } from '@pages/onboarding/type';
import { getToken } from '@utils/storage';
import { useBusinessCardPresignedUrl } from '@pages/onboarding/hooks/usePresignedUrl';

const Step명함인증 = () => {
const { setData } = useOutletContext<JoinContextType>();
const { res } = useBusinessCardPresignedUrl();
const mutation = useOCRBizQuery();
const cardmutation = useBusinessCardQuery();
const navigate = useNavigate();
Expand Down
17 changes: 12 additions & 5 deletions src/pages/onboarding/hooks/usePresignedUrl.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { useQuery } from '@tanstack/react-query';
import { presignedUrlAxios } from '../apis/profileImageAxios';
import { profileUrlAxios } from '../apis/profileImageAxios';
import { businessCardUrlAxios } from '../apis/businesscardAxios';

const usePresignedUrl = () => {
export const useProfilePresignedUrl = () => {
const { data } = useQuery({
queryKey: ['presignedurl'],
queryFn: presignedUrlAxios,
queryKey: ['profile-url'],
queryFn: profileUrlAxios,
});
return { res: data?.data?.data };
};

export default usePresignedUrl;
export const useBusinessCardPresignedUrl = () => {
const { data } = useQuery({
queryKey: ['businesscard-url'],
queryFn: businessCardUrlAxios,
});
return { res: data?.data?.data };
};

0 comments on commit 16bdcce

Please sign in to comment.