Skip to content

Commit

Permalink
refactor: isMemberPage -> isPreview로 네이밍 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
xodms0309 committed Oct 17, 2023
1 parent 28cf569 commit d990fe1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import { useInfiniteMemberRecipeQuery } from '@/hooks/queries/members';
import useDisplaySlice from '@/utils/displaySlice';

interface MemberRecipeListProps {
isMemberPage?: boolean;
isPreview?: boolean;
}

const MemberRecipeList = ({ isMemberPage = false }: MemberRecipeListProps) => {
const MemberRecipeList = ({ isPreview = false }: MemberRecipeListProps) => {
const scrollRef = useRef<HTMLDivElement>(null);

const { fetchNextPage, hasNextPage, data } = useInfiniteMemberRecipeQuery();
const memberRecipes = data?.pages.flatMap((page) => page.recipes);
const recipeToDisplay = useDisplaySlice(isMemberPage, memberRecipes);
const recipeToDisplay = useDisplaySlice(isPreview, memberRecipes);

useIntersectionObserver<HTMLDivElement>(fetchNextPage, scrollRef, hasNextPage);

Expand All @@ -40,7 +40,7 @@ const MemberRecipeList = ({ isMemberPage = false }: MemberRecipeListProps) => {

return (
<MemberRecipeListContainer>
{!isMemberPage && (
{!isPreview && (
<TotalRecipeCount color={theme.colors.gray4}>
<strong>{totalRecipeCount}</strong>개의 꿀조합을 남겼어요!
</TotalRecipeCount>
Expand All @@ -50,7 +50,7 @@ const MemberRecipeList = ({ isMemberPage = false }: MemberRecipeListProps) => {
{recipeToDisplay?.map((recipe) => (
<li key={recipe.id}>
<Link as={RouterLink} to={`${PATH.RECIPE}/${recipe.id}`}>
<RecipeItem recipe={recipe} isMemberPage={isMemberPage} />
<RecipeItem recipe={recipe} isMemberPage={isPreview} />
</Link>
</li>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import type { MemberReview } from '@/types/review';

interface MemberReviewItemProps {
review: MemberReview;
isMemberPage: boolean;
isPreview: boolean;
}

const MemberReviewItem = ({ review, isMemberPage }: MemberReviewItemProps) => {
const MemberReviewItem = ({ review, isPreview }: MemberReviewItemProps) => {
const theme = useTheme();

const { mutate } = useDeleteReview();
Expand Down Expand Up @@ -50,7 +50,7 @@ const MemberReviewItem = ({ review, isMemberPage }: MemberReviewItemProps) => {
<Text size="sm" weight="bold">
{productName}
</Text>
{!isMemberPage && (
{!isPreview && (
<Button variant="transparent" customHeight="auto" onClick={handleReviewDelete}>
<SvgIcon variant="trashcan" width={20} height={20} />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { useInfiniteMemberReviewQuery } from '@/hooks/queries/members';
import useDisplaySlice from '@/utils/displaySlice';

interface MemberReviewListProps {
isMemberPage?: boolean;
isPreview?: boolean;
}

const MemberReviewList = ({ isMemberPage = false }: MemberReviewListProps) => {
const MemberReviewList = ({ isPreview = false }: MemberReviewListProps) => {
const scrollRef = useRef<HTMLDivElement>(null);
const { fetchNextPage, hasNextPage, data } = useInfiniteMemberReviewQuery();
const memberReviews = data.pages.flatMap((page) => page.reviews);
const reviewsToDisplay = useDisplaySlice(isMemberPage, memberReviews);
const reviewsToDisplay = useDisplaySlice(isPreview, memberReviews);

useIntersectionObserver<HTMLDivElement>(fetchNextPage, scrollRef, hasNextPage);

Expand All @@ -40,7 +40,7 @@ const MemberReviewList = ({ isMemberPage = false }: MemberReviewListProps) => {

return (
<MemberReviewListContainer>
{!isMemberPage && (
{!isPreview && (
<TotalReviewCount color={theme.colors.gray4}>
<strong>{totalReviewCount}</strong>개의 리뷰를 남겼어요!
</TotalReviewCount>
Expand All @@ -50,7 +50,7 @@ const MemberReviewList = ({ isMemberPage = false }: MemberReviewListProps) => {
{reviewsToDisplay.map((review) => (
<li key={review.reviewId}>
<Link as={RouterLink} to={`${PATH.REVIEW}/${review.reviewId}`} block>
<MemberReviewItem review={review} isMemberPage={isMemberPage} />
<MemberReviewItem review={review} isPreview={isPreview} />
</Link>
</li>
))}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/MemberPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export const MemberPage = () => {
<Spacing size={5} />
<ErrorBoundary fallback={ErrorComponent} handleReset={reset}>
<Suspense fallback={<Loading />}>
<MemberReviewList isMemberPage />
<MemberReviewList isPreview />
</Suspense>
</ErrorBoundary>
<Spacing size={45} />
<NavigableSectionTitle title="내가 작성한 꿀조합" routeDestination={`${PATH.MEMBER}/recipe`} />
<ErrorBoundary fallback={ErrorComponent} handleReset={reset}>
<Suspense fallback={<Loading />}>
<MemberRecipeList isMemberPage />
<MemberRecipeList isPreview />
</Suspense>
</ErrorBoundary>
<Spacing size={40} />
Expand Down

0 comments on commit d990fe1

Please sign in to comment.