From 51c17289f4560d49c81767b2bfd51df89570f660 Mon Sep 17 00:00:00 2001 From: na-reum Date: Sun, 10 Dec 2023 02:33:36 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=A2=8B=EC=95=84=EC=9A=94=20=ED=95=A9?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index.tsx | 61 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index 7e1ecc89..e4642202 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,5 +1,6 @@ import { ampli } from '@/ampli'; -import { useInfinitePosts } from '@api/post/hooks'; +import { useInfinitePosts, useMutationUpdateLike } from '@api/post/hooks'; +import LikeButton from '@components/button/LikeButton'; import FeedItem from '@components/page/meetingDetail/Feed/FeedItem'; import MeetingInfo from '@components/page/meetingDetail/Feed/FeedItem/MeetingInfo'; import MobileFeedListSkeleton from '@components/page/meetingDetail/Feed/Skeleton/MobileFeedListSkeleton'; @@ -12,10 +13,12 @@ import { useDisplay } from '@hooks/useDisplay'; import { useIntersectionObserver } from '@hooks/useIntersectionObserver'; import type { NextPage } from 'next'; import Link from 'next/link'; +import { useRouter } from 'next/router'; import { styled } from 'stitches.config'; const Home: NextPage = () => { const { isTablet } = useDisplay(); + const router = useRouter(); const { data: postsData, fetchNextPage, hasNextPage, isFetchingNextPage } = useInfinitePosts(TAKE_COUNT); @@ -25,25 +28,43 @@ const Home: NextPage = () => { } }; const { setTarget } = useIntersectionObserver({ onIntersect }); - const renderedPosts = postsData?.pages.map(post => ( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - - - - } - /> - - - )); + + const { mutate: mutateLikeInAllPost } = useMutationUpdateLike(TAKE_COUNT); + + const handleClickLike = + (postId: number) => (mutateCb: (postId: number) => void) => (e: React.MouseEvent) => { + e.preventDefault(); + ampli.clickFeedlistLike({ location: router.pathname }); + mutateCb(postId); + }; + + const renderedPosts = postsData?.pages.map(post => { + if (!post) return; + return ( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + + + + } + HeaderSection={ + + } + /> + + + ); + }); return ( <>