Skip to content

Commit

Permalink
feat: fix fetch entries
Browse files Browse the repository at this point in the history
  • Loading branch information
HereEast committed Nov 17, 2024
1 parent 6933b89 commit f4e198c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
19 changes: 12 additions & 7 deletions client/src/components/layouts/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="flex flex-col items-center gap-6">
<Rating />
<>
{isLoading && <div>Loading...</div>}
{!isLoading && data?.year && (
<div className="flex flex-col items-center gap-6">
<Rating />

{data?.months.map((month) => (
<MonthCard key={month.month} year={data.year} monthData={month} />
))}
</div>
{data?.months.map((month) => (
<MonthCard key={month.month} year={data.year} monthData={month} />
))}
</div>
)}
</>
);
}
3 changes: 1 addition & 2 deletions client/src/hooks/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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 }),
});

Expand Down

0 comments on commit f4e198c

Please sign in to comment.