Skip to content
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

게스트 매치 상세 페이지 지도로 보기 구현 #367

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/pages/GamesDetailPage/GameLocation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import toast from 'react-hot-toast';
import { Map, MapMarker } from 'react-kakao-maps-sdk';

import { Game } from '@type/models';

import MarkerSvg from '@assets/mapMarker.svg';

type GameLocationProps = {
match: Game;
};

export const GameLocation = ({ match }: GameLocationProps) => {
return (
<Map
center={{ lat: match.latitude, lng: match.longitude }}
style={{ width: '100%', height: '300px' }}
level={4}
>
<MapMarker
position={{
lat: match.latitude,
lng: match.longitude,
}}
image={{
src: MarkerSvg,
size: {
width: 48,
height: 68,
},
options: {
offset: {
x: 23,
y: 55,
},
},
}}
onClick={() => copyLocation(match.mainAddress)}
clickable={true}
></MapMarker>
</Map>
);
};

const copyLocation = async (location: Game['mainAddress']) => {
try {
await navigator.clipboard.writeText(location);

toast.success('위치 정보가 복사되었습니다.');
} catch (err) {
console.error('Failed to copy: ', err);
}
};
1 change: 1 addition & 0 deletions src/pages/GamesDetailPage/GamesDetailPage.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const ButtonWrapper = styled.div`
width: 100dvw;
bottom: 70px;
left: 0;
z-index: 1;
`;

export const PositionItemBox = styled.div`
Expand Down
5 changes: 5 additions & 0 deletions src/pages/GamesDetailPage/GamesDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Ball from '@assets/ball.svg';
import GameMember from '@assets/gameMember.svg';
import Money from '@assets/money.svg';

import { GameLocation } from './GameLocation';
import {
ButtonWrapper,
GrayText,
Expand Down Expand Up @@ -255,6 +256,10 @@ export const GamesDetailPage = () => {
))}
</Guests>
</GuestsContainer>
<Text size={20} weight={700}>
지도로 보기
</Text>
<GameLocation match={match} />
<ButtonWrapper>
{loginInfo && !isStarted && canParticipate && (
<ErrorBoundary
Expand Down
Loading