Skip to content

Conversation

@ssuminii
Copy link
Contributor

@ssuminii ssuminii commented Nov 17, 2024

🚀 풀 리퀘스트 제안

closes #43

📋 작업 내용

  • 전략 등록 조회(get) msw 구현 및 api 연동
  • 전략 등록 요청(post) msw 구현 및 api 연동
  • 상품유형, 매매유형, 주기 옵션 데이터 가져오는 커스텀 훅 작성
  • zustand 사용하여 전략 등록 폼 상태 관리

🔧 변경 사항

  • 📃 README.md
  • 📦 package.json
  • 🔥 파일 삭제
  • 🧹 그 외 ex) .gitignore 등

주요 변경 사항을 요약해 주세요.

📸 스크린샷 (선택 사항)

Nov-17-2024 22-20-05

📄 기타

추가적으로 전달하고 싶은 내용이나 특별한 요구 사항이 있으면 작성해 주세요.

Sourcery에 의한 요약

MSW를 사용하여 전략 등록 및 검색 기능을 구현하고, 이를 API와 통합하며, Zustand로 폼 상태를 관리합니다. 옵션 데이터 가져오기를 위한 커스텀 훅을 사용하여 전략 생성 폼을 리팩토링합니다.

새로운 기능:

  • MSW를 사용하여 전략 등록 및 검색을 구현하고 API와 통합합니다.
  • 제품 유형, 거래 유형 및 주기를 위한 옵션 데이터를 가져오는 커스텀 훅을 생성합니다.
  • Zustand를 사용하여 전략 등록 폼 상태를 관리합니다.

개선 사항:

  • 데이터 가져오기를 위한 중앙 집중식 상태 관리 및 커스텀 훅을 사용하여 전략 생성 폼을 리팩토링합니다.
Original summary in English

Summary by Sourcery

Implement strategy registration and retrieval functionalities using MSW, integrate them with the API, and manage form state with Zustand. Refactor the strategy creation form to utilize centralized state management and custom hooks for fetching options data.

New Features:

  • Implement strategy registration and retrieval using MSW and integrate with API.
  • Create custom hooks to fetch options data for product type, trading type, and cycle.
  • Manage strategy registration form state using Zustand.

Enhancements:

  • Refactor strategy creation form to use centralized state management and custom hooks for data fetching.

@ssuminii ssuminii added the ✨ Feature 기능 개발 label Nov 17, 2024
@ssuminii ssuminii self-assigned this Nov 17, 2024
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 17, 2024

리뷰어 가이드 by Sourcery

이 PR은 API 모킹을 위한 MSW(Mock Service Worker)와 폼 상태 관리를 위한 Zustand를 사용하여 전략 등록 기능을 구현합니다. 구현에는 등록 폼 데이터를 가져오고 새로운 전략을 제출하기 위한 API 엔드포인트, 폼 기능을 지원하기 위한 커스텀 훅 및 유틸리티가 포함됩니다.

전략 등록 API 상호작용을 위한 시퀀스 다이어그램

sequenceDiagram
    actor User
    participant UI
    participant API
    participant MSW

    User->>UI: 전략 등록 폼 작성
    UI->>API: GET /api/strategies/registration-form
    API->>MSW: 전략 옵션이 포함된 모킹된 응답
    MSW-->>API: 전략 옵션 반환
    API-->>UI: 전략 옵션 제공
    User->>UI: 전략 등록 폼 제출
    UI->>API: POST /api/strategies with form data
    API->>MSW: 전략 제출을 위한 모킹된 응답
    MSW-->>API: 제출 성공 반환
    API-->>UI: 전략 등록 성공 확인
Loading

전략 관련 타입에 대한 업데이트된 클래스 다이어그램

classDiagram
    class TradingType {
        +number tradingTypeId
        +string tradingTypeName
        +string tradingTypeIcon
    }
    class InvestmentAssetClass {
        +number investmentAssetClassesId
        +string investmentAssetClassesName
        +string investmentAssetClassesIcon
    }
    class TradingCycleClass {
        +number tradingCycleId
        +string tradingCycleName
        +string tradingTypeIcon
    }
    class StrategyRequestBody {
        +string strategyTitle
        +number tradingTypeId
        +number tradingCycleId
        +string minInvestmentAmount
        +string strategyOverview
        +string isPosted
        +number[] investmentAssetClassesIdList
    }
    class StrategyFormState {
        +string strategy
        +string text
        +string operation
        +string cycle
        +string fund
        +string publicStatus
        +string[] selectedProducts
        +void setField(field, value)
        +void checkProduct(productId)
        +void clearForm()
    }
    note for StrategyFormState "Zustand를 사용하여 상태 관리"
Loading

파일 수준 변경 사항

변경 사항 세부 사항 파일
전략 등록 API 엔드포인트를 위한 MSW 핸들러 구현
  • 거래 유형, 자산 클래스 및 주기를 위한 모의 데이터로 등록 폼 데이터를 가져오는 GET 엔드포인트 추가
  • 요청 유효성 검사를 포함한 전략 제출을 위한 POST 엔드포인트 추가
  • 'Auth' 헤더를 사용한 인증 검사 구현
