Skip to content

Conversation

@Panda-raccoon
Copy link
Contributor

@Panda-raccoon Panda-raccoon commented Nov 17, 2024

🚀 풀 리퀘스트 제안

📋 작업 내용

메인페이지(홈페이지) 트레이더 섹션 부분 CSS 스타일링 했습니다.
투자자섹션과 같은 부분은 나중에 컴포넌트 분리예정입니다.
API 적용 코드 작성했습니다.

🔧 변경 사항

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

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

📸 스크린샷 (선택 사항)

image

📄 기타

API적용 하는 코드 맞는지 확인 부탁드립니다

Sourcery에 의한 요약

홈페이지의 트레이더 섹션에 대한 CSS 스타일링을 구현하고 트레이더 및 전략 통계를 가져오는 API를 통합합니다.

새로운 기능:

  • 홈페이지의 트레이더 섹션에 대한 CSS 스타일링을 구현하여 시각적 표현과 사용자 경험을 향상시킵니다.

개선 사항:

  • 트레이더 및 전략 통계를 동적으로 가져와 홈페이지에 표시하는 API 통합을 추가합니다.
Original summary in English

Summary by Sourcery

Implement CSS styling for the trader section on the homepage and integrate API to fetch trader and strategy statistics.

New Features:

  • Implement CSS styling for the trader section on the homepage, enhancing the visual presentation and user experience.

Enhancements:

  • Add API integration to fetch and display trader and strategy statistics dynamically on the homepage.

@Panda-raccoon Panda-raccoon self-assigned this Nov 17, 2024
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 17, 2024

리뷰어 가이드 by Sourcery

이 PR은 메인 페이지의 트레이더 섹션 스타일링과 기능을 구현합니다. 변경 사항에는 반응형 디자인을 갖춘 새로운 트레이더 섹션 추가, 트레이더 통계를 위한 API 통합 구현, 기존 투자자 섹션 스타일 재구성이 포함됩니다.

변경 사항이 간단해 보이며 시각적 표현이 필요하지 않으므로 다이어그램이 생성되지 않았습니다.

파일 수준 변경 사항

변경 사항 세부 사항 파일
트레이더 및 전략 통계를 위한 API 통합 추가
  • 트레이더 및 전략 수를 추적하기 위한 useState 훅 구현
  • API에서 통계 데이터를 가져오기 위한 useEffect 훅 추가
  • API 요청에 대한 오류 처리 추가
src/pages/HomePage.tsx
트레이더 섹션 UI 구성 요소 및 스타일링 구현
  • 좌우 콘텐츠 영역이 있는 새로운 트레이더 섹션 레이아웃 생성
  • 사용자 이미지를 포함한 트레이더 통계 표시 추가
  • 트레이더 작업을 위한 반응형 버튼 그룹 구현
  • 트레이더 섹션 콘텐츠를 위한 스타일링된 텍스트 구성 요소 추가
src/pages/HomePage.tsx
기존 스타일 재구성 및 개선
  • 유지보수성을 높이기 위해 CSS 스타일 이름 변경 및 재구성
  • 적절한 레이어 관리를 위한 z-index 처리 추가
  • 겹치는 효과로 사용자 이미지 스타일링 개선
  • 테마 변수를 사용하여 색상 스킴 업데이트
src/pages/HomePage.tsx
내비게이션 기능 업데이트
  • 중복된 전략 목록 내비게이션 제거
  • 일관된 내비게이션을 위한 버튼 클릭 핸들러 업데이트
src/pages/HomePage.tsx

관련 문제일 가능성 있음


팁 및 명령어

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 trader section styling and functionality on the main page. The changes include adding a new trader section with responsive design, implementing API integration for trader statistics, and reorganizing the existing investor section styles.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Added API integration for trader and strategy statistics
  • Implemented useState hooks for tracking trader and strategy counts
  • Added useEffect hook to fetch statistics data from API
  • Added error handling for API requests
