Skip to content

Commit

Permalink
[FE] feat: 상품 상세 로그인 필요 메시지에 로그인 링크 추가 (#319)
Browse files Browse the repository at this point in the history
* feat: 비로그인 상품 리뷰 조회 메시지 로그인 경로 링크 추가

* refactor: 로그인 페이지 상수처리
  • Loading branch information
Leejin-Yang authored Aug 4, 2023
1 parent ba27a0d commit f4f9361
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
28 changes: 23 additions & 5 deletions frontend/src/components/Review/ReviewList/ReviewList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Text } from '@fun-eat/design-system';
import React from 'react';
import { Text, Link } from '@fun-eat/design-system';
import { Link as RouterLink } from 'react-router-dom';
import styled from 'styled-components';

import ReviewItem from '../ReviewItem/ReviewItem';

import { PATH } from '@/constants/path';
import { useInfiniteProductReviews } from '@/hooks/product';
import type { SortOption } from '@/types/common';

Expand All @@ -20,9 +21,14 @@ const ReviewList = ({ productId, selectedOption }: ReviewListProps) => {

if (error) {
return (
<ErrorDescription align="center" weight="bold" size="lg">
{LOGIN_ERROR_MESSAGE}
</ErrorDescription>
<ErrorContainer>
<ErrorDescription align="center" weight="bold" size="lg">
{LOGIN_ERROR_MESSAGE}
</ErrorDescription>
<LoginLink as={RouterLink} to={PATH.LOGIN} block>
로그인하러 가기
</LoginLink>
</ErrorContainer>
);
}

Expand All @@ -48,8 +54,20 @@ const ReviewListContainer = styled.ul`
row-gap: 60px;
`;

const ErrorContainer = styled.div`
display: flex;
flex-direction: column;
align-items: center;
`;

const ErrorDescription = styled(Text)`
padding: 40px 0;
white-space: pre-line;
word-break: break-all;
`;

const LoginLink = styled(Link)`
padding: 16px 24px;
border: 1px solid ${({ theme }) => theme.colors.gray4};
border-radius: 8px;
`;
3 changes: 2 additions & 1 deletion frontend/src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useEffect } from 'react';
import { Navigate } from 'react-router-dom';
import styled from 'styled-components';

import { PATH } from '@/constants/path';
import { useMember } from '@/hooks/auth';
import { useMemberValueContext } from '@/hooks/context';

Expand All @@ -15,7 +16,7 @@ const ProfilePage = () => {
}, []);

if (member === null) {
return <Navigate to="/login" replace />;
return <Navigate to={PATH.LOGIN} replace />;
}

return (
Expand Down

0 comments on commit f4f9361

Please sign in to comment.