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

[Feat] usepagenation 적용, 버그 및 css 수정 #1498 #1502

Merged
merged 15 commits into from
Aug 23, 2024

Conversation

cweedlee
Copy link
Collaborator

@cweedlee cweedlee commented Aug 22, 2024

📌 개요

  • 페이지네이션 받아오는 api 전부 usePageNation 사용해서 받아오도록 수정

💻 작업사항

usePageNation 사용법

  • 컴포넌트 내부 세팅 : content(data array) 및 페이지네이션 컴포넌트에 들어갈 인자 리턴
const { content: agendaHistory, PagaNationElementProps } =
    usePageNation<AgendaHistoryItemProps>({ url: '/profile/history/list' });
  • 리턴값에 페이지네이션 컴포넌트 세팅 : 앞에서 받아온 인자를 풀어서 그대로 넣어주면 됩니다.
<PageNation {...PagaNationElementProps} />
  • 자동으로 세팅됩니다. 아래는 usePageNation에서 받는 매개변수입니다.
const usePageNation = <T>({
  url: string; // api 받아올 주소. agenda 다음부터
  params?: Record<string, any>; // 쿼리파라미터 있을 경우 추가. 페이지는 필요 없으며, 사이즈는 따로 들어감. 
  size?: number; // 페이지 사이즈
  useIdx?: boolean; // 인덱싱 추가 여부 : 해당 데이터 타입에 idx?: number; 추가하여 보여주는 게 필요할 때
}) => {
  • 인덱싱 추가 예시 : 아래와 같이 페이지 값 기반으로 자동 파싱해서 데이터 반환
Screenshot 2024-08-22 at 9 56 18 PM

계속 호출하는 문제: api 호출 조건 제한을 통해 해결

  useEffect(() => {
    const fetchData = async () => {
      const data = await getData(currentPage.current);
      totalPages.current = Math.ceil(data.totalSize / size);
      setContent(data.content);
    };
    if (!status.current || status.current / 100 != 2) fetchData();
    console.log(url);
  }, [currentPage, getData, size]);

size, currentPage 변경 시 자동 호출
또한 다른 이유로 불렸을 경우에도 이전 호출 성공했을 경우 (200번대 status) 호출하지 않음

css

Screenshot 2024-08-22 at 9 59 58 PM

💡관련 Issue

@cweedlee cweedlee linked an issue Aug 22, 2024 that may be closed by this pull request
9 tasks
@cweedlee cweedlee changed the base branch from main to agenda August 22, 2024 13:00
Copy link
Contributor

@irenee-14 irenee-14 left a comment

Choose a reason for hiding this comment

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

받아오는 데이터 형식이 pagenation으로 변경되어 기능들이 작동이 잘 되지 않았었는데 그에 맞추어 잘 수정된 것 같아요~~ LGTM! 자잘한 부분들도 수정되어 좋습니당◡̈

@@ -3,6 +3,7 @@ import { AgendaDataProps } from 'types/agenda/agendaDetail/agendaTypes';
import { showPeriod, fillZero } from 'utils/handleTime';
import AgendaTag from 'components/agenda/utils/AgendaTag';
import styles from 'styles/agenda/Home/AgendaInfo.module.scss';
import { isSoloTeam } from '../utils/team';
Copy link
Contributor

Choose a reason for hiding this comment

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

상대경로

import { AgendaInfoProps } from 'types/agenda/agendaDetail/tabs/agendaInfoTypes';
import { AgendaStatus } from 'constants/agenda/agenda';
import { ShareBtn } from 'components/agenda/button/Buttons';
import { UploadBtn } from 'components/agenda/button/UploadBtn';
import styles from 'styles/agenda/agendaDetail/AgendaInfo.module.scss';
import { isSoloTeam } from '../utils/team';
Copy link
Contributor

Choose a reason for hiding this comment

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

상대경로

Comment on lines +1 to +3
export function isSoloTeam(minPeople: number, maxPeople: number) {
return maxPeople === 1 && minPeople === 1;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

이전에 제대로 처리되지 않은 부분 수정해주셔서 감사합니당 ㅎㅎ

@@ -2,25 +2,22 @@ import { ParticipantTabProps } from 'types/agenda/agendaDetail/tabs/participantT
import ParticipantsList from 'components/agenda/agendaDetail/tabs/ParticipantsList';
import styles from 'styles/agenda/agendaDetail/tabs/AgendaParticipants.module.scss';
import ParticipantTeamList from './ParticipantTeamList';
import { isSoloTeam } from '../../utils/team';
Copy link
Contributor

Choose a reason for hiding this comment

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

상대경로

fetchData();
});
if (!status.current || status.current / 100 != 2) fetchData();
console.log(url);
Copy link
Contributor

Choose a reason for hiding this comment

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

console.log~

@irenee-14 irenee-14 added the enhancement New feature or request label Aug 23, 2024
Copy link
Contributor

@JeongRon JeongRon left a comment

Choose a reason for hiding this comment

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

참여자, 공지사항 등의 map 에러들이 paegnation 코드로 인해 에러가 발생했었는데, 확인해보니 모두 정상 작동되는 것을 확인했습니다! LGTM! 👍

@cweedlee cweedlee merged commit 8d82b71 into agenda Aug 23, 2024
@cweedlee
Copy link
Collaborator Author

넵 콘솔로그 / 상대경로 처리하는 김에 겸사겸사 다 처리했습니다~! 감사합니다
close #1498

@cweedlee cweedlee deleted the Feat/#1498-usepagenation-apply-bug-css branch August 29, 2024 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] usePageNation반영 / 버그 / css
3 participants