src/pages/HomePage.tsx
Implemented trader section UI components and styling
  • Created a new trader section layout with left and right content areas
  • Added trader statistics display with user images
  • Implemented responsive button group for trader actions
  • Added styled text components for trader section content
src/pages/HomePage.tsx
Reorganized and improved existing styles
  • Renamed and reorganized CSS styles for better maintainability
  • Added z-index handling for proper layer management
  • Improved user image styling with overlapping effects
  • Updated color scheme using theme variables
src/pages/HomePage.tsx
Updated navigation functionality
  • Removed redundant strategy list navigation
  • Updated button click handlers for consistent navigation
src/pages/HomePage.tsx

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 04:02 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.

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

전반적인 의견:

  • API 가져오기 로직을 사용자 정의 훅(예: useTraderStats)으로 이동하여 관심사를 분리하고 유지 보수성을 향상시키는 것을 고려해보세요. 또한 API 엔드포인트 이름을 일관되게 사용하세요 (trader-Strategy vs trader-strategy).
  • 투자자와 트레이더 섹션 간에 유사한 패턴이 있습니다. 코드 중복을 줄이고 유지 보수성을 향상시키기 위해 지금 공유 컴포넌트를 추출하는 것을 고려해보세요.
검토 중에 살펴본 내용입니다
  • 🟡 일반 문제: 1개의 문제 발견
  • 🟢 보안: 모두 양호
  • 🟢 테스트: 모두 양호
  • 🟡 복잡성: 1개의 문제 발견
  • 🟢 문서화: 모두 양호

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

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

Overall Comments:

  • Consider moving the API fetching logic into a custom hook (e.g., useTraderStats) to separate concerns and improve maintainability. Also ensure consistent API endpoint naming (trader-Strategy vs trader-strategy).
  • There are similar patterns between investor and trader sections. Consider extracting shared components now rather than later to reduce code duplication and improve maintainability.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 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.

import { ROUTES } from '@/constants/routes';
import theme from '@/styles/theme';

