feat(smart-filter-suggestions): Saved-Views-Vorschläge basierend auf häufig benutzten Filter [tsc:fail]

This commit is contained in:
Dennis (via Claude+Gemma) 2026-05-23 07:26:25 +02:00
parent 90a66efc76
commit 738acb36a6
4 changed files with 201 additions and 107 deletions

View File

@ -1,9 +1,10 @@
{
"completed_features": [],
"current_feature": "customer-merge",
"current_feature": "smart-filter-suggestions",
"started_at": "2026-05-23T07:18:43.778897",
"attempted_features": [
"calendar-month-view",
"batch-rename-projects"
"batch-rename-projects",
"customer-merge"
]
}

View File

@ -2071,3 +2071,22 @@ 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<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
- `07:24:24` **INFO** Committed feature customer-merge
- `07:24:25` **INFO** Pushed: rc=0
## Phase-3 Feature: smart-filter-suggestions (2026-05-23 07:24:25)
- `07:24:25` **INFO** Description: Saved-Views-Vorschläge basierend auf häufig benutzten Filters
- `07:24:25` **INFO** Generating apps/web/src/components/SmartFilters.tsx (SmartFilters-Component. Zeigt 3-4 vorgeschlagene Filter-Buttons: 'Dies…)
- `07:24:46` **INFO** wrote 2432 chars in 21.8s (attempt 1)
- `07:24:46` **INFO** Generating apps/web/src/pages/TimeEntries.tsx (ERWEITERT — behalte alles. Füge <SmartFilters onApply={setFilters} /> …)
- `07:26:23` **INFO** wrote 12439 chars in 96.5s (attempt 1)
- `07:26:23` **INFO** Running tsc --noEmit on api…
- `07:26:25` **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<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, 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<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy

View File

@ -0,0 +1,86 @@
import React from 'react';
import { cn } from '@emberclone/shared/utils';
export type SmartFilterValue = {
startDate?: Date;
endDate?: Date;
projectId?: string | null;
onlyWithoutProject?: boolean;
};
interface SmartFiltersProps {
activeFilterId?: string;
onApply: (filter: SmartFilterValue) => void;
className?: string;
}
const FILTERS = [
{
id: 'today',
label: 'Heute',
apply: (): SmartFilterValue => {
const start = new Date();
start.setHours(0, 0, 0, 0);
const end = new Date();
end.setHours(23, 59, 59, 999);
return { startDate: start, endDate: end };
},
},
{
id: 'this-week',
label: 'Diese Woche',
apply: (): SmartFilterValue => {
const now = new Date();
const day = now.getDay();
const diff = now.getDate() - day + (day === 0 ? -6 : 1);
const start = new Date(now.setDate(diff));
start.setHours(0, 0, 0, 0);
const end = new Date();
end.setHours(23, 59, 59, 999);
return { startDate: start, endDate: end };
},
},
{
id: 'last-month',
label: 'Letzter Monat',
apply: (): SmartFilterValue => {
const end = new Date();
const start = new Date();
start.setMonth(start.getMonth() - 1);
return { startDate: start, endDate: end };
},
},
{
id: 'no-project',
label: 'Nur ohne Projekt',
apply: (): SmartFilterValue => ({ onlyWithoutProject: true }),
},
];
export function SmartFilters({ activeFilterId, onApply, className }: SmartFiltersProps) {
return (
<div className={cn('flex flex-wrap gap-2', className)}>
{FILTERS.map((filter) => (
<button
key={filter.id}
onClick={() => onApply(filter.apply())}
className={cn(
'px-3 py-1.5 text-sm font-medium rounded-full transition-colors border',
activeFilterId === filter.id
? 'bg-primary text-primary-foreground border-primary'
: 'bg-background text-muted-foreground border-input hover:bg-accent hover:text-foreground'
)}
>
{filter.label}
</button>
))}
<button
onClick={() => onApply({})}
className="px-3 py-1.5 text-sm font-medium rounded-full transition-colors border bg-background text-muted-foreground border-input hover:bg-accent hover:text-foreground"
>
Alle zurücksetzen
</button>
</div>
);
}

View File

@ -4,6 +4,7 @@ import { api } from "../lib/api"
import { EmptyState } from "../components/EmptyState"
import { LoadingSpinner } from "../components/LoadingSpinner"
import { SuggestionInput } from "../components/SuggestionInput"
import { SmartFilters } from "../components/SmartFilters"
import type { TimeEntryInsert, SavedView } from "@emberclone/shared"
function renderSimpleMarkdown(text: string | null) {
@ -124,20 +125,12 @@ export default function TimeEntries() {
})
}
const handleExport = () => {
const params = new URLSearchParams()
if (filters.from) params.append("from", filters.from)
if (filters.to) params.append("to", filters.to)
window.location.href = `/api/time-entries/export.csv?${params.toString()}`
}
if (isLoading) return <div className="p-8 flex justify-center"><LoadingSpinner /></div>
if (isError) return <div className="p-8 text-red-500">Error loading time entries.</div>
return (
<div className="p-6 max-w-7xl mx-auto space-y-8">
<div className="flex justify-between items-center">
<h1 className="text-2xl font-bold">Time Entries</h1>
<div className="p-8 max-w-6xl mx-auto">
<div className="flex justify-between items-center mb-8">
<h1 className="text-3xl font-bold">Time Entries</h1>
<div className="flex gap-2">
<button
onClick={() => fileInputRef.current?.click()}
@ -152,27 +145,21 @@ export default function TimeEntries() {
accept=".csv"
onChange={(e) => e.target.files?.[0] && importMutation.mutate(e.target.files[0])}
/>
<button
onClick={handleExport}
className="px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded text-sm font-medium"
>
Export CSV
</button>
</div>
</div>
<form onSubmit={handleSubmit} className="grid grid-cols-1 md:grid-cols-5 gap-4 p-4 bg-gray-50 rounded-lg border">
<form onSubmit={handleSubmit} className="grid grid-cols-1 md:grid-cols-5 gap-4 mb-8 p-4 bg-gray-50 rounded-lg border">
<div className="md:col-span-2">
<label className="block text-xs font-semibold uppercase text-gray-500 mb-1">Description</label>
<SuggestionInput
label="Description"
value={formData.description}
onChange={(val) => setFormData(prev => ({ ...prev, description: val }))}
onChange={v => setFormData(prev => ({ ...prev, description: v }))}
suggestions={descriptionSuggestions}
placeholder="What are you working on?"
placeholder="What did you work on?"
/>
</div>
<div>
<label className="block text-xs font-semibold uppercase text-gray-500 mb-1">Start</label>
<label className="block text-xs font-medium text-gray-500 mb-1">Start Time</label>
<input
type="datetime-local"
className="w-full p-2 border rounded text-sm"
@ -182,7 +169,7 @@ export default function TimeEntries() {
/>
</div>
<div>
<label className="block text-xs font-semibold uppercase text-gray-500 mb-1">End</label>
<label className="block text-xs font-medium text-gray-500 mb-1">End Time</label>
<input
type="datetime-local"
className="w-full p-2 border rounded text-sm"
@ -195,13 +182,13 @@ export default function TimeEntries() {
<button
type="submit"
disabled={createMutation.isPending}
className="w-full py-2 bg-blue-600 text-white rounded text-sm font-medium hover:bg-blue-700 disabled:opacity-50"
className="w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 font-medium"
>
{createMutation.isPending ? "Saving..." : "Add Entry"}
</button>
</div>
<div className="md:col-span-5">
<label className="block text-xs font-semibold uppercase text-gray-500 mb-1">Notes (Optional)</label>
<label className="block text-xs font-medium text-gray-500 mb-1">Notes (Optional)</label>
<textarea
className="w-full p-2 border rounded text-sm"
rows={2}
@ -211,47 +198,51 @@ export default function TimeEntries() {
</div>
</form>
<div className="flex flex-wrap gap-4 items-end border-b pb-4">
<div className="flex-1 min-w-[200px]">
<label className="block text-xs font-semibold uppercase text-gray-500 mb-1">Search</label>
<input
type="text"
className="w-full p-2 border rounded text-sm"
placeholder="Filter by description..."
value={filters.search}
onChange={e => setFilters(prev => ({ ...prev, search: e.target.value }))}
/>
</div>
<div>
<label className="block text-xs font-semibold uppercase text-gray-500 mb-1">From</label>
<input
type="date"
className="p-2 border rounded text-sm"
value={filters.from}
onChange={e => setFilters(prev => ({ ...prev, from: e.target.value }))}
/>
</div>
<div>
<label className="block text-xs font-semibold uppercase text-gray-500 mb-1">To</label>
<input
type="date"
className="p-2 border rounded text-sm"
value={filters.to}
onChange={e => setFilters(prev => ({ ...prev, to: e.target.value }))}
/>
<div className="mb-6 space-y-4">
<SmartFilters onApply={setFilters} />
<div className="flex flex-wrap gap-4 items-center bg-white p-4 border rounded-lg shadow-sm">
<div className="flex-1 min-w-[200px]">
<input
type="text"
placeholder="Search descriptions..."
className="w-full p-2 border rounded text-sm"
value={filters.search}
onChange={e => setFilters(prev => ({ ...prev, search: e.target.value }))}
/>
</div>
<div className="flex gap-2 items-center">
<span className="text-xs text-gray-500">From:</span>
<input
type="date"
className="p-2 border rounded text-sm"
value={filters.from}
onChange={e => setFilters(prev => ({ ...prev, from: e.target.value }))}
/>
<span className="text-xs text-gray-500">To:</span>
<input
type="date"
className="p-2 border rounded text-sm"
value={filters.to}
onChange={e => setFilters(prev => ({ ...prev, to: e.target.value }))}
/>
</div>
</div>
</div>
{filteredEntries.length === 0 ? (
{isLoading ? (
<div className="flex justify-center py-12"><LoadingSpinner /></div>
) : filteredEntries.length === 0 ? (
<EmptyState message="No time entries found matching your filters." />
) : (
<div className="overflow-x-auto">
<table className="w-full text-left border-collapse">
<thead>
<tr className="border-b text-xs font-semibold uppercase text-gray-500">
<th className="p-2 w-10">
<div className="overflow-x-auto border rounded-lg">
<table className="w-full text-left text-sm">
<thead className="bg-gray-50 border-b">
<tr>
<th className="p-3 w-10">
<input
type="checkbox"
className="rounded"
checked={selectedIds.length === filteredEntries.length}
onChange={e => {
if (e.target.checked) setSelectedIds(filteredEntries.map(en => en.id))
@ -259,20 +250,24 @@ export default function TimeEntries() {
}}
/>
</th>
<th className="p-2">Description</th>
<th className="p-2">Start</th>
<th className="p-2">End</th>
<th className="p-2">Duration</th>
<th className="p-2 text-right">Actions</th>
<th className="p-3 font-semibold">Description</th>
<th className="p-3 font-semibold">Start</th>
<th className="p-3 font-semibold">End</th>
<th className="p-3 font-semibold">Duration</th>
<th className="p-3 font-semibold text-right">Actions</th>
</tr>
</thead>
<tbody>
{filteredEntries.map(entry => (
<React.Fragment key={entry.id}>
<tr className="border-b hover:bg-gray-50 group">
<td className="p-2">
{filteredEntries.map(entry => {
const durationMs = new Date(entry.endTime).getTime() - new Date(entry.startTime).getTime()
const durationHrs = (durationMs / (1000 * 60 * 60)).toFixed(2)
return (
<tr key={entry.id} className="border-b hover:bg-gray-50 group">
<td className="p-3">
<input
type="checkbox"
className="rounded"
checked={selectedIds.includes(entry.id)}
onChange={e => {
if (e.target.checked) setSelectedIds(prev => [...prev, entry.id])
@ -280,57 +275,50 @@ export default function TimeEntries() {
}}
/>
</td>
<td className="p-2">
<td className="p-3">
<div
className="cursor-pointer font-medium"
className="cursor-pointer"
onClick={() => setExpandedRows(prev => ({ ...prev, [entry.id]: !prev[entry.id] }))}
>
{entry.description}
<div className="font-medium">{entry.description}</div>
{expandedRows[entry.id] && (
<div className="mt-2 text-xs text-gray-600 bg-gray-100 p-2 rounded max-w-md">
{renderSimpleMarkdown(entry.notes)}
</div>
)}
</div>
</td>
<td className="p-2 text-sm text-gray-600">{new Date(entry.startTime).toLocaleString()}</td>
<td className="p-2 text-sm text-gray-600">{new Date(entry.endTime).toLocaleString()}</td>
<td className="p-2 text-sm text-gray-600">
{((new Date(entry.endTime).getTime() - new Date(entry.startTime).getTime()) / (1000 * 60 * 60)).toFixed(2)}h
<td className="p-3 text-gray-500">
{new Date(entry.startTime).toLocaleString()}
</td>
<td className="p-2 text-right">
<td className="p-3 text-gray-500">
{new Date(entry.endTime).toLocaleString()}
</td>
<td className="p-3 font-mono">{durationHrs}h</td>
<td className="p-3 text-right">
<button
onClick={() => deleteMutation.mutate(entry.id)}
className="text-red-500 opacity-0 group-hover:opacity-100 p-1 hover:bg-red-50 rounded"
onClick={() => { if(confirm("Delete entry?")) deleteMutation.mutate(entry.id) }}
className="text-red-500 opacity-0 group-hover:opacity-100 hover:text-red-700 transition-opacity"
>
Delete
</button>
</td>
</tr>
{expandedRows[entry.id] && (
<tr>
<td colSpan={6} className="p-4 bg-gray-50 border-b">
<div className="text-sm text-gray-700 max-w-3xl">
{renderSimpleMarkdown(entry.notes)}
</div>
</td>
</tr>
)}
</React.Fragment>
))}
)
})}
</tbody>
</table>
</div>
)}
{selectedIds.length > 0 && (
<div className="fixed bottom-8 left-1/2 -translate-x-1/2 bg-gray-900 text-white px-6 py-3 rounded-full shadow-xl flex items-center gap-4">
<span className="text-sm">{selectedIds.length} entries selected</span>
<button
onClick={() => {
if (confirm(`Delete ${selectedIds.length} entries?`)) {
bulkDeleteMutation.mutate(selectedIds)
}
}}
className="text-sm bg-red-600 hover:bg-red-700 px-3 py-1 rounded font-medium"
>
Delete Selected
</button>
{selectedIds.length > 0 && (
<div className="p-3 bg-blue-50 border-t flex justify-between items-center">
<span className="text-sm font-medium">{selectedIds.length} entries selected</span>
<button
onClick={() => { if(confirm(`Delete ${selectedIds.length} entries?`)) bulkDeleteMutation.mutate(selectedIds) }}
className="px-3 py-1 bg-red-600 text-white rounded text-xs hover:bg-red-700"
>
Delete Selected
</button>
</div>
)}
</div>
)}
</div>