Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix πŸͺ›] ν™ˆ, 검색 버그 #151

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/pages/HomePage/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -15,7 +15,6 @@ const HomePage = () => {
<Banner bannerList={bannerProjectList} />
)}
<ProjectListSection />
<Box height="15rem" />
</>
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/HomePage/components/Banner/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -72,6 +73,7 @@ const Banner = ({ bannerList }: bannerListProps) => {
<HStack height="90%">
<Image
src={project.thumbnailUrl}
fallbackSrc={noImage}
alt="projectImg"
height={isLargerThan768 ? "90%" : "50%"}
marginTop="4rem"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const ProjectListSection = () => {
const {
allProjectList,
isAllProjectLoading,
refetchAllProject,
fetchNextPage,
hasNextPage,
isFetchingNextPage,
Expand All @@ -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(() => {
Expand Down
1 change: 1 addition & 0 deletions src/pages/ProfilePage/components/Projects/ProjectsGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const ProjectsGrid = ({ userId, type }: ProjectsGridProps) => {
}: ProjectProperties) => (
<GridItem key={id}>
<ProjectCard
url={`/project/${id}`}
imgUrl={thumbnailUrl}
viewCount={viewCount}
heartCount={likeCount}
Expand Down
22 changes: 13 additions & 9 deletions src/pages/ProjectListPage/ProjectListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -43,19 +42,23 @@ const ProjectListPage = () => {

const isLoading = isAllProjectLoading || isRefetching

const projectCount =
allProjectList != undefined && allProjectList.pages[0].totalElements

const handleSelect = (e: ChangeEvent<HTMLSelectElement>) => {
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(() => {
Expand Down Expand Up @@ -89,11 +92,13 @@ const ProjectListPage = () => {
/>
<Container maxW={isLargerThan1200 ? "80%" : "95%"}>
<Stack marginTop="15rem">
<ProjectFilter
sortOption={sortOption}
handleChange={handleChange}
handleSelect={handleSelect}
/>
{projectCount ? (
<ProjectFilter
sortOption={sortOption}
handleChange={handleChange}
handleSelect={handleSelect}
/>
) : null}
<ProjectList
projects={allProjectList}
isLoading={isLoading}
Expand All @@ -102,7 +107,6 @@ const ProjectListPage = () => {
/>
</Stack>
</Container>
<Box height="15rem" />
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const SearchBarSection = ({ search, onSubmit }: SearchBarSectionProps) => {
onChange={handleChange}
/>
<Button
type="submit"
position="absolute"
top="2.3rem"
right="1rem"
Expand Down
Loading