From 85838f2f8c01f7f339ab59930db8d83d169d2e02 Mon Sep 17 00:00:00 2001 From: ooherin <555ohr@naver.com> Date: Thu, 10 Oct 2024 17:23:15 +0900 Subject: [PATCH 1/9] =?UTF-8?q?fix:=20position=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/apis/checklist.ts | 7 +++++++ frontend/src/apis/url.ts | 2 +- .../AddressModal/RealTimeAddressModal.tsx | 5 +++-- frontend/src/components/_common/Map/AddressMap.tsx | 2 +- .../src/components/_common/Map/RealTimeMap.tsx | 14 +++++++------- frontend/src/constants/map.ts | 8 +++++--- frontend/src/hooks/useMutateChecklist.ts | 7 +------ frontend/src/hooks/useRoomInfoNonValidated.ts | 8 +++++--- frontend/src/mocks/handlers/subway.ts | 2 +- frontend/src/pages/ChecklistDetailPage.tsx | 2 +- frontend/src/store/roomInfoNonValidatedStore.ts | 4 ++++ frontend/src/types/address.ts | 4 ++-- frontend/src/types/checklist.ts | 2 ++ frontend/src/utils/createKakaoMapElements.ts | 3 ++- 14 files changed, 42 insertions(+), 28 deletions(-) diff --git a/frontend/src/apis/checklist.ts b/frontend/src/apis/checklist.ts index 91de2cf2e..3090ff4c8 100644 --- a/frontend/src/apis/checklist.ts +++ b/frontend/src/apis/checklist.ts @@ -34,6 +34,13 @@ export const postChecklist = async (checklist: ChecklistPostForm) => { return response; }; +export const postChecklistV1 = async (checklist: ChecklistPostForm) => { + checklist.room.structure = checklist.room.structure === 'NONE' ? undefined : checklist.room.structure; + checklist.room = mapObjUndefinedToNull(checklist.room); + const response = await fetcher.post({ url: BASE_URL + ENDPOINT.CHECKLISTS, body: checklist }); + return response; +}; + export const putChecklist = async (id: number, checklist: ChecklistPostForm) => { checklist.room.structure = checklist.room.structure === 'NONE' ? undefined : checklist.room.structure; checklist.room = mapObjUndefinedToNull(checklist.room); diff --git a/frontend/src/apis/url.ts b/frontend/src/apis/url.ts index 9c333cb7a..128e957e2 100644 --- a/frontend/src/apis/url.ts +++ b/frontend/src/apis/url.ts @@ -23,5 +23,5 @@ export const ENDPOINT = { LOGOUT: '/oauth/logout', USER_INFO: '/user/me', //subway - SUBWAY: (position: Position) => `/stations/nearest?latitude=${position.lat}&longitude=${position.lon}`, + SUBWAY: (position: Position) => `/stations/nearest?latitude=${position.latitude}&longitude=${position.longitude}`, }; diff --git a/frontend/src/components/NewChecklist/AddressModal/RealTimeAddressModal.tsx b/frontend/src/components/NewChecklist/AddressModal/RealTimeAddressModal.tsx index 2918ed58f..79884478d 100644 --- a/frontend/src/components/NewChecklist/AddressModal/RealTimeAddressModal.tsx +++ b/frontend/src/components/NewChecklist/AddressModal/RealTimeAddressModal.tsx @@ -14,7 +14,7 @@ import { title4 } from '@/styles/common'; import { Position } from '@/types/address'; const RealTimeAddressModal = () => { - const DEFAULT_POSITION = { lat: 0, lon: 0 }; + const DEFAULT_POSITION = { latitude: 0, longitude: 0 }; const roomInfoUnvalidatedActions = useStore(roomInfoNonValidatedStore, state => state.actions); @@ -28,9 +28,10 @@ const RealTimeAddressModal = () => { const { searchSubwayStationsByPosition } = useRoomInfoNonValidated(); const handleSubmitAddress = () => { - if (position.lat && position.lon) { + if (position.latitude && position.longitude) { roomInfoUnvalidatedActions.set('address', currentAddress); roomInfoUnvalidatedActions.set('buildingName', currentBuildingName); + roomInfoUnvalidatedActions.set('position', position); searchSubwayStationsByPosition(position); closeModal(); diff --git a/frontend/src/components/_common/Map/AddressMap.tsx b/frontend/src/components/_common/Map/AddressMap.tsx index e2cd3a519..e8530ec6a 100644 --- a/frontend/src/components/_common/Map/AddressMap.tsx +++ b/frontend/src/components/_common/Map/AddressMap.tsx @@ -23,7 +23,7 @@ const AddressMap = ({ location }: { location: string }) => { kakao.maps.load(() => { if (!mapContainerRef.current) return; const mapOption = { - center: new kakao.maps.LatLng(DEFAULT_POSITION.lat, DEFAULT_POSITION.lon), + center: new kakao.maps.LatLng(DEFAULT_POSITION.latitude, DEFAULT_POSITION.longitude), level: 3, }; // 지도 생성 diff --git a/frontend/src/components/_common/Map/RealTimeMap.tsx b/frontend/src/components/_common/Map/RealTimeMap.tsx index 5a35205bb..c90817e83 100644 --- a/frontend/src/components/_common/Map/RealTimeMap.tsx +++ b/frontend/src/components/_common/Map/RealTimeMap.tsx @@ -44,7 +44,7 @@ const RealTimeMap = ({ mapRef.current = map; /*마커 생성*/ - const marker = createMarker(kakao, map, new kakao.maps.LatLng(position.lat, position.lon)); + const marker = createMarker(kakao, map, new kakao.maps.LatLng(position.latitude, position.longitude)); markerRef.current = marker; /*인포윈도우 생성*/ @@ -55,7 +55,7 @@ const RealTimeMap = ({ kakao.maps.event.addListener(map, 'click', (mouseEvent: any) => { const latlng = mouseEvent.latLng; map.setCenter(latlng); - setPosition({ lat: latlng.getLat(), lon: latlng.getLng() }); + setPosition({ latitude: latlng.getLat(), longitude: latlng.getLng() }); if (markerRef.current) { markerRef.current.setPosition(latlng); @@ -66,13 +66,13 @@ const RealTimeMap = ({ /* 실시간 위치 찾기 */ const successGeolocation = (position: GeolocationPosition) => { - const lat = position.coords.latitude; - const lon = position.coords.longitude; + const latitude = position.coords.latitude; + const longitude = position.coords.longitude; - const locPosition = new kakao.maps.LatLng(lat, lon); + const locPosition = new kakao.maps.LatLng(latitude, longitude); const message = `이 위치가 맞나요?`; - setPosition({ lat, lon }); + setPosition({ latitude, longitude }); map.setCenter(locPosition); setRealTimeLocationState('success'); @@ -121,7 +121,7 @@ const RealTimeMap = ({ if (markerRef.current && mapRef.current && realTimeLocationState !== 'loading') { const { kakao } = window as any; - const locPosition = new kakao.maps.LatLng(position.lat, position.lon); + const locPosition = new kakao.maps.LatLng(position.latitude, position.longitude); markerRef.current.setPosition(locPosition); mapRef.current.setCenter(locPosition); diff --git a/frontend/src/constants/map.ts b/frontend/src/constants/map.ts index 921b48b8a..9670dd61b 100644 --- a/frontend/src/constants/map.ts +++ b/frontend/src/constants/map.ts @@ -1,4 +1,6 @@ -export const DEFAULT_POSITION = { - lat: 37.51524850249633, - lon: 127.10305696808169, +import { Position } from '@/types/address'; + +export const DEFAULT_POSITION: Position = { + latitude: 1, + longitude: 1, }; diff --git a/frontend/src/hooks/useMutateChecklist.ts b/frontend/src/hooks/useMutateChecklist.ts index 147cdad31..b2ec1ccca 100644 --- a/frontend/src/hooks/useMutateChecklist.ts +++ b/frontend/src/hooks/useMutateChecklist.ts @@ -51,15 +51,10 @@ const useMutateChecklist = ( //TODO: 나중에 해당 키 이름 수정 const roomInfoUnvalidatedAnswerWithoutSubway = removeKey(roomInfoUnvalidatedAnswer, 'nearSubwayStation'); - const formattedUnvalidatedValues = { - station: roomInfoUnvalidatedAnswer.nearSubwayStation[0]?.stationName, - walkingTime: roomInfoUnvalidatedAnswer.nearSubwayStation[0]?.walkingTime, - }; - const postData = { room: { ...roomInfoAnswer, - ...{ ...roomInfoUnvalidatedAnswerWithoutSubway, ...formattedUnvalidatedValues }, + ...{ ...roomInfoUnvalidatedAnswerWithoutSubway }, }, options: selectedOptions, questions: transformQuestions(checklistCategoryQnA), diff --git a/frontend/src/hooks/useRoomInfoNonValidated.ts b/frontend/src/hooks/useRoomInfoNonValidated.ts index be7c57066..be878fcdb 100644 --- a/frontend/src/hooks/useRoomInfoNonValidated.ts +++ b/frontend/src/hooks/useRoomInfoNonValidated.ts @@ -2,6 +2,7 @@ import { useStore } from 'zustand'; import { getNearSubways } from '@/apis/subway'; import roomInfoNonValidatedStore from '@/store/roomInfoNonValidatedStore'; +import { Position } from '@/types/address'; /** useRoomInfoNonValidated : 방 기본정보에서 인풋 형식이 아니고, 검증이 필요없는 필드에 대한 함수를 모아놓은 훅입니다. (주소, 지하철, 관리비, 방구조) @@ -12,8 +13,9 @@ useRoomInfoNonValidated : 방 기본정보에서 인풋 형식이 아니고, 검 const useRoomInfoNonValidated = () => { const roomInfoNonValidated = useStore(roomInfoNonValidatedStore, state => state.actions); - const searchSubwayStationsByPosition = async ({ lat, lon }: { lat: number; lon: number }) => { - const nearSubways = await getNearSubways({ lat, lon }); + const searchSubwayStationsByPosition = async ({ latitude, longitude }: Position) => { + const nearSubways = await getNearSubways({ latitude, longitude }); + roomInfoNonValidated.set('position', { latitude, longitude }); roomInfoNonValidated.set('nearSubwayStation', nearSubways); return nearSubways; }; @@ -28,7 +30,7 @@ const useRoomInfoNonValidated = () => { geocoder.addressSearch(address, function (result: any, status: any) { /* 정상적으로 검색이 완료됐으면*/ if (status === kakao.maps.services.Status.OK) { - return searchSubwayStationsByPosition({ lat: result[0].y, lon: result[0].x }); + return searchSubwayStationsByPosition({ latitude: result[0].y, longitude: result[0].x }); } }); }); diff --git a/frontend/src/mocks/handlers/subway.ts b/frontend/src/mocks/handlers/subway.ts index 971f5a687..fe036fefe 100644 --- a/frontend/src/mocks/handlers/subway.ts +++ b/frontend/src/mocks/handlers/subway.ts @@ -4,7 +4,7 @@ import { BASE_URL, ENDPOINT } from '@/apis/url'; import { nearSubway } from '@/mocks/fixtures/subway'; export const SubwayHandlers = [ - http.get(BASE_URL + ENDPOINT.SUBWAY({ lat: 0, lon: 0 }), () => { + http.get(BASE_URL + ENDPOINT.SUBWAY({ latitude: 0, longitude: 0 }), () => { return HttpResponse.json(nearSubway, { status: 200 }); }), ]; diff --git a/frontend/src/pages/ChecklistDetailPage.tsx b/frontend/src/pages/ChecklistDetailPage.tsx index f40af7a95..ddd10202e 100644 --- a/frontend/src/pages/ChecklistDetailPage.tsx +++ b/frontend/src/pages/ChecklistDetailPage.tsx @@ -47,7 +47,7 @@ const ChecklistDetailPage = () => { /* 정상적으로 검색이 완료됐으면*/ if (status === kakao.maps.services.Status.OK) { const findSubway = async () => { - const nearSubways = await getNearSubways({ lat: result[0].y, lon: result[0].x }); + const nearSubways = await getNearSubways({ latitude: result[0].y, longitude: result[0].x }); setNearSubways(nearSubways); }; findSubway(); diff --git a/frontend/src/store/roomInfoNonValidatedStore.ts b/frontend/src/store/roomInfoNonValidatedStore.ts index 1c635f530..d350916af 100644 --- a/frontend/src/store/roomInfoNonValidatedStore.ts +++ b/frontend/src/store/roomInfoNonValidatedStore.ts @@ -1,11 +1,14 @@ import { createStore } from 'zustand'; +import { DEFAULT_POSITION } from '@/constants/map'; +import { Position } from '@/types/address'; import { SubwayStation } from '@/types/subway'; interface States { nearSubwayStation: SubwayStation[]; address: string; buildingName: string; + position: Position; } interface Actions { @@ -17,6 +20,7 @@ const defaultStates = { nearSubwayStation: [], address: '', buildingName: '', + position: DEFAULT_POSITION, }; const roomInfoNonValidatedStore = createStore()(set => ({ diff --git a/frontend/src/types/address.ts b/frontend/src/types/address.ts index ecf96b46d..fdc842894 100644 --- a/frontend/src/types/address.ts +++ b/frontend/src/types/address.ts @@ -5,8 +5,8 @@ export interface Address { } export interface Position { - lat: number; - lon: number; + latitude: number; + longitude: number; } export interface OpenOptions { diff --git a/frontend/src/types/checklist.ts b/frontend/src/types/checklist.ts index a64a4f7cf..d060060ee 100644 --- a/frontend/src/types/checklist.ts +++ b/frontend/src/types/checklist.ts @@ -1,3 +1,4 @@ +import { Position } from '@/types/address'; import { AnswerType } from '@/types/answer'; import { Category } from '@/types/category'; import { Option } from '@/types/option'; @@ -76,6 +77,7 @@ export interface ChecklistPostForm { room: RoomInfo; options: number[]; questions: AnswerPostForm[]; + geolocation?: Position; //TODO: 나중에 지우기 } export type MutateType = 'add' | 'edit'; diff --git a/frontend/src/utils/createKakaoMapElements.ts b/frontend/src/utils/createKakaoMapElements.ts index 090835254..068af9982 100644 --- a/frontend/src/utils/createKakaoMapElements.ts +++ b/frontend/src/utils/createKakaoMapElements.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ + import { DEFAULT_POSITION } from '@/constants/map'; const createKakaoMapElements = () => { @@ -6,7 +7,7 @@ const createKakaoMapElements = () => { const container = document.getElementById('map'); if (!container) return; - const center = new kakao.maps.LatLng(DEFAULT_POSITION.lat, DEFAULT_POSITION.lon); + const center = new kakao.maps.LatLng(DEFAULT_POSITION.latitude, DEFAULT_POSITION.longitude); const options = { center, From c1c9f0bd113c685ef182f54acac73fc4d6b4bd4d Mon Sep 17 00:00:00 2001 From: ooherin <555ohr@naver.com> Date: Thu, 10 Oct 2024 17:35:13 +0900 Subject: [PATCH 2/9] =?UTF-8?q?fix:=20=EB=B0=B1=EC=97=94=EB=93=9C=20api=20?= =?UTF-8?q?=EB=A8=B8=EC=A7=80=20=ED=9B=84=20=EB=8B=A4=EC=8B=9C=20=EC=8B=9C?= =?UTF-8?q?=EB=8F=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/apis/checklist.ts | 16 ++++++++-------- frontend/src/apis/url.ts | 1 + frontend/src/hooks/useMutateChecklist.ts | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/frontend/src/apis/checklist.ts b/frontend/src/apis/checklist.ts index 3090ff4c8..838d5d5af 100644 --- a/frontend/src/apis/checklist.ts +++ b/frontend/src/apis/checklist.ts @@ -27,17 +27,17 @@ export const getChecklists = async () => { return data.checklists.map(mapObjNullToUndefined); }; -export const postChecklist = async (checklist: ChecklistPostForm) => { - checklist.room.structure = checklist.room.structure === 'NONE' ? undefined : checklist.room.structure; - checklist.room = mapObjUndefinedToNull(checklist.room); - const response = await fetcher.post({ url: BASE_URL + ENDPOINT.CHECKLISTS, body: checklist }); - return response; -}; +// export const postChecklist = async (checklist: ChecklistPostForm) => { +// checklist.room.structure = checklist.room.structure === 'NONE' ? undefined : checklist.room.structure; +// checklist.room = mapObjUndefinedToNull(checklist.room); +// const response = await fetcher.post({ url: BASE_URL + ENDPOINT.CHECKLISTS, body: checklist }); +// return response; +// }; -export const postChecklistV1 = async (checklist: ChecklistPostForm) => { +export const postChecklist = async (checklist: ChecklistPostForm) => { checklist.room.structure = checklist.room.structure === 'NONE' ? undefined : checklist.room.structure; checklist.room = mapObjUndefinedToNull(checklist.room); - const response = await fetcher.post({ url: BASE_URL + ENDPOINT.CHECKLISTS, body: checklist }); + const response = await fetcher.post({ url: BASE_URL + ENDPOINT.V1_CHECKLISTS, body: checklist }); return response; }; diff --git a/frontend/src/apis/url.ts b/frontend/src/apis/url.ts index 128e957e2..82fee8391 100644 --- a/frontend/src/apis/url.ts +++ b/frontend/src/apis/url.ts @@ -6,6 +6,7 @@ export const BASE_URL = API_URL; export const ENDPOINT = { // checklist CHECKLISTS: '/checklists', + V1_CHECKLISTS: '/v1/checklists', CHECKLIST_QUESTION: '/checklists/questions', CHECKLIST_ALL_QUESTION: '/custom-checklist/all', CHECKLIST_CUSTOM: '/custom-checklist', diff --git a/frontend/src/hooks/useMutateChecklist.ts b/frontend/src/hooks/useMutateChecklist.ts index b2ec1ccca..0557d8a13 100644 --- a/frontend/src/hooks/useMutateChecklist.ts +++ b/frontend/src/hooks/useMutateChecklist.ts @@ -58,6 +58,7 @@ const useMutateChecklist = ( }, options: selectedOptions, questions: transformQuestions(checklistCategoryQnA), + position: roomInfoUnvalidated.position, }; const putData = { From ac924055130ef7e326b1be8db64861e3d7c7a49d Mon Sep 17 00:00:00 2001 From: ooherin <555ohr@naver.com> Date: Fri, 11 Oct 2024 16:34:16 +0900 Subject: [PATCH 3/9] =?UTF-8?q?fix:=20=EC=83=88=20=EC=B2=B4=ED=81=AC?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20post=20=ED=8F=AC=EB=A7=B7=20v1=20?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/constants/map.ts | 4 ++-- frontend/src/hooks/useMutateChecklist.ts | 5 ++--- frontend/src/hooks/useRoomInfoNonValidated.ts | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/frontend/src/constants/map.ts b/frontend/src/constants/map.ts index 9670dd61b..b97497122 100644 --- a/frontend/src/constants/map.ts +++ b/frontend/src/constants/map.ts @@ -1,6 +1,6 @@ import { Position } from '@/types/address'; export const DEFAULT_POSITION: Position = { - latitude: 1, - longitude: 1, + latitude: 37.5061912, + longitude: 127.0508228, }; diff --git a/frontend/src/hooks/useMutateChecklist.ts b/frontend/src/hooks/useMutateChecklist.ts index 0557d8a13..1f7944548 100644 --- a/frontend/src/hooks/useMutateChecklist.ts +++ b/frontend/src/hooks/useMutateChecklist.ts @@ -49,7 +49,7 @@ const useMutateChecklist = ( } //TODO: 나중에 해당 키 이름 수정 - const roomInfoUnvalidatedAnswerWithoutSubway = removeKey(roomInfoUnvalidatedAnswer, 'nearSubwayStation'); + const roomInfoUnvalidatedAnswerWithoutSubway = removeKey(roomInfoUnvalidatedAnswer, 'position'); const postData = { room: { @@ -58,7 +58,7 @@ const useMutateChecklist = ( }, options: selectedOptions, questions: transformQuestions(checklistCategoryQnA), - position: roomInfoUnvalidated.position, + geolocation: roomInfoUnvalidated.position, }; const putData = { @@ -78,7 +78,6 @@ const useMutateChecklist = ( if (onSuccessCallback) { onSuccessCallback(); } - const location = res.headers.get('location'); if (location) navigate(location); }, diff --git a/frontend/src/hooks/useRoomInfoNonValidated.ts b/frontend/src/hooks/useRoomInfoNonValidated.ts index be878fcdb..be2cff73d 100644 --- a/frontend/src/hooks/useRoomInfoNonValidated.ts +++ b/frontend/src/hooks/useRoomInfoNonValidated.ts @@ -16,7 +16,6 @@ const useRoomInfoNonValidated = () => { const searchSubwayStationsByPosition = async ({ latitude, longitude }: Position) => { const nearSubways = await getNearSubways({ latitude, longitude }); roomInfoNonValidated.set('position', { latitude, longitude }); - roomInfoNonValidated.set('nearSubwayStation', nearSubways); return nearSubways; }; From 524d5465bf1e0ab5aee774d8df437f9782cb9d87 Mon Sep 17 00:00:00 2001 From: ooherin <555ohr@naver.com> Date: Fri, 11 Oct 2024 16:47:39 +0900 Subject: [PATCH 4/9] =?UTF-8?q?feat:=20post=20form=20=EB=B0=94=EB=80=8C?= =?UTF-8?q?=EB=8A=94=20=EB=A1=9C=EC=A7=81=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/apis/checklist.ts | 1 + frontend/src/hooks/useMutateChecklist.ts | 26 +++++++++---------- frontend/src/hooks/useRoomInfoNonValidated.ts | 1 + .../src/store/roomInfoNonValidatedStore.ts | 9 ++++++- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/frontend/src/apis/checklist.ts b/frontend/src/apis/checklist.ts index 838d5d5af..c5552b45c 100644 --- a/frontend/src/apis/checklist.ts +++ b/frontend/src/apis/checklist.ts @@ -27,6 +27,7 @@ export const getChecklists = async () => { return data.checklists.map(mapObjNullToUndefined); }; +//TODO: 기존 form // export const postChecklist = async (checklist: ChecklistPostForm) => { // checklist.room.structure = checklist.room.structure === 'NONE' ? undefined : checklist.room.structure; // checklist.room = mapObjUndefinedToNull(checklist.room); diff --git a/frontend/src/hooks/useMutateChecklist.ts b/frontend/src/hooks/useMutateChecklist.ts index 1f7944548..fec956ee1 100644 --- a/frontend/src/hooks/useMutateChecklist.ts +++ b/frontend/src/hooks/useMutateChecklist.ts @@ -34,27 +34,27 @@ const useMutateChecklist = ( const checklistCategoryQnA = useChecklistStore(state => state.checklistCategoryQnA); //스토어에서 actions을 제외한 values 만 꺼내오는 함수 - const roomInfoUnvalidatedValues = () => { - const { actions, ...values } = roomInfoUnvalidated; - void actions; - return values; - }; + // const roomInfoUnvalidatedValues = () => { + // const { actions, ...values } = roomInfoUnvalidated; + // void actions; + // return values; + // }; - const roomInfoUnvalidatedAnswer = roomInfoUnvalidatedValues(); + // const roomInfoUnvalidatedAnswer = roomInfoUnvalidatedValues(); - function removeKey(obj: T, key: K): Omit { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { [key]: _, ...rest } = obj; - return rest; - } + // function removeKey(obj: T, key: K): Omit { + // // eslint-disable-next-line @typescript-eslint/no-unused-vars + // const { [key]: _, ...rest } = obj; + // return rest; + // } //TODO: 나중에 해당 키 이름 수정 - const roomInfoUnvalidatedAnswerWithoutSubway = removeKey(roomInfoUnvalidatedAnswer, 'position'); + //const roomInfoUnvalidatedAnswerWithoutSubway = removeKey(roomInfoUnvalidatedAnswer, 'position'); const postData = { room: { ...roomInfoAnswer, - ...{ ...roomInfoUnvalidatedAnswerWithoutSubway }, + ...roomInfoUnvalidatedActions.getFormValues(), }, options: selectedOptions, questions: transformQuestions(checklistCategoryQnA), diff --git a/frontend/src/hooks/useRoomInfoNonValidated.ts b/frontend/src/hooks/useRoomInfoNonValidated.ts index be2cff73d..b338e166b 100644 --- a/frontend/src/hooks/useRoomInfoNonValidated.ts +++ b/frontend/src/hooks/useRoomInfoNonValidated.ts @@ -16,6 +16,7 @@ const useRoomInfoNonValidated = () => { const searchSubwayStationsByPosition = async ({ latitude, longitude }: Position) => { const nearSubways = await getNearSubways({ latitude, longitude }); roomInfoNonValidated.set('position', { latitude, longitude }); + roomInfoNonValidated.set('nearSubwayStation', nearSubways.stations); return nearSubways; }; diff --git a/frontend/src/store/roomInfoNonValidatedStore.ts b/frontend/src/store/roomInfoNonValidatedStore.ts index d350916af..77e93ee31 100644 --- a/frontend/src/store/roomInfoNonValidatedStore.ts +++ b/frontend/src/store/roomInfoNonValidatedStore.ts @@ -14,6 +14,7 @@ interface States { interface Actions { set: (name: T, value: States[T]) => void; resetAll: () => void; + getFormValues: () => { address: string; buildingName: string }; } const defaultStates = { @@ -23,11 +24,17 @@ const defaultStates = { position: DEFAULT_POSITION, }; -const roomInfoNonValidatedStore = createStore()(set => ({ +const roomInfoNonValidatedStore = createStore()((set, get) => ({ ...defaultStates, actions: { set: (name, value) => set({ [name]: value }), resetAll: () => set(defaultStates), + getFormValues: () => { + return { + address: get().address, + buildingName: get().buildingName, + }; + }, }, })); From cc13a31f3aa050b6853499fd768f2da4066b83f7 Mon Sep 17 00:00:00 2001 From: ooherin <555ohr@naver.com> Date: Fri, 11 Oct 2024 17:02:19 +0900 Subject: [PATCH 5/9] =?UTF-8?q?fix:=20=ED=8F=AC=EB=A7=B7=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/hooks/useMutateChecklist.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/frontend/src/hooks/useMutateChecklist.ts b/frontend/src/hooks/useMutateChecklist.ts index fec956ee1..bf3dd5b48 100644 --- a/frontend/src/hooks/useMutateChecklist.ts +++ b/frontend/src/hooks/useMutateChecklist.ts @@ -33,24 +33,6 @@ const useMutateChecklist = ( // 체크리스트 답변 const checklistCategoryQnA = useChecklistStore(state => state.checklistCategoryQnA); - //스토어에서 actions을 제외한 values 만 꺼내오는 함수 - // const roomInfoUnvalidatedValues = () => { - // const { actions, ...values } = roomInfoUnvalidated; - // void actions; - // return values; - // }; - - // const roomInfoUnvalidatedAnswer = roomInfoUnvalidatedValues(); - - // function removeKey(obj: T, key: K): Omit { - // // eslint-disable-next-line @typescript-eslint/no-unused-vars - // const { [key]: _, ...rest } = obj; - // return rest; - // } - - //TODO: 나중에 해당 키 이름 수정 - //const roomInfoUnvalidatedAnswerWithoutSubway = removeKey(roomInfoUnvalidatedAnswer, 'position'); - const postData = { room: { ...roomInfoAnswer, From 67714833499e6630f17e5eb413a8b09362c1abc1 Mon Sep 17 00:00:00 2001 From: ooherin <555ohr@naver.com> Date: Mon, 14 Oct 2024 13:41:00 +0900 Subject: [PATCH 6/9] =?UTF-8?q?feat:=20moveSection=20=ED=81=B4=EB=A6=AD=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EC=84=B9=EC=85=98=20=ED=81=AC?= =?UTF-8?q?=EA=B8=B0=EB=A5=BC=20=EC=A4=84=EC=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/hooks/useMoveSection.ts | 5 +++-- frontend/src/pages/NewChecklistPage.tsx | 4 ---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/frontend/src/hooks/useMoveSection.ts b/frontend/src/hooks/useMoveSection.ts index aace102e8..b861c16da 100644 --- a/frontend/src/hooks/useMoveSection.ts +++ b/frontend/src/hooks/useMoveSection.ts @@ -32,9 +32,10 @@ const useMoveSection = (sectionRefs: React.MutableRefObject<(HTMLElement | null) const sectionHeight = sectionElement.offsetHeight; const clickYPosition = event.clientY - sectionElement.getBoundingClientRect().top; - if (clickYPosition < sectionHeight / 2) { + if (clickYPosition < sectionHeight * 0.2) { scrollToPrevSection(index); - } else { + } + if (clickYPosition > sectionHeight * 0.8) { scrollToNextSection(index); } }; diff --git a/frontend/src/pages/NewChecklistPage.tsx b/frontend/src/pages/NewChecklistPage.tsx index ae6287a2b..801152174 100644 --- a/frontend/src/pages/NewChecklistPage.tsx +++ b/frontend/src/pages/NewChecklistPage.tsx @@ -1,4 +1,3 @@ -import { useNavigate } from 'react-router-dom'; import { useStore } from 'zustand'; import Button from '@/components/_common/Button/Button'; @@ -11,7 +10,6 @@ import MemoButton from '@/components/NewChecklist/MemoModal/MemoButton'; import MemoModal from '@/components/NewChecklist/MemoModal/MemoModal'; import NewChecklistContent from '@/components/NewChecklist/NewChecklistContent'; import SubmitModalWithSummary from '@/components/NewChecklist/SubmitModalWithSummary/SubmitModalWithSummary'; -import { ROUTE_PATH } from '@/constants/routePath'; import { DEFAULT_CHECKLIST_TAB_PAGE } from '@/constants/system'; import useChecklistTabs from '@/hooks/useChecklistTabs'; import useHandleTip from '@/hooks/useHandleTip'; @@ -23,7 +21,6 @@ import useChecklistStore from '@/store/useChecklistStore'; import useSelectedOptionStore from '@/store/useSelectedOptionStore'; const NewChecklistPage = () => { - const navigate = useNavigate(); useChecklistTemplate(); // 체크리스트 질문 가져오기 및 준비 const { tabs } = useChecklistTabs(); @@ -51,7 +48,6 @@ const NewChecklistPage = () => { checklistActions.reset(); selectedOptionActions.reset(); resetShowTip(); // 옵션의 팁박스 다시표시 - navigate(ROUTE_PATH.checklistList); }; return ( From 951e889ee20b02c72e2afb45c084dca6d6ccc798 Mon Sep 17 00:00:00 2001 From: ooherin <555ohr@naver.com> Date: Mon, 14 Oct 2024 13:42:12 +0900 Subject: [PATCH 7/9] =?UTF-8?q?fix:=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/apis/checklist.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/frontend/src/apis/checklist.ts b/frontend/src/apis/checklist.ts index c5552b45c..8d7a53a91 100644 --- a/frontend/src/apis/checklist.ts +++ b/frontend/src/apis/checklist.ts @@ -27,14 +27,6 @@ export const getChecklists = async () => { return data.checklists.map(mapObjNullToUndefined); }; -//TODO: 기존 form -// export const postChecklist = async (checklist: ChecklistPostForm) => { -// checklist.room.structure = checklist.room.structure === 'NONE' ? undefined : checklist.room.structure; -// checklist.room = mapObjUndefinedToNull(checklist.room); -// const response = await fetcher.post({ url: BASE_URL + ENDPOINT.CHECKLISTS, body: checklist }); -// return response; -// }; - export const postChecklist = async (checklist: ChecklistPostForm) => { checklist.room.structure = checklist.room.structure === 'NONE' ? undefined : checklist.room.structure; checklist.room = mapObjUndefinedToNull(checklist.room); From d4855e1234d1e8136d86631d01a52ec814bc827c Mon Sep 17 00:00:00 2001 From: ooherin <555ohr@naver.com> Date: Mon, 14 Oct 2024 14:04:34 +0900 Subject: [PATCH 8/9] =?UTF-8?q?fix:=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/NewChecklistPage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/NewChecklistPage.tsx b/frontend/src/pages/NewChecklistPage.tsx index 801152174..c7fdd9a3c 100644 --- a/frontend/src/pages/NewChecklistPage.tsx +++ b/frontend/src/pages/NewChecklistPage.tsx @@ -42,7 +42,7 @@ const NewChecklistPage = () => { // 로그인 요청 모달 const { isModalOpen: isLoginModalOpen, openModal: openLoginModal, closeModal: closeLoginModal } = useModal(); - const resetAndGoHome = () => { + const resetChecklist = () => { roomInfoActions.resetAll(); roomInfoNonValidatedActions.resetAll(); checklistActions.reset(); @@ -71,7 +71,7 @@ const NewChecklistPage = () => { @@ -86,7 +86,7 @@ const NewChecklistPage = () => { } isOpen={isAlertModalOpen} onClose={closeAlertModal} - handleApprove={resetAndGoHome} + handleApprove={resetChecklist} approveButtonName="나가기" /> From ffb20c8ae8685ff4bb1d2fbcf88cf649504ab736 Mon Sep 17 00:00:00 2001 From: ooherin <555ohr@naver.com> Date: Mon, 14 Oct 2024 14:07:17 +0900 Subject: [PATCH 9/9] =?UTF-8?q?fix:=20url=20=EC=9D=B4=EB=A6=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/apis/checklist.ts | 2 +- frontend/src/apis/url.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/apis/checklist.ts b/frontend/src/apis/checklist.ts index 8d7a53a91..8027445bb 100644 --- a/frontend/src/apis/checklist.ts +++ b/frontend/src/apis/checklist.ts @@ -30,7 +30,7 @@ export const getChecklists = async () => { export const postChecklist = async (checklist: ChecklistPostForm) => { checklist.room.structure = checklist.room.structure === 'NONE' ? undefined : checklist.room.structure; checklist.room = mapObjUndefinedToNull(checklist.room); - const response = await fetcher.post({ url: BASE_URL + ENDPOINT.V1_CHECKLISTS, body: checklist }); + const response = await fetcher.post({ url: BASE_URL + ENDPOINT.CHECKLISTS_V1, body: checklist }); return response; }; diff --git a/frontend/src/apis/url.ts b/frontend/src/apis/url.ts index 82fee8391..f5752eb54 100644 --- a/frontend/src/apis/url.ts +++ b/frontend/src/apis/url.ts @@ -6,7 +6,7 @@ export const BASE_URL = API_URL; export const ENDPOINT = { // checklist CHECKLISTS: '/checklists', - V1_CHECKLISTS: '/v1/checklists', + CHECKLISTS_V1: '/v1/checklists', CHECKLIST_QUESTION: '/checklists/questions', CHECKLIST_ALL_QUESTION: '/custom-checklist/all', CHECKLIST_CUSTOM: '/custom-checklist',