src/mocks/handlers/strategy.handlers.ts
Zustand를 사용하여 전략 생성 폼 리팩토링
  • 폼 상태 관리를 위한 Zustand 스토어 생성
  • 로컬 상태를 Zustand 스토어 훅으로 대체
  • API 통합을 통한 폼 제출 처리 추가
src/components/page/strategy-create/StrategyCreateForm.tsx
src/stores/strategyFormStore.ts
API 통합 및 커스텀 훅 추가
  • 폼 데이터를 가져오고 전략을 제출하기 위한 API 함수 생성
  • 전략 옵션 데이터를 가져오기 위한 커스텀 훅 구현
  • API 데이터를 선택 옵션으로 매핑하기 위한 유틸리티 함수 추가
src/api/strategy.ts
src/hooks/useFetchStrategyOptionData.ts
src/utils/mapToOptions.ts
상수 및 구성을 별도의 파일로 이동
  • 투자 펀드 및 가시성 옵션을 상수 파일로 추출
  • 새로운 데이터 구조를 처리하기 위해 제품 유형 구성 요소 업데이트
src/constants/createOptopns.ts
src/components/page/strategy-create/form-content/ProductType.tsx

연결된 이슈에 대한 평가

이슈 목표 해결됨 설명
#43 전략 등록 데이터를 가져오기 위한 MSW API 구현 (거래 유형, 제품 유형, 주기)
#43 전략 등록을 위한 MSW API를 통해 가상 서버로 유효한 데이터 전송 (로컬 환경에서 테스트)
#43 MSW를 포함한 성공/실패 시나리오 처리, 성공 시 전략 세부 페이지로의 네비게이션 및 실패 시 오류 메시지 표시

연결될 수 있는 이슈


팁 및 명령어

Sourcery와 상호작용

  • 새로운 리뷰 트리거: 풀 리퀘스트에 @sourcery-ai review라고 댓글을 남깁니다.
  • 토론 계속: Sourcery의 리뷰 댓글에 직접 답글을 남깁니다.
  • 리뷰 댓글에서 GitHub 이슈 생성: 리뷰 댓글에서 Sourcery에게 이슈 생성을 요청합니다.
  • 풀 리퀘스트 제목 생성: 풀 리퀘스트 제목 어디에나 @sourcery-ai를 작성하여 언제든지 제목을 생성합니다.
  • 풀 리퀘스트 요약 생성: 풀 리퀘스트 본문 어디에나 @sourcery-ai summary를 작성하여 언제든지 PR 요약을 생성합니다. 이 명령어를 사용하여 요약이 삽입될 위치를 지정할 수도 있습니다.

경험 맞춤화

대시보드에 접속하여:

  • Sourcery가 생성한 풀 리퀘스트 요약, 리뷰어 가이드 등과 같은 리뷰 기능을 활성화하거나 비활성화합니다.
  • 리뷰 언어를 변경합니다.
  • 사용자 정의 리뷰 지침을 추가, 제거 또는 편집합니다.
  • 기타 리뷰 설정을 조정합니다.

도움 받기

Original review guide in English

Reviewer's Guide by Sourcery

This PR implements the strategy registration functionality using MSW (Mock Service Worker) for API mocking and Zustand for form state management. The implementation includes API endpoints for fetching registration form data and submitting new strategies, along with custom hooks and utilities to support the form functionality.

Sequence diagram for strategy registration API interactions

sequenceDiagram
    actor User
    participant UI
    participant API
    participant MSW

    User->>UI: Fill strategy registration form
    UI->>API: GET /api/strategies/registration-form
    API->>MSW: Mocked response with strategy options
    MSW-->>API: Return strategy options
    API-->>UI: Provide strategy options
    User->>UI: Submit strategy registration form
    UI->>API: POST /api/strategies with form data
    API->>MSW: Mocked response for strategy submission
    MSW-->>API: Return submission success
    API-->>UI: Confirm strategy registration success
Loading

Updated class diagram for strategy-related types

classDiagram
    class TradingType {
        +number tradingTypeId
        +string tradingTypeName
        +string tradingTypeIcon
    }
    class InvestmentAssetClass {
        +number investmentAssetClassesId
        +string investmentAssetClassesName
        +string investmentAssetClassesIcon
    }
    class TradingCycleClass {
        +number tradingCycleId
        +string tradingCycleName
        +string tradingTypeIcon
    }
    class StrategyRequestBody {
        +string strategyTitle
        +number tradingTypeId
        +number tradingCycleId
        +string minInvestmentAmount
        +string strategyOverview
        +string isPosted
        +number[] investmentAssetClassesIdList
    }
    class StrategyFormState {
        +string strategy
        +string text
        +string operation
        +string cycle
        +string fund
        +string publicStatus
        +string[] selectedProducts
        +void setField(field, value)
        +void checkProduct(productId)
        +void clearForm()
    }
    note for StrategyFormState "Uses Zustand for state management"
