-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add map view to place page (#168)
* refactor: make getMarkerType reusable * refactor: rename place-box to place-detail * refactor: make place-map-popup more scalable * feat: add map view for single place * feat: add gps button to place-map * chore: remove console.log * refactor: make place related types readable * refactor: make register page as server component * refactor: refactor file structure under place - use route groups i/o conditional branching with path * refactor: remove brackets from className * refactor: improve type definitions for Place*
- Loading branch information
Showing
35 changed files
with
370 additions
and
275 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use client' | ||
|
||
import type { ReactNode } from 'react' | ||
import { usePathname } from 'next/navigation' | ||
|
||
import AccessibleIconButton from '@/components/common/accessible-icon-button' | ||
import useSafeRouter from '@/hooks/use-safe-router' | ||
|
||
const PlaceDetailLayout = ({ children }: { children: ReactNode }) => { | ||
const router = useSafeRouter() | ||
const pathname = usePathname() | ||
|
||
return ( | ||
<div className="relative flex min-h-dvh flex-col bg-neutral-700"> | ||
<header className="absolute left-0 top-0 z-[100] h-[60px] w-full bg-gradient-to-t from-[rgba(33,33,36,0)] to-[rgba(33,33,36,0.6)]"> | ||
<AccessibleIconButton | ||
icon={{ type: 'caretLeft', size: 'xl' }} | ||
label="뒤로 가기" | ||
className="absolute left-[10px] top-[26px]" | ||
onClick={() => router.back()} | ||
/> | ||
|
||
<AccessibleIconButton | ||
icon={{ type: 'mapView', size: 'xl', fill: 'neutral-000' }} | ||
label="지도" | ||
className="absolute right-[10px] top-[26px] z-[120]" | ||
onClick={() => { | ||
router.push(`${pathname}/map`) | ||
}} | ||
/> | ||
</header> | ||
|
||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
export default PlaceDetailLayout |
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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,19 @@ | ||
import PlaceMapBox from '@/app/place/[placeId]/map/place-map-box' | ||
import { getMapId } from '@/services/map-id' | ||
import { api } from '@/utils/api' | ||
|
||
const PlaceMap = async ({ params }: { params?: { placeId?: number } }) => { | ||
const mapId = (await getMapId()) || '' | ||
const response = | ||
!!mapId && !!params?.placeId | ||
? await api.place.mapId.kakao.kakaoPlaceId.get({ | ||
mapId, | ||
kakaoPlaceId: params?.placeId ?? -1, | ||
}) | ||
: null | ||
const place = response?.data | ||
|
||
return place && <PlaceMapBox place={place} mapId={mapId} /> | ||
} | ||
|
||
export default PlaceMap |
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,54 @@ | ||
'use client' | ||
|
||
import GPSButton from '@/components/kakao-map/gps-button' | ||
import KakaoMap from '@/components/kakao-map/kakao-map' | ||
import Marker from '@/components/kakao-map/marker' | ||
import PlaceMapPopup from '@/components/place/place-map-popup' | ||
import useSafeRouter from '@/hooks/use-safe-router' | ||
import type { PlaceDetail } from '@/models/api/place' | ||
import type { ClassName } from '@/models/common' | ||
import type { MapInfo } from '@/models/map' | ||
import { getMarkerType } from '@/services/marker' | ||
import cn from '@/utils/cn' | ||
|
||
interface PlaceMapBoxProps extends ClassName { | ||
place: PlaceDetail | ||
mapId: MapInfo['id'] | ||
} | ||
|
||
const PlaceMapBox = ({ className, place, mapId }: PlaceMapBoxProps) => { | ||
const type = getMarkerType(place.category, true) | ||
const router = useSafeRouter() | ||
|
||
return ( | ||
<div | ||
className={cn( | ||
'flex min-h-dvh w-full flex-col items-center justify-center bg-neutral-700 px-5', | ||
className, | ||
)} | ||
> | ||
<KakaoMap | ||
className="h-dvh w-[calc(100%+40px)]" | ||
center={{ lat: place.y, lng: place.x }} | ||
> | ||
<Marker | ||
key={place.kakaoId} | ||
latitude={place.y} | ||
longitude={place.x} | ||
isSaved={place.isRegisteredPlace} | ||
type={type} | ||
/> | ||
|
||
<div className="absolute bottom-5 z-10 flex w-full flex-col items-end gap-4 px-5"> | ||
<GPSButton /> | ||
|
||
<button onClick={() => router.safeBack()} className="w-full"> | ||
<PlaceMapPopup mapId={mapId} selectedPlace={place} /> | ||
</button> | ||
</div> | ||
</KakaoMap> | ||
</div> | ||
) | ||
} | ||
|
||
export default PlaceMapBox |
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.