Skip to content

feat: 진단 API 연동 및 위험도 분석 섹션 구현#53

Merged
Dobbymin merged 16 commits intomainfrom
feat#51-diagnostic
Aug 22, 2025
Merged

feat: 진단 API 연동 및 위험도 분석 섹션 구현#53
Dobbymin merged 16 commits intomainfrom
feat#51-diagnostic

Conversation

@Dobbymin
Copy link
Copy Markdown
Contributor

📝 요약 (Summary)

진단 API 연동을 통한 위험도 분석 기능을 구현하고, Zustand를 활용한 전역 상태 관리 시스템을 구축했습니다. 사용자가 주소와 집 정보를 입력하고 진단 버튼을 클릭하면 API를 통해 위험도 분석 결과를 받아와 화면에 표시하는 기능을 추가했습니다.

✅ 주요 변경 사항 (Key Changes)

  • 진단 API 연동 및 전역 상태 관리 스토어(useHouseData) 구현
  • 위험도 분석 섹션(RiskAnalysisSummarySection)에 데이터 로딩 및 오류 처리 추가
  • 임대인 신뢰도 섹션(LandlordReliabilitySection)에 데이터 로딩 및 오류 처리 추가
  • Zustand 스토어에 Redux DevTools 지원 추가
  • 컴포넌트별 데이터 props 전달 및 기본 데이터 처리 로직 구현

💻 상세 구현 내용 (Implementation Details)

1. 진단 API 연동 ()

  • 진단 API 엔드포인트 정의 및 타입 정의
  • 주소, 상세주소, 집 유형, 보증금 정보를 받아 위험도 분석 요청

2. 전역 상태 관리 ()

  • Zustand를 사용한 진단 데이터 전역 상태 관리
  • API 응답 형태 자동 감지 및 처리 로직
  • Redux DevTools 지원으로 디버깅 기능 강화
  • 로딩 상태, 에러 상태 관리

3. 진단 폼 개선 ()

  • useMutation을 사용한 API 호출 로직 구현
  • 성공/실패/로딩 상태에 따른 스토어 상태 업데이트
  • 에러 핸들링 및 사용자 피드백 제공

4. 위험도 분석 섹션 ()

  • 진단 데이터 기반으로 위험도 점수 및 위험 요인 표시
  • 데이터가 없을 때 mock 데이터 사용으로 UI 유지
  • 데이터 구조 검증 및 에러 처리

5. 임대인 신뢰도 섹션 ()

  • 진단 데이터 기반으로 임대인 정보 표시
  • GradeBox, SubrogationPaymentBox, MultiHouseBox 컴포넌트에 데이터 전달
  • 로딩 상태 및 에러 상태 처리

6. 컴포넌트별 데이터 처리

  • GradeBox: 임대인 등급 정보 표시
  • SubrogationPaymentBox: 대위변제 정보 표시
  • MultiHouseBox: 다주택 정보 표시
  • ReasonBox: 신뢰도 이유 표시

🚀 트러블 슈팅 (Trouble Shooting)

1. API 응답 구조 불일치 문제

  • 문제: API 응답이 형태로 오는데 기존 타입과 불일치
  • 해결: ApiResponse 타입 추가 및 스토어에서 자동 감지하여 처리하는 로직 구현

2. 데이터 구조 검증 문제

  • 문제: 필수 필드가 없는 경우 런타임 오류 발생
  • 해결: 데이터 구조 검증 로직 추가 및 안전한 접근 방식 적용

3. 컴포넌트 간 데이터 전달 복잡성

  • 문제: 여러 컴포넌트에 데이터를 props로 전달하는 복잡성
  • 해결: Zustand 전역 상태 관리로 중앙화된 데이터 관리

⚠️ 알려진 이슈 및 참고 사항 (Known Issues & Notes)

  • 진단 API 서버 연결이 필요합니다 (현재는 타입 정의만 완료)
  • Mock 데이터는 개발 환경에서만 사용됩니다
  • Redux DevTools 확장 프로그램 설치가 필요합니다 (개발자 도구에서 상태 변화 확인 가능)

📸 스크린샷 (Screenshots)

진단 기능 구현으로 인한 UI 변경사항:

  • 진단 버튼 클릭 시 로딩 상태 표시
  • 진단 완료 후 위험도 점수 및 위험 요인 표시
  • 임대인 신뢰도 정보 표시
  • 에러 발생 시 사용자 친화적 메시지 표시

#️⃣ 관련 이슈 (Related Issues)