Loading

File-Level Changes

Change Details Files
Implemented MSW handlers for strategy registration API endpoints
  • Added GET endpoint for fetching registration form data with mock data for trading types, asset classes, and cycles
  • Added POST endpoint for strategy submission with request validation
  • Implemented authentication check using 'Auth' header
src/mocks/handlers/strategy.handlers.ts
Refactored strategy creation form to use Zustand for state management
  • Created Zustand store for managing form state
  • Replaced local state with Zustand store hooks
  • Added form submission handling with API integration
src/components/page/strategy-create/StrategyCreateForm.tsx
src/stores/strategyFormStore.ts
Added API integration and custom hooks
  • Created API functions for fetching form data and submitting strategies
  • Implemented custom hook for fetching strategy option data
  • Added utility function for mapping API data to select options
src/api/strategy.ts
src/hooks/useFetchStrategyOptionData.ts
src/utils/mapToOptions.ts
Moved constants and configuration to separate files
  • Extracted investment funds and visibility options to constants file
  • Updated product type component to handle new data structure
src/constants/createOptopns.ts
src/components/page/strategy-create/form-content/ProductType.tsx

Assessment against linked issues

Issue Objective Addressed Explanation
#43 Implement MSW API for fetching strategy registration data (trade type, product type, cycle)
#43 Send valid data to virtual server through MSW API for strategy registration (test in local environment)
#43 Handle success/failure scenarios with MSW including navigation to strategy detail page on success and error message display on failure

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions
Copy link

@github-actions github-actions bot temporarily deployed to pull request November 17, 2024 13:21 Inactive
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

안녕하세요 @ssuminii - 변경 사항을 검토했습니다. 다음은 피드백입니다:

전반적인 의견:

  • console.log 문을 제거하고 코드베이스 전반에 걸쳐 오류 처리를 표준화하는 것을 고려하세요. 프로덕션 코드는 console.log/console.error 대신 적절한 오류 추적/로깅을 사용해야 합니다.
검토 중에 살펴본 내용입니다
  • 🟡 일반 문제: 2개의 문제 발견
  • 🟢 보안: 모두 양호
  • 🟢 테스트: 모두 양호
  • 🟢 복잡성: 모두 양호
  • 🟢 문서화: 모두 양호

Sourcery는 오픈 소스에 무료입니다 - 리뷰가 마음에 드셨다면 공유를 고려해 주세요 ✨
더 유용하게 도와주세요! 각 댓글에 👍 또는 👎를 클릭해 주시면 피드백을 사용하여 리뷰를 개선하겠습니다.
Original comment in English

Hey @ssuminii - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider removing console.log statements and standardizing error handling across the codebase. Production code should use proper error tracking/logging instead of console.log/console.error.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

});
return res.data;
} catch (error) {
console.error('failed to fetch strategy registration data', error);
Copy link

Choose a reason for hiding this comment

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

issue: fetchStrategyRegistration에서 오류 처리가 개선되어야 합니다

단순히 로그를 기록하고 암시적으로 undefined를 반환하는 대신, 이 함수는 오류를 던져 호출자가 적절한 오류 처리를 할 수 있도록 해야 합니다.

Original comment in English

issue: Error handling needs improvement in fetchStrategyRegistration

Instead of just logging and implicitly returning undefined, this function should throw the error to allow proper error handling by the caller.

prev.includes(product) ? prev.filter((item) => item !== product) : [...prev, product]
);
const handleFileSelect = (selectedFile: File) => {
console.log(file);
Copy link

Choose a reason for hiding this comment

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

issue: 파일 업로드 처리가 불완전합니다

파일 업로드 로직이 이전 파일 값을 로그로 기록하고 파일이 전략 제출 페이로드에 포함되지 않습니다. 파일 업로드가 요구 사항이라면 이를 적절히 처리해야 합니다.

Original comment in English

issue: File upload handling is incomplete

The file upload logic logs the old file value and the file isn't included in the strategy submission payload. This should be properly handled if file upload is a requirement.

@github-actions
Copy link

@github-actions github-actions bot temporarily deployed to pull request November 17, 2024 13:28 Inactive
@github-actions
Copy link

@github-actions github-actions bot temporarily deployed to pull request November 17, 2024 14:07 Inactive
Copy link
Collaborator

@clara-shin clara-shin left a comment

Choose a reason for hiding this comment

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

승인! 고생하셨습니다

Copy link
Contributor

@jizerozz jizerozz left a comment

Choose a reason for hiding this comment

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

승인... await 추가 갬사..합니다

@jizerozz jizerozz merged commit 163da5c into develop Nov 17, 2024
3 checks passed
@jizerozz jizerozz deleted the feat/strategyCreatePage-#43 branch November 17, 2024 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 기능 개발

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants