Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix, Feat] 댓글, 답글 CRUD api 연결, 기능 구현 #130

Merged
merged 114 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
14f48e3
[Fix] href
callmebyneon Jul 25, 2024
10232ba
Merge branch 'dev' of https://github.com/woongteco/nextcamp-12t into …
callmebyneon Jul 25, 2024
1022815
Merge branch 'dev' into feature/crud
callmebyneon Jul 30, 2024
7fc3388
[Chore] 컴포넌트 파일 위치 변경
callmebyneon Jul 30, 2024
5bc082c
[Feat] Suspense를 이용해 dynamic import 시 대체 UI 표시
callmebyneon Jul 30, 2024
da1a552
[Fix, Feat] 공통 컴포넌트 업데이트
callmebyneon Jul 30, 2024
43bca01
[Chore] 이미지 수정
callmebyneon Jul 30, 2024
1e26d83
[Feat] 전체 화면 로딩 컴포넌트 추가
callmebyneon Jul 30, 2024
719cb5f
[Chore] 프로필 스키마 타입 추가
callmebyneon Jul 30, 2024
95be3ea
[Refactor, Chore] 아이콘 버튼들 분리, 테스트중
callmebyneon Jul 30, 2024
0a4e4a7
[Chore, Style] 스타일 및 이름 수정
callmebyneon Jul 30, 2024
6d6f647
[Chore] handleAlert 파일 위치 변경으로 경로 수정
callmebyneon Jul 30, 2024
f27fb12
[Fix] 세션 프로바이더 삭제
callmebyneon Jul 30, 2024
eb04dfa
[Chore]
callmebyneon Jul 30, 2024
46c5156
[Feat] crud 테스트중
callmebyneon Jul 30, 2024
52d5dde
[Chore] defaultValue blocked
callmebyneon Jul 30, 2024
cae3a11
Merge branch 'dev' into feature/crud
callmebyneon Jul 31, 2024
e55cab4
[Chore] 프로필 미리보기 삭제
callmebyneon Jul 31, 2024
1bd3db5
[Style] loading spinner 사용을 위한 공통 로딩 컨테이너 분리
callmebyneon Jul 31, 2024
4de3375
[Chore] rm unused component
callmebyneon Jul 31, 2024
2cb005c
[Chore] 파일 위치 변경
callmebyneon Jul 31, 2024
7ba373a
[Chore] 중복 session 검사 제거 => ProfileForms에서 session 검사
callmebyneon Jul 31, 2024
36af18f
[Chore] rm unused size
callmebyneon Jul 31, 2024
bd694f4
[Chore] p 태그 아래 중첩 태그 오류 방지를 위해 div 태그로 변경
callmebyneon Jul 31, 2024
6d3a9ec
[Refactor, Feat]
callmebyneon Jul 31, 2024
3248c73
[Chore] rm unused code block
callmebyneon Jul 31, 2024
17c36ee
[Fix] document is not definded 오류 방지로 LoadingContainer 조건 추가
callmebyneon Jul 31, 2024
770bc49
[Feat] 계정 삭제 확인 모달 추가
callmebyneon Jul 31, 2024
0e367ef
[Refactor, Fix] 관심 카테고리 선택 단계 분리
callmebyneon Jul 31, 2024
2160a3c
[Refactor] toast 라이브러리 사용시 handleAlert로 대체
callmebyneon Jul 31, 2024
674cea8
[Chore]
callmebyneon Jul 31, 2024
3c93d9a
[Feat] 회원 데이터 삭제 액션 추가
callmebyneon Jul 31, 2024
b3fc2b0
[Feat, Fix] JSDoc 추가, 프로필 정보 업데이트 오류 수정
callmebyneon Jul 31, 2024
7f6db12
[Refactor, Style] props 전달 삭제, 이벤트 함수 내부에서 정의 후 실행, 스타일 수정
callmebyneon Jul 31, 2024
03361b4
[Refactor, Feat] 회원 가입 후 관심카테고리 선택 페이지 추가
callmebyneon Jul 31, 2024
1e40f46
[Feat, Fix] 프로필 정보 오류 수정
callmebyneon Jul 31, 2024
517bb6b
[Feat] 뒤로 돌아가기 버튼 추가
callmebyneon Jul 31, 2024
f878114
[Chore] 카테고리 그룹 데이터 분리
callmebyneon Jul 31, 2024
81b938b
[Refactor, Feat] 메인 검색창 컴포넌트 분리, 스터디 검색 결과로 이동
callmebyneon Jul 31, 2024
49cfe99
[Chore] 탭 버튼 클릭 핸들러 다시 클릭시 값 없음 테스트
callmebyneon Jul 31, 2024
0419204
[Feat, Fix] 필터 재선택 혹은 전체 선택 시 해당 필터링 취소하도록 수정
callmebyneon Jul 31, 2024
8b6d32b
[Feat] 후에 프로필의 관심 카테고리, 가장 최근에 만들어진 스터디들 데이터 가져와서 보여주기
callmebyneon Jul 31, 2024
89208b1
[Style] GridField 그리드 무너짐 해결 스타일 추가
callmebyneon Jul 31, 2024
8c66bf4
[Feat] 관련 스터디 링크 검색, 선택 테스트중
callmebyneon Jul 31, 2024
2493d2d
Merge branch 'dev' into feature/crud
callmebyneon Jul 31, 2024
a4a6d44
[Fix, Refactor] 로그인한 사용자 프로필 이미지 연결
callmebyneon Aug 6, 2024
8227d8a
[Feat] 더미 액션 추가
callmebyneon Aug 6, 2024
f1abd0d
[Feat] 미션 보드 삭제, 참여 신청한 스터디 목록 영역 추가
callmebyneon Aug 6, 2024
45039e0
[Feat] 관련 스터디 링크 select로 검색, 선택하여 링크 추가
callmebyneon Aug 6, 2024
0cd42fe
[Chore, Refactor] 유틸 함수 이동
callmebyneon Aug 6, 2024
43df009
[Feat] 유더 데이터 가져오는 액션 추가
callmebyneon Aug 6, 2024
1c9831b
[Fix] 에러 메시지 수정
callmebyneon Aug 6, 2024
f2d8d39
[Chore] 액션, formData 이름 수정
callmebyneon Aug 6, 2024
63e9686
[Fix] 글 상세 데이터 적용
callmebyneon Aug 6, 2024
0fbe9cb
[Chore, Style]
callmebyneon Aug 6, 2024
e5989ca
[Fix] 프로필 업데이트 기능 오류 수정
callmebyneon Aug 6, 2024
3264df4
Merge branch 'dev' into feature/crud
callmebyneon Aug 6, 2024
5c9fc11
[Fix] rm type error, change temp error text
callmebyneon Aug 6, 2024
d0555ed
[Refactor] 글로벌 유틸 함수 위치 변경
callmebyneon Aug 6, 2024
ad1ca8c
[Refactor, Feat] es-hangul 라이브러리를 이용하여 초성 검색 기능 추가
callmebyneon Aug 6, 2024
086f671
[Refactor, Style, Fix] 버튼 컴포넌트 리팩토링, 호버 인터랙션 스타일 미적용 문제 해결
callmebyneon Aug 6, 2024
d5e4735
[Fix] 공통 컴포넌트 내부에서 세션 외 데이터를 가져오지 않도록 수정
callmebyneon Aug 6, 2024
b2d76df
[Fix] 댓글 입력 창에서 현재 로그인한(작성중인) 사용자 프로필 표시
callmebyneon Aug 6, 2024
0d80d7d
[Chore] 머지 되지 않은 부분 다시 덮어쓰기
callmebyneon Aug 6, 2024
c316465
[Fix] 커뮤니티 글 작성 시 관련 스터디 링크 값 전달 수정 중, 유저 데이터 타입 통일중
callmebyneon Aug 7, 2024
53ea18b
Merge branch 'dev' into feature/crud
callmebyneon Aug 7, 2024
fd29b9d
[Fix] 커뮤니티 글 작성, 삭제 수정 - 관련 스터디 데이터 입출력 확인 완료
callmebyneon Aug 7, 2024
6e140a2
[Refacor Chore] accept 값 수정, type 위치 변경
callmebyneon Aug 7, 2024
51f5df9
[Chore]
callmebyneon Aug 7, 2024
b0b8363
[Feat] 조회수 increase 액션 수정
callmebyneon Aug 7, 2024
0e7be58
[Feat] 커뮤니티 글 정렬 로직 수정
callmebyneon Aug 7, 2024
539f98d
[Style] 클래스 선택자 수정
callmebyneon Aug 8, 2024
d339475
[Fix] 사용자 데이터 타입 통일, 수정, Profile 스키마 deprecated로 액션 수정 `\lib\schema.ts`
callmebyneon Aug 8, 2024
b689157
Merge branch 'feature/crud' of https://github.com/woongteco/nextcamp-…
callmebyneon Aug 8, 2024
e219fec
Merge branch 'dev' into feature/crud
callmebyneon Aug 8, 2024
2d0d978
[Chore] import missing Link
callmebyneon Aug 8, 2024
68e9a14
[Chore, Fix]
callmebyneon Aug 8, 2024
9b08f56
[Feat] 작성자 본인일때 커뮤니티 글 업데이트
callmebyneon Aug 8, 2024
4b49c65
Merge branch 'dev' into feature/crud
callmebyneon Aug 9, 2024
f6c3bc7
[Refactor] 썸네일 컴포넌트 통일, props 수정
callmebyneon Aug 12, 2024
2adcc00
[Refactor] 로고 svg 컴포넌트 대체
callmebyneon Aug 12, 2024
184010e
[Feat] 찜한 스터디, 지원한 스터디, 좋아요한 글 목록 저장을 위한 스키마 추가
callmebyneon Aug 12, 2024
b6d7670
[Chore] 설명 추가
callmebyneon Aug 12, 2024
ea0c01d
[Feat] 로그인한 사용자 메인 스터디 현황 보드 데이터 연결, 찜한 스터디 목록 가져오기 액션 추가
callmebyneon Aug 12, 2024
02f55c0
Merge branch 'dev' into feature/crud
callmebyneon Aug 12, 2024
42a281d
[Feat] 대댓글 길이까지 계산하는 유틸 함수 추가, 사용
callmebyneon Aug 13, 2024
0703bf3
[Style, Fix] 오타 수정
callmebyneon Aug 13, 2024
7106287
[Chore] custom fetch 함수 설정
callmebyneon Aug 13, 2024
12a9699
[Fix] radio name, value 속성 수정
callmebyneon Aug 13, 2024
183f581
[Fix] init 속성 optional 변경
callmebyneon Aug 13, 2024
c7b77a0
[Chore]
callmebyneon Aug 13, 2024
12002a5
[Chore] 로그인 성공 시 메인 페이지가 아닌 이전 페이지로 이동
callmebyneon Aug 13, 2024
efcb7cb
[Feat, Fix] 커뮤니티 글 API CRUD 수정, 기능 테스트 완료
callmebyneon Aug 13, 2024
fc9a5fc
[Fix] userId가 없을 때 getAllStudies()
callmebyneon Aug 14, 2024
f4a2119
[Chore]
callmebyneon Aug 14, 2024
c04392a
Merge branch 'dev' into feature/crud
callmebyneon Aug 14, 2024
c55f728
[Fix] 다른 페이지에서 로그인 후 redirect 방법 다시 생각해보기
callmebyneon Aug 14, 2024
8a64bff
[Fix] createdAt 갱신 대신 timestamp 사용으로 createdAt, updatedAt 관리
callmebyneon Aug 14, 2024
0fc8029
[Fix] svg dot path 생략되는 문제 수정
callmebyneon Aug 15, 2024
c0fe080
[Refactor] post 데이터 작성자 populate select 범위 수정
callmebyneon Aug 15, 2024
2c6886b
[Chore] 사용하지 않는 import 삭제
callmebyneon Aug 15, 2024
f9531cb
[Feat] 댓글, 답글 CRUD 기능 구현
callmebyneon Aug 15, 2024
1629d11
[Chore] 비공개 라우트 제거, 준비되지 않은 페이지 안내
callmebyneon Aug 16, 2024
4adbf56
[Fix] reply가 없거나 배열이 아닌 경우 예외 처리 수정
callmebyneon Aug 16, 2024
468ba1c
[Fix] 로그인하지 않은 사용자의 경우 조건 수정
callmebyneon Aug 16, 2024
9b5a415
[Style] mt-100 삭제, Footer 사용 시 이전 sibiling에 mb-100 or pb-100 추가 필요
callmebyneon Aug 16, 2024
d210037
[Style] 댓글 콘텐츠 영역 whitespace, word-break 설정 수정
callmebyneon Aug 16, 2024
ea18e11
[Fix] 오류 수정
callmebyneon Aug 16, 2024
d0d034d
[Chore] 사용하지 않는 console.* 삭제, 주석 처리
callmebyneon Aug 16, 2024
fc9099e
Merge branch 'dev' into feature/crud
callmebyneon Aug 16, 2024
dd79692
[Chore] merge error 해결
callmebyneon Aug 16, 2024
619223c
[Feat] getStudy() 테스트
callmebyneon Aug 16, 2024
820fff8
[Fix] /study 접속 시 자동으로 /search? 쿼리 이동 오류 수정. useEffect 제거
callmebyneon Aug 16, 2024
fd2895a
Merge branch 'dev' into feature/crud
callmebyneon Aug 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/app/(route)/_components/DeletePostButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import handleAlert from "@/common/Molecules/handleAlert";
import { deleteCommunity } from "@/lib/actions/communityAction";
import { TProps } from "@/types/component/props";
import { cfetch } from "@/utils/customFetch";
import { useRouter } from "next/navigation";
Expand All @@ -18,11 +17,11 @@ export default function DeletePostButton({
})
.then((res) => res.json())
.then(({ data }) => {
console.log(data);
// console.log(data);
return data;
})
.catch((err) => {
console.error(err);
// console.error(err);
return { state: false, message: "상태 업데이트에 실패했습니다." };
});