@Dobbymin Dobbymin linked an issue Aug 22, 2025 that may be closed by this pull request
@Dobbymin Dobbymin self-assigned this Aug 22, 2025
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @Dobbymin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 풀 리퀘스트는 주택 진단 API를 시스템에 연동하고, 사용자가 입력한 주소와 집 정보를 기반으로 위험도를 분석하여 시각적으로 보여주는 기능을 구현합니다. 핵심적으로는 진단 API와의 통신 로직을 추가하고, Zustand를 활용한 전역 상태 관리 시스템을 구축하여 API 응답 데이터를 효율적으로 관리합니다. 이를 통해 위험도 분석 섹션과 임대인 신뢰도 섹션이 동적으로 데이터를 표시하며, 로딩 및 오류 처리와 같은 사용자 피드백 메커니즘도 함께 개선되었습니다.

Highlights

  • 진단 API 연동: 주소와 집 정보를 입력받아 위험도 분석 API를 호출하고, 그 결과를 화면에 표시하는 기능이 구현되었습니다.
  • Zustand 기반 전역 상태 관리 시스템 구축: Zustand를 활용하여 진단 데이터(위험도 요약, 임대인 정보 등)를 전역적으로 관리하는 useHouseData 스토어가 새로 추가되었습니다. 이를 통해 컴포넌트 간 데이터 전달이 간소화되고, 로딩 및 에러 상태 관리가 용이해졌습니다.
  • 위험도 분석 및 임대인 신뢰도 섹션 구현 및 개선: 위험도 분석 섹션과 임대인 신뢰도 섹션이 API 응답 데이터를 기반으로 정보를 표시하도록 업데이트되었습니다. 데이터 로딩 중 스피너 표시, 오류 메시지 출력, 그리고 데이터가 없을 경우의 처리 로직이 추가되어 사용자 경험이 개선되었습니다.
  • 개발자 도구 지원 강화: Zustand 스토어에 Redux DevTools 지원이 추가되어 개발 중 상태 변화를 쉽게 추적하고 디버깅할 수 있게 되었습니다.
  • 데이터 모델 및 상수 정의 업데이트: API 응답 구조 변경에 따른 타입 정의(RiskFactor -> Factor, RiskSummarygrade 추가) 및 APARTMENT 주택 유형 값 변경 등 데이터 모델 및 상수 정의가 업데이트되었습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

이번 PR은 진단 API 연동과 Zustand를 이용한 전역 상태 관리를 통해 위험도 분석 기능을 구현한 점이 인상적입니다. 전반적으로 코드 구조가 잘 잡혀있고, 로딩 및 에러 상태 처리도 꼼꼼하게 구현되었습니다. 코드의 안정성과 유지보수성을 높이기 위해 몇 가지 개선점을 제안합니다.

const data = diagnosisData || DEFAULT_RISK_ANALYSIS_DATA.data;

// 데이터 구조 검증
if (!data?.riskSummary?.score || !data?.riskSummary?.factors) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

데이터 구조를 검증하는 로직에서 !data?.riskSummary?.score 부분에 잠재적인 버그가 있습니다. score 값이 0일 경우, !0true로 평가되어 유효한 데이터임에도 불구하고 "데이터 구조가 올바르지 않습니다."라는 메시지가 표시될 수 있습니다. scorenull 또는 undefined인지 명시적으로 확인하는 것이 더 안전합니다.

Suggested change
if (!data?.riskSummary?.score || !data?.riskSummary?.factors) {
if (data?.riskSummary?.score == null || !data?.riskSummary?.factors) {

Comment on lines +55 to +57
resetState: () => {
set({ diagnosisData: null });
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

resetState 함수가 clearDiagnosisData와 동일하게 diagnosisData만 초기화하고 있습니다. 함수의 이름에 맞게 isLoadingerror를 포함한 스토어의 모든 상태를 초기값으로 되돌리는 것이 더 명확하고 예측 가능한 동작일 것입니다. 또한, 이 수정이 적용되면 clearDiagnosisData 함수는 resetState와 기능이 일부 중복되므로, resetState로 통일하거나 별도의 역할이 없다면 제거하는 것을 고려해볼 수 있습니다.

Suggested change
resetState: () => {
set({ diagnosisData: null });
},
resetState: () => {
set({ diagnosisData: null, isLoading: false, error: null });
},

@Dobbymin Dobbymin merged commit 020b917 into main Aug 22, 2025
2 checks passed
@Dobbymin Dobbymin deleted the feat#51-diagnostic branch August 22, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[기능 구현] 진단하기 API 구현

1 participant