From 782ed616d179bf5b6729a458d5b863851891b326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EA=B1=B4=EC=9A=B0?= Date: Tue, 20 Feb 2024 15:34:51 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20feat:=20=ED=9B=84=EA=B8=B0=20?= =?UTF-8?q?=EC=8B=A0=EA=B3=A0=ED=95=98=EA=B8=B0=20api=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/[eventId]/_components/Banner.tsx | 4 +- .../[eventId]/_components/EventReview.tsx | 61 +++++++++++-------- app/_api/api.ts | 11 ++-- app/_components/modal/ReportModal.tsx | 15 ++++- app/_hooks/useInfScroll.ts | 35 ----------- app/_types/postBodyType.ts | 10 ++- 6 files changed, 65 insertions(+), 71 deletions(-) delete mode 100644 app/_hooks/useInfScroll.ts diff --git a/app/(route)/event/[eventId]/_components/Banner.tsx b/app/(route)/event/[eventId]/_components/Banner.tsx index 262ef0b3..95f378e7 100644 --- a/app/(route)/event/[eventId]/_components/Banner.tsx +++ b/app/(route)/event/[eventId]/_components/Banner.tsx @@ -61,7 +61,7 @@ const Banner = ({ data, eventId }: Props) => { return instance.get(`/event/${eventId}/update/application`); }, }); - const hasEditApplication = !(editApplication && editApplication?.length === 0); + const hasEditApplication = editApplication ? editApplication?.length !== 0 : false; return ( <> @@ -139,7 +139,7 @@ const Banner = ({ data, eventId }: Props) => { - {modal === "report" && } + {modal === "report" && } ); }; diff --git a/app/(route)/event/[eventId]/_components/EventReview.tsx b/app/(route)/event/[eventId]/_components/EventReview.tsx index a7a17c0b..f18a47c9 100644 --- a/app/(route)/event/[eventId]/_components/EventReview.tsx +++ b/app/(route)/event/[eventId]/_components/EventReview.tsx @@ -3,7 +3,9 @@ import Image from "next/image"; import { useRouter } from "next/navigation"; import { useState } from "react"; import Evaluation from "@/components/Evaluation"; +import ReportModal from "@/components/modal/ReportModal"; import { instance } from "@/api/api"; +import { useModal } from "@/hooks/useModal"; import { getSession } from "@/store/session/cookies"; import { EventReviewType } from "@/types/index"; import HeartIcon from "@/public/icon/heart.svg"; @@ -36,36 +38,43 @@ const EventReview = ({ data }: Props) => { likeMutation.mutate(); }; + const { modal, openModal, closeModal } = useModal(); + return ( -
-
-
- 프로필 이미지 + <> +
+
+
+ 프로필 이미지 +
+
{data.user?.nickName}
+
-
{data.user.nickName}
- -
- - {data.isPublic && ( - <> -
{data?.description}
-
    - {data?.reviewImages?.map((image, index) => ( -
  • - 후기 사진 -
  • - ))} -
- - )} + + {data.isPublic && ( + <> +
{data?.description}
+
    + {data?.reviewImages?.map((image, index) => ( +
  • + 후기 사진 +
  • + ))} +
+ + )} -
- +
+ +
-
+ {modal === "report" && } + ); }; diff --git a/app/_api/api.ts b/app/_api/api.ts index 50456215..7e036c31 100644 --- a/app/_api/api.ts +++ b/app/_api/api.ts @@ -74,7 +74,7 @@ export class Api { ...(endPoint === "/file/upload" ? {} : { "Content-Type": "application/json" }), }, }); - const result = STR_RES_ENDPOINT.includes(endPoint) ? await res.text() : await res.json(); + const result = STR_RES_ENDPOINT.includes(endPoint) || endPoint.split("/").includes("claims") ? await res.text() : await res.json(); this.makeError(result); return result; @@ -151,7 +151,8 @@ type PostEndPoint = | "/event/update/application" | "/event/update/approval" | "/artist/request" - | "/event/claim"; + | "/event/claim" + | `/reviews/${string}/claims`; type PutEndPoint = `/event/${string}` | `/users/${string}/profile` | `/users/${string}/password`; type DeleteEndPoint = `/users/${string}/artists` | `/reviews/${string}/images` | `/users/${string}`; @@ -188,8 +189,10 @@ type PostBodyType = T extends "/event" : T extends "/artist/request" ? Req_Post_Type["request"] : T extends "/event/claim" - ? Req_Post_Type["claim"] - : unknown; + ? Req_Post_Type["eventClaim"] + : T extends `/reviews/${string}/claims` + ? Req_Post_Type["reviewClaim"] + : unknown; type GetQueryType = T extends "/event" ? Req_Query_Type["행사목록"] diff --git a/app/_components/modal/ReportModal.tsx b/app/_components/modal/ReportModal.tsx index a2a647e1..22694512 100644 --- a/app/_components/modal/ReportModal.tsx +++ b/app/_components/modal/ReportModal.tsx @@ -6,7 +6,12 @@ import { getSession } from "@/store/session/cookies"; import { ModalBaseType } from "@/types/index"; import TextModal from "./TextModal"; -const ReportModal = ({ closeModal }: ModalBaseType) => { +interface Props extends ModalBaseType { + type: "event" | "review"; + reviewId?: string; +} + +const ReportModal = ({ closeModal, type, reviewId }: Props) => { const session = getSession(); const { eventId } = useParams(); const eventIdStr: string = Array.isArray(eventId) ? eventId[0] : eventId; @@ -19,7 +24,13 @@ const ReportModal = ({ closeModal }: ModalBaseType) => { return; } try { - const res = await instance.post("/event/claim", { eventId: eventIdStr, userId: session.user.userId, description: form.description }); + let res; + + if (type === "event") { + res = await instance.post("/event/claim", { eventId: eventIdStr, userId: session.user.userId, description: form.description }); + } else if (type === "review") { + res = await instance.post(`/reviews/${reviewId}/claims`, { userId: session.user.userId, description: form.description }); + } if (res.error) { throw new Error(res.error); diff --git a/app/_hooks/useInfScroll.ts b/app/_hooks/useInfScroll.ts deleted file mode 100644 index 9d5f1cc2..00000000 --- a/app/_hooks/useInfScroll.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { useEffect, useMemo, useRef, useState } from "react"; - -const useInfScroll = () => { - // 보여지고 있는지를 나타내는 state - const [isVisible, setIsVisible] = useState(false); - const infRef = useRef(null); - - // new IntersectionObserver()로 생성한 인스턴스가 observer - useEffect(() => { - const observer = new IntersectionObserver((entries) => { - // entries는 인스턴스의 배열 - // 얼마만큼의 비율을 가졌을 때 실행시킬지 - // 관찰 대상을 지정하고, 관찰될 때 어떤 작동을 할지 - const entry = entries[0]; - // isIntersecting은 교차 되고 있는지를 알려주는 boolean 값 - setIsVisible(entry.isIntersecting); - }); - - if (infRef.current) { - // 관찰할 대상 등록 - observer.observe(infRef.current); - } - return () => { - observer.disconnect(); - }; - }, [isVisible, infRef.current]); - - return { - isVisible, - setIsVisible, - infRef, - }; -}; - -export default useInfScroll; diff --git a/app/_types/postBodyType.ts b/app/_types/postBodyType.ts index 819e29a1..48d01f26 100644 --- a/app/_types/postBodyType.ts +++ b/app/_types/postBodyType.ts @@ -109,12 +109,17 @@ type Req_Post_Request = { name: string; }; -type Req_Post_Claim = { +type Req_Post_Event_Claim = { eventId: string; userId: string; description: string; }; +type Req_Post_Review_Claim = { + userId: string; + description: string; +}; + export type Req_Post_Type = { event: Req_Post_Event; eventLike: Req_Post_Event_Like; @@ -132,5 +137,6 @@ export type Req_Post_Type = { edit: Req_Post_Edit_Application; approve: Req_Post_Approval; request: Req_Post_Request; - claim: Req_Post_Claim; + eventClaim: Req_Post_Event_Claim; + reviewClaim: Req_Post_Review_Claim; }; From 6f0f88054d0d6cb454542d1abe1d95e36411e1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EA=B1=B4=EC=9A=B0?= Date: Tue, 20 Feb 2024 15:42:56 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20fix:=20=EB=82=B4=20?= =?UTF-8?q?=ED=9B=84=EA=B8=B0=EC=9D=BC=20=EB=95=8C=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/(route)/event/[eventId]/_components/EventReview.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/(route)/event/[eventId]/_components/EventReview.tsx b/app/(route)/event/[eventId]/_components/EventReview.tsx index f18a47c9..fb21e95f 100644 --- a/app/(route)/event/[eventId]/_components/EventReview.tsx +++ b/app/(route)/event/[eventId]/_components/EventReview.tsx @@ -38,6 +38,8 @@ const EventReview = ({ data }: Props) => { likeMutation.mutate(); }; + const isMyReview = !!session && session?.user.userId === data?.user?.id; + const publicText = data.isPublic ? "공개" : "비공개"; const { modal, openModal, closeModal } = useModal(); return ( @@ -48,9 +50,7 @@ const EventReview = ({ data }: Props) => { 프로필 이미지
{data.user?.nickName}
- +
{isMyReview ? publicText : }
{data.isPublic && ( From 16c3d8ece52a2d698b84160b7810ed4016665657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EA=B1=B4=EC=9A=B0?= Date: Tue, 20 Feb 2024 15:48:22 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20fix:=20=EB=88=84?= =?UTF-8?q?=EB=9D=BD=EB=90=9C=20=ED=83=80=EC=9E=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/_components/header/MobileHeader.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/_components/header/MobileHeader.tsx b/app/_components/header/MobileHeader.tsx index 6b4af559..31b0f009 100644 --- a/app/_components/header/MobileHeader.tsx +++ b/app/_components/header/MobileHeader.tsx @@ -48,7 +48,7 @@ const MobileHeader = ({ handleClick }: Props) => { )} {bottomSheet === "event-kebab" && } - {modal === "report" && } + {modal === "report" && } ); };