Skip to content
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
13 changes: 0 additions & 13 deletions src/apis/Example/artist.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/apis/Example/type.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 5 additions & 1 deletion src/apis/auctionRegister/postAuctionRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { TAuctionRegisterFormData } from './type';
export const postAuctionRegister = async (
data: TAuctionRegisterFormData
): Promise<TGetResponse<void>> => {
const response = await instance.post('/api/auction/register', data);
const formData = new FormData();
formData.append('artwork_id', data.artwork_id.toString());
formData.append('start_price', data.start_price.toString());

const response = await instance.post('/api/auction/register', formData);
return response.data;
};
4 changes: 2 additions & 2 deletions src/apis/auctionRegister/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export type TGetAvailableArtworksResponse = {
* @author 홍규진
*/
export type TAuctionRegisterFormData = {
artwork_id: number | null;
start_price: number | null;
artwork_id: number;
start_price: number;
};
22 changes: 22 additions & 0 deletions src/apis/exhibitRegister/postExhibitRegister.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* 전시 등록 API 호출
* 멀티파트로 제공해야하는 데이터는 다음과 같이 제공해야합니다.
* @author 홍규진
*/

import { instance } from '../axios';
import { TPostExhibitionRegisterFormData } from './types';

export const postExhibitionRegister = async (
data: TPostExhibitionRegisterFormData
) => {
const formData = new FormData();
formData.append('title', data.title);
formData.append('exhibit_image', data.exhibit_image);

await instance.post('/api/exhibition', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ export type TGetExhibitAvailableArtworksResponse = {
title: string;
thumbnail_image_url: string;
};

export type TPostExhibitionRegisterFormData = {
title: string;
exhibit_image: File;
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,10 @@ import { TUpdateUserInfo } from './type';
* 사용자 정보 수정 API 호출 함수
* @param userInfo - 수정할 사용자 정보 (nickname, address, birth)
* @returns API 응답(TGetResponse)
* @author 노찬영
* @author 노찬영, 홍규진
*/

export const updateUserInfo = async (
userInfo: TUpdateUserInfo
): Promise<TGetResponse<null>> => {
try {
const response = await instance.patch<TGetResponse<null>>(
`/api/user/update`,
userInfo
);
return response.data;
} catch (error) {
console.error('사용자 정보 수정 실패:', error);
throw error;
}
): Promise<void> => {
await instance.patch<TGetResponse<void>>(`/api/user/update`, userInfo);
};
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions src/apis/register/oAuthLogin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { instance } from '../axios';
import { TGetResponse } from '../type';
import { TOauthLoginWithCode } from './type';

/**
* 소셜 로그인 완료 응답 데이터 타입
* isComplete: 회원가입 완료 여부
* token: 인가 토큰
* @author 홍규진
*/
type TAuthResponse = {
isComplete: boolean;
token: string;
Expand Down
6 changes: 6 additions & 0 deletions src/apis/register/postAuthRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { instance } from '@/apis/axios';
import { TGetResponse } from '@/apis/type';
import { TRegisterFormData, TAuthResponse } from './type.ts';

/**
* 회원가입 완료 API 호출
* @param authData 회원가입 완료 폼 데이터
* @returns 회원가입 완료 응답 데이터
* @author 홍규진
*/
export const postAuthRegister = async (
authData: TRegisterFormData
): Promise<TAuthResponse> => {
Expand Down
12 changes: 12 additions & 0 deletions src/apis/register/type.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
/**
* 회원가입 폼 데이터 타입
* @author 홍규진
*/
export type TRegisterFormData = {
role: 'BUYER' | 'AUTHOR'; // 사용자 유형
name: string; // 이름
phone_number: string; // 전화번호
nickname: string; // 닉네임
};

/**
* 소셜 로그인 코드 타입
* @author 홍규진
*/
export type TOauthLoginWithCode = {
code: string;
social_type: string;
};

/**
* 회원가입 완료 응답 데이터 타입
* @author 홍규진
*/
export type TAuthResponse = {
isComplete: boolean;
token: string;
Expand Down
5 changes: 2 additions & 3 deletions src/components/common/Error/DefaultErrorFallbackUI/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ export default function DefaultErrorFallbackUI({
<LogoImage src={MainLogo} alt="Main Logo" />
<ErrorIcon>⚠️</ErrorIcon>
<ErrorMessage>잠시 문제가 발생했어요</ErrorMessage>
<ErrorDetail>{error.name}</ErrorDetail>
<ErrorDetail>{error.message}</ErrorDetail>
<RetryButton onClick={resetErrorBoundary}>
다시 시도하기
</RetryButton>
<RetryButton onClick={resetErrorBoundary}>다시 시도하기</RetryButton>
</ErrorContent>
</ErrorContainer>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/PageLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const PageLayout = ({ children }: PageLayoutProps) => {
}

function handleLinkMypageFn() {
navigate('/mypage/art-buyer');
navigate('/mypage/buyer');
}

return (
Expand Down
129 changes: 109 additions & 20 deletions src/constants/mutationKey.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
import { postAuthRegister } from '@/apis/register/postAuthRegister';
import { postAuctionRegister } from '@/apis/auctionRegister/postAuctionRegister';
import { postArtworkRegister } from '@/apis/artworkRegister/postArtworkRegister';
import { getAvailableArtworksQuery } from '@/constants/queryKeys';
import {
getArtworkDetailQuery,
getAuctionListQuery,
getBuyerMypageQuery,
getExhibitionListQuery,
} from '@/constants/queryKeys';
import { postAuctionBid } from '@/apis/auction/postAuctionBid';
import { toggleArtworkLike } from '@/apis/artwork-like/like';
import { postMySpace } from '@/apis/artwork-detail/postMySpace';
import { postAuctionLike } from '@/apis/auction/postAuctionLike';
import { postAuctionUnlike } from '@/apis/auction/postAuctionUnlike';
import { toggleArtworkLike } from '@/apis/artworkLike/like';
import { postMySpace } from '@/apis/artworkDetail/postMySpace';
import { getMainDataQuery } from '@/constants/queryKeys';
import { requestKakaoPay } from '@/apis/kakaoPay/paymentPreparation';
import { approveKakaoPay } from '@/apis/kakaoPay/paymentAuthorization';
import { updateUserInfo } from '@/apis/mypageBuyer/artBuyer';
import { TUpdateUserInfo } from '@/apis/mypageBuyer/type';
import { postExhibitionRegister } from '@/apis/exhibitRegister/postExhibitRegister';
import { TAuctionRegisterFormData } from '@/apis/auctionRegister/type';
/**
* 뮤테이션 키 관리를 위한 상수 정의 - 상수값을 사용해 mutation 성공 여부, 실패등에 따른 값 선언을 위한 유지보수성을 높이기 위해 사용합니다. (param은 넣지 않습니다. 하위 함수에서 넣어줍니다.)
* @mutationKey - 뮤테이션 함수 구분을 위한 키 값입니다.
* @successMutationKey - 뮤테이션 성공 후 호출될 쿼리 키 값 (쿼리 키 무효화를 통해 refetch를 위해 사용할 값입니다.)
* @mutationFn - 뮤테이션 함수입니다.
* @author 홍규진
*/
/*-----------------------------------------------------------*/

/**
* 인증 회원가입 뮤테이션
* @author 홍규진
* */
export const postAuthRegisterMutation = () => {
return {
mutationKey: ['auth'],
mutationKey: ['postAuthRegister'],
successMutationKey: [...getMainDataQuery().queryKey],
mutationFn: postAuthRegister,
};
};
Expand All @@ -22,72 +46,137 @@ export const postAuthRegisterMutation = () => {
* */
export const postAuctionRegisterMutation = () => {
return {
mutationKey: [...getAvailableArtworksQuery().queryKey],
mutationFn: postAuctionRegister,
mutationKey: ['postAuctionRegister'],
successMutationKey: [...getAuctionListQuery('').queryKey],
mutationFn: (data: TAuctionRegisterFormData) => postAuctionRegister(data),
};
};
/**
* 전시 등록 뮤테이션
* 전시 등록후 전시 목록 조회 쿼리 키 무효화
* @author 홍규진
* */
export const postExhibitionRegisterMutation = () => {
return {
mutationKey: ['postExhibitionRegister'],
successMutationKey: [...getExhibitionListQuery('').queryKey],
mutationFn: postExhibitionRegister,
};
};

/**
* 작품 등록 뮤테이션
* TODO-[홍규진] 작품 등록 후, 화면 내 작품 쿼리 키 지정시 해당 키로 수정 필요
*작품 등록 후, 메인 화면 내 작품 쿼리 키 무효화
* @author 홍규진
* */
export const postArtworkRegisterMutation = () => {
return {
mutationKey: ['artwork'],
mutationKey: ['postArtworkRegister'],
successMutationKey: [...getMainDataQuery().queryKey],
mutationFn: postArtworkRegister,
};
};

/**
* 경매 입찰 뮤테이션
* @author 이하늘
* 경매 입찰 후 경매 목록 조회 쿼리 키 무효화
* @author 이하늘, 홍규진
* */
export const postAuctionBidMutation = () => {
return {
mutationKey: ['auctionBid'],
mutationKey: ['postAuctionBid'],
successMutationKey: [...getAuctionListQuery('').queryKey],
mutationFn: postAuctionBid,
};
};

/*
/**
* 작품 좋아요 뮤테이션
* @author 김서윤
*/
* 작품 좋아요 후 작품 상세 조회 쿼리 키 무효화
* @author 김서윤, 홍규진
* */
export const toggleArtworkLikeMutation = (artworkId: number) => {
return {
mutationKey: ['artworkDetail', artworkId],
mutationKey: ['toggleArtworkLike'],
successMutationKey: [...getArtworkDetailQuery(artworkId).queryKey],
mutationFn: () => toggleArtworkLike(artworkId),
};
};

/**
* 카카오페이 결제 준비 뮤테이션
* @author 노찬영, 홍규진
* */
export const requestKakaoPayMutation = () => {
return {
mutationKey: ['requestKakaoPay'],
successMutationKey: [...getAuctionListQuery('').queryKey],
mutationFn: (paymentId: number) => requestKakaoPay(paymentId),
};
};

/**
* 카카오페이 결제 승인 뮤테이션
* 카카오페이 결제 승인 후 경매 목록 조회 쿼리 키 무효화
* @author 노찬영, 홍규진
*/
export const approveKakaoPayMutation = () => {
return {
mutationKey: ['approveKakaoPay'],
successMutationKey: [...getAuctionListQuery('').queryKey],
mutationFn: (paymentId: number, pgToken: string) =>
approveKakaoPay(paymentId, pgToken),
};
};

/**
* 사용자 정보 수정 뮤테이션
* 사용자 정보 수정 후 사용자 마이페이지 조회 쿼리 키 무효화
* @author 노찬영, 홍규진
*/
export const updateUserInfoMutation = () => {
return {
mutationKey: ['updateUserInfo'],
successMutationKey: [...getBuyerMypageQuery().queryKey],
mutationFn: (userInfo: TUpdateUserInfo) => updateUserInfo(userInfo),
};
};

/**
* 내 공간 등록 뮤테이션
* @author 김서윤
* 내 공간 등록 후 사용자 마이페이지 조회 쿼리 키 무효화
* @author 김서윤, 홍규진
* */
export const postMySpaceMutation = () => {
return {
mutationKey: ['new_userspace'],
mutationKey: ['postMySpace'],
successMutationKey: [...getBuyerMypageQuery().queryKey],
mutationFn: postMySpace,
};
};

/**
* 경매 좋아요 뮤테이션
* @author 이하늘
* 경매 좋아요 후 경매 목록 조회 쿼리 키 무효화
* @author 이하늘, 홍규진
* */
export const postAuctionLikeMutation = () => {
return {
mutationKey: ['auctionLike'],
mutationKey: ['postAuctionLike'],
successMutationKey: [...getAuctionListQuery('').queryKey],
mutationFn: postAuctionLike,
};
};

/**
* 경매 좋아요 취소 뮤테이션
* @author 이하늘
* 경매 좋아요 취소 후 경매 목록 조회 쿼리 키 무효화
* @author 이하늘, 홍규진
* */
export const postAuctionUnlikeMutation = () => {
return {
mutationKey: ['auctionUnlike'],
mutationKey: ['postAuctionUnlike'],
successMutationKey: [...getAuctionListQuery('').queryKey],
mutationFn: postAuctionUnlike,
};
};
Loading
Loading