From d893035ba97a21d4a3fc650abdc8cbdf6fb0258e Mon Sep 17 00:00:00 2001 From: seungboshim Date: Fri, 20 Dec 2024 03:50:49 +0900 Subject: [PATCH 1/2] refactor: google maps geocoding --- apps/salon/index.html | 4 ++ .../src/components/my/info/OwnerInfo.tsx | 5 +-- apps/salon/src/pages/My/index.tsx | 1 - apps/salon/src/utils/getGeocoding.ts | 38 +++++++++++-------- apps/salon/vercel.json | 8 +--- apps/salon/vite.config.ts | 7 ---- 6 files changed, 29 insertions(+), 34 deletions(-) diff --git a/apps/salon/index.html b/apps/salon/index.html index df3bcb7e..92a4fd61 100644 --- a/apps/salon/index.html +++ b/apps/salon/index.html @@ -15,6 +15,10 @@ crossorigin="anonymous" href="https://ownglyph-ryryu.vercel.app/style.css" /> + 두리묭실 diff --git a/apps/salon/src/components/my/info/OwnerInfo.tsx b/apps/salon/src/components/my/info/OwnerInfo.tsx index 3eff23aa..ab52e75a 100644 --- a/apps/salon/src/components/my/info/OwnerInfo.tsx +++ b/apps/salon/src/components/my/info/OwnerInfo.tsx @@ -14,10 +14,10 @@ interface OwnerInfoProps { shopId: number; image: string; shopName: string; - shopEmail: string; + // shopEmail: string; } -export const OwnerInfo = ({ image, shopName, shopEmail }: OwnerInfoProps) => { +export const OwnerInfo = ({ image, shopName }: OwnerInfoProps) => { const navigate = useNavigate(); const handleNavigate = () => { @@ -32,7 +32,6 @@ export const OwnerInfo = ({ image, shopName, shopEmail }: OwnerInfoProps) => {
안녕하세요! - {shopEmail ? shopEmail : 'email'} 내 포트폴리오 보기 diff --git a/apps/salon/src/pages/My/index.tsx b/apps/salon/src/pages/My/index.tsx index b27da9a5..33c5dab0 100644 --- a/apps/salon/src/pages/My/index.tsx +++ b/apps/salon/src/pages/My/index.tsx @@ -61,7 +61,6 @@ const MyPage = () => { shopId={shopProfile.id} shopName={shopProfile.name} image={groomerProfile.image} - shopEmail={groomerProfile.email} /> 위도/경도 */ export const getGeocoding = async (query: string): Promise => { - const response = await axios.get('/naver-api/map-geocode/v2/geocode', { - params: { - query: query, - }, - headers: { - 'x-ncp-apigw-api-key-id': NAVER_MAP_CLIENT_ID, - 'x-ncp-apigw-api-key': NAVER_MAP_CLIENT_KEY, - Accept: 'application/json', - }, - }); - const { y, x } = response.data.addresses[0]; - const lat = parseFloat(y); - const lon = parseFloat(x); - return { lat, lon }; + try { + const response = await axios.get( + `https://maps.googleapis.com/maps/api/geocode/json`, + { + params: { + address: query, + key: GOOGLE_MAP_API_KEY, + }, + }, + ); + + if (response.data.status !== 'OK') { + throw new Error('지오코딩 실패'); + } + + const { lat, lng } = response.data.results[0].geometry.location; + return { lat, lon: lng }; + } catch (error) { + console.error('지오코딩 에러:', error); + throw new Error('주소를 검색할 수 없습니다.'); + } }; diff --git a/apps/salon/vercel.json b/apps/salon/vercel.json index 3ec34ec3..3a48e56b 100644 --- a/apps/salon/vercel.json +++ b/apps/salon/vercel.json @@ -1,9 +1,3 @@ { - "rewrites": [ - { "source": "/(.*)", "destination": "/" }, - { - "source": "/naver-api/:path*", - "destination": "https://naveropenapi.apigw.ntruss.com/:path*" - } - ] + "rewrites": [{ "source": "/(.*)", "destination": "/" }] } diff --git a/apps/salon/vite.config.ts b/apps/salon/vite.config.ts index fda672ba..2737f6d6 100644 --- a/apps/salon/vite.config.ts +++ b/apps/salon/vite.config.ts @@ -19,12 +19,5 @@ export default defineConfig({ }, server: { port: 3001, - proxy: { - '/naver-api': { - target: 'https://naveropenapi.apigw.ntruss.com', - changeOrigin: true, - rewrite: (path) => path.replace(/^\/naver-api/, ''), - }, - }, }, }); From b0b8b303f8aed35b05b03a5da03dc24dd885b2b5 Mon Sep 17 00:00:00 2001 From: seungboshim Date: Fri, 20 Dec 2024 04:00:43 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=EC=98=A4=ED=83=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/salon/index.html | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/salon/index.html b/apps/salon/index.html index 92a4fd61..7c5d20db 100644 --- a/apps/salon/index.html +++ b/apps/salon/index.html @@ -15,15 +15,12 @@ crossorigin="anonymous" href="https://ownglyph-ryryu.vercel.app/style.css" /> - 두리묭실
+