From 908b98cedbc983707fd7823480cb6edad1c6650b Mon Sep 17 00:00:00 2001 From: Younes Date: Tue, 17 Oct 2023 18:30:23 +0100 Subject: [PATCH] fix home layout --- .../src/components/home/ProjectGrid.tsx | 48 ++++++++----------- apps/frontend/src/pages/home.tsx | 2 +- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/apps/frontend/src/components/home/ProjectGrid.tsx b/apps/frontend/src/components/home/ProjectGrid.tsx index 64bc5e52..3ebc8afe 100644 --- a/apps/frontend/src/components/home/ProjectGrid.tsx +++ b/apps/frontend/src/components/home/ProjectGrid.tsx @@ -12,14 +12,12 @@ import { Typography, } from "@mui/material"; import Grid from "@mui/material/Grid"; -import { useQueryClient } from "@tanstack/react-query"; import { debounce } from "lodash"; import * as R from "ramda"; import * as React from "react"; import { useMemo, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { TransitionGroup } from "react-transition-group"; -import { useDidUpdate } from "rooks"; import { StyledTitle } from "~components/typography"; import { trpc } from "~utils/trpc"; @@ -27,7 +25,6 @@ import { trpc } from "~utils/trpc"; import ProjectThumbnail from "./ProjectThumbnail"; export const ProjectGrid: React.FC = () => { - const queryClient = useQueryClient(); const searchInputRef = useRef(null); const [searchTerm, setSearchTerm] = useState(undefined); @@ -41,16 +38,12 @@ export const ProjectGrid: React.FC = () => { }, 1000); const { data: user } = trpc.user.me.useQuery(); - const [data] = trpc.project.list.useSuspenseQuery({ + const [data, mutation] = trpc.project.list.useSuspenseQuery({ term: searchTerm, }); const { t } = useTranslation(); - useDidUpdate(() => { - queryClient.invalidateQueries(["projects"]); - }, [user]); - const userProjects = useMemo( () => data.items.filter((project) => user && project.userId == user.id), [user, data] @@ -90,10 +83,13 @@ export const ProjectGrid: React.FC = () => { height: 50, }} > - - - - {/* */} + {mutation.isFetching ? ( + + ) : ( + + + + )} { - {[...userProjects, ...userProjects, ...userProjects].map( - (project) => ( - - - - ) - )} + {userProjects.map((project) => ( + + + + ))} @@ -150,11 +144,7 @@ export const ProjectGrid: React.FC = () => { - {[ - ...publicProjects, - ...publicProjects, - ...publicProjects, - ].map((project) => ( + {publicProjects.map((project) => ( { {noProjects && ( { >