Skip to content
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

Bug/location 동일 동명 선택 가능 #34

Merged
merged 9 commits into from
Sep 24, 2021
Merged

Bug/location 동일 동명 선택 가능 #34

merged 9 commits into from
Sep 24, 2021

Conversation

skawnkk
Copy link
Contributor

@skawnkk skawnkk commented Sep 23, 2021

기능요약 (이 PR은 어떤 일을 하나요?)

  • 기존에는 동명이 동일하면, 도시가 달라도 선택이 되지 않는 오류가 있었음
  • 수정 후, 동일한 동명이라도 선택할 수 있게 변경됨

작업내용

  • 기존에는 location정보를 dongName으로만 받았는데, 전체 주소를 받도록 처리함
  • 그리고 새로 선택한 동명과 기존의 주소값을을 비교해 겹치는 동명이 있는지 판단함

이 PR이 필요한 이유 (optional)

  • 이슈#30에러 수정

변경사항에 대한 렌더링 화면 변화를 캡처해 첨부해주세요.

image

@skawnkk skawnkk added the 🦋 fix 버그 수정 (a bug fix) label Sep 23, 2021
@skawnkk skawnkk self-assigned this Sep 23, 2021
Copy link
Contributor

@17-sss 17-sss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전체적으로 좋습니다. 오늘은 의견이 많은 것 같기도 하네요 😅
헌데 yarn.lock이 또 올라와있고 .gitignore는 삭제되었네요.
이 부분은 같이하거나 제가 조금있다가 추가적인 커밋을 하도록 하겠습니다.
고생하셨습니다 주나미 😊

Comment on lines +40 to +41
const dongName = (region: string) => region.split(" ").reverse()[0];
const cityName = (region: string) => region.split(" ").reverse()[1];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

의견입니다!
현재 dongName, cityName은 함수인데, 꼭 일반 변수처럼 보이네요..
앞에 get이라던지 동사가 붙어있다면 어떨까요?

또한 함수를 2개를 선언하는 것이 아닌
const getRegionInfo = (region: string) => region.split(" ").reverse();
dongName, cityName을 불러올 때는
const [dongName, cityName] = getRegionInfo(location)

Comment on lines +110 to +124
{searchLogs.map((location, idx) =>
!isSameDong ? (
<TargetButton
key={idx}
displayName={dongName(location)}
onDeleteItemClick={handleDeleteTarget(location)}
/>
) : (
<TargetButton
key={idx}
displayName={cityName(location) + " " + dongName(location)}
onDeleteItemClick={handleDeleteTarget(location)}
/>
),
)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

의견입니다!

searchLogs.map((location, idx) =>
이 부분 뒤에서 지금처럼 바로 조건에 따른 JSX를 리턴하는게 아닌
const [dongName, cityName] = getRegionInfo(location)
이렇게 미리 값을 계산해놓고 JSX를 렌더하는 건 어떨까요?

{searchLogs.map((location, idx) => {
  const [dongName, cityName] = getRegionInfo(location);
  return !isSameDong ? (
    <TargetButton key={idx} displayName={dongName} onDeleteItemClick={handleDeleteTarget(location)} />
  ) : (
    <TargetButton
      key={idx}
      displayName={`${cityName} ${dongName}`}
      onDeleteItemClick={handleDeleteTarget(location)}
    />
  );
})}

또한 일반적인 경우에는 "~동" 으로만 나오고 같은 동이 있을 경우에는 "~구 ~동"으로만 나오는 로직이군요.
멋집니다 :)

@skawnkk skawnkk merged commit ed64af7 into dev Sep 24, 2021
@skawnkk skawnkk deleted the bug/location branch September 24, 2021 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦋 fix 버그 수정 (a bug fix)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants