From df27ec87c27fff9039c26018a0fc78cc982cca47 Mon Sep 17 00:00:00 2001 From: Savien/Woo Jun Han <49388937+MrMirror21@users.noreply.github.com> Date: Fri, 24 Jan 2025 18:21:56 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20:=20=EA=B3=B5=EA=B3=A0=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=8B=9C=20api=20=EB=AA=85=EC=84=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=9C=BC=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=20=EC=9E=85=EB=A0=A5=20=EB=88=84=EB=9D=BD=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#127?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Employer/PostCreate/Step2.tsx | 2 +- src/hooks/api/useAddressSearch.ts | 13 +++++++++---- src/pages/Employer/Post/EmployerEditPostPage.tsx | 15 +++++++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/components/Employer/PostCreate/Step2.tsx b/src/components/Employer/PostCreate/Step2.tsx index fb003e8..9792d13 100644 --- a/src/components/Employer/PostCreate/Step2.tsx +++ b/src/components/Employer/PostCreate/Step2.tsx @@ -33,7 +33,7 @@ const Step2 = ({ handleAddressSearch, // 검색할 주소 입력 시 실시간 검색 handleAddressSelect, // 검색 결과 중 원하는 주소를 선택할 시 state에 입력 setAddressInput, - } = useAddressSearch(); + } = useAddressSearch(postInfo.body.address); const handleAddressSelection = (selectedAddressName: string) => { const result = handleAddressSelect(selectedAddressName); diff --git a/src/hooks/api/useAddressSearch.ts b/src/hooks/api/useAddressSearch.ts index eb60496..4a59044 100644 --- a/src/hooks/api/useAddressSearch.ts +++ b/src/hooks/api/useAddressSearch.ts @@ -1,5 +1,6 @@ import { useSearchAddress } from '@/hooks/api/useKaKaoMap'; import { Document, AddressType, GeoPosition } from '@/types/api/map'; +import { Address } from '@/types/postCreate/postCreate'; import { pick } from '@/utils/map'; import { Dispatch, SetStateAction, useCallback, useState } from 'react'; @@ -27,14 +28,18 @@ interface UseAddressSearchReturn { setCurrentGeoInfo: Dispatch>; } -export const useAddressSearch = (): UseAddressSearchReturn => { - const [addressInput, setAddressInput] = useState(''); +export const useAddressSearch = ( + addressBeforeEdit?: Address, +): UseAddressSearchReturn => { + const [addressInput, setAddressInput] = useState( + addressBeforeEdit?.address_name || '', + ); const [addressSearchResult, setAddressSearchResult] = useState( [], ); const [currentGeoInfo, setCurrentGeoInfo] = useState({ - lat: 0, - lon: 0, + lat: addressBeforeEdit?.latitude || 0, + lon: addressBeforeEdit?.longitude || 0, }); const { searchAddress } = useSearchAddress({ diff --git a/src/pages/Employer/Post/EmployerEditPostPage.tsx b/src/pages/Employer/Post/EmployerEditPostPage.tsx index b566b92..8132ed5 100644 --- a/src/pages/Employer/Post/EmployerEditPostPage.tsx +++ b/src/pages/Employer/Post/EmployerEditPostPage.tsx @@ -20,7 +20,7 @@ const EmployerEditPostPage = () => { const { isEdit } = location.state || {}; const { id } = useParams(); const { currentPostId } = useCurrentPostIdStore(); - console.log(currentPostId) + console.log(currentPostId); const [currentStep, setCurrentStep] = useState(1); const [postInfo, setPostInfo] = useState( initialJobPostingState, @@ -56,8 +56,15 @@ const EmployerEditPostPage = () => { work_period: serverData.working_conditions.work_period, hourly_rate: serverData.working_conditions.hourly_rate, employment_type: serverData.working_conditions.employment_type, - address: {...postInfo.body.address, address_name: serverData.company_information.company_address}, - recruitment_dead_line: serverData.recruitment_conditions.recruitment_deadline, + address: { + ...postInfo.body.address, + address_name: serverData.workplace_information.main_address, + latitude: serverData.workplace_information.latitude, + longitude: serverData.workplace_information.longitude, + address_detail: serverData.workplace_information.detailed_address, + }, + recruitment_dead_line: + serverData.recruitment_conditions.recruitment_deadline, recruitment_number: serverData.recruitment_conditions.number_of_recruits, gender: serverData.recruitment_conditions.gender, age_restriction: initialJobPostingState.body.age_restriction, @@ -107,7 +114,7 @@ const EmployerEditPostPage = () => { length={5} currentStep={currentStep} mainColor="#1E1926" - textColor='#FFFFFF' + textColor="#FFFFFF" />