From f79197014af2f2102d6c9fea46a191f0fe120b32 Mon Sep 17 00:00:00 2001 From: "misung.dev" Date: Tue, 1 Oct 2024 15:47:39 +0900 Subject: [PATCH] =?UTF-8?q?#93=20[REFACTOR]=20card=20API=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2024-WELLET-client | 1 + src/apis/cards.js | 32 ++++++++++++++++---------------- src/apis/index.js | 4 +++- src/pages/HomePage/HomePage.jsx | 7 +++---- 4 files changed, 23 insertions(+), 21 deletions(-) create mode 160000 2024-WELLET-client diff --git a/2024-WELLET-client b/2024-WELLET-client new file mode 160000 index 0000000..95e9363 --- /dev/null +++ b/2024-WELLET-client @@ -0,0 +1 @@ +Subproject commit 95e9363f5c9f49d791f8a94e233bbe474db3fa20 diff --git a/src/apis/cards.js b/src/apis/cards.js index bf0b6d4..254415a 100644 --- a/src/apis/cards.js +++ b/src/apis/cards.js @@ -1,29 +1,29 @@ import { authAxios } from '../axios'; // 전체 명함 조회 -export const getCards = async ({ member_id }) => { - const response = await authAxios.get(`/cards/${member_id}`); - // console.log(response.data.result); - return response; +export const getCardList = async ({ member_id }) => { + const { data } = await authAxios.get(`/cards/${member_id}`); + + return data; }; // 명함 생성 -export const postCards = async ({ member_id, data }) => { - const response = await authAxios.post(`/cards/${member_id}`, data); - // console.log(response); - return response; +export const postCard = async ({ member_id, data }) => { + const { data } = await authAxios.post(`/cards/${member_id}`, data); + + return data; }; // 명함 삭제 -export const deleteCards = async ({ card_id }) => { - const response = await authAxios.delete(`/cards/${card_id}`); - // console.log(response); - return response; +export const deleteCard = async ({ card_id }) => { + const { data } = await authAxios.delete(`/cards/${card_id}`); + + return data; }; // 명함 수정 -export const putCards = async ({ card_id, data }) => { - const response = await authAxios.put(`/cards/${card_id}`, data); - // console.log(response); - return response; +export const putCard = async ({ card_id, data }) => { + const { data } = await authAxios.put(`/cards/${card_id}`, data); + + return data; }; diff --git a/src/apis/index.js b/src/apis/index.js index 400c528..7851f99 100644 --- a/src/apis/index.js +++ b/src/apis/index.js @@ -1 +1,3 @@ -export { getGroupList } from './group'; +export * from './group'; +export * from './cards'; +export * from './myCard'; diff --git a/src/pages/HomePage/HomePage.jsx b/src/pages/HomePage/HomePage.jsx index cc11638..7bcf78a 100644 --- a/src/pages/HomePage/HomePage.jsx +++ b/src/pages/HomePage/HomePage.jsx @@ -10,8 +10,7 @@ import { } from '../../components'; import { useVisibleCardsEffect } from '../../utils/HomePageUtils/homePageEffects'; import CARDS_SAMPLE_DATA from '../../constants/cardsSampleData.js'; -import { getMyCard } from '../../apis/myCard.js'; -import { getCards } from '../../apis/cards.js'; +import { getCardList, getMyCard } from '../../apis'; const member_id = 5; // dummy data @@ -33,8 +32,8 @@ export default function HomePage() { async function fetchCards(member_id) { try { - const response = await getCards({ member_id: member_id }); - setCardsData(response.data.cards); + const { cards } = await getCardList({ member_id: member_id }); + setCardsData(cards); } catch (error) { console.error('카드 리스트를 불러오지 못했습니다.', error); }