Skip to content

Commit 65f161a

Browse files
committed
401수정
1 parent eb20d6c commit 65f161a

File tree

5 files changed

+7
-24
lines changed

5 files changed

+7
-24
lines changed

src/domains/community/api/fetchComment.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export const fetchComment = async (postId: ParamValue | number): Promise<Comment
77
const res = await fetch(`${getApi}/posts/${postId}/comments`, {
88
method: 'GET',
99
cache: 'no-store', // 캐시 비활성화
10-
credentials: 'include',
1110
});
1211
const data = await res.json();
1312

src/domains/community/api/fetchPost.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export async function likePost(postId: number | ParamValue) {
9999
export async function getLikePost(postId: number | ParamValue) {
100100
const res = await fetch(`${getApi}/posts/${postId}/like`, {
101101
method: 'GET',
102-
credentials: 'include',
103102
});
104103
if (!res.ok) throw new Error('좋아요 실패');
105104
const data = await res.json();

src/domains/community/detail/DetailHeader.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Label from '@/domains/shared/components/label/Label';
22
import EditDelete from './EditDelete';
33
import { useRouter } from 'next/navigation';
44
import { useAuthStore } from '@/domains/shared/store/auth';
5-
import { useToast } from '@/shared/hook/useToast';
65
import ConfirmModal from '@/shared/components/modal-pop/ConfirmModal';
76
import { useState } from 'react';
87
import { getApi } from '@/app/api/config/appConfig';
@@ -18,7 +17,6 @@ function DetailHeader({ categoryName, postId, userNickName }: Props) {
1817
const [deletePost, setDeletePost] = useState(false);
1918
const router = useRouter();
2019
const user = useAuthStore((state) => state.user);
21-
const { toastError } = useToast();
2220

2321
const handleConfirmDelete = async (postId: number | ParamValue) => {
2422
if (!user) {

src/domains/community/hook/useComment.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { useState, useEffect, useCallback } from 'react';
22
import { deleteComment, fetchComment, updateComment } from '../api/fetchComment';
33
import { getApi } from '@/app/api/config/appConfig';
44
import { CommentType } from '../types/post';
5-
import { User } from '@/domains/shared/store/auth';
65
import { ParamValue } from 'next/dist/server/request/params';
6+
import { User } from '@/domains/shared/store/auth';
77

88
export function useComments(postId: ParamValue, user: User | null) {
99
const [comments, setComments] = useState<CommentType[] | null>(null);
@@ -15,12 +15,6 @@ export function useComments(postId: ParamValue, user: User | null) {
1515
} | null>(null);
1616

1717
const fetchData = useCallback(async () => {
18-
// 로그인 상태일 때만 댓글 조회
19-
if (!user) {
20-
setComments([]);
21-
return;
22-
}
23-
2418
const data = await fetchComment(postId);
2519
if (!data) return;
2620
setComments(data);
@@ -80,13 +74,11 @@ export function useComments(postId: ParamValue, user: User | null) {
8074
};
8175

8276
const loadMoreComments = async (lastCommentId: number) => {
83-
if (isEnd || isLoading || !user) return;
77+
if (isEnd || isLoading) return;
8478

8579
setIsLoading(true);
8680
try {
87-
const res = await fetch(`${getApi}/posts/${postId}/comments?lastId=${lastCommentId}`, {
88-
credentials: 'include',
89-
});
81+
const res = await fetch(`${getApi}/posts/${postId}/comments?lastId=${lastCommentId}`, {});
9082
const newComments = await res.json();
9183

9284
if (newComments.data.length === 0) {

src/domains/shared/components/profile/Profile.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
import useFetchProfile from '@/domains/mypage/api/fetchProfile';
21
import SsuryImage from '@/domains/mypage/main/SsuryImage';
3-
import { useEffect } from 'react';
2+
import { useAuthStore } from '@/domains/shared/store/auth';
43

54
type Props = {
65
userNickname: string;
76
};
87

98
function Profile({ userNickname }: Props) {
10-
const { profile, fetchProfile } = useFetchProfile();
11-
useEffect(() => {
12-
fetchProfile();
13-
}, [fetchProfile, profile?.data?.abvLevel]);
9+
const user = useAuthStore((state) => state.user);
1410

15-
if (!profile?.data) return null;
16-
const { abvLevel } = profile.data;
11+
if (!user) return null;
1712

1813
return (
1914
<div className="flex gap-2 items-center justify-start">
2015
<div className="w-8 h-8 flex items-center justify-center" aria-label="작성자 아이콘">
2116
<div className="w-8 flex items-center justify-center">
22-
<SsuryImage abvLevel={abvLevel} />
17+
<SsuryImage abvLevel={user.abv_degree || 5.0} />
2318
</div>
2419
</div>
2520
<span aria-label="작성자 이름" className="text-sm">

0 commit comments

Comments
 (0)