From 1b09e8f825097ee3019e2bb377ad60c83259a0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=EC=A7=80?= <103625348+eunji-0623@users.noreply.github.com> Date: Wed, 31 Jul 2024 23:05:59 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"Revert=20"Feat:=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=20=ED=8C=9D=EC=97=85=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ActivityDetails/ActivityDetails.tsx | 8 +- components/Chat/SendChat.tsx | 37 +++++---- components/Chat/SendChat.types.ts | 2 + components/MyActivity/Card/Card.tsx | 12 ++- components/Popup/ChatPopup.tsx | 83 +++++++++++++++---- components/Popup/ChatPopup.types.tsx | 6 ++ public/icon/chat_close.svg | 1 + public/icon/prev_arrow.svg | 1 + server/server.js | 1 + 9 files changed, 115 insertions(+), 36 deletions(-) create mode 100644 public/icon/chat_close.svg create mode 100644 public/icon/prev_arrow.svg diff --git a/components/ActivityDetails/ActivityDetails.tsx b/components/ActivityDetails/ActivityDetails.tsx index 29e75ef..dcbef29 100644 --- a/components/ActivityDetails/ActivityDetails.tsx +++ b/components/ActivityDetails/ActivityDetails.tsx @@ -28,6 +28,7 @@ import { usePopup } from '@/hooks/usePopup'; import { darkModeState } from '@/states/themeState'; import SendChat from '../Chat/SendChat'; import { ShareButton } from '../ShareButton/ShareButton'; +import { loginState } from '@/states/loginState'; import { ViewedActivitiesState } from '@/states/ViewedState'; import { ViewedActivityProps } from '../ViewedActivities/ViewedActivities.type'; @@ -35,6 +36,7 @@ export default function ActivityDetails({ id }: ActivityDetailsProps) { const router = useRouter(); const [isOpen, setIsOpen] = useState(false); const isDarkMode = useRecoilValue(darkModeState); + const isLogined = useRecoilValue(loginState); const [currentPage, setCurrentPage] = useState( router.query.page ? parseInt(router.query.page as string, 10) : 1 ); @@ -203,12 +205,14 @@ export default function ActivityDetails({ id }: ActivityDetailsProps) { -
+
- {!isAuthor && ( + {isLogined && !isAuthor && ( )} - {isPopupOpen && ( - + )} ); diff --git a/components/Chat/SendChat.types.ts b/components/Chat/SendChat.types.ts index e67e308..9db2d2a 100644 --- a/components/Chat/SendChat.types.ts +++ b/components/Chat/SendChat.types.ts @@ -1,4 +1,6 @@ export interface SendChatProps { receiver: number; activityId: number; + activityTitle: string; + activityImage: string; } diff --git a/components/MyActivity/Card/Card.tsx b/components/MyActivity/Card/Card.tsx index 1f2af02..3cdabef 100644 --- a/components/MyActivity/Card/Card.tsx +++ b/components/MyActivity/Card/Card.tsx @@ -12,6 +12,8 @@ import Link from 'next/link'; import ChatPopup from '@/components/Popup/ChatPopup'; import { useUserData } from '@/hooks/useUserData'; import socket from '@/server/server'; +import { useRecoilValue } from 'recoil'; +import { darkModeState } from '@/states/themeState'; function PopoverButton({ children, onClick }: PopoverButtonProps) { return ( @@ -69,7 +71,7 @@ function Card({ }: CardProps) { const [isPopoverOpen, setIsPopoverOpen] = useState(false); const [isPopupOpen, setIsPopupOpen] = useState(false); - const { userData } = useUserData(); + const isDarkMode = useRecoilValue(darkModeState); const handleClickMeatball = () => { setIsPopoverOpen(!isPopoverOpen); @@ -132,7 +134,11 @@ function Card({
+ )} +
@@ -60,6 +106,10 @@ function ChatPopup({ activityId={activityId} handleSenderId={setSenderId} handleSendEnable={setIsSendEnabled} + isEnter={isEnter} + handleIsEnter={setIsEnter} + handleNickName={setNickName} + handleProfile={setProfile} /> ) : ( @@ -91,18 +141,23 @@ function ShowChatRoomList({ activityId, handleSenderId, handleSendEnable, + isEnter, + handleIsEnter, + handleNickName, + handleProfile, }: ChatRoomPopupProps) { const [rooms, setRooms] = useState([]); - const [isEnter, setIsEnter] = useState(false); const { userData } = useUserData(); - const handleClickRoom = (userId: number) => { + const handleClickRoom = (userId: number, index: number) => { socket.emit('inquiryAdmin', userData.id, activityId, userId, (res: any) => { console.log('inquiryAdmin res', res); }); - setIsEnter(true); + handleIsEnter(true); handleSenderId(userId); handleSendEnable(true); + handleNickName(rooms[index].user.name); + handleProfile(rooms[index].user.profile); }; useEffect(() => { @@ -129,8 +184,8 @@ function ShowChatRoomList({