From 21c6040d8a800d7390220861f83febbd37c65cea Mon Sep 17 00:00:00 2001 From: jiohjung98 Date: Fri, 31 May 2024 22:38:17 +0900 Subject: [PATCH 01/15] =?UTF-8?q?feat:=20=EC=98=A4=ED=94=BC=EC=8A=A4=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=EC=A0=95=EB=B3=B4=20api=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/map/getSelectedOffice.ts | 24 +++++ src/api/types/branch.ts | 13 ++- src/components/map/OfficeInfo.tsx | 168 +++++++++++++++-------------- src/components/map/OfficeModal.tsx | 25 ++++- 4 files changed, 145 insertions(+), 85 deletions(-) create mode 100644 src/api/map/getSelectedOffice.ts diff --git a/src/api/map/getSelectedOffice.ts b/src/api/map/getSelectedOffice.ts new file mode 100644 index 0000000..052f659 --- /dev/null +++ b/src/api/map/getSelectedOffice.ts @@ -0,0 +1,24 @@ +import { SelectedBranch } from '@/api/types/branch'; + +export const getSelectedOfficeInfo = async (name: string): Promise => { + try { + const backendUrl = process.env.NEXT_PUBLIC_BASE_URL; + const token = document.cookie.replace(/(?:(?:^|.*;\s*)token\s*=\s*([^;]*).*$)|^.*$/, "$1"); + const response = await fetch(`${backendUrl}branches/${encodeURIComponent(name)}`, { + method: 'GET', + headers: { + 'Authorization': `Bearer ${token}`, + 'Content-Type': 'application/json' + }, + cache: 'no-store' + }); + if (!response.ok) { + throw new Error('Failed to fetch branch information'); + } + const data: SelectedBranch = await response.json(); + return data; + } catch (error) { + console.error('Error fetching branch info:', error); + throw error; + } +}; diff --git a/src/api/types/branch.ts b/src/api/types/branch.ts index c5895ab..8eae982 100644 --- a/src/api/types/branch.ts +++ b/src/api/types/branch.ts @@ -29,4 +29,15 @@ export interface MapSearchResultProps { export interface OfficeInfoProps { branchName: string; branchAddress: string; -} \ No newline at end of file +} + +export interface SelectedBranch { + branchName: string; + branchAddress: string; + branchLatitude: number; + branchLongitude: number; + branchPhoneNumber: string; + roadFromStation: string; + stationToBranch: string[]; +} + \ No newline at end of file diff --git a/src/components/map/OfficeInfo.tsx b/src/components/map/OfficeInfo.tsx index ea7e983..3a0acfa 100644 --- a/src/components/map/OfficeInfo.tsx +++ b/src/components/map/OfficeInfo.tsx @@ -8,105 +8,115 @@ import { Pagination } from 'swiper/modules'; import { IoIosArrowRoundBack } from 'react-icons/io'; import { OfficeInfoProps } from '@/api/types/branch'; -const OfficeInfo: React.FC = ({ branchName, branchAddress }) => { +const OfficeInfo: React.FC = ({ branchName }) => { const router = useRouter(); + const { address, branchPhoneNumber, roadFromStation, stationToBranch } = router.query; + + console.log(address); + console.log(branchPhoneNumber); + const handleBackClick = () => { router.push('/map'); }; return ( -
-
- - {branchName} -
+
+
+ + + {branchName} +
-
- - - Office Image 1 - - - Office Image 2 - - - Office Image 3 - - -
+
+ + + Office Image 1 + + + Office Image 2 + + + Office Image 3 + + +
-
찾아오는길
-
- OfficeLocationSmall -

{branchAddress}

-
-
- OfficeCallImg -

{branchAddress}

-
-
- OfficeParkImg -

출차 전 2층 데스크에서 1시간 무료 적용,
이후 10분당 800원 비용 발생

-
+
찾아오는길
+
+ OfficeLocationSmall +
+

{address}

+

{stationToBranch}

+

{roadFromStation}

+
+
+
+ OfficeCallImg +

{branchPhoneNumber}

+
+
+ OfficeParkImg +

출차 전 2층 데스크에서 1시간 무료 적용,
이후 10분당 800원 비용 발생

+
-
공용 공간 리스트
-
    -
  • A룸 - 10명 수용 가능
  • -
  • B룸 - 9명 수용 가능
  • -
  • C룸 - 13명 수용 가능
  • -
+
공용 공간 리스트
+ {/*
    + {stationToBranch && stationToBranch.split(',').map((item, index) => ( +
  • {item}
  • + ))} +
*/}
-
편의시설
-
-
- LoungeImg -

라운지

-
-
- RechargeImg -

리차징룸

+
편의시설
+
+
+ LoungeImg +

라운지

+
+
+ RechargeImg +

리차징룸

+
+
+ ParcelImg +

무인택배

+
+
+ PhoneBooseImg +

폰부스

+
+
+ PrinterImg +

복합기

+
+
+ SnackBarImg +

스낵바

+
+
+ SuppliesImg +

사무용품

+
+
+ CoffeeImg +

무제한 커피

+
-
- ParcelImg -

무인택배

-
-
- PhoneBooseImg -

폰부스

-
-
- PrinterImg -

복합기

-
-
- SnackBarImg -

스낵바

-
-
- SuppliesImg -

사무용품

-
-
- CoffeeImg -

무제한 커피

-
-
-
공지사항
+
공지사항