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

대시보드 UI 구현 #40

Closed
wants to merge 20 commits into from
Closed

대시보드 UI 구현 #40

wants to merge 20 commits into from

Conversation

jangwonyoon
Copy link
Contributor

관련 이슈

변경 사항

  • 설명:대시보드 UI 구현
    • React table 패키지 추가
    • Date-fns 패키지 추가
    • 테이블 페이지 네이션 구현, 필터링 구현
    • 에러바운더리 Layout 내부에서 구현
    • Loading 스피너 구현

스크린샷 2024-09-19 오후 2 25 22

스크린샷 2024-09-19 오후 2 25 45

스크린샷 2024-09-19 오후 2 25 48

스크린샷 2024-09-19 오후 2 24 09

코드 리뷰 시 주의 사항

  • 설명: 유효성 검사는 아직 진행하지 않았습니다. @Seung-wan 님 주문 목록 코드 확인후 테이블 컴포넌트 공통화 진행하겠습니다. 간단한 에러바운더리 처리와 로딩 스피너 구현했는데, 상의 후 에러바운더리 커스텀 처리도 하면 좋을거 같습니다.

기타 사항

  • 기타 코멘트나 필요한 정보가 있다면 추가해주세요.

Copy link
Contributor

@AyoungWon AyoungWon 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.

옹 머지되면 저도 가져다 써야겠네요

Comment on lines +42 to +71
const columns: ColumnDef<Order>[] = useMemo(
() => [
{
header: 'OrderID',
accessorKey: 'orderId',
enableSorting: true,
},
{
header: 'storeName',
accessorKey: 'storeName',
enableSorting: true,
},
{
header: 'ordererName',
accessorKey: 'ordererName',
enableSorting: true,
},
{
header: 'menutotalPrice',
accessorKey: 'menutotalPrice',
accessorFn: (data) => formatToKoreanCurrency(data.menutotalPrice),
enableSorting: true,
},
{
header: 'status',
accessorKey: 'status',
enableSorting: true,
},
],
[],
Copy link
Contributor

Choose a reason for hiding this comment

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

최근에는 굳이 써야하는 곳이 아니라면 useMemo를 안쓰는게 오히려 메모리 측면에 낫다는 이야기가 있더라구요. 저도 적정선이 어딘지 참으로 고민이되요 ㅎ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

맞아요!! useMemo는 저도 최대한 지양 해야 한다고 생각하는데, React table 예시에서 useMemo로 표현한게 있길래 일단은 급하게 구현하느라 메모를 써서 표현해봤어요. 좀더 찾아봐서 수정해야하는 포인트라고 생각합니다 ㅎㅎ React table을 처음 사용해봐서요ㅠ

Copy link
Contributor

Choose a reason for hiding this comment

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

요기서 columns 배열은 컴포넌트 외부로 분리되어도 괜찮을 것 같네요!

Comment on lines +17 to +32
return (
<ImageLoader
accept=".jpg, .jpeg, .png .JPG"
onMetadataLoaded={(data) => {
setSrc(data.src);
}}
limit={{
width: {
max: 3000,
onError: (error) => {
console.log(error);
},
},
height: 3000,
}}
>
Copy link
Contributor

Choose a reason for hiding this comment

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

헿 사용해주는 사람이 생겼다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

정말 편한 라이브러리 입니다 굿굿!! pic-pik

Comment on lines +10 to +12
const ImageUpload = () => {
return <PicPickComponent />;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

단순 궁금증인데 한번더 감싸신 이유가뭘까용?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

지금 코드가 이전 코드인거 같네요 ?? 이상하넹 수정한지 좀 됐는데 다시 확인해볼게요. 현재는 아래와 같아요

export const ImageUpload = () => {
  const [originalImageMetadata, setOriginalImageMetadata] =
    useState<ImageMetadata | null>(null);

  const { metadata } = useResizeImage({
    metadata: originalImageMetadata,
    option: {
      mode: 'aspectRatio',
      ...(originalImageMetadata &&
      originalImageMetadata.width > originalImageMetadata.height
        ? { height: 352 }
        : { width: 352 }),
    },
  });

  return (
    <div css={_imageWrapper}>
      <ImageLoader onMetadataLoaded={setOriginalImageMetadata}>
        {originalImageMetadata && metadata ? (
          <div css={_imageLoader}>
            <img src={metadata.src} width={'100%'} />
          </div>
        ) : (
          <div css={_imageLoader}>Please upload a picture</div>
        )}
      </ImageLoader>
    </div>
  );
};

Copy link
Contributor

@Seung-wan Seung-wan left a comment

Choose a reason for hiding this comment

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

테이블 컴포넌트는 장원님이 만들어주신 방향으로 가는게 좋을 것 같습니다!
(제가 너무 대충 만들어서요 ㅠㅠ)

Comment on lines +42 to +71
const columns: ColumnDef<Order>[] = useMemo(
() => [
{
header: 'OrderID',
accessorKey: 'orderId',
enableSorting: true,
},
{
header: 'storeName',
accessorKey: 'storeName',
enableSorting: true,
},
{
header: 'ordererName',
accessorKey: 'ordererName',
enableSorting: true,
},
{
header: 'menutotalPrice',
accessorKey: 'menutotalPrice',
accessorFn: (data) => formatToKoreanCurrency(data.menutotalPrice),
enableSorting: true,
},
{
header: 'status',
accessorKey: 'status',
enableSorting: true,
},
],
[],
Copy link
Contributor

Choose a reason for hiding this comment

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

요기서 columns 배열은 컴포넌트 외부로 분리되어도 괜찮을 것 같네요!

Comment on lines +33 to +42
const OpeningHoursAndFees = ({
open,
close,
minCost,
delivery,
}: OpeningHoursAndFeesProps) => {
const [openTime, setOpenTime] = useState<string>(open);
const [closeTime, setCloseTime] = useState<string>(close);
const [minOrder, setMinOrder] = useState<number>(minCost);
const [deliveryFee, setDeliveryFee] = useState<string>(delivery);
Copy link
Contributor

Choose a reason for hiding this comment

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

props로 받은 값을 useState의 초기값으로 넣으면 props 값이 변경이 되어도 useState의 값은 초기값을 계속 유지하게 되어서 요렇게 작성하는 건 좋지 않은 패턴인 것 같아요!
부모 컴포넌트에서 OpeningHoursAndFees 컴포넌트에 상태를 변경하는 함수를 전달해주는게 어떨까 싶네요!

@jangwonyoon jangwonyoon deleted the feature/store branch October 20, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants