Skip to content

Commit

Permalink
refactor: 받은 리뷰가 없을 경우, EmptyContent 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
soosoo22 committed Feb 12, 2025
1 parent 40d0482 commit c31a51c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 25 deletions.
4 changes: 3 additions & 1 deletion frontend/src/components/common/EmptyContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ interface EmptyContentProps {
iconWidth?: string;
iconMessageGap?: string;
messageFontSize?: string;
isBorder?: boolean;
}

const EmptyContent = ({
iconHeight,
iconWidth,
iconMessageGap,
messageFontSize,
isBorder,
children,
}: EssentialPropsWithChildren<EmptyContentProps>) => {
return (
<S.EmptyContent $iconMessageGap={iconMessageGap}>
<S.EmptyContent $iconMessageGap={iconMessageGap} $isBorder={isBorder}>
<S.Img $height={iconHeight} $width={iconWidth} alt="" src={Icon} />
<S.MessageContainer $messageFontSize={messageFontSize}>{children}</S.MessageContainer>
</S.EmptyContent>
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/components/common/EmptyContent/styles.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import styled from '@emotion/styled';

export const EmptyContent = styled.div<{ $iconMessageGap?: string }>`
export const EmptyContent = styled.div<{ $iconMessageGap?: string; $isBorder?: boolean }>`
display: flex;
flex-direction: column;
gap: ${(props) => props.$iconMessageGap ?? '3.2rem'};
align-items: center;
${({ theme, $isBorder }) =>
$isBorder &&
`
border: 0.2rem solid ${theme.colors.lightGray};
border-radius: 1rem;
padding: 4rem 0;
`}
`;

interface ImgProps {
$height?: string;
$width?: string;
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/constants/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ export const REVIEW_MESSAGE = {
};

export const REVIEW_EMPTY = {
noReviewInTotal: '아직 받은 리뷰가 없어요!',
noReviewInQuestion: '이 질문은 아직 받은 답변이 없어요!',
noReviewInTotal: '아직 받은 리뷰가 없어요...',
noReviewLink: '생성한 리뷰 링크가 없어요...',
noReviewInQuestion: '이 질문은 아직 받은 답변이 없어요...',
};

export const REVIEW_URL_GENERATOR_FORM_VALIDATION = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useContext, useEffect, useState } from 'react';

import { Accordion, Dropdown, HighlightEditorContainer } from '@/components';
import { Accordion, Dropdown, EmptyContent, HighlightEditorContainer } from '@/components';
import { DropdownItem } from '@/components/common/Dropdown';
import ReviewEmptySection from '@/components/common/ReviewEmptySection';
import { ReviewInfoDataContext } from '@/components/layouts/ReviewDisplayLayout/ReviewInfoDataProvider';
import { REVIEW_EMPTY, SESSION_STORAGE_KEY } from '@/constants';
import { GroupedReview } from '@/types';
Expand Down Expand Up @@ -41,21 +40,29 @@ const ReviewCollectionPageContents = () => {
const hasNoCheckboxAnswer = review.votes?.every((vote) => vote.count === 0);

return hasNoCheckboxAnswer ? (
<ReviewEmptySection content={REVIEW_EMPTY.noReviewInQuestion} />
<EmptyContent iconWidth="18rem" messageFontSize="1.8rem" iconMessageGap="2.6rem">
{REVIEW_EMPTY.noReviewInQuestion}
</EmptyContent>
) : (
<DoughnutChart reviewVotes={review.votes!} />
);
}

if (review.answers?.length === 0) {
return <ReviewEmptySection content={REVIEW_EMPTY.noReviewInQuestion} />;
<EmptyContent iconWidth="18rem" messageFontSize="1.8rem" iconMessageGap="2.6rem">
{REVIEW_EMPTY.noReviewInQuestion}
</EmptyContent>;
}

return <HighlightEditorContainer questionId={review.question.id} answerList={review.answers!} />;
};

if (totalReviewCount === 0) {
return <ReviewEmptySection content={REVIEW_EMPTY.noReviewInTotal} />;
return (
<EmptyContent iconWidth="17rem" messageFontSize="2rem" iconMessageGap="2.6rem" isBorder={true}>
{REVIEW_EMPTY.noReviewInTotal}
</EmptyContent>
);
}

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useNavigate } from 'react-router';

import { URLGeneratorForm, EmptyContent } from '@/components';
import { ROUTE } from '@/constants';
import { REVIEW_EMPTY, ROUTE } from '@/constants';
import { useGetReviewLinks } from '@/hooks';

import ReviewLinkLayout from '../layouts/ReviewLinkLayout';
Expand Down Expand Up @@ -35,11 +35,9 @@ const ReviewLinkDashboard = () => {
subTitle="클릭하면 해당 프로젝트의 리뷰 목록으로 이동해요"
>
{reviewLinks.lastReviewGroupId === 0 ? (
<S.EmptyContentWrapper>
<EmptyContent iconWidth="15rem" messageFontSize="1.8rem" iconMessageGap="2rem">
생성한 리뷰 링크가 없어요...
</EmptyContent>
</S.EmptyContentWrapper>
<EmptyContent iconWidth="15rem" messageFontSize="1.8rem" iconMessageGap="2rem" isBorder={true}>
{REVIEW_EMPTY.noReviewLink}
</EmptyContent>
) : (
reviewLinks.reviewGroups.map((reviewGroup) => (
<ReviewLinkItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,3 @@ export const LinkSection = styled.section`
width: 90%;
}
`;

export const EmptyContentWrapper = styled.div`
border: 0.2rem solid ${({ theme }) => theme.colors.lightGray};
border-radius: 1rem;
padding: 3rem 0;
`;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext } from 'react';
import { useNavigate } from 'react-router';

import { ReviewEmptySection } from '@/components';
import { EmptyContent } from '@/components';
import ReviewCard from '@/components/common/ReviewCard';
import UndraggableWrapper from '@/components/common/UndraggableWrapper';
import { ReviewInfoDataContext } from '@/components/layouts/ReviewDisplayLayout/ReviewInfoDataProvider';
Expand Down Expand Up @@ -41,7 +41,9 @@ const ReviewListPageContents = () => {
return (
<>
{totalReviewCount === 0 ? (
<ReviewEmptySection content={REVIEW_EMPTY.noReviewInTotal} />
<EmptyContent iconWidth="17rem" messageFontSize="2rem" iconMessageGap="2.6rem" isBorder={true}>
{REVIEW_EMPTY.noReviewInTotal}
</EmptyContent>
) : (
<S.ReviewSection>
{reviews.map((review, index) => {
Expand Down

0 comments on commit c31a51c

Please sign in to comment.