const HomePage = () => {
Copy link

Choose a reason for hiding this comment

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

issue (complexity): 공유 스타일과 데이터 가져오기 로직을 재사용 가능한 컴포넌트와 훅으로 추출하는 것을 고려해보세요

코드는 두 가지 주요 영역에서 단순화될 수 있습니다:

  1. 스타일 중복을 줄이기 위해 공유 스타일 섹션 컴포넌트를 만드세요:
const SharedSection = styled.section`
  position: relative;
  max-width: ${theme.layout.width.content};
  margin: 0 auto;

  // 두 섹션에 공통된 스타일
  .content {
    display: flex;
    gap: 20px;
    height: 894px;
  }

  .text-content {
    padding: 88px 0;
  }
`;

// 사용 예:
<SharedSection className={isTrader ? 'trader-section' : 'investor-section'}>
  <div className="content">
    <div className="text-content">
      {/* 내용 */}
    </div>
  </div>
</SharedSection>
  1. 트레이더 통계 가져오기를 사용자 정의 훅으로 추출하세요:
const useTraderStats = () => {
  const [stats, setStats] = useState({ traderCount: '0', strategyCount: '0' });

  useEffect(() => {
    const fetchStats = async () => {
      try {
        const { traderCount, strategyCount } = await fetch('/api/trader-Strategy')
          .then(res => res.json());
        setStats({ traderCount, strategyCount });
      } catch (error) {
        console.error('Failed to fetch trader stats:', error);
      }
    };
    fetchStats();
  }, []);

  return stats;
};

// 사용 예:
const { traderCount, strategyCount } = useTraderStats();

이러한 변경 사항은 기능을 유지하면서 코드 중복을 줄이고 유지 보수성을 향상시킬 것입니다.

Original comment in English

issue (complexity): Consider extracting shared styles and data fetching logic into reusable components and hooks

The code could be simplified in two key areas:

  1. Create a shared styled section component to reduce style duplication:
const SharedSection = styled.section`
  position: relative;
  max-width: ${theme.layout.width.content};
  margin: 0 auto;

  // Common styles for both sections
  .content {
    display: flex;
    gap: 20px;
    height: 894px;
  }

  .text-content {
    padding: 88px 0;
  }
`;

// Usage:
<SharedSection className={isTrader ? 'trader-section' : 'investor-section'}>
  <div className="content">
    <div className="text-content">
      {/* Content */}
    </div>
  </div>
</SharedSection>
  1. Extract trader stats fetching to a custom hook:
const useTraderStats = () => {
  const [stats, setStats] = useState({ traderCount: '0', strategyCount: '0' });

  useEffect(() => {
    const fetchStats = async () => {
      try {
        const { traderCount, strategyCount } = await fetch('/api/trader-Strategy')
          .then(res => res.json());
        setStats({ traderCount, strategyCount });
      } catch (error) {
        console.error('Failed to fetch trader stats:', error);
      }
    };
    fetchStats();
  }, []);

  return stats;
};

// Usage:
const { traderCount, strategyCount } = useTraderStats();

These changes will reduce code duplication while maintaining functionality and improving maintainability.

@jizerozz jizerozz added the 🎨 Html&css 마크업 & 스타일링 label Nov 17, 2024
Copy link
Contributor

@ssuminii ssuminii 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

Choose a reason for hiding this comment

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

api 호출 하는 부분 맞게 잘 쓰신 것 같아요!! 저희 api 호출할 때 axios를 자주 사용해서 호출할텐데 이 부분 찾아보시고 적용해봐도 좋을 것 같아욥!! 코드가 쪼끔 더 간단해진답니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

useEffect(() => {
const fetchTraderStats = async () => {
try {
const { data } = await axios.get('/api/trader-Strategy');
setTraderCount(data.traderCount);
setStrategyCount(data.strategyCount);
} catch (error) {
console.error('트레이더 통계 조회 실패:', error);
}
};

fetchTraderStats();
}, []);

요렇게용?

Copy link
Contributor

Choose a reason for hiding this comment

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

일단 그렇게 바꿔두세요... 근데 아마 또 axios 호출하는 부분이 바뀔수 있어요. 그때가서 또 변경하라고 말씀드릴께요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넵 알겠습니다!
지금은 axios로 적용했습니다! 바꿨습니다!

Copy link
Contributor

@seoyoonyi seoyoonyi left a comment

Choose a reason for hiding this comment

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

rankingButtonStyle에 border: none; 있어요. 그거 0으로 바꿔주세요

Copy link
Contributor

Choose a reason for hiding this comment

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

일단 그렇게 바꿔두세요... 근데 아마 또 axios 호출하는 부분이 바뀔수 있어요. 그때가서 또 변경하라고 말씀드릴께요!

투자자 가입하기
</Button>
<Button variant='secondary' size='xl' width={208} onClick={handleStrategyListClick}>
<Button variant='secondary' size='xl' width={208} onClick={handleTraderListClick}>
Copy link
Contributor

@seoyoonyi seoyoonyi Nov 17, 2024

Choose a reason for hiding this comment

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

트레이더 리스트 아니고 전략쪽 페이지로 이동해야 됩니다

스크린샷 2024-11-17 오후 8 52 30

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const handleTraderListClick = () => {
navigate(ROUTES.STRATEGY.LIST);
};

전략랭킹 버튼 누르면 전략랭킹 리스트로 가게끔 바꿨습니다!

@github-actions
Copy link

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

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

@github-actions github-actions bot temporarily deployed to pull request November 17, 2024 13:27 Inactive
@clara-shin clara-shin merged commit 01b2ee5 into develop Nov 17, 2024
3 checks passed
@clara-shin clara-shin deleted the feat/HomeTrader-#46 branch November 17, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🎨 Html&css 마크업 & 스타일링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants