From f4e198cc01412503ef75074eb77e8b1a22cb5b84 Mon Sep 17 00:00:00 2001 From: Nastia Piven Date: Sun, 17 Nov 2024 20:09:06 +0100 Subject: [PATCH] feat: fix fetch entries --- client/src/components/layouts/Timeline.tsx | 19 ++++++++++++------- client/src/hooks/queries.ts | 3 +-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/client/src/components/layouts/Timeline.tsx b/client/src/components/layouts/Timeline.tsx index cc22dd3..6011063 100644 --- a/client/src/components/layouts/Timeline.tsx +++ b/client/src/components/layouts/Timeline.tsx @@ -6,15 +6,20 @@ import { useAppContext, useUserYear } from "~/hooks"; export function Timeline() { const { today } = useAppContext(); - const { data } = useUserYear(today.year); + const { data, isLoading } = useUserYear(today.year); return ( -
- + <> + {isLoading &&
Loading...
} + {!isLoading && data?.year && ( +
+ - {data?.months.map((month) => ( - - ))} -
+ {data?.months.map((month) => ( + + ))} +
+ )} + ); } diff --git a/client/src/hooks/queries.ts b/client/src/hooks/queries.ts index af4c2cd..07931ad 100644 --- a/client/src/hooks/queries.ts +++ b/client/src/hooks/queries.ts @@ -4,7 +4,6 @@ import { getEntries } from "~/api/entries"; import { getUserTasks } from "~/api/tasks"; import { getUserYear } from "~/api/users"; - // Year export function useUserYear(year: number) { const { data, isLoading, isError } = useQuery({ @@ -37,7 +36,7 @@ export function useEntries(props: UseEntriesProps) { const { taskId, year, month, day } = props; const { data, isLoading, isError } = useQuery({ - queryKey: ["entires"], + queryKey: ["entires", month, day, taskId], queryFn: () => getEntries({ taskId, year, month, day }), });