Skip to content

Commit 3f275b2

Browse files
Feat/칵테일 댓글기능#97 (#120)
* [feat]칵테일 댓글 ui * [chore] merge전 커밋 * [chore] 확인용 커밋 * 댓글에러 * 포맷 * 커뮤니티 댓글 수정 * [chore]풀 전용 커밋 * [feat] 칵테일 댓글등록 * [feat]로그인 유저 킵 버튼 * [feat] 나만의 바 라벨링 * [feat]로그인 한 유저 킵버튼 * [feaet] 상세페이지 킵 * [feat]레시피페이지정렬 * [feat] 댓글 클릭시 해당 글로 보내주는 기능 * [feat]댓글 작성 토스트 * [feat]댓글 validation * [feat]댓글 validation * [fix] 댓글, 킵 아이템 비로그인 경고 * [fix] mypage 401에러 대응 --------- Co-authored-by: EunbinJung <[email protected]>
1 parent b7ed8ff commit 3f275b2

File tree

34 files changed

+761
-336
lines changed

34 files changed

+761
-336
lines changed

next.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import type { NextConfig } from 'next';
22

33
const nextConfig: NextConfig = {
4+
45
images: {
56
remotePatterns: [
67
{
78
protocol: 'https',
8-
hostname:'www.thecocktaildb.com'
9-
}
10-
]
9+
hostname: 'www.thecocktaildb.com',
10+
},
11+
],
1112
},
1213
env: {
1314
NPUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"react": "19.1.0",
2727
"react-dom": "19.1.0",
2828
"react-hot-toast": "^2.6.0",
29+
"react-intersection-observer": "^9.16.0",
2930
"react-use": "^17.6.0"
3031
},
3132
"devDependencies": {
@@ -61,4 +62,4 @@
6162
},
6263
"homepage": "https://github.com/prgrms-web-devcourse-final-project/WEB5_6_HaeDokCoding_FE#readme",
6364
"description": ""
64-
}
65+
}

src/app/mypage/my-active/my-like/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export const metadata: Metadata = {
88
};
99

1010
function Page() {
11-
// return <MyLike />;
11+
return <MyLike />;
1212
}
1313
export default Page;

src/domains/community/hook/useComment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function useComments(postId: number, user: User | null, accessToken: stri
2323
fetchData();
2424
}, [fetchData]);
2525

26-
const handleUpdateComment = async (commentId: number, postId: number, content: string) => {
26+
const handleUpdateComment = async (commentId: number, content: string) => {
2727
if (!user) {
2828
alert('로그인이 필요합니다');
2929
return;
@@ -43,7 +43,7 @@ export function useComments(postId: number, user: User | null, accessToken: stri
4343
}
4444
};
4545

46-
const handleAskDeleteComment = (commentId: number, postId: number) => {
46+
const handleAskDeleteComment = (commentId: number) => {
4747
setDeleteTarget({ commentId, postId });
4848
};
4949

src/domains/mypage/components/ToggleBtn.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ function ToggleBtn() {
1616
credentials: 'include',
1717
});
1818
const json = await res.json();
19-
console.log(json);
2019
setIsAlarm(json.data.enabled);
2120
} catch {
2221
console.error();

src/domains/mypage/components/pages/my-active/MyComment.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,26 @@
22
import { getApi } from '@/app/api/config/appConfig';
33
import { CommentType } from '@/domains/community/types/post';
44
import CommentList from '@/domains/shared/components/comment/CommentList';
5+
import { useAuthStore } from '@/domains/shared/store/auth';
56
import { useEffect, useState } from 'react';
7+
import { useShallow } from 'zustand/shallow';
68

79
function MyComment() {
10+
const { user } = useAuthStore(
11+
useShallow((state) => ({
12+
user: state.user,
13+
}))
14+
);
15+
816
const [myComment, setMyComment] = useState<CommentType[]>([]);
9-
const [isLoading, setIsLoading] = useState<boolean>(false);
17+
const [isLoading] = useState<boolean>(false);
18+
1019
const fetchComment = async () => {
1120
const res = await fetch(`${getApi}/me/comments`, {
1221
method: 'GET',
1322
credentials: 'include',
1423
});
1524
const json = await res.json();
16-
console.log(json);
1725
setMyComment(json.data.items);
1826
};
1927

@@ -23,13 +31,18 @@ function MyComment() {
2331

2432
return (
2533
<section>
26-
{/* {CommentList.length !== 0 ? (
27-
<CommentList comments={myComment} isLoading={isLoading} />
34+
{CommentList.length !== 0 ? (
35+
<CommentList
36+
comments={myComment}
37+
isLoading={isLoading}
38+
myPage={true}
39+
currentUserNickname={user?.nickname}
40+
/>
2841
) : (
2942
<div className="flex justify-center">
3043
<p>작성한 댓글이 없습니다.</p>
3144
</div>
32-
)} */}
45+
)}
3346
</section>
3447
);
3548
}

src/domains/mypage/components/pages/my-active/MyLike.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,31 @@ import { getApi } from '@/app/api/config/appConfig';
33
import PostCard from '@/domains/community/main/PostCard';
44
import { useEffect, useState } from 'react';
55

6-
interface MyLike {
7-
postId: number;
8-
title: string;
9-
likedAt: Date;
10-
posetCreatedAt: Date;
11-
}
12-
136
function MyLike() {
14-
const [myLike, setMyLike] = useState<MyLike[]>([]);
7+
const [myLike, setMyLike] = useState([]);
158
const [isLoading, setIsLoading] = useState(false);
169

1710
const fetchLike = async () => {
18-
const res = await fetch(`${getApi}/me/likes/posts`, {
11+
const res = await fetch(`${getApi}/me/likes`, {
1912
method: 'GET',
2013
credentials: 'include',
2114
});
2215
const json = await res.json();
23-
// setMyLike(json.data.items);
16+
setMyLike(json.data.items);
2417
};
2518

2619
useEffect(() => {
2720
fetchLike();
2821
}, []);
2922

30-
// return <PostCard posts={myLike} isLoading={isLoading} />;
23+
return (
24+
<section className="flex justify-center">
25+
{myLike.length > 0 ? (
26+
<PostCard posts={myLike} isLoading={isLoading} />
27+
) : (
28+
<div>아직 좋아요를 누른 글이 없습니다</div>
29+
)}
30+
</section>
31+
);
3132
}
3233
export default MyLike;

src/domains/mypage/components/pages/my-active/MyPost.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function MyPost() {
1212
credentials: 'include',
1313
});
1414
const json = await res.json();
15+
console.log(json);
1516
setMyPost(json.data.items);
1617
};
1718

src/domains/mypage/components/pages/my-alarm/MyAlarm.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { useEffect, useState } from 'react';
33
import Alarm from '../../Alarm';
44
import { getApi } from '@/app/api/config/appConfig';
5+
import TextButton from '@/shared/components/button/TextButton';
56

67
interface MyAlarm {
78
notificationId: number;
@@ -29,6 +30,9 @@ function MyAlarm() {
2930

3031
return (
3132
<section>
33+
<div className="flex justify-end">
34+
<TextButton className="my-5">전체삭제</TextButton>
35+
</div>
3236
{myAlarm.length !== 0 ? (
3337
myAlarm.map(({ notificationId, title, content }) => (
3438
<Alarm key={notificationId} title={title} content={content} />

0 commit comments

Comments
 (0)