Skip to content
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
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@master

- name: .env setting
run: |
echo "VITE_KAKAOMAP_API_KEY=${{ secrets.VITE_KAKAOMAP_API_KEY }}" >> .env

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ dist-ssr
*.njsproj
*.sln
*.sw?

# Environment variables
.env
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"react": "^19.1.1",
"react-dom": "^19.1.1",
"react-hook-form": "^7.62.0",
"react-kakao-maps-sdk": "^1.2.0",
"react-router-dom": "^7.8.1",
"recharts": "^3.1.2",
"sonner": "^2.0.7",
Expand Down Expand Up @@ -66,6 +67,7 @@
"eslint-plugin-unused-imports": "^4.1.4",
"globals": "^16.3.0",
"husky": "^9.1.7",
"kakao.maps.d.ts": "^0.1.40",
"lint-staged": "^16.1.5",
"prettier-plugin-tailwindcss": "^0.6.14",
"tw-animate-css": "^1.3.7",
Expand Down
30 changes: 30 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions src/features/main/ui/MapSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button } from '@/shared';
import { Button, KakaoMap } from '@/shared';

import { HOUSE_TYPES } from '../constants';

Expand All @@ -15,10 +15,7 @@ export const MapSection = () => {

{/* TODO: 추후 지도 (카카오맵, 네이버 지도, 구글 맵 등) 컴포넌트 추가 */}
<div className='flex flex-1 items-center justify-center bg-gray-100'>
<div className='text-center text-gray-500'>
<p className='mb-2 text-lg font-medium'>지도가 여기에 표시됩니다</p>
<p className='text-sm'>주소를 입력하고 진단하기를 눌러보세요</p>
</div>
<KakaoMap lat={35.1690637154991} lng={129.136018268316} />
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

지도에 표시될 기본 위도와 경도 값이 하드코딩되어 있습니다. 이러한 '매직 넘버'는 코드의 가독성과 유지보수성을 저해할 수 있습니다. 이 값들을 src/features/main/constants.ts와 같은 파일에 DEFAULT_MAP_CENTER 상수로 정의하고, KakaoMap 컴포넌트에 props를 넘길 때 스프레드 연산자를 사용하면 더 간결해집니다.

Suggested change
<KakaoMap lat={35.1690637154991} lng={129.136018268316} />
<KakaoMap {...DEFAULT_MAP_CENTER} />

</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/shared/components/features/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './layout';
export * from './header';
export * from './optimized-image';
export * from './kakao-map';
32 changes: 32 additions & 0 deletions src/shared/components/features/kakao-map/KakaoMap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Map, MapMarker, useKakaoLoader } from 'react-kakao-maps-sdk';

type Props = {
lat: number;
lng: number;
};

export const KakaoMap = ({ lat, lng }: Props) => {
const [loading, error] = useKakaoLoader({
appkey: import.meta.env.VITE_KAKAOMAP_API_KEY,
libraries: ['clusterer', 'drawing', 'services'],
});
Comment on lines +9 to +12
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

useKakaoLoader를 통해 카카오맵 라이브러리를 불러올 때 clusterer, drawing, services를 모두 포함하고 있습니다. 현재 구현에서는 마커 표시 기능만 사용되므로, 이 라이브러리들이 당장 필요하지 않다면 제거하여 초기 로딩 성능을 개선하는 것을 고려해볼 수 있습니다. 불필요한 라이브러리를 로드하면 초기 로딩 시간이 길어질 수 있습니다. 필요한 시점에 동적으로 로드하거나, 실제로 사용될 때 추가하는 것이 좋습니다.

  const [loading, error] = useKakaoLoader({
    appkey: import.meta.env.VITE_KAKAOMAP_API_KEY,
  });


const center = {
lat: lat,
lng: lng,
};
Comment on lines +14 to +17
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

객체의 키와 값으로 사용되는 변수명이 같을 경우, ES6의 속성 축약 표현(property shorthand)을 사용하여 코드를 더 간결하게 만들 수 있습니다.

  const center = {
    lat,
    lng,
  };


if (loading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
Comment on lines +19 to +20
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

로딩 및 에러 상태를 간단한 div 태그로 처리하고 있습니다. 사용자 경험(UX)과 UI 일관성을 위해 프로젝트 내에 공용으로 사용하는 SpinnerError 컴포넌트가 있다면 그것을 활용하는 것이 좋습니다. 예를 들어, 로딩 중에는 스피너를 보여주고, 에러 발생 시에는 사용자에게 친화적인 메시지와 함께 재시도 옵션을 제공하는 등의 개선을 고려해볼 수 있습니다.


return (
<Map // 지도를 표시할 Container
id='map'
center={center}
className='h-full w-full'
level={3} // 지도의 확대 레벨
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

지도의 확대 레벨(level) 값으로 3이 하드코딩되어 있습니다. 이 값의 의미를 명확히 하고 유지보수를 용이하게 하기 위해 DEFAULT_MAP_LEVEL과 같은 이름의 상수로 정의하여 사용하는 것을 권장합니다.

      level={DEFAULT_MAP_LEVEL} // 지도의 확대 레벨

>
<MapMarker position={center} />
</Map>
);
};
1 change: 1 addition & 0 deletions src/shared/components/features/kakao-map/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './KakaoMap';
4 changes: 3 additions & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},

"types": ["kakao.maps.d.ts"]
},
"include": ["src"]
}
7 changes: 3 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
],
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }],
"compilerOptions": {
"types": ["kakao.maps.d.ts"],

"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
Expand Down
Loading