Skip to content

Commit

Permalink
Merge pull request #68 from Funssion-SWM/develop
Browse files Browse the repository at this point in the history
추천 기능 추가
  • Loading branch information
dongree authored Nov 9, 2023
2 parents 650937b + 9920b9f commit 230e6a1
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 57 deletions.
159 changes: 112 additions & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/app/memos/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Header from '@/components/shared/Header';
import MemoViewer from '@/components/memo/MemoViewer';
import { getMemoById } from '@/service/memos';
import { getMemoById, getMemoRecommendationsById } from '@/service/memos';
import LayoutWrapper from '@/components/shared/LayoutWrapper';
import MemoSideBar from '@/components/memo/MemoSideBar';
import { getCommentsByPostTypeAndPostId } from '@/service/comments';
Expand Down Expand Up @@ -28,6 +28,7 @@ export default async function MemoPage({ params: { slug } }: Props) {
const commentData = getCommentsByPostTypeAndPostId('memo', memoId, cookie);
const myData = checkUser(cookie);
const questionsData = getQuestionsByMemoId(memoId);
const recommendationsData = getMemoRecommendationsById(memoId);

const [
{
Expand All @@ -48,12 +49,14 @@ export default async function MemoPage({ params: { slug } }: Props) {
{ isLike },
comments,
{ id, isLogin, authority },
recommendations,
questions,
] = await Promise.all([
memoData,
likeData,
commentData,
myData,
recommendationsData,
questionsData,
]);

Expand Down Expand Up @@ -98,6 +101,7 @@ export default async function MemoPage({ params: { slug } }: Props) {
authorId={authorId}
comments={comments}
questions={questions}
recommendations={recommendations}
memoId={memoId}
userId={id}
isFollowed={isFollowed}
Expand Down
21 changes: 18 additions & 3 deletions src/app/series/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import LayoutWrapper from '@/components/shared/LayoutWrapper';
import { checkUser, getUserInfo } from '@/service/auth';
import { getCommentsByPostTypeAndPostId } from '@/service/comments';
import { getIsLike } from '@/service/like';
import { getMemoById } from '@/service/memos';
import { getMemoById, getMemoRecommendationsById } from '@/service/memos';
import { getNotificationsTop30 } from '@/service/notification';
import { getQuestionsByMemoId } from '@/service/questions';
import { getSeriesById } from '@/service/series';
Expand Down Expand Up @@ -34,9 +34,23 @@ export default async function SeriesDetailPage({ params: { slug } }: Props) {
);
const myData = checkUser(cookie);
const questionsData = getQuestionsByMemoId(memoInfoList[0].id);
const recommendationsData = getMemoRecommendationsById(memoInfoList[0].id);

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

const { isFollowed, followCnt, followerCnt } = await getUserInfo(
memo.authorId,
Expand All @@ -63,6 +77,7 @@ export default async function SeriesDetailPage({ params: { slug } }: Props) {
memo={memo}
comments={comments}
questions={questions}
recommendation={recommendation}
isLike={isLike}
userId={id}
isLogin={isLogin}
Expand Down
9 changes: 9 additions & 0 deletions src/components/memo/MemoSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ import QuestionsList from '../question/QuestionsList';
import { useRouter } from 'next/navigation';
import { notifyToast } from '@/service/notify';
import { Rank } from '@/types/rank';
import { Memo } from '@/types/memo';
import MemosGrid from './MemosGrid';

type Props = {
authorName: string;
authorProfileImagePath: string;
authorId: number;
comments: Comment[];
questions: Question[];
recommendations: Memo[];
memoId: number;
userId: number;
isFollowed: boolean;
Expand All @@ -35,6 +38,7 @@ export default function MemoSideBar({
authorId,
comments,
questions,
recommendations,
memoId,
userId,
isFollowed,
Expand Down Expand Up @@ -128,6 +132,11 @@ export default function MemoSideBar({
</button>
</>
)}
{currnetCategory === 'recommendation' && (
<div className="p-2">
<MemosGrid memos={recommendations} colNum={1} />
</div>
)}
</aside>
)}
</div>
Expand Down
8 changes: 3 additions & 5 deletions src/components/memo/MemoSidebarHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,11 @@ export default function MemoSidebarHeader({
onClick={() => onCategoryBtnClick('question')}
isSelected={currentCategory === 'question'}
/>
{/* <BarBtn
<BarBtn
text="추천"
onClick={() => {
alert('지원 예정입니다! 개발자들이 열심히 개발하고 있어요 :)');
}}
onClick={() => onCategoryBtnClick('recommendation')}
isSelected={currentCategory === 'recommendation'}
/> */}
/>
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/components/memo/MemosGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function MemosGrid({
className={`grid gap-4 grid-cols-1
${
{
1: '',
2: 'lg:grid-cols-2',
3: 'md:grid-cols-2 lg:grid-cols-3',
4: 'sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4',
Expand Down
Loading

0 comments on commit 230e6a1

Please sign in to comment.