From f66a7cf2a63c4b99b93937cd0907faa20bf93f64 Mon Sep 17 00:00:00 2001 From: Seung Min Lee <74231194+miloul@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:34:26 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[Fix=20=F0=9F=AA=9B]=20=ED=99=88,=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20=EB=B2=84=EA=B7=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/HomePage/HomePage.tsx | 3 +-- .../HomePage/components/Banner/Banner.tsx | 2 ++ .../ProjectListSection/ProjectListSection.tsx | 8 +++---- src/pages/ProjectListPage/ProjectListPage.tsx | 22 +++++++++++-------- .../SearchBarSection/SearchBarSection.tsx | 1 + 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/pages/HomePage/HomePage.tsx b/src/pages/HomePage/HomePage.tsx index 09d5e88b..c04a2947 100644 --- a/src/pages/HomePage/HomePage.tsx +++ b/src/pages/HomePage/HomePage.tsx @@ -1,4 +1,4 @@ -import { Box, Skeleton } from "@chakra-ui/react" +import { Skeleton } from "@chakra-ui/react" import Banner from "./components/Banner/Banner" import ProjectListSection from "./components/ProjectListSection/ProjectListSection" @@ -15,7 +15,6 @@ const HomePage = () => { )} - ) } diff --git a/src/pages/HomePage/components/Banner/Banner.tsx b/src/pages/HomePage/components/Banner/Banner.tsx index 31a612e4..867f8f96 100644 --- a/src/pages/HomePage/components/Banner/Banner.tsx +++ b/src/pages/HomePage/components/Banner/Banner.tsx @@ -19,6 +19,7 @@ import "swiper/css/pagination" import { Autoplay, Navigation, Pagination } from "swiper/modules" import { SwiperSlide } from "swiper/react" +import noImage from "@assets/images/noImage.jpg" import sidepeekBlue from "@assets/images/sidepeek_blue.png" import { CustomSwiper } from "./Banner.style" @@ -72,6 +73,7 @@ const Banner = ({ bannerList }: bannerListProps) => { projectImg { const { allProjectList, isAllProjectLoading, - refetchAllProject, fetchNextPage, hasNextPage, isFetchingNextPage, @@ -36,17 +35,16 @@ const ProjectListSection = () => { const value = e.target.value as SortSelectType if (value !== sortOption) { + setSortOption(value) queryClient.removeQueries({ queryKey: [QUERYKEY.ALL_PROJECTS] }) queryClient.refetchQueries({ queryKey: [QUERYKEY.ALL_PROJECTS] }) } - setSortOption(value) - - refetchAllProject() } const handleChange = () => { setIsReleased(!isReleased) - refetchAllProject() + queryClient.removeQueries({ queryKey: [QUERYKEY.ALL_PROJECTS] }) + queryClient.refetchQueries({ queryKey: [QUERYKEY.ALL_PROJECTS] }) } const loadMoreProjects = useCallback(() => { diff --git a/src/pages/ProjectListPage/ProjectListPage.tsx b/src/pages/ProjectListPage/ProjectListPage.tsx index 40713abf..8a8e0c9d 100644 --- a/src/pages/ProjectListPage/ProjectListPage.tsx +++ b/src/pages/ProjectListPage/ProjectListPage.tsx @@ -2,7 +2,6 @@ import { ChangeEvent, useEffect, useState } from "react" import { useInView } from "react-intersection-observer" import { useLocation, useNavigate, useSearchParams } from "react-router-dom" -import { Box } from "@chakra-ui/react" import { Container, Stack, useMediaQuery } from "@chakra-ui/react" import { useQueryClient } from "@tanstack/react-query" @@ -43,19 +42,23 @@ const ProjectListPage = () => { const isLoading = isAllProjectLoading || isRefetching + const projectCount = + allProjectList != undefined && allProjectList.pages[0].totalElements + const handleSelect = (e: ChangeEvent) => { const value = e.target.value as SortSelectType if (value !== sortOption) { + setSortOption(value) queryClient.removeQueries({ queryKey: [QUERYKEY.ALL_PROJECTS] }) queryClient.refetchQueries({ queryKey: [QUERYKEY.ALL_PROJECTS] }) } - setSortOption(value) } const handleChange = () => { setIsReleased(!isReleased) - refetchAllProject() + queryClient.removeQueries({ queryKey: [QUERYKEY.ALL_PROJECTS] }) + queryClient.refetchQueries({ queryKey: [QUERYKEY.ALL_PROJECTS] }) } useEffect(() => { @@ -89,11 +92,13 @@ const ProjectListPage = () => { /> - + {projectCount ? ( + + ) : null} { /> - ) } diff --git a/src/pages/ProjectListPage/components/SearchBarSection/SearchBarSection.tsx b/src/pages/ProjectListPage/components/SearchBarSection/SearchBarSection.tsx index 6c9cbaa9..9e493ead 100644 --- a/src/pages/ProjectListPage/components/SearchBarSection/SearchBarSection.tsx +++ b/src/pages/ProjectListPage/components/SearchBarSection/SearchBarSection.tsx @@ -62,6 +62,7 @@ const SearchBarSection = ({ search, onSubmit }: SearchBarSectionProps) => { onChange={handleChange} />