-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: group profile #146
Merged
Merged
feat: group profile #146
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a0ee489
feat: set inital design
Pridesd 57fdc00
feat: set profile link
Pridesd 5e101de
feat: add blue color
Pridesd b5f4a8e
feat: set TasteRate
Pridesd 9b23ad4
feat: add differ api
Pridesd 0fcc198
fix: fix initial rate
Pridesd c517008
feat: set initial-panel
Pridesd fd8f4f8
feat: add place item
Pridesd 2370dd2
chore: change style
Pridesd e7a820f
feat: set profile
Pridesd 3308595
feat: set update map id logic
Pridesd c770498
fix: lint error
Pridesd 6027356
feat: set 스켈레톤
Pridesd 264cb2a
refactor: add mapId
Pridesd 4773284
feat: 맵아이디를 적용해보았어용
Pridesd 72768d7
feat: 더보기를 추가했어용
Pridesd cfa73ce
feat: 더보기 버튼 디자인을 쌈@@뽕하게 바꿨어용
Pridesd 35914ce
fix: lint error
Pridesd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import type { PlaceType } from '@/models/api/place' | ||
import type { MapInfo } from '@/models/map' | ||
import type { User } from '@/models/user' | ||
import { getMapId } from '@/services/map-id' | ||
import { api } from '@/utils/api' | ||
import { useEffect, useState } from 'react' | ||
import PlaceItem from './place-item' | ||
import { APIError } from '@/models/api' | ||
import { notify } from '@/components/common/custom-toast' | ||
import EmptyPlaceList from '@/components/place/empty-place-list' | ||
import PlacePopupSkeleton from '@/components/place/place-popup-skeleton' | ||
|
||
const LikedPlacePanel = ({ userId }: { userId: User['id'] }) => { | ||
const [mapId, setMapId] = useState<MapInfo['id']>('') | ||
const [places, setPlaces] = useState<PlaceType[]>() | ||
|
||
const renderPlaces = () => { | ||
if (typeof places === 'undefined') { | ||
return ( | ||
<div className="flex flex-col gap-2.5 py-[18px]"> | ||
<PlacePopupSkeleton /> | ||
<PlacePopupSkeleton /> | ||
<PlacePopupSkeleton /> | ||
</div> | ||
) | ||
} | ||
if (places.length === 0) { | ||
return ( | ||
<EmptyPlaceList | ||
className="pt-[75px]" | ||
message="등록하거나 좋아요한 맛집이 없어요" | ||
/> | ||
) | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col gap-2.5 py-[18px]"> | ||
{places.map((place) => ( | ||
<PlaceItem | ||
key={place.place.id} | ||
className="w-full border-[1px] border-neutral-500 bg-neutral-600" | ||
mapId={mapId} | ||
selectedPlace={place} | ||
/> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
useEffect(() => { | ||
const getLikedPlace = async () => { | ||
try { | ||
const currentMapId = await getMapId() | ||
if (!currentMapId) { | ||
throw new Error('잘못된 접근입니다.') | ||
} | ||
setMapId(currentMapId) | ||
const { data } = await api.place.like.mapId.userId.get({ | ||
mapId: currentMapId, | ||
userId, | ||
}) | ||
setPlaces(data) | ||
} catch (error) { | ||
if (error instanceof APIError) { | ||
notify.error(error.message) | ||
} else { | ||
notify.error('에러가 발생했습니다.') | ||
} | ||
} | ||
} | ||
|
||
getLikedPlace() | ||
}, [userId]) | ||
|
||
return ( | ||
<div role="tabpanel" id="tappanel-liked" aria-labelledby="tap-liked"> | ||
{renderPlaces()} | ||
</div> | ||
) | ||
} | ||
|
||
export default LikedPlacePanel |
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
'use client' | ||
|
||
import AccessibleIconButton from '@/components/common/accessible-icon-button' | ||
import Avatar from '@/components/common/avatar' | ||
import Typography from '@/components/common/typography' | ||
import useFetch from '@/hooks/use-fetch' | ||
import useSafeRouter from '@/hooks/use-safe-router' | ||
import type { User } from '@/models/user' | ||
import { api } from '@/utils/api' | ||
import TasteRate from './taste-rate' | ||
import { useState } from 'react' | ||
import LikedPlacePanel from './liked-place-panel' | ||
import RegisterededPlacePanel from './registered-place-panel' | ||
|
||
type PlaceFilter = 'register' | 'liked' | ||
|
||
const Profile = ({ params: { id } }: { params: { id: User['id'] } }) => { | ||
const router = useSafeRouter() | ||
const { data: userData } = useFetch(() => api.users.id.get(id)) | ||
const [type, setType] = useState<PlaceFilter>('register') | ||
|
||
const getIsSelected = (currentType: PlaceFilter) => type === currentType | ||
|
||
return ( | ||
<div className="flex flex-col gap-6"> | ||
<header className="relative flex items-center pt-4"> | ||
<AccessibleIconButton | ||
icon={{ type: 'caretLeft', size: 'xl' }} | ||
label="이전 페이지" | ||
className="p-[10px]" | ||
onClick={() => router.back()} | ||
/> | ||
<Typography | ||
className="absolute left-1/2 translate-x-[-50%]" | ||
as="h1" | ||
size="body0" | ||
> | ||
그룹원 프로필 | ||
</Typography> | ||
</header> | ||
|
||
<div className="flex flex-col items-center gap-[18px]"> | ||
<div className="flex flex-col items-center gap-6"> | ||
<Avatar | ||
value={userData?.nickname} | ||
imageUrl={userData?.profileImage} | ||
className={`h-20 w-20 text-[40px] ${!userData?.profileImage && 'border-2 border-[#17171A] border-opacity-20'}`} | ||
/> | ||
<Typography size="h3">{userData?.nickname}</Typography> | ||
</div> | ||
<TasteRate userId={id} /> | ||
<div className="h-[18px] w-full bg-neutral-600"></div> | ||
</div> | ||
<section className="flex flex-col px-5"> | ||
<div role="tablist" className="flex items-center gap-4"> | ||
<button | ||
role="tab" | ||
className={`border-b-[1px] pb-1 ${getIsSelected('register') ? 'border-neutral-000' : 'border-transparent'}`} | ||
id="tap-register" | ||
aria-controls="tappanel-register" | ||
aria-selected={getIsSelected('register')} | ||
onClick={() => setType('register')} | ||
> | ||
<Typography size="body1">맛집 등록</Typography> | ||
</button> | ||
<button | ||
role="tab" | ||
className={`border-b-[1px] pb-1 ${getIsSelected('liked') ? 'border-neutral-000' : 'border-transparent'}`} | ||
id="tap-liked" | ||
aria-controls="tappanel-liked" | ||
aria-selected={getIsSelected('liked')} | ||
onClick={() => setType('liked')} | ||
> | ||
<Typography size="body1">좋아요</Typography> | ||
</button> | ||
</div> | ||
{type === 'liked' ? ( | ||
<LikedPlacePanel userId={id} /> | ||
) : ( | ||
<RegisterededPlacePanel userId={id} /> | ||
)} | ||
</section> | ||
</div> | ||
) | ||
} | ||
|
||
export default Profile |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
지도 홈에 진입했을 때만 updateMapIdCookie 해줘도 될 것 같아요! 이게 mount를 두 번 트리거해서 골칫덩이더라구요 그래서 map/mapId의 경우에 좀 귀찮은 작업을 추가해서 updateMapIdCookie를 해줬어요 ㅜ e397684