Skip to content

Commit

Permalink
<FEAT> (FE): detail한 부분들 수정 및 구현 #23
Browse files Browse the repository at this point in the history
  • Loading branch information
ha4219 committed Dec 9, 2022
1 parent cf7f398 commit 146bba5
Show file tree
Hide file tree
Showing 8 changed files with 37,002 additions and 8,249 deletions.
28,511 changes: 28,511 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-ga": "^3.3.1",
"react-helmet": "^6.1.0",
"react-quill": "^2.0.0",
"react-router-dom": "^6.4.1",
"react-scripts": "5.0.1",
Expand Down Expand Up @@ -59,6 +60,7 @@
]
},
"devDependencies": {
"@types/react-helmet": "^6.1.6",
"@types/react-swipeable-views": "^0.13.1",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
Expand Down
76 changes: 76 additions & 0 deletions src/components/SEO.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { Helmet } from 'react-helmet';
import React from 'react';
import Logo from '@assets/logo512.png';

const SEO = ({
title,
description,
url,
image,
me,
meta = [],
}: {
title?: string;
description?: string;
url: string;
image?: string;
me?: string;
meta?: { property: string; content: string }[];
}) => {
return (
<Helmet
title={title}
htmlAttributes={{ lang: 'ko' }}
meta={[
...meta,
{ name: `description`, content: description },
{
property: 'og:url',
content: url,
},
{
property: 'og:type',
content: 'website',
},
{
property: 'og:title',
content: title,
},
{
property: 'og:description',
content: description,
},
{
property: 'og:image',
content: image ? image : Logo,
},
// {
// property: 'fb:app_id',
// content: someFbAppId,
// },
{
property: 'twitter:card',
content: 'summary',
},
{
property: 'twitter:creator',
content: me ? me : 'unknown',
},
{
property: 'twitter:title',
content: title,
},
{
property: 'twitter:description',
content: description,
},
{
property: 'twitter:image',
content: image ? image : Logo,
},
]}
/>
);
};

export default React.memo(SEO);
8 changes: 8 additions & 0 deletions src/pages/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ import Banner from '@components/main/Banner';
import CardGroup from '@components/main/CardGroup';
import IntroSection from '@components/main/IntroSection';
import Partners from '@components/main/Partners';
import SEO from '@components/SEO';
import { Container } from '@mui/material';
import React from 'react';
import { useLocation } from 'react-router-dom';

const Main = () => {
const location = useLocation();
return (
<div>
<SEO
title="Welcome MBTIWithUs!"
description="다양한 mbti를 만나보세요!"
url={location?.pathname}
/>
<Banner />
<Container sx={{ py: 3 }}>
<Partners />
Expand Down
6 changes: 6 additions & 0 deletions src/pages/board/BoardDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import BoardCommentInput from '@components/board/BoardCommentInput';
import { toast } from 'react-toastify';
import BoardWriter from '@components/board/BoardWriter';
import NotFound from '@components/NotFound';
import SEO from '@components/SEO';

const BoardDetailPage = () => {
const { id } = useParams();
Expand Down Expand Up @@ -103,6 +104,11 @@ const BoardDetailPage = () => {

return (
<Container sx={{ py: 3 }}>
<SEO
title={data?.title}
description={data?.content}
url={location?.pathname}
/>
{isLoading ? (
<OverlayLoading isLoading />
) : error || !data ? (
Expand Down
6 changes: 6 additions & 0 deletions src/pages/board/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import api from '@libs/api';
import BoardWriter from '@components/board/BoardWriter';
import { useLocation } from 'react-router-dom';
import useIntersection from '@hooks/useIntersection';
import SEO from '@components/SEO';

const LIMIT = 10;

Expand Down Expand Up @@ -69,6 +70,11 @@ const BoardPage = () => {

return (
<Container sx={{ py: 3 }}>
<SEO
title="서로 다른 MBTI의 사람들과 소통하세요!"
description="여러 사람들과 만날 수 있습니다"
url={location?.pathname}
/>
{isLoading ? (
<OverlayLoading isLoading />
) : (
Expand Down
16 changes: 13 additions & 3 deletions src/pages/profile/Result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@ import ProgressRow from '@components/mbti/ProgressRow';
import { UserStateContext } from '@contexts/UserContext';
import { Avatar, Box, Container, Divider, Typography } from '@mui/material';
import LinkMui from '@mui/material/Link';
import React, { useContext } from 'react';
import { useLocation } from 'react-router-dom';
import React, { useContext, useEffect } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { IMbtiResult } from 'types';
import { getMbtiResult2String } from '@libs/mbti';

const ResultPage = () => {
const location = useLocation();
const result: IMbtiResult = location.state;
const auth = useContext(UserStateContext);

const mbti = getMbtiResult2String(result);

const navigate = useNavigate();
useEffect(() => {
if (auth?.userLoading) {
return;
}

if (!auth?.token) {
navigate('/login');
}
}, [auth]);

return (
<Container sx={{ py: 3 }}>
<Container maxWidth="sm">
Expand Down
Loading

0 comments on commit 146bba5

Please sign in to comment.