From bcc960ae947fe810bc0cd1b629e86b6577933207 Mon Sep 17 00:00:00 2001 From: inyoung Date: Thu, 18 Apr 2024 19:10:26 +0900 Subject: [PATCH 01/35] =?UTF-8?q?Hotfix:=20=EB=A7=88=EC=9D=B8=EB=8D=94=20?= =?UTF-8?q?=EB=8B=B5=EC=9E=A5=EC=8D=BB=EB=8A=94=EC=A7=80=20=EC=97=AC?= =?UTF-8?q?=EB=B6=80=EC=97=90=20=EB=94=B0=EB=9D=BC=20=EB=8B=B5=EC=9E=A5?= =?UTF-8?q?=EC=93=B0=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20=ED=99=9C=EC=84=B1,?= =?UTF-8?q?=20=EB=B9=84=ED=99=9C=EC=84=B1=ED=99=94=20#211?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/get.ts | 3 +++ .../SellerOpenConsult/BottomSection.tsx | 21 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/api/get.ts b/src/api/get.ts index a6fd9cbf..c8fb34ee 100644 --- a/src/api/get.ts +++ b/src/api/get.ts @@ -149,6 +149,9 @@ export const getCounselorsComments = async (postId: any) => export const getCustomersComments = async (postId: any) => await getInstance(`/comments/customers/${postId}`); +export const getCounselorsIsWriteComments = async (postId: any) => + await getInstance(`/comments/counselors/authentication/${postId}`); + // Post Controller export const getOneOpenConsult = async (id: string | undefined) => await getInstance(`/posts/${id}`); diff --git a/src/components/Seller/SellerOpenConsult/BottomSection.tsx b/src/components/Seller/SellerOpenConsult/BottomSection.tsx index a7482684..53d64bce 100644 --- a/src/components/Seller/SellerOpenConsult/BottomSection.tsx +++ b/src/components/Seller/SellerOpenConsult/BottomSection.tsx @@ -1,5 +1,5 @@ import { Button } from 'components/Common/Button'; -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import reactTextareaAutosize from 'react-textarea-autosize'; import styled from 'styled-components'; import { ReactComponent as SendIcon } from 'assets/icons/icon-send.svg'; @@ -7,6 +7,7 @@ import { Green, Grey3, Grey6, LightGreen, White } from 'styles/color'; import { useRecoilValue, useSetRecoilState } from 'recoil'; import { isSendPopupOpenState } from 'utils/atom'; import { useNavigate, useParams } from 'react-router-dom'; +import { getCounselorsIsWriteComments } from 'api/get'; interface BottomSectionProps { isReplying: boolean; setIsReplying: React.Dispatch>; @@ -22,6 +23,7 @@ function BottomSection({ const navigate = useNavigate(); const setIsSendPopupOpen = useSetRecoilState(isSendPopupOpenState); const { consultid } = useParams(); + const [isAlreadyWrite, setIsAlreadyWrite] = useState(false); const handleNavigateRandomConsult = () => { if (localStorage.getItem('randomConsult')) { const randomNumList = JSON.parse(localStorage.getItem('randomConsult')); @@ -34,6 +36,18 @@ function BottomSection({ } // 그냥 open-consult id쳐서 들어왔을 경우 추후 예외처리.. }; + useEffect(() => { + const fetchIsAlreadyWrite = async () => { + const res: any = await getCounselorsIsWriteComments(consultid); + if (res.status === 200) { + setIsAlreadyWrite(res.data); + } else if (res.response.status === 404) { + alert('존재하지 않는 상담입니다.'); + navigate('/minder/consult?type=open-consult'); + } + }; + fetchIsAlreadyWrite(); + }); return ( {isReplying ? ( @@ -70,10 +84,13 @@ function BottomSection({