-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
스케줄 상세주소 추가 작업 #300
스케줄 상세주소 추가 작업 #300
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useEffect } from 'react'; | ||
|
||
const useScript = (url: string) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 hook에서 isScriptLoaded 같은 상태를 관리하고 hook 외부로 헤딩 싱태를 return 해주면 hook의 사용도가 더 올라갈거 같다는 생각! |
||
useEffect(() => { | ||
const script = document.createElement('script'); | ||
script.src = url; | ||
script.async = true; | ||
document.body.appendChild(script); | ||
return () => { | ||
document.body.removeChild(script); | ||
}; | ||
}, [url]); | ||
}; | ||
|
||
export default useScript; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ export interface ScheduleFormValues { | |
longitude: string; | ||
placeName: string; | ||
}; | ||
detailAddress?: string; | ||
} | ||
|
||
export const getScheduleStatusText = (status: ValueOf<typeof ScheduleStatus>) => { | ||
|
@@ -43,7 +44,13 @@ export const getScheduleStatusText = (status: ValueOf<typeof ScheduleStatus>) => | |
export const parseScheduleResponseToFormValues = ( | ||
response: ScheduleResponse, | ||
): ScheduleFormValues => { | ||
const { name, generationNumber, startedAt, eventList, location } = response; | ||
const { | ||
name, | ||
generationNumber, | ||
startedAt, | ||
eventList, | ||
location: { address, placeName, latitude, longitude }, | ||
} = response; | ||
|
||
const date: Dayjs = dayjs(startedAt, 'YYYY-MM-DD').startOf('day'); | ||
|
||
|
@@ -58,22 +65,41 @@ export const parseScheduleResponseToFormValues = ( | |
})), | ||
})); | ||
|
||
const isOffline = !!location.address; | ||
if (address) { | ||
// address의 형식: 주소 (상세주소) | ||
const baseAddress = address.replace(/\s*\(.*?\)\s*/g, ''); | ||
const [, detailAddress] = address.match(/\(([^)]+)\)/) ?? []; | ||
Comment on lines
+70
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이건 내 개인취향인데 정규식은 최대한 하는일에 맞게 이름을 지어주면 코드 파악이나 유지보수 할때 좋은거 같아! 사실 정규식이 한눈에 딱 보고 뭐하는지 알기가 힘드니ㅎㅎ |
||
return { | ||
name, | ||
generationNumber, | ||
date, | ||
sessions, | ||
locationType: LocationType.OFFLINE, | ||
placeName, | ||
detailAddress, | ||
locationInfo: { | ||
address: baseAddress, | ||
latitude: String(latitude), | ||
longitude: String(longitude), | ||
placeName, | ||
}, | ||
}; | ||
} | ||
|
||
return { | ||
name, | ||
generationNumber, | ||
date, | ||
sessions, | ||
locationType: isOffline ? LocationType.OFFLINE : LocationType.ONLINE, | ||
placeName: isOffline ? location.placeName : undefined, | ||
locationType: LocationType.ONLINE, | ||
}; | ||
}; | ||
|
||
export const parseFormValuesToScheduleRequest = ( | ||
formValues: ScheduleFormValues, | ||
): ScheduleCreateRequest | ScheduleUpdateRequest => { | ||
const { generationNumber, date, sessions, name, locationType, locationInfo } = formValues; | ||
const { generationNumber, date, sessions, name, locationType, locationInfo, detailAddress } = | ||
formValues; | ||
|
||
const formattedDate = date.format('YYYY-MM-DD'); | ||
|
||
|
@@ -99,7 +125,7 @@ export const parseFormValuesToScheduleRequest = ( | |
}; | ||
|
||
if (locationType === LocationType.OFFLINE && locationInfo) { | ||
scheduleRequest.address = locationInfo.address; | ||
scheduleRequest.address = `${locationInfo.address}${detailAddress ? `(${detailAddress})` : ''}`; | ||
scheduleRequest.latitude = Number(locationInfo.latitude); | ||
scheduleRequest.longitude = Number(locationInfo.longitude); | ||
scheduleRequest.placeName = locationInfo.placeName; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
우리 public 레포인데 이건 이렇게 노출해도 되는건가?.?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
띠용..😓 처리할게용