Expand Down
2 changes: 1 addition & 1 deletion src/app/(route)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function MainLayout({ children }: TProps) {
return (
<>
<Header />
<main className="min-h-full mt-16 py-20">
<main className="min-h-full mt-16 mb-100 py-20">
<Container>{children}</Container>
</main>
<Footer />
Expand Down
2 changes: 1 addition & 1 deletion src/app/(route)/my/post/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default async function MyPost() {
if (!result.state) return notFound();

const posts: PostDataFull[] = result.data;
console.log("posts", posts);
// console.log("posts", posts);

return (
<div className="w-full lg:w-[calc(100vw-240px-30px-2rem)] xl:w-[calc(1200px-280px-30px-2rem)]">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function DeleteAccountConfirm({ email }: { email: string }) {
handleAlert("error", result.message);
}
} catch (error) {
console.log(error);
console.error(error);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function FormEditProfile({
handleAlert("error", result.message);
}
} catch (error) {
console.log(error);
console.error(error);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export default function FormEditProfileImageWithPreview({
}

async function onSave() {
console.log("save");
try {
const result = await updateUserData(id, { profile_img: imageUrl });

Expand All @@ -78,7 +77,7 @@ export default function FormEditProfileImageWithPreview({
handleAlert("error", result.message);
}
} catch (error) {
console.log(error);
console.error(error);
}
}

Expand All @@ -98,7 +97,7 @@ export default function FormEditProfileImageWithPreview({
handleAlert("error", result.message);
}
} catch (error) {
console.log(error);
console.error(error);
}
}

Expand Down
7 changes: 2 additions & 5 deletions src/app/(route)/post/[postId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default async function PostDetail({
const session = await getSession();

const postDetail = await cfetch("/api/community/" + postId, {
next: { tags: ["community"] },
next: { tags: ["community", postId] },
})
.then((res) => res.json())
.then(({ data }) => data)
Expand Down Expand Up @@ -94,10 +94,7 @@ export default async function PostDetail({
</div>
<LinkedStudyCard studyId={post.contents.linkedStudyId || ""} />
</article>
<CommentArea
sessionId={session?.user.id || ""}
comments={post.comments}
/>
<CommentArea sessionId={session?.user.id || ""} postId={postId} />
</div>
);
}
1 change: 0 additions & 1 deletion src/app/(route)/post/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default async function CommunityPostList({
})
.then((res) => res.json())
.then(({ data }) => {
console.log("data", data);
return data;
})
.catch((err) => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/(route)/study/[studyPostId]/_components/Comment.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ProfileImg from "@/common/Atoms/Image/ProfileImg";
import CommentInput from "@/common/Organisms/Comment/CommentInput";
import CommentInputForm from "@/common/Organisms/Comment/CommentInput";
import { QandAIcon } from "@public/icons";
import Image from "next/image";
import CommentList, { TComment } from "./CommentList";
Expand Down Expand Up @@ -31,7 +31,7 @@ export default function Comment({ comments }: { comments: TComment[] }) {
alt="프로필 이미지"
className="my-[6px]"
/>
<CommentInput />
<CommentInputForm />
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import StudyDetailContent from "./StudyDetailContent";
import StudyDetailThumbnail from "./StudyDetailThumbnail";
import CommentArea from "@/common/Templates/CommentArea";
import { comments } from "@/dummies/comments";
import { getSession } from "@/auth";

export default function StudyDetail() {
export default async function StudyDetail() {
const user = getStudyLeaderUser();
const session = await getSession();
const { studyPostId: postId, thumbnailInfo, contents } = getStudyPostDetail();

return (
<div>
<StudyDetailThumbnail thumbnailInfo={thumbnailInfo} />
<StudyDetailContent contents={contents} user={user} />
<CommentArea comments={comments} sessionId="" />
<CommentArea postId={String(postId)} sessionId={session?.user.id || ""} />
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ export default function StudyCategoryTabButtonList({
const clickHandler = (value: string) => {
setSelected((prev) => {
if (prev === value) {
onChangeQuery("");
return "";
}
onChangeQuery(value);
return value;
});
};

useEffect(() => {
onChangeQuery(select);
}, [select]);

return (
<div className="flex gap-4 w-fit mb-11">
{studyCategoryIcons.map(({ label, value, iconName }) => {
Expand Down
40 changes: 40 additions & 0 deletions src/app/(studyroom)/_components/NotPrepare.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"use client";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";

export default function NotPrepare() {
const router = useRouter();
return (
<div className="mx-auto mt-36 flex flex-col gap-10 items-center justify-center w-[480px]">
<h2 className="text-H2 text-black">아직 준비되지 않은 페이지에요.</h2>
<div className="svgBox w-[270px] h-[181px]">
<Image
src="/icons/404.png"
width={270}
height={181}
alt="404 Not-Found"
/>
</div>
<div className="flex flex-col gap-6 items-center justify-center w-full h-[200px] rounded-[20px] bg-alt/50 border border-[#F7F7F8]">
<p className="text-[22px] font-semibold text-black">
돌아가서 다른 스터디를 탐색하는 건 어떨까요?
</p>
<div className="flex items-center gap-4">
<Link
href="/"
className="text-center px-6 py-3 rounded-[10px] border border-main-600 text-main-600 font-bold"
>
홈으로 이동
</Link>
<button
onClick={() => router.back()}
className="text-center px-6 py-3 rounded-[10px] border border-label-neutral text-label-neutral font-bold"
>
뒤로 돌아가기
</button>
</div>
</div>
</div>
);
}
7 changes: 0 additions & 7 deletions src/app/(studyroom)/_studyroom/[studyroomId]/page.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions src/app/(studyroom)/_studyroom/[studyroomId]/setting/page.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions src/app/(studyroom)/_studyroom/create/page.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions src/app/(studyroom)/_studyroom/page.tsx

This file was deleted.

5 changes: 5 additions & 0 deletions src/app/(studyroom)/studyroom/[studyroomId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import NotPrepare from "../../_components/NotPrepare";

export default function StudyroomDashboard() {
return <NotPrepare />;
}
5 changes: 5 additions & 0 deletions src/app/(studyroom)/studyroom/[studyroomId]/setting/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import NotPrepare from "@/app/(studyroom)/_components/NotPrepare";

export default function StudyroomSetting() {
return <NotPrepare />;
}
14 changes: 14 additions & 0 deletions src/app/(studyroom)/studyroom/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Footer, Header, Container } from "@/common/Layout";
import { TProps } from "@/types/component/props";

export default function StudyroomLayout({ children }: TProps) {
return (
<>
<Header />
<main className="min-h-full mt-16 pt-20 pb-[180px] bg-card">
<Container>{children}</Container>
</main>
<Footer />
</>
);
}
5 changes: 5 additions & 0 deletions src/app/(studyroom)/studyroom/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { notFound } from "next/navigation";

export default function Studyroom() {
return notFound();
}
13 changes: 9 additions & 4 deletions src/app/_components/RecommendProStudies.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import StudyCardList from "@/common/Templates/CardList";
import { filterStudies, getAllStudies } from "@/lib/actions/studyAction";
import {
filterStudies,
getAllStudies,
getStudy,
} from "@/lib/actions/studyAction";
import { getUserData } from "@/lib/actions/userAction";
import { StudyDataFull } from "@/types/model/StudyCard";

async function getFavorStudies(userId: string) {
// 1. profile에서 관심 카테고리 가져오기
Expand All @@ -9,7 +14,7 @@ async function getFavorStudies(userId: string) {
const profile = await getUserData(userId);

if (profile.state === false) {
const result = await getAllStudies();
const result = await getStudy();
return result;
}

Expand All @@ -24,13 +29,13 @@ export default async function RecommendProStudies({
userId: string;
}) {
const result =
userId === "" ? await getAllStudies() : await getFavorStudies(userId);
userId === "" ? await getStudy() : await getFavorStudies(userId);

if (result.state === false) {
throw new Error("관심 카테고리의 스터디 정보 가져오기 실패");
}

const recommend = result.data;
const recommend: StudyDataFull[] = result.data;

return <StudyCardList studyCards={recommend} count={8} />;
}
51 changes: 51 additions & 0 deletions src/app/api/comment/[id]/reply/[reId]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { deleteReply, updateReply } from "@/lib/actions/replyAction";
import { NextRequest } from "next/server";

export async function PATCH(
request: NextRequest,
{ params }: { params: { id: string; reId: string } }
) {
// const { searchParams } = request.nextUrl;
// const commentId = searchParams.get("parentId");
// const replyId = searchParams.get("replyId");
const commentId = params.id;
const replyId = params.reId;
const formData = await request.formData();

if (!commentId || !replyId) {
return Response.json(
{ error: "comment 또는 reply id가 없습니다." },
{ status: 400 }
);
}

const result = await updateReply(commentId, replyId, formData);
if (result.state === false) {
return Response.json({ error: result }, { status: 500 });
}
return Response.json({ data: result }, { status: 200 });
}

export async function DELETE(
_: NextRequest,
{ params }: { params: { id: string; reId: string } }
) {
// const { searchParams } = request.nextUrl;
// const commentId = searchParams.get("parentId");
// const replyId = searchParams.get("replyId");
const commentId = params.id;
const replyId = params.reId;

if (!commentId || !replyId) {
return Response.json(
{ error: "comment 또는 reply id가 없습니다." },
{ status: 400 }
);
}

const result = await deleteReply(commentId, replyId);
if (result.success === false) {
return Response.json({ error: result }, { status: 500 });
}
return Response.json({ data: result }, { status: 200 });
}
31 changes: 31 additions & 0 deletions src/app/api/comment/[id]/reply/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { getSession } from "@/auth";
import { createReply } from "@/lib/actions/replyAction";
import { NextRequest } from "next/server";

export async function POST(
request: NextRequest,
{ params }: { params: { id: string } }
) {
// 작성자 session id 확인
const session = await getSession();
const userId: string | undefined = session?.user.id;

// const { searchParams } = request.nextUrl;
// const userId = searchParams.get("userId");
// const commentId = searchParams.get("parentId");
const commentId = params.id;
const formData = await request.formData();

if (!userId || !commentId) {
return Response.json(
{ error: "user 또는 comment id가 없습니다." },
{ status: 400 }
);
}

const result = await createReply(userId, commentId, formData);
if (result.state === false) {
return Response.json({ error: result }, { status: 500 });
}
return Response.json({ data: result }, { status: 200 });
}
Loading