From 1a9f51c44a6760661810dc230736d5cb7a9f882d Mon Sep 17 00:00:00 2001 From: cjeongmin Date: Wed, 15 May 2024 02:01:09 +0900 Subject: [PATCH] feat: Change pointer appearance when hover, redirect profile page when user profile image clicked. (#75) --- src/app/pages/shared-post-page.tsx | 32 ++++++++++++++++++------ src/components/shared-posts/PostCard.tsx | 25 +++++++++++++++--- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/app/pages/shared-post-page.tsx b/src/app/pages/shared-post-page.tsx index 15eff7f737..fb47d65486 100644 --- a/src/app/pages/shared-post-page.tsx +++ b/src/app/pages/shared-post-page.tsx @@ -449,14 +449,6 @@ export function SharedPostPage({ const { mutate: deleteSharedPost } = useDeleteSharedPost(); - const [selected, setSelected] = useState< - | { - memberId: string; - profileImage: string; - } - | undefined - >(undefined); - const { isLoading: isSharedPostLoading, data: sharedPost } = useSharedPost({ postId, enabled: type === 'hasRoom' && auth?.accessToken != null, @@ -468,6 +460,21 @@ export function SharedPostPage({ enabled: type === 'dormitory' && auth?.accessToken != null, }); + const [selected, setSelected] = useState< + | { + memberId: string; + profileImage: string; + } + | undefined + >( + sharedPost != null + ? { + memberId: sharedPost.data.publisherAccount.memberId, + profileImage: sharedPost.data.publisherAccount.profileImageFileName, + } + : undefined, + ); + const { data: userData } = useUserData(auth?.accessToken != null); const [userId, setUserId] = useState(''); @@ -493,6 +500,15 @@ export function SharedPostPage({ sharedPost?.data.publisherAccount.memberId ?? '', ); + useEffect(() => { + if (selected != null || sharedPost == null) return; + + setSelected({ + memberId: sharedPost.data.publisherAccount.memberId, + profileImage: sharedPost.data.publisherAccount.profileImageFileName, + }); + }, [selected, sharedPost]); + useEffect(() => { if (sharedPost?.data.address.roadAddress != null) { fromAddrToCoord({ query: sharedPost?.data.address.roadAddress }).then( diff --git a/src/components/shared-posts/PostCard.tsx b/src/components/shared-posts/PostCard.tsx index 7cd8022cd5..be8c02eeb9 100644 --- a/src/components/shared-posts/PostCard.tsx +++ b/src/components/shared-posts/PostCard.tsx @@ -1,5 +1,6 @@ 'use client'; +import { useRouter } from 'next/navigation'; import styled from 'styled-components'; import { HorizontalDivider } from '@/components'; @@ -24,6 +25,8 @@ const styles = { border-radius: 16px; object-fit: cover; + + cursor: pointer; `, content: styled.div` flex-grow: 1; @@ -44,6 +47,8 @@ const styles = { font-style: normal; font-weight: 700; line-height: normal; + + cursor: pointer; } h2 { @@ -68,6 +73,8 @@ const styles = { writer: styled.div` position: relative; + cursor: pointer; + display: flex; flex-shrink: 0; flex-direction: column; @@ -129,6 +136,8 @@ export function PostCard({ post: SharedPostListItem | DormitorySharedPostListItem; onClick: () => void; }) { + const router = useRouter(); + const recruitmentCapacity = 'roomInfo' in post ? post.roomInfo.recruitmentCapacity @@ -136,9 +145,13 @@ export function PostCard({ return (
- - - + + +

{post.title}

{post.address.roadAddress}

@@ -156,7 +169,11 @@ export function PostCard({ )}
- + { + router.push(`/profile/${post.publisherAccount.memberId}`); + }} + >

50%