diff --git a/apps/timo-web/app/[locale]/(main)/(with-time-sidebar)/home/_hooks/use-home-todos-by-date.ts b/apps/timo-web/app/[locale]/(main)/(with-time-sidebar)/home/_hooks/use-home-todos-by-date.ts index 7d2c5ad8..17a56c56 100644 --- a/apps/timo-web/app/[locale]/(main)/(with-time-sidebar)/home/_hooks/use-home-todos-by-date.ts +++ b/apps/timo-web/app/[locale]/(main)/(with-time-sidebar)/home/_hooks/use-home-todos-by-date.ts @@ -49,6 +49,7 @@ export const useHomeTodosByDate = ( const { mutate: stopTimer } = useStopTimer(); const { invalidateHomeView, + invalidateStatistics, invalidateTimerState, invalidateTimeBoxes, invalidateFocusTodo, @@ -120,6 +121,7 @@ export const useHomeTodosByDate = ( invalidateHomeAndFocus(); invalidateTimeBoxes(); invalidateTodoDetail(dateKey, todoId); + invalidateStatistics(); }, onError: () => { setTodosByDate((prev) => ({ ...prev, [dateKey]: previous })); @@ -148,6 +150,7 @@ export const useHomeTodosByDate = ( onSuccess: () => { invalidateHomeAndFocus(); invalidateTodoDetail(dateKey, todoId); + invalidateStatistics(); }, }, ); @@ -216,6 +219,7 @@ export const useHomeTodosByDate = ( invalidateHomeAndFocus(); invalidateTimeBoxes(); invalidateTodoDetail(dateKey, todoId); + invalidateStatistics(); }, onError: () => { setTodosByDate((prev) => ({ ...prev, [dateKey]: previous })); diff --git a/apps/timo-web/app/[locale]/(main)/statistics/_components/StatisticsCalendar.tsx b/apps/timo-web/app/[locale]/(main)/statistics/_components/StatisticsCalendar.tsx index 69d2756f..98b16dad 100644 --- a/apps/timo-web/app/[locale]/(main)/statistics/_components/StatisticsCalendar.tsx +++ b/apps/timo-web/app/[locale]/(main)/statistics/_components/StatisticsCalendar.tsx @@ -85,7 +85,7 @@ export const StatisticsCalendar = ({ return (
-
+

{formatStatisticsMonth(currentMonth, locale)} @@ -112,7 +112,7 @@ export const StatisticsCalendar = ({

-
+
{Array.from({ length: firstDayOffset }, (_, index) => (
))} diff --git a/apps/timo-web/app/[locale]/(main)/statistics/_components/StatisticsSidePanel.tsx b/apps/timo-web/app/[locale]/(main)/statistics/_components/StatisticsSidePanel.tsx index 4037f77d..35b72c2a 100644 --- a/apps/timo-web/app/[locale]/(main)/statistics/_components/StatisticsSidePanel.tsx +++ b/apps/timo-web/app/[locale]/(main)/statistics/_components/StatisticsSidePanel.tsx @@ -28,7 +28,7 @@ export type StatisticsSidePanelProps = | StatisticsDaySidePanelProps; const SIDE_PANEL_CLASS_NAME = - "border-timo-gray-500 bg-white h-full w-[304px] shrink-0 border-l text-timo-black"; + "border-timo-gray-500 bg-white h-full w-[304px] shrink-0 overflow-y-auto border-l text-timo-black"; const getDiffLabel = ( diffMinutes: number, @@ -102,14 +102,18 @@ export const StatisticsSidePanel = (props: StatisticsSidePanelProps) => {
    - {detail.todos.map((todo) => { + {detail.todos.map((todo, index) => { const diffMinutes = todo.actualTimeMinutes - todo.estimatedTimeMinutes; + const isLastTodo = index === detail.todos.length - 1; return (
  • @@ -128,7 +132,9 @@ export const StatisticsSidePanel = (props: StatisticsSidePanelProps) => { {formatStatisticsClockText(todo.estimatedTimeMinutes)} - + {getDiffLabel(diffMinutes, t)}

    diff --git a/apps/timo-web/app/[locale]/(main)/statistics/_containers/StatisticsCalendarContainer.tsx b/apps/timo-web/app/[locale]/(main)/statistics/_containers/StatisticsCalendarContainer.tsx index 2472c9a5..10dfd4b9 100644 --- a/apps/timo-web/app/[locale]/(main)/statistics/_containers/StatisticsCalendarContainer.tsx +++ b/apps/timo-web/app/[locale]/(main)/statistics/_containers/StatisticsCalendarContainer.tsx @@ -1,10 +1,7 @@ "use client"; -import { useTranslations } from "next-intl"; - import { StatisticsCalendar } from "@/app/[locale]/(main)/statistics/_components/StatisticsCalendar"; import { useStatisticsCalendarQuery } from "@/app/[locale]/(main)/statistics/_queries/use-statistics-query"; -import { LottiePlayer } from "@/components/lottie/LottiePlayer"; import { formatDateKey } from "@/utils/date/date"; interface StatisticsCalendarContainerProps { @@ -14,56 +11,18 @@ interface StatisticsCalendarContainerProps { onSelectDate: (date: Date) => void; } -interface StatisticsCalendarStatusProps { - lottieSrc: string; - message: string; - role?: "status" | "alert"; -} - -const StatisticsCalendarStatus = ({ - lottieSrc, - message, - role = "status", -}: StatisticsCalendarStatusProps) => { - return ( -
    - -

    {message}

    -
    - ); -}; - export const StatisticsCalendarContainer = ({ currentMonth, displayDate, selectedDate, onSelectDate, }: StatisticsCalendarContainerProps) => { - const t = useTranslations("Statistics.calendar"); const yearMonth = formatDateKey(currentMonth).slice(0, 7); const calendarQuery = useStatisticsCalendarQuery(yearMonth); const calendarData = calendarQuery.data?.data; - if (calendarQuery.isPending) { - return ( - - ); - } - - if (calendarQuery.isError || !calendarData) { - return ( - - ); + if (calendarQuery.isPending || calendarQuery.isError || !calendarData) { + return null; } return ( diff --git a/apps/timo-web/app/[locale]/(main)/statistics/_containers/StatisticsContainer.tsx b/apps/timo-web/app/[locale]/(main)/statistics/_containers/StatisticsContainer.tsx index 73dd709f..361ba886 100644 --- a/apps/timo-web/app/[locale]/(main)/statistics/_containers/StatisticsContainer.tsx +++ b/apps/timo-web/app/[locale]/(main)/statistics/_containers/StatisticsContainer.tsx @@ -69,13 +69,13 @@ export const StatisticsContainer = () => { }; return ( -
    -
    +
    +
    -
    +
    +
    {animationData && ( { + const queryClient = useQueryClient(); + + const invalidateStatistics = () => { + queryClient.invalidateQueries({ queryKey: getGetSummaryQueryKey() }); + queryClient.invalidateQueries({ queryKey: getGetDailyQueryKey() }); + queryClient.invalidateQueries({ queryKey: getGetCalendarQueryKey() }); + }; + + return { + invalidateStatistics, + }; +}; diff --git a/apps/timo-web/hooks/timer/use-timer-query-invalidation.ts b/apps/timo-web/hooks/timer/use-timer-query-invalidation.ts index 38b3662a..500c6cc3 100644 --- a/apps/timo-web/hooks/timer/use-timer-query-invalidation.ts +++ b/apps/timo-web/hooks/timer/use-timer-query-invalidation.ts @@ -9,9 +9,11 @@ import { } from "@/api/generated/endpoints/home/home"; import { getGetTimeBoxesQueryKey } from "@/api/generated/endpoints/time-box/time-box"; import { getGetActiveTimerQueryKey } from "@/api/generated/endpoints/timer/timer"; +import { useStatisticsQueryInvalidation } from "@/hooks/statistics/use-statistics-query-invalidation"; export const useTimerQueryInvalidation = () => { const queryClient = useQueryClient(); + const { invalidateStatistics } = useStatisticsQueryInvalidation(); const invalidateActiveTimer = () => queryClient.invalidateQueries({ queryKey: getGetActiveTimerQueryKey() }); @@ -27,11 +29,13 @@ export const useTimerQueryInvalidation = () => { invalidateActiveTimer(); invalidateHomeView(); invalidateTimeBoxes(); + invalidateStatistics(); }; return { invalidateActiveTimer, invalidateHomeView, + invalidateStatistics, invalidateTimeBoxes, invalidateTodayView, invalidateFocusTodo, diff --git a/apps/timo-web/hooks/todo-modal/create/use-create-todo-submit.ts b/apps/timo-web/hooks/todo-modal/create/use-create-todo-submit.ts index d7074344..2db717c6 100644 --- a/apps/timo-web/hooks/todo-modal/create/use-create-todo-submit.ts +++ b/apps/timo-web/hooks/todo-modal/create/use-create-todo-submit.ts @@ -8,6 +8,7 @@ import type { CreateTodoRequest } from "@/schemas/todo/todo-schema"; import { getGetHomeQueryKey } from "@/api/generated/endpoints/home/home"; import { useCreateTodo } from "@/api/generated/endpoints/todo/todo"; +import { useStatisticsQueryInvalidation } from "@/hooks/statistics/use-statistics-query-invalidation"; import { todoCreateResponseSchema } from "@/schemas/todo/todo-schema"; const buildCreateTodoRequestBody = ( @@ -30,6 +31,7 @@ export const useCreateTodoSubmit = () => { const [isErrorToastOpen, setIsErrorToastOpen] = useState(false); const { mutate: createTodo } = useCreateTodo(); const queryClient = useQueryClient(); + const { invalidateStatistics } = useStatisticsQueryInvalidation(); const handleSubmit = (data: CreateTodoRequest) => { createTodo( @@ -44,6 +46,7 @@ export const useCreateTodoSubmit = () => { } queryClient.invalidateQueries({ queryKey: getGetHomeQueryKey() }); + invalidateStatistics(); }, onError: () => { setIsErrorToastOpen(true); diff --git a/apps/timo-web/hooks/todo-modal/detail/use-delete-todo-submit.ts b/apps/timo-web/hooks/todo-modal/detail/use-delete-todo-submit.ts index 74fffc5b..2d6de50b 100644 --- a/apps/timo-web/hooks/todo-modal/detail/use-delete-todo-submit.ts +++ b/apps/timo-web/hooks/todo-modal/detail/use-delete-todo-submit.ts @@ -11,6 +11,7 @@ import { getGetTodayQueryKey, } from "@/api/generated/endpoints/home/home"; import { useDeleteTodo } from "@/api/generated/endpoints/todo/todo"; +import { useStatisticsQueryInvalidation } from "@/hooks/statistics/use-statistics-query-invalidation"; export interface DeleteTodoSubmitHandlers { onSuccess: () => void; @@ -20,6 +21,7 @@ export interface DeleteTodoSubmitHandlers { export const useDeleteTodoSubmit = () => { const { mutate: deleteTodo } = useDeleteTodo(); const queryClient = useQueryClient(); + const { invalidateStatistics } = useStatisticsQueryInvalidation(); const handleDelete = ( todoId: number, @@ -31,6 +33,7 @@ export const useDeleteTodoSubmit = () => { onSuccess: () => { queryClient.invalidateQueries({ queryKey: getGetHomeQueryKey() }); queryClient.invalidateQueries({ queryKey: getGetTodayQueryKey() }); + invalidateStatistics(); queryClient.invalidateQueries({ queryKey: getGetFocusTodoQueryKey(), }); diff --git a/apps/timo-web/hooks/todo-modal/detail/use-update-todo-submit.ts b/apps/timo-web/hooks/todo-modal/detail/use-update-todo-submit.ts index 6a9379f5..9e1d2140 100644 --- a/apps/timo-web/hooks/todo-modal/detail/use-update-todo-submit.ts +++ b/apps/timo-web/hooks/todo-modal/detail/use-update-todo-submit.ts @@ -14,6 +14,7 @@ import { getGetTodoDetailQueryKey, useUpdateTodo, } from "@/api/generated/endpoints/todo/todo"; +import { useStatisticsQueryInvalidation } from "@/hooks/statistics/use-statistics-query-invalidation"; export interface UpdateTodoSubmitParams { todoId: number; @@ -29,6 +30,7 @@ export interface UpdateTodoSubmitHandlers { export const useUpdateTodoSubmit = () => { const { mutate: updateTodo } = useUpdateTodo(); const queryClient = useQueryClient(); + const { invalidateStatistics } = useStatisticsQueryInvalidation(); const handleUpdate = ( { todoId, date, data }: UpdateTodoSubmitParams, @@ -43,6 +45,7 @@ export const useUpdateTodoSubmit = () => { queryClient.invalidateQueries({ queryKey: getGetTodoDetailQueryKey(todoId, { date }), }); + invalidateStatistics(); queryClient.invalidateQueries({ queryKey: getGetFocusTodoQueryKey(), });