From 5a3619b2ed6fd96de2aeee4e96beb9366f52853e Mon Sep 17 00:00:00 2001 From: "Dennis (via Claude+Gemma)" Date: Sat, 23 May 2026 06:52:08 +0200 Subject: [PATCH] feat(time-spent-widget): Time-Spent-Summary-Widget (Today/Week/Month total) sidebar [tsc:fail] --- .phase14-state.json | 5 +- GENERATION_LOG.md | 17 +++++ apps/web/src/components/TimeSpentSummary.tsx | 70 ++++++++++++++++++++ 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 apps/web/src/components/TimeSpentSummary.tsx diff --git a/.phase14-state.json b/.phase14-state.json index 01feca0..cfd79b1 100644 --- a/.phase14-state.json +++ b/.phase14-state.json @@ -1,8 +1,9 @@ { "completed_features": [], - "current_feature": "quick-add-popover", + "current_feature": "time-spent-widget", "started_at": "2026-05-23T06:49:38.915806", "attempted_features": [ - "markdown-editor" + "markdown-editor", + "quick-add-popover" ] } \ No newline at end of file diff --git a/GENERATION_LOG.md b/GENERATION_LOG.md index 6d9a24d..80cdf4f 100644 --- a/GENERATION_LOG.md +++ b/GENERATION_LOG.md @@ -1695,3 +1695,20 @@ src/index.ts(27,25): error TS2769: No overload matches this call. Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error. Argument of type 'Promise' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'. Type 'Promise' provides no match for the signature '(instance: FastifyInstance, FastifyBaseLogger, FastifyTy +- `06:51:43` **INFO** Committed feature quick-add-popover +- `06:51:43` **INFO** Pushed: rc=0 + +## Phase-3 Feature: time-spent-widget (2026-05-23 06:51:43) + +- `06:51:43` **INFO** Description: Time-Spent-Summary-Widget (Today/Week/Month total) sidebar +- `06:51:43` **INFO** Generating apps/web/src/components/TimeSpentSummary.tsx (TimeSpentSummary-Widget. Fetch entries + summarize per period (heute/w…) +- `06:52:07` **INFO** wrote 2624 chars in 23.5s (attempt 1) +- `06:52:07` **INFO** Running tsc --noEmit on api… +- `06:52:08` **WARN** tsc errors: +src/index.ts(27,25): error TS2769: No overload matches this call. + Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error. + Argument of type 'Promise' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'. + Type 'Promise' provides no match for the signature '(instance: FastifyInstance, FastifyBaseLogger, FastifyTypeProvider>, opts: { ...; }, done: (err?: Error | undefined) => void): void'. + Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error. + Argument of type 'Promise' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'. + Type 'Promise' provides no match for the signature '(instance: FastifyInstance, FastifyBaseLogger, FastifyTy diff --git a/apps/web/src/components/TimeSpentSummary.tsx b/apps/web/src/components/TimeSpentSummary.tsx new file mode 100644 index 0000000..8301def --- /dev/null +++ b/apps/web/src/components/TimeSpentSummary.tsx @@ -0,0 +1,70 @@ +import React from 'react'; +import { useQuery } from '@tanstack/react-query'; +import { + type TimeEntry, + type TimeSpentSummary +} from '@emberclone/shared'; + +interface TimeSpentSummaryProps { + dailyTargetHours?: number; +} + +const TimeSpentSummary: React.FC = ({ dailyTargetHours = 8 }) => { + const { data, isLoading, error } = useQuery({ + queryKey: ['time-spent-summary'], + queryFn: async () => { + const res = await fetch('/api/time/summary'); + if (!res.ok) throw new Error('Failed to fetch summary'); + return res.json(); + }, + }); + + if (isLoading) return
Loading summary...
; + if (error) return
Error loading summary
; + + const periods = [ + { label: 'Today', value: data?.today || 0, key: 'today' }, + { label: 'This Week', value: data?.week || 0, key: 'week' }, + { label: 'This Month', value: data?.month || 0, key: 'month' }, + ]; + + const formatHours = (decimalHours: number) => { + const h = Math.floor(decimalHours); + const m = Math.round((decimalHours - h) * 60); + return `${h}h ${m}m`; + }; + + return ( +
+

Time Spent

+
+ {periods.map((period) => { + // For "Today", we compare against dailyTarget. For others, we just show the value. + const isToday = period.key === 'today'; + const percentage = isToday + ? Math.min((period.value / dailyTargetHours) * 100, 100) + : 0; + + return ( +
+
+ {period.label} + {formatHours(period.value)} +
+ {isToday && ( +
+
+
+ )} +
+ ); + })} +
+
+ ); +}; + +export default TimeSpentSummary; \ No newline at end of file