-
Notifications
You must be signed in to change notification settings - Fork 6
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
[FE] feature/#301 내 정보 페이지 구현 #309
Changes from 1 commit
99faae7
dc13809
c8eaa48
fbaa976
0847d46
bbfa912
f44cdac
13092dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
import { Fragment, useEffect, useState } from 'react'; | ||
import { styled } from 'styled-components'; | ||
import { getApi } from '../../../apis/getApi'; | ||
import { MyInfoPinType, MyInfoTopicType } from '../../../types/MyInfo'; | ||
import PinCard from '../../PinCard'; | ||
import TopicCard from '../../TopicCard'; | ||
|
||
const data = [ | ||
{ | ||
id: 1, | ||
name: '준팍의 또 토픽', | ||
image: 'https://map-befine-official.github.io/favicon.png', | ||
pinCount: 3, | ||
bookmarkCount: 0, | ||
isBookmarked: false, | ||
updatedAt: '2023-08-14T13:15:40.15966098', | ||
}, | ||
{ | ||
id: 2, | ||
name: '준팍의 두번째 토픽', | ||
image: 'https://map-befine-official.github.io/favicon.png', | ||
pinCount: 5, | ||
bookmarkCount: 0, | ||
isBookmarked: false, | ||
updatedAt: '2023-08-14T13:15:40.15966888', | ||
}, | ||
{ | ||
id: 3, | ||
name: '준팍의 또 토픽', | ||
image: 'https://map-befine-official.github.io/favicon.png', | ||
pinCount: 3, | ||
bookmarkCount: 0, | ||
isBookmarked: false, | ||
updatedAt: '2023-08-14T13:15:40.15966098', | ||
}, | ||
{ | ||
id: 4, | ||
name: '준팍의 두번째 토픽', | ||
image: 'https://map-befine-official.github.io/favicon.png', | ||
pinCount: 5, | ||
bookmarkCount: 0, | ||
isBookmarked: false, | ||
updatedAt: '2023-08-14T13:15:40.15966888', | ||
}, | ||
]; | ||
|
||
const data2 = [ | ||
{ | ||
id: 1, | ||
name: '매튜의 산스장', | ||
address: '지번 주소', | ||
description: '매튜가 사랑하는 산스장', | ||
latitude: 37.0, | ||
longitude: 127.0, | ||
}, | ||
{ | ||
id: 2, | ||
name: '매튜의 안갈집', | ||
address: '지번 주소', | ||
description: '매튜가 두번은 안 갈 집', | ||
latitude: 37.0, | ||
longitude: 127.0, | ||
}, | ||
{ | ||
id: 3, | ||
name: '매튜의 산스장', | ||
address: '지번 주소', | ||
description: '매튜가 사랑하는 산스장', | ||
latitude: 37.0, | ||
longitude: 127.0, | ||
}, | ||
{ | ||
id: 4, | ||
name: '매튜의 안갈집', | ||
address: '지번 주소', | ||
description: '매튜가 두번은 안 갈 집', | ||
latitude: 37.0, | ||
longitude: 127.0, | ||
}, | ||
]; | ||
|
||
interface MyInfoListProps { | ||
isTopic: boolean; | ||
} | ||
|
||
const MyInfoList = ({ isTopic }: MyInfoListProps) => { | ||
const [myInfoTopics, setMyInfoTopics] = useState<MyInfoTopicType[]>([]); | ||
const [myInfoPins, setMyInfoPins] = useState<MyInfoPinType[]>([]); | ||
|
||
const getMyInfoListFromServer = async () => { | ||
if (isTopic) { | ||
const serverMyInfoTopics = await getApi<MyInfoTopicType[]>( | ||
'default', | ||
'/members/pins', | ||
); | ||
setMyInfoTopics(serverMyInfoTopics); | ||
} | ||
|
||
if (!isTopic) { | ||
const serverMyInfoPins = await getApi<MyInfoPinType[]>( | ||
'default', | ||
'/members/topics', | ||
); | ||
setMyInfoPins(serverMyInfoPins); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
// getMyInfoListFromServer(); | ||
}, []); | ||
|
||
if (!isTopic) | ||
return ( | ||
<MyInfoListWrapper> | ||
{data2.map((pin, index) => { | ||
return ( | ||
index < 3 && ( | ||
<Fragment key={pin.id}> | ||
<PinCard | ||
pinId={pin.id} | ||
pinTitle={pin.name} | ||
pinAddress={pin.address} | ||
pinDescription={pin.description} | ||
/> | ||
</Fragment> | ||
) | ||
); | ||
})} | ||
</MyInfoListWrapper> | ||
); | ||
|
||
if (!data) return <></>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 early return 이 !isTopic 보다 위에 있으면 좋을 것 같아요~~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 와우 제가 캐치 하지 못한 부분을 잡아주시다니 바로 반영하겠습니닷 !!! |
||
|
||
return ( | ||
<MyInfoListWrapper> | ||
{data.map((topic, index) => { | ||
return ( | ||
index < 3 && ( | ||
<Fragment key={topic.id}> | ||
<TopicCard | ||
topicId={topic.id} | ||
topicImage={topic.image} | ||
topicTitle={topic.name} | ||
topicUpdatedAt={topic.updatedAt} | ||
topicPinCount={topic.pinCount} | ||
/> | ||
</Fragment> | ||
) | ||
); | ||
})} | ||
</MyInfoListWrapper> | ||
); | ||
}; | ||
|
||
const MyInfoListWrapper = styled.ul` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 멘틱멘틱 시멘틱 굳~~ 👍👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 우하핳 😆 |
||
display: grid; | ||
grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); | ||
grid-row-gap: ${({ theme }) => theme.spacing[5]}; | ||
`; | ||
|
||
export default MyInfoList; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { styled } from 'styled-components'; | ||
import Flex from '../common/Flex'; | ||
import Text from '../common/Text'; | ||
import Box from '../common/Box'; | ||
import Space from '../common/Space'; | ||
import { lazy, Suspense } from 'react'; | ||
import TopicCardListSeleton from '../TopicCardList/TopicCardListSeleton'; | ||
import Button from '../common/Button'; | ||
import MyInfoList from './MyInfoList'; | ||
|
||
interface MyInfoContainerProps { | ||
containerTitle: string; | ||
containerDescription: string; | ||
routeWhenSeeAll: () => void; | ||
} | ||
|
||
const MyInfoContainer = ({ | ||
containerTitle, | ||
containerDescription, | ||
routeWhenSeeAll, | ||
}: MyInfoContainerProps) => ( | ||
<section> | ||
<Flex $justifyContent="space-between" $alignItems="flex-end"> | ||
<Box> | ||
<Text | ||
color="black" | ||
$fontSize="extraLarge" | ||
$fontWeight="bold" | ||
tabIndex={0} | ||
> | ||
{containerTitle} | ||
</Text> | ||
<Space size={0} /> | ||
<Text | ||
color="gray" | ||
$fontSize="default" | ||
$fontWeight="normal" | ||
tabIndex={1} | ||
> | ||
{containerDescription} | ||
</Text> | ||
</Box> | ||
|
||
{ | ||
<SeeAllButton variant="primary" onClick={routeWhenSeeAll}> | ||
전체 보기 | ||
</SeeAllButton> | ||
} | ||
</Flex> | ||
|
||
<Space size={4} /> | ||
|
||
<Suspense fallback={<TopicCardListSeleton />}> | ||
{containerTitle === '나의 핀' ? ( | ||
<MyInfoList isTopic={false} /> | ||
) : ( | ||
<MyInfoList isTopic={true} /> | ||
)} | ||
</Suspense> | ||
</section> | ||
); | ||
|
||
const SeeAllButton = styled(Button)` | ||
cursor: pointer; | ||
`; | ||
|
||
export default MyInfoContainer; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,16 @@ import Space from '../common/Space'; | |
import Text from '../common/Text'; | ||
|
||
const LoginError = () => { | ||
const loginButtonClick = () => { | ||
window.location.href = 'https://mapbefine.kro.kr/api/oauth/kakao'; | ||
}; | ||
|
||
return ( | ||
<Flex | ||
$flexDirection="column" | ||
$justifyContent="center" | ||
$alignItems="center" | ||
width="100vw" | ||
width="100%" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오잉 이 부분은 왜 퍼센트로 하셨죵? 특별한 이유가 있나요?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분 사이드바가 축소 되었을 때 지도를 보이게 하려고 했었는데 지금 생각해보니 모아보기와 즐겨찾기, 프로필 기능 쓸 때 모두 전체 화면이라 100vw로 두는게 좋을 것 같습니다! |
||
height="100vh" | ||
> | ||
<LoginErrorIcon /> | ||
|
@@ -25,7 +29,9 @@ const LoginError = () => { | |
나만의 지도를 만들어 보세요. | ||
</Text> | ||
<Space size={5} /> | ||
<NotFoundButton variant="primary">카카오로 시작하기</NotFoundButton> | ||
<NotFoundButton variant="primary" onClick={loginButtonClick}> | ||
카카오로 시작하기 | ||
</NotFoundButton> | ||
</Flex> | ||
</Flex> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
재사용의 관점에서는 지금도 충분히 좋습니다만, MyInfoList 컴포넌트는 껍데기 UI만 유지하고 props 받은 값들을 렌더링할 수 있도록 하는 것도 괜찮아보여요.
Fetching 로직도 분기처리하고 있기 때문에 위 상태들을 부모로 올리고 fetching 로직을 분리해서 실행시킨 후 set 된 값들을 props로 이 컴포넌트에 전달하는 것이 어떨까 하는 생각도 드네요.
아니면 아예 topic, pin 이렇게 나누는 것도 고려해볼만 하네욥~~ 물론 제 얇은 지식이기에 내일 다시 보면 생각 바뀌어서 이 코멘트를 삭제할 수도 있을거 같아요 🤪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<세인과 페어 프로그래밍 완료. 나중에 리팩토링 하기로 결정!>