Skip to content

Commit

Permalink
Merge pull request #93 from Funssion-SWM/develop
Browse files Browse the repository at this point in the history
Chore: header 중복 제거
  • Loading branch information
dongree authored Dec 22, 2023
2 parents 2d3cf6f + 95c5806 commit f311bd9
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 131 deletions.
101 changes: 38 additions & 63 deletions src/app/memos/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import Header from '@/components/shared/Header';
import MemoViewer from '@/components/memo/MemoViewer';
import { getMemoById, getMemoRecommendationsById } from '@/service/memos';
import LayoutWrapper from '@/components/shared/LayoutWrapper';
import MemoSideBar from '@/components/memo/MemoSideBar';
import { getCommentsByPostTypeAndPostId } from '@/service/comments';
import { cookies } from 'next/headers';
import { getIsLike } from '@/service/like';
import { ACCESS_TOKEN, REFRESH_TOKEN } from '@/utils/const';
import { checkUser, getUserInfo } from '@/service/auth';
import { getQuestionsByMemoId } from '@/service/questions';
import { getNotificationsTop30 } from '@/service/notification';
import { notFound } from 'next/navigation';

type Props = {
Expand Down Expand Up @@ -50,75 +47,53 @@ export default async function MemoPage({ params: { slug } }: Props) {
const questionsData = getQuestionsByMemoId(memoId);
const recommendationsData = getMemoRecommendationsById(memoId);

const [
{ isLike },
comments,
{ id, isLogin, authority },
recommendations,
questions,
] = await Promise.all([
likeData,
commentData,
myData,
recommendationsData,
questionsData,
]);
const [{ isLike }, comments, { id, isLogin }, recommendations, questions] =
await Promise.all([
likeData,
commentData,
myData,
recommendationsData,
questionsData,
]);

const { isFollowed, followCnt, followerCnt } = await getUserInfo(
authorId,
cookie
);

const { profileImageFilePath } = isLogin
? await getUserInfo(id)
: { profileImageFilePath: undefined };

const notifications = isLogin ? await getNotificationsTop30(cookie) : [];

return (
<section>
<Header
<div className="flex w-full ">
<MemoViewer
title={memoTitle}
content={JSON.parse(memoText)}
color={memoColor}
memoTags={memoTags}
memoId={memoId}
likes={likes}
isLike={isLike}
isMyMemo={isMine}
createdDate={createdDate}
seriesId={seriesId}
seriesTitle={seriesTitle}
isLogin={isLogin}
/>
<MemoSideBar
authorName={authorName}
authorProfileImagePath={authorProfileImagePath}
authorId={authorId}
comments={comments}
questions={questions}
recommendations={recommendations}
memoId={memoId}
userId={id}
isFollowed={isFollowed}
isMyMemo={isMine}
isLogin={isLogin}
notifications={notifications}
profileImageFilePath={profileImageFilePath}
currentPage="memos"
authority={authority}
authorFollowingNum={followCnt}
authorFollowerNum={followerCnt}
authorRank={authorRank}
/>
<LayoutWrapper paddingY="sm:py-5">
<div className="flex w-full ">
<MemoViewer
title={memoTitle}
content={JSON.parse(memoText)}
color={memoColor}
memoTags={memoTags}
memoId={memoId}
likes={likes}
isLike={isLike}
isMyMemo={isMine}
createdDate={createdDate}
seriesId={seriesId}
seriesTitle={seriesTitle}
isLogin={isLogin}
/>
<MemoSideBar
authorName={authorName}
authorProfileImagePath={authorProfileImagePath}
authorId={authorId}
comments={comments}
questions={questions}
recommendations={recommendations}
memoId={memoId}
userId={id}
isFollowed={isFollowed}
isMyMemo={isMine}
isLogin={isLogin}
authorFollowingNum={followCnt}
authorFollowerNum={followerCnt}
authorRank={authorRank}
/>
</div>
</LayoutWrapper>
</section>
</div>
);
}

Expand Down
40 changes: 10 additions & 30 deletions src/app/questions/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import QuestionDetail from '@/components/question/QuestionDetail';
import Header from '@/components/shared/Header';
import LayoutWrapper from '@/components/shared/LayoutWrapper';
import { getAnswersByQuestionId } from '@/service/answers';
import { checkUser, getUserInfo } from '@/service/auth';
import { checkUser } from '@/service/auth';
import { getIsLike } from '@/service/like';
import { getMemoById } from '@/service/memos';
import { getNotificationsTop30 } from '@/service/notification';
import { getQuestionById } from '@/service/questions';
import { ACCESS_TOKEN, REFRESH_TOKEN } from '@/utils/const';
import { cookies } from 'next/headers';
Expand All @@ -32,44 +29,27 @@ export default async function QuestionPage({ params: { slug } }: Props) {
const myData = checkUser(cookie);
const likeData = getIsLike('questions', questionId, cookie);

const [answers, { id, isLogin, authority }, { isLike }] = await Promise.all([
const [answers, { id, isLogin }, { isLike }] = await Promise.all([
answersData,
myData,
likeData,
]);

const { profileImageFilePath } = isLogin
? await getUserInfo(id)
: { profileImageFilePath: undefined };

const notifications = isLogin ? await getNotificationsTop30(cookie) : [];

const { memoTitle } = question.memoId
? await getMemoById(question.memoId)
: {
memoTitle: '',
};

return (
<section>
<Header
isLogin={isLogin}
notifications={notifications}
profileImageFilePath={profileImageFilePath}
currentPage="questions"
authority={authority}
/>
<LayoutWrapper>
<QuestionDetail
questionData={question}
answers={answers}
isLike={isLike}
userId={id}
memoTitle={memoTitle}
isLogin={isLogin}
/>
</LayoutWrapper>
</section>
<QuestionDetail
questionData={question}
answers={answers}
isLike={isLike}
userId={id}
memoTitle={memoTitle}
isLogin={isLogin}
/>
);
}

Expand Down
56 changes: 18 additions & 38 deletions src/app/series/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import SeriesDetailContainer from '@/components/series/SeriesDetailContainer';
import Header from '@/components/shared/Header';
import LayoutWrapper from '@/components/shared/LayoutWrapper';
import { checkUser, getUserInfo } from '@/service/auth';
import { getCommentsByPostTypeAndPostId } from '@/service/comments';
import { getIsLike } from '@/service/like';
import { getMemoById, getMemoRecommendationsById } from '@/service/memos';
import { getNotificationsTop30 } from '@/service/notification';
import { getQuestionsByMemoId } from '@/service/questions';
import { getSeriesById } from '@/service/series';
import { ACCESS_TOKEN, REFRESH_TOKEN } from '@/utils/const';
Expand Down Expand Up @@ -44,7 +41,7 @@ export default async function SeriesDetailPage({ params: { slug } }: Props) {
memo,
{ isLike },
comments,
{ id, isLogin, authority },
{ id, isLogin },
questions,
recommendation,
] = await Promise.all([
Expand All @@ -61,41 +58,24 @@ export default async function SeriesDetailPage({ params: { slug } }: Props) {
cookie
);

const { profileImageFilePath } = isLogin
? await getUserInfo(id)
: { profileImageFilePath: undefined };

const notifications = isLogin ? await getNotificationsTop30(cookie) : [];

return (
<section>
<Header
isLogin={isLogin}
notifications={notifications}
profileImageFilePath={profileImageFilePath}
currentPage="series"
authority={authority}
/>
<LayoutWrapper paddingY="sm:py-5">
<SeriesDetailContainer
memo={memo}
comments={comments}
questions={questions}
recommendation={recommendation}
isLike={isLike}
userId={id}
isLogin={isLogin}
isFollowed={isFollowed}
authorFollowingNum={followCnt}
authorFollowerNum={followerCnt}
memoInfoList={memoInfoList}
seriesLikeNum={likes}
seriesId={seriesId}
isMySeries={id === memo.authorId}
seriesTitle={title}
/>
</LayoutWrapper>
</section>
<SeriesDetailContainer
memo={memo}
comments={comments}
questions={questions}
recommendation={recommendation}
isLike={isLike}
userId={id}
isLogin={isLogin}
isFollowed={isFollowed}
authorFollowingNum={followCnt}
authorFollowerNum={followerCnt}
memoInfoList={memoInfoList}
seriesLikeNum={likes}
seriesId={seriesId}
isMySeries={id === memo.authorId}
seriesTitle={title}
/>
);
}

Expand Down

0 comments on commit f311bd9

Please sign in to comment.