-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#99 [FEAT] 내 명함 API 연동
- Loading branch information
Showing
10 changed files
with
4,898 additions
and
226 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
export { getGroupList, postGroup, deleteGroup, putGroup } from './group'; | ||
export { getCards, getCardDetail, postCards, deleteCards, putCards, searchCards } from './cards'; | ||
export { | ||
getCards, | ||
getCardDetail, | ||
postCards, | ||
deleteCards, | ||
putCards, | ||
searchCards, | ||
} from './cards'; | ||
export { getMyCard, postMyCard, deleteMyCard, putMyCard } from './myCard'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,51 @@ | ||
import * as S from './MyPage.style'; | ||
import Icon from '../../components/Icon/Icon'; | ||
import React, { useState } from 'react'; | ||
import React, { useState, useEffect } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { HiOutlineLink } from 'react-icons/hi'; | ||
|
||
// 더미 데이터 | ||
const myInfo = { | ||
name: '김은지', | ||
job: 'Web Engineer', | ||
team: '개발팀', | ||
company: null, | ||
phone: '010-1234-5678', | ||
email: '[email protected]', | ||
tel: '81-2-222-3456', | ||
address: '서울시 강남구 테헤란로 134, 5-6층 (역삼동, 포스크타워 역삼)', | ||
}; | ||
import MY_CARD_SAMPLE_DATA from '../../constants/myCardSampleData'; | ||
import { getMyCard } from '../../apis'; // API 함수 불러오기 | ||
import ProfileImgDefault from '../../assets/images/profile-img-default.svg'; | ||
|
||
export default function MyPage() { | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
const [isToastVisible, setIsToastVisible] = useState(false); | ||
const [isModalOpen, setIsModalOpen] = useState(false); // QR 코드 모달 상태 | ||
const [isToastVisible, setIsToastVisible] = useState(false); // 토스트 메시지 상태 | ||
const [myInfo, setMyInfo] = useState(MY_CARD_SAMPLE_DATA); // 명함 정보 상태 | ||
|
||
// 마이페이지의 명함 정보를 API에서 받아오기 | ||
useEffect(() => { | ||
const fetchMyCard = async () => { | ||
try { | ||
const response = await getMyCard(); | ||
console.log(response); // Check the API response | ||
setMyInfo(response.data); // Use sample data if API response is empty | ||
} catch (error) { | ||
console.error('명함 정보를 가져오는 데 실패했습니다.', error); | ||
setMyInfo(MY_CARD_SAMPLE_DATA); // Use sample data on error | ||
} | ||
}; | ||
|
||
fetchMyCard(); | ||
}, []); | ||
const profileImageUrl = myInfo.profImgUrl || ProfileImgDefault; | ||
const handleShareClick = () => { | ||
setIsModalOpen(true); | ||
setIsModalOpen(true); // QR 코드 모달 열기 | ||
}; | ||
|
||
const handleCloseModal = () => { | ||
setIsModalOpen(false); | ||
setIsModalOpen(false); // QR 코드 모달 닫기 | ||
}; | ||
|
||
const handleCopyLinkClick = () => { | ||
setIsToastVisible(true); | ||
setIsToastVisible(true); // 링크 복사 시 토스트 메시지 보이기 | ||
setTimeout(() => { | ||
setIsToastVisible(false); | ||
setIsToastVisible(false); // 3초 후 토스트 메시지 숨기기 | ||
}, 3000); | ||
}; | ||
|
||
const navigate = useNavigate(); | ||
const handleEditButtonClick = () => { | ||
navigate('/mypage/edit'); | ||
navigate('/mypage/edit'); // 편집 페이지로 이동 | ||
}; | ||
|
||
return ( | ||
|
@@ -54,7 +62,11 @@ export default function MyPage() { | |
<S.MidBar> | ||
<S.LeftContainer2 /> | ||
<S.MyInfoSummaryWrapper> | ||
<S.ProfileImageWrapper>프로필 사진</S.ProfileImageWrapper> | ||
<S.ProfileImageWrapper> | ||
<S.PicContainer> | ||
<S.ProfilePic src={profileImageUrl} alt={`나의 프로필`} /> | ||
</S.PicContainer> | ||
</S.ProfileImageWrapper> | ||
</S.MyInfoSummaryWrapper> | ||
<S.ShareIconWrapper> | ||
<Icon | ||
|
@@ -81,24 +93,32 @@ export default function MyPage() { | |
<S.MyInfoValue>{myInfo.company}</S.MyInfoValue> | ||
) : ( | ||
<S.MyInfoValueNull> | ||
(정보가 없습니다. 편집하기를 눌러 명함을 완성하세요.) | ||
정보가 없습니다. 편집하기를 눌러 명함을 완성하세요. | ||
</S.MyInfoValueNull> | ||
)} | ||
</S.MyInfoItem> | ||
<S.MyInfoItem> | ||
<S.MyInfoLabel>직책 / 부서</S.MyInfoLabel> | ||
<S.MyInfoValue> | ||
{myInfo.job ? ( | ||
myInfo.team ? ( | ||
`${myInfo.job} / ${myInfo.team}` | ||
{myInfo.position ? ( | ||
myInfo.department ? ( | ||
<> | ||
{myInfo.position} / {myInfo.department} | ||
</> | ||
) : ( | ||
<>{myInfo.job}</> | ||
<> | ||
{myInfo.position} /{' '} | ||
<S.MyInfoValueNull>정보가 없습니다.</S.MyInfoValueNull> | ||
</> | ||
) | ||
) : myInfo.team ? ( | ||
<>{myInfo.team}</> | ||
) : myInfo.department ? ( | ||
<> | ||
<S.MyInfoValueNull>정보가 없습니다.</S.MyInfoValueNull> /{' '} | ||
{myInfo.department} | ||
</> | ||
) : ( | ||
<S.MyInfoValueNull> | ||
(정보가 없습니다. 편집하기를 눌러 명함을 완성하세요.) | ||
정보가 없습니다. 편집하기를 눌러 명함을 완성하세요. | ||
</S.MyInfoValueNull> | ||
)} | ||
</S.MyInfoValue> | ||
|
@@ -116,7 +136,7 @@ export default function MyPage() { | |
<S.MyInfoValue>{myInfo.phone}</S.MyInfoValue> | ||
) : ( | ||
<S.MyInfoValueNull> | ||
(정보가 없습니다. 편집하기를 눌러 명함을 완성하세요.) | ||
정보가 없습니다. 편집하기를 눌러 명함을 완성하세요. | ||
</S.MyInfoValueNull> | ||
)} | ||
<S.IconBox> | ||
|
@@ -132,7 +152,7 @@ export default function MyPage() { | |
<S.MyInfoValue>{myInfo.email}</S.MyInfoValue> | ||
) : ( | ||
<S.MyInfoValueNull> | ||
(정보가 없습니다. 편집하기를 눌러 명함을 완성하세요.) | ||
정보가 없습니다. 편집하기를 눌러 명함을 완성하세요. | ||
</S.MyInfoValueNull> | ||
)} | ||
<Icon id='mail' width='20' height='14' /> | ||
|
@@ -145,7 +165,7 @@ export default function MyPage() { | |
<S.MyInfoValue>{myInfo.tel}</S.MyInfoValue> | ||
) : ( | ||
<S.MyInfoValueNull> | ||
(정보가 없습니다. 편집하기를 눌러 명함을 완성하세요.) | ||
정보가 없습니다. 편집하기를 눌러 명함을 완성하세요. | ||
</S.MyInfoValueNull> | ||
)} | ||
<Icon id='call' width='20' height='14' /> | ||
|
@@ -157,7 +177,7 @@ export default function MyPage() { | |
<S.MyInfoValue>{myInfo.address}</S.MyInfoValue> | ||
) : ( | ||
<S.MyInfoValueNull> | ||
(정보가 없습니다. 편집하기를 눌러 명함을 완성하세요.) | ||
정보가 없습니다. 편집하기를 눌러 명함을 완성하세요. | ||
</S.MyInfoValueNull> | ||
)} | ||
</S.MyInfoItem> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.