feat(breadcrumbs-everywhere): Breadcrumb auf allen List-Pages [tsc:fail]

This commit is contained in:
Dennis (via Claude+Gemma) 2026-05-23 09:15:44 +02:00
parent 43861d5ff9
commit 2fe907da4e
5 changed files with 495 additions and 466 deletions

View File

@ -1,9 +1,10 @@
{ {
"completed_features": [], "completed_features": [],
"current_feature": "time-entry-clone", "current_feature": "breadcrumbs-everywhere",
"started_at": "2026-05-23T09:03:38.637785", "started_at": "2026-05-23T09:03:38.637785",
"attempted_features": [ "attempted_features": [
"customer-contact-info", "customer-contact-info",
"project-billing-rate" "project-billing-rate",
"time-entry-clone"
] ]
} }

View File

@ -3253,3 +3253,25 @@ 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. 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>'. 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>, Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>,
- `09:10:31` **INFO** Committed feature time-entry-clone
- `09:10:31` **INFO** Pushed: rc=0
## Phase-3 Feature: breadcrumbs-everywhere (2026-05-23 09:10:31)
- `09:10:31` **INFO** Description: Breadcrumb auf allen List-Pages
- `09:10:31` **INFO** Generating apps/web/src/pages/Customers.tsx (ERWEITERT — füge <Breadcrumb items={[{label:'Dashboard',to:'/'},{label…)
- `09:12:17` **INFO** wrote 12585 chars in 105.9s (attempt 1)
- `09:12:17` **INFO** Generating apps/web/src/pages/Projects.tsx (ERWEITERT — füge <Breadcrumb items={[{label:'Dashboard',to:'/'},{label…)
- `09:13:51` **INFO** wrote 11188 chars in 93.7s (attempt 1)
- `09:13:51` **INFO** Generating apps/web/src/pages/TimeEntries.tsx (ERWEITERT — füge <Breadcrumb items={[{label:'Dashboard',to:'/'},{label…)
- `09:15:43` **INFO** wrote 15310 chars in 112.1s (attempt 1)
- `09:15:43` **INFO** Running tsc --noEmit on api…
- `09:15:44` **WARN** tsc errors:
src/db/schema.ts(37,14): error TS7022: 'customers' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
src/db/schema.ts(45,59): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
src/db/schema.ts(49,14): error TS7022: 'projects' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
src/db/schema.ts(53,56): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
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>,

View File

@ -4,6 +4,7 @@ import { Star, Merge, X, Upload, Plus, Archive, Trash2, Tag as TagIcon, Mail, Ph
import { api } from "../lib/api" import { api } from "../lib/api"
import { memo } from "react" import { memo } from "react"
import type { Customer } from "@emberclone/shared" import type { Customer } from "@emberclone/shared"
import Breadcrumb from "../components/Breadcrumb"
const COLOR_PALETTE = [ const COLOR_PALETTE = [
'border-l-4 border-rose-300', 'border-l-4 border-rose-300',
@ -115,195 +116,204 @@ export default function Customers() {
const [showArchived, setShowArchived] = useState(false) const [showArchived, setShowArchived] = useState(false)
const [selectedIds, setSelectedIds] = useState<string[]>([]) const [selectedIds, setSelectedIds] = useState<string[]>([])
const [bulkTag, setBulkTag] = useState("") const [bulkTag, setBulkTag] = useState("")
const [mergeTarget, setMergeTarget] = useState<{ sourceId: string; targetId: string | "" } | null>(null)
const { data: customers, isLoading, isError } = useQuery({ const { data: customers = [] } = useQuery({
queryKey: ["customers"], queryKey: ['customers'],
queryFn: () => api.listCustomers() queryFn: async () => {
const res = await api.get('/customers')
return res.data as Customer[]
}
}) })
const createMutation = useMutation({ const createMutation = useMutation({
mutationFn: (payload: { name: string; email?: string; phone?: string; tags: string[] }) => api.createCustomer(payload), mutationFn: async (newCustomer: Partial<Customer>) => {
onSuccess: () => { const res = await api.post('/customers', newCustomer)
queryClient.invalidateQueries({ queryKey: ["customers"] }) return res.data
setName("") },
setEmail("") onSuccess: () => queryClient.invalidateQueries({ queryKey: ['customers'] })
setPhone("")
setTags("")
}
}) })
const archiveMutation = useMutation({ const updateMutation = useMutation({
mutationFn: (id: string) => api.archiveCustomer(id), mutationFn: async ({ id, data }: { id: string, data: Partial<Customer> }) => {
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["customers"] }) const res = await api.patch(`/customers/${id}`, data)
}) return res.data
},
const pinMutation = useMutation({ onSuccess: () => queryClient.invalidateQueries({ queryKey: ['customers'] })
mutationFn: ({ id, pinned }: { id: string; pinned: boolean }) => api.pinCustomer(id, pinned),
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["customers"] })
}) })
const deleteMutation = useMutation({ const deleteMutation = useMutation({
mutationFn: (id: string) => api.deleteCustomer(id), mutationFn: async (id: string) => {
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["customers"] }) await api.delete(`/customers/${id}`)
}) },
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['customers'] })
const tagMutation = useMutation({
mutationFn: ({ ids, tag }: { ids: string[]; tag: string }) => api.addTagsToCustomers(ids, [tag]),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["customers"] })
setBulkTag("")
setSelectedIds([])
}
}) })
const filteredCustomers = useMemo(() => { const filteredCustomers = useMemo(() => {
if (!customers) return [] return customers
return customers.filter(c => { .filter(c => (showArchived ? true : !c.archivedAt))
const matchesArchived = showArchived ? c.archivedAt : !c.archivedAt .filter(c => c.name.toLowerCase().includes(name.toLowerCase()))
const matchesTag = filterTag ? c.tags?.some(t => t.toLowerCase().includes(filterTag.toLowerCase())) : true .filter(c => c.email?.toLowerCase().includes(email.toLowerCase()))
return matchesArchived && matchesTag .filter(c => c.phone?.toLowerCase().includes(phone.toLowerCase()))
}) .filter(c => !filterTag || c.tags?.includes(filterTag))
}, [customers, showArchived, filterTag]) .sort((a, b) => (b.pinnedAt ? 1 : 0) - (a.pinnedAt ? 1 : 0))
}, [customers, name, email, phone, filterTag, showArchived])
if (isLoading) return <div className="p-8 text-center text-gray-500">Loading customers...</div> const handleCreate = (e: React.FormEvent) => {
if (isError) return <div className="p-8 text-center text-red-500">Error loading customers.</div> e.preventDefault()
createMutation.mutate({
name,
email,
phone,
tags: tags ? tags.split(',').map(t => t.trim()) : []
})
setName(""); setEmail(""); setPhone(""); setTags("");
}
const handleToggleSelect = (id: string) => {
setSelectedIds(prev => prev.includes(id) ? prev.filter(i => i !== id) : [...prev, id])
}
const handleBulkTag = () => {
selectedIds.forEach(id => {
updateMutation.mutate({
id,
data: { tags: [...(customers.find(c => c.id === id)?.tags || []), bulkTag] }
})
})
setBulkTag("")
setSelectedIds([])
}
return ( return (
<div className="max-w-4xl mx-auto p-6"> <div className="p-6 max-w-6xl mx-auto">
<div className="flex items-center justify-between mb-8"> <Breadcrumb items={[{ label: 'Dashboard', to: '/' }, { label: 'Customers' }]} />
<h1 className="text-2xl font-bold text-gray-800">Customers</h1>
<div className="flex items-center gap-2">
<button
onClick={() => setShowArchived(!showArchived)}
className={`px-3 py-1 text-sm rounded-full transition-colors ${showArchived ? 'bg-orange-100 text-orange-600' : 'bg-gray-100 text-gray-600 hover:bg-gray-200'}`}
>
{showArchived ? "Show Active" : "Show Archived"}
</button>
</div>
</div>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8"> <div className="mt-6 grid grid-cols-1 lg:grid-cols-3 gap-8">
<div className="md:col-span-2 bg-white p-4 rounded-lg shadow-sm border border-gray-100"> <div className="lg:col-span-1 space-y-6">
<div className="grid grid-cols-2 gap-3 mb-3"> <div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
<h2 className="text-lg font-semibold mb-4 flex items-center gap-2">
<Plus size={20} className="text-blue-500" /> Add Customer
</h2>
<form onSubmit={handleCreate} className="space-y-4">
<div>
<label className="block text-xs font-medium text-gray-500 mb-1">Name *</label>
<input <input
placeholder="Name *" value={name} onChange={e => setName(e.target.value)} required
value={name} className="w-full p-2 border rounded text-sm focus:ring-2 focus:ring-blue-500 outline-none"
onChange={e => setName(e.target.value)} placeholder="John Doe"
className="p-2 text-sm border rounded focus:ring-2 focus:ring-blue-500 outline-none"
/> />
</div>
<div>
<label className="block text-xs font-medium text-gray-500 mb-1">Email</label>
<input <input
placeholder="Email" value={email} onChange={e => setEmail(e.target.value)}
value={email} className="w-full p-2 border rounded text-sm focus:ring-2 focus:ring-blue-500 outline-none"
onChange={e => setEmail(e.target.value)} placeholder="john@example.com"
className="p-2 text-sm border rounded focus:ring-2 focus:ring-blue-500 outline-none"
/> />
</div>
<div>
<label className="block text-xs font-medium text-gray-500 mb-1">Phone</label>
<input <input
placeholder="Phone" value={phone} onChange={e => setPhone(e.target.value)}
value={phone} className="w-full p-2 border rounded text-sm focus:ring-2 focus:ring-blue-500 outline-none"
onChange={e => setPhone(e.target.value)} placeholder="+49 123 456789"
className="p-2 text-sm border rounded focus:ring-2 focus:ring-blue-500 outline-none"
/> />
</div>
<div>
<label className="block text-xs font-medium text-gray-500 mb-1">Tags (comma separated)</label>
<input <input
placeholder="Tags (comma separated)" value={tags} onChange={e => setTags(e.target.value)}
value={tags} className="w-full p-2 border rounded text-sm focus:ring-2 focus:ring-blue-500 outline-none"
onChange={e => setTags(e.target.value)} placeholder="VIP, Lead, Tech"
className="p-2 text-sm border rounded focus:ring-2 focus:ring-blue-500 outline-none"
/> />
</div> </div>
<button <button
onClick={() => createMutation.mutate({ name, email, phone, tags: tags.split(',').map(t => t.trim()).filter(Boolean) })} type="submit"
disabled={!name || createMutation.isPending} disabled={createMutation.isPending}
className="w-full flex items-center justify-center gap-2 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 transition-colors" className="w-full py-2 bg-blue-600 text-white rounded text-sm font-medium hover:bg-blue-700 transition-colors disabled:opacity-50"
> >
<Plus size={16} /> {createMutation.isPending ? "Creating..." : "Add Customer"} {createMutation.isPending ? "Creating..." : "Create Customer"}
</button> </button>
</form>
</div> </div>
<div className="bg-white p-4 rounded-lg shadow-sm border border-gray-100"> <div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
<div className="flex items-center gap-2 mb-3"> <h2 className="text-lg font-semibold mb-4 flex items-center gap-2">
<TagIcon size={16} className="text-gray-400" /> <TagIcon size={20} className="text-purple-500" /> Bulk Actions
<input </h2>
placeholder="Filter by tag..." <div className="space-y-4">
value={filterTag}
onChange={e => setFilterTag(e.target.value)}
className="flex-1 p-2 text-sm border-none focus:ring-0 outline-none"
/>
</div>
{selectedIds.length > 0 && (
<div className="mt-4 pt-4 border-t">
<div className="text-xs font-medium text-gray-500 mb-2">{selectedIds.length} selected</div>
<div className="flex gap-2"> <div className="flex gap-2">
<input <input
placeholder="Add tag..." value={bulkTag} onChange={e => setBulkTag(e.target.value)}
value={bulkTag} className="flex-1 p-2 border rounded text-sm focus:ring-2 focus:ring-purple-500 outline-none"
onChange={e => setBulkTag(e.target.value)} placeholder="New tag..."
className="flex-1 p-2 text-sm border rounded outline-none"
/> />
<button <button
onClick={() => tagMutation.mutate({ ids: selectedIds, tag: bulkTag })} onClick={handleBulkTag}
disabled={!bulkTag} disabled={selectedIds.length === 0 || !bulkTag}
className="p-2 bg-gray-800 text-white rounded hover:bg-gray-900 disabled:opacity-50" className="px-3 py-2 bg-purple-600 text-white rounded text-sm font-medium hover:bg-purple-700 transition-colors disabled:opacity-50"
> >
<Plus size={16} /> Add
</button> </button>
</div> </div>
<div className="text-xs text-gray-400">
{selectedIds.length} customers selected
</div>
</div> </div>
)}
</div> </div>
</div> </div>
<div className="space-y-1"> <div className="lg:col-span-2 space-y-4">
<div className="flex flex-wrap gap-3 items-center justify-between bg-white p-4 rounded-xl shadow-sm border border-gray-100">
<div className="flex gap-2 flex-wrap">
<input
placeholder="Filter by name..."
value={name} onChange={e => setName(e.target.value)}
className="p-2 border rounded text-sm w-40 focus:ring-2 focus:ring-blue-500 outline-none"
/>
<input
placeholder="Filter by email..."
value={email} onChange={e => setEmail(e.target.value)}
className="p-2 border rounded text-sm w-40 focus:ring-2 focus:ring-blue-500 outline-none"
/>
<input
placeholder="Filter by tag..."
value={filterTag} onChange={e => setFilterTag(e.target.value)}
className="p-2 border rounded text-sm w-40 focus:ring-2 focus:ring-blue-500 outline-none"
/>
</div>
<label className="flex items-center gap-2 text-sm text-gray-600 cursor-pointer">
<input
type="checkbox" checked={showArchived}
onChange={e => setShowArchived(e.target.checked)}
className="rounded text-blue-600"
/>
Show Archived
</label>
</div>
<div className="space-y-2">
{filteredCustomers.length === 0 ? ( {filteredCustomers.length === 0 ? (
<div className="text-center py-12 text-gray-400">No customers found.</div> <div className="text-center py-12 text-gray-400 bg-white rounded-xl border border-dashed border-gray-300">
No customers found matching your filters.
</div>
) : ( ) : (
filteredCustomers.map(customer => ( filteredCustomers.map(customer => (
<CustomerRow <CustomerRow
key={customer.id} key={customer.id}
customer={customer} customer={customer}
isSelected={selectedIds.includes(customer.id)} isSelected={selectedIds.includes(customer.id)}
onSelect={(id) => setSelectedIds(prev => prev.includes(id) ? prev.filter(i => i !== id) : [...prev, id])} onSelect={handleToggleSelect}
onArchive={(id) => archiveMutation.mutate(id)} onPin={(id, pinned) => updateMutation.mutate({ id, data: { pinnedAt: pinned ? new Date().toISOString() : null } })}
onPin={(id, pinned) => pinMutation.mutate({ id, pinned })} onArchive={(id) => updateMutation.mutate({ id, data: { archivedAt: new Date().toISOString() } })}
onMerge={(id) => setMergeTarget({ sourceId: id, targetId: "" })}
onDelete={(id) => { if(confirm("Delete customer?")) deleteMutation.mutate(id) }} onDelete={(id) => { if(confirm("Delete customer?")) deleteMutation.mutate(id) }}
onMerge={(id) => alert(`Merge logic for ${id} not implemented`)}
/> />
)) ))
)} )}
</div> </div>
{mergeTarget && (
<div className="fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50">
<div className="bg-white p-6 rounded-lg shadow-xl max-w-md w-full">
<h3 className="text-lg font-bold mb-4">Merge Customer</h3>
<p className="text-sm text-gray-600 mb-4">Select the target customer to merge into.</p>
<div className="max-h-60 overflow-y-auto mb-4 space-y-2">
{customers?.filter(c => c.id !== mergeTarget.sourceId).map(c => (
<button
key={c.id}
onClick={() => setMergeTarget(prev => prev ? { ...prev, targetId: c.id } : null)}
className={`w-full text-left p-2 text-sm rounded border ${mergeTarget.targetId === c.id ? 'border-blue-500 bg-blue-50' : 'border-gray-200 hover:bg-gray-50'}`}
>
{c.name}
</button>
))}
</div>
<div className="flex justify-end gap-3">
<button onClick={() => setMergeTarget(null)} className="px-4 py-2 text-sm text-gray-600 hover:text-gray-800">Cancel</button>
<button
disabled={!mergeTarget.targetId}
onClick={() => {
// api.mergeCustomers(mergeTarget.sourceId, mergeTarget.targetId)
setMergeTarget(null)
}}
className="px-4 py-2 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50"
>
Confirm Merge
</button>
</div> </div>
</div> </div>
</div> </div>
)}
</div>
) )
} }

View File

@ -3,6 +3,7 @@ import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
import { Copy, Trash2, Edit3, X, Plus, Archive, ArchiveRestore, Euro } from "lucide-react" import { Copy, Trash2, Edit3, X, Plus, Archive, ArchiveRestore, Euro } from "lucide-react"
import { api } from "../lib/api" import { api } from "../lib/api"
import { useToast } from "../hooks/use-toast" import { useToast } from "../hooks/use-toast"
import { Breadcrumb } from "../components/ui/Breadcrumb"
export default function Projects() { export default function Projects() {
const queryClient = useQueryClient() const queryClient = useQueryClient()
@ -41,7 +42,7 @@ export default function Projects() {
} }
}) })
} }
}, [projects]) }, [projects, toast])
const createMutation = useMutation({ const createMutation = useMutation({
mutationFn: ({ name, customerId, icon, billingRate }: { name: string; customerId: string; icon: string; billingRate: number }) => mutationFn: ({ name, customerId, icon, billingRate }: { name: string; customerId: string; icon: string; billingRate: number }) =>
@ -118,34 +119,28 @@ export default function Projects() {
} }
const toggleSelect = (id: string) => { const toggleSelect = (id: string) => {
setSelectedIds(prev => setSelectedIds(prev => prev.includes(id) ? prev.filter(i => i !== id) : [...prev, id])
prev.includes(id) ? prev.filter(i => i !== id) : [...prev, id]
)
} }
const filteredProjects = projects?.filter((p: any) => if (projectsLoading || customersLoading) return <div className="p-6">Loading...</div>
showArchived ? true : p.active !== false
)
if (projectsLoading || customersLoading) return <div className="p-6 text-gray-500">Loading projects...</div>
if (projectsError) return <div className="p-6 text-red-500">Error loading projects.</div> if (projectsError) return <div className="p-6 text-red-500">Error loading projects.</div>
return ( return (
<div className="p-6 max-w-6xl mx-auto"> <div className="p-6 max-w-6xl mx-auto space-y-6">
<div className="flex justify-between items-center mb-6"> <Breadcrumb items={[{ label: 'Dashboard', to: '/' }, { label: 'Projects' }]} />
<div className="flex justify-between items-center">
<h1 className="text-2xl font-bold">Projects</h1> <h1 className="text-2xl font-bold">Projects</h1>
<div className="flex gap-2">
<button <button
onClick={() => setShowArchived(!showArchived)} onClick={() => setShowArchived(!showArchived)}
className={`px-3 py-1 text-sm rounded border ${showArchived ? 'bg-gray-200' : 'bg-white'}`} className="text-sm text-gray-500 hover:text-gray-700 flex items-center gap-2"
> >
{showArchived ? <ArchiveRestore className="inline w-4 h-4 mr-1" /> : <Archive className="inline w-4 h-4 mr-1" />} {showArchived ? <ArchiveRestore size={16} /> : <Archive size={16} />}
{showArchived ? "Show Active" : "Show Archived"} {showArchived ? "Show Active" : "Show Archived"}
</button> </button>
</div> </div>
</div>
<form onSubmit={handleSubmit} className="grid grid-cols-1 md:grid-cols-5 gap-3 mb-8 p-4 bg-gray-50 rounded-lg border"> <form onSubmit={handleSubmit} className="grid grid-cols-1 md:grid-cols-5 gap-4 bg-gray-50 p-4 rounded-lg border">
<input <input
placeholder="Project Name" placeholder="Project Name"
value={name} value={name}
@ -169,37 +164,39 @@ export default function Projects() {
className="p-2 border rounded" className="p-2 border rounded"
/> />
<div className="relative"> <div className="relative">
<Euro className="absolute left-2 top-2.5 w-4 h-4 text-gray-400" /> <Euro className="absolute left-2 top-2.5 text-gray-400" size={16} />
<input <input
type="number" type="number"
step="0.01" placeholder="Rate"
placeholder="Rate/h"
value={billingRate} value={billingRate}
onChange={e => setBillingRate(e.target.value)} onChange={e => setBillingRate(e.target.value)}
className="p-2 pl-7 border rounded w-full" className="p-2 pl-7 border rounded w-full"
/> />
</div> </div>
<button type="submit" className="bg-blue-600 text-white p-2 rounded flex items-center justify-center gap-2 hover:bg-blue-700"> <button type="submit" className="bg-blue-600 text-white p-2 rounded hover:bg-blue-700 flex items-center justify-center gap-2">
<Plus className="w-4 h-4" /> Create <Plus size={16} /> Create
</button> </button>
</form> </form>
{selectedIds.length > 0 && ( {selectedIds.length > 0 && (
<form onSubmit={handleBulkRename} className="flex gap-2 mb-4 p-2 bg-blue-50 border border-blue-200 rounded items-center"> <form onSubmit={handleBulkRename} className="flex gap-2 p-3 bg-blue-50 border border-blue-200 rounded-lg items-center">
<span className="text-sm text-blue-700 mr-2">{selectedIds.length} selected</span> <span className="text-sm font-medium text-blue-700">{selectedIds.length} selected:</span>
<input <input
placeholder="Prefix for bulk rename..." placeholder="Prefix for rename..."
value={bulkPrefix} value={bulkPrefix}
onChange={e => setBulkPrefix(e.target.value)} onChange={e => setBulkPrefix(e.target.value)}
className="p-1 text-sm border rounded" className="p-1 border rounded text-sm"
/> />
<button type="submit" className="text-sm bg-blue-600 text-white px-3 py-1 rounded">Rename</button> <button type="submit" className="text-sm bg-blue-600 text-white px-3 py-1 rounded hover:bg-blue-700">Rename</button>
<button <button
type="button" type="button"
onClick={() => bulkDeleteMutation.mutate(selectedIds)} onClick={() => bulkDeleteMutation.mutate(selectedIds)}
className="text-sm bg-red-600 text-white px-3 py-1 rounded" className="text-sm bg-red-600 text-white px-3 py-1 rounded hover:bg-red-700 flex items-center gap-1"
> >
Delete Selected <Trash2 size={14} /> Delete
</button>
<button type="button" onClick={() => setSelectedIds([])} className="p-1 text-gray-500 hover:text-gray-700">
<X size={16} />
</button> </button>
</form> </form>
)} )}
@ -209,7 +206,7 @@ export default function Projects() {
<thead> <thead>
<tr className="border-b text-gray-500 text-sm"> <tr className="border-b text-gray-500 text-sm">
<th className="p-2 w-10"> <th className="p-2 w-10">
<input type="checkbox" onChange={toggleSelectAll} checked={selectedIds.length === (filteredProjects?.length || 0)} /> <input type="checkbox" onChange={toggleSelectAll} checked={selectedIds.length === (projects?.length || 0)} />
</th> </th>
<th className="p-2">Project</th> <th className="p-2">Project</th>
<th className="p-2">Customer</th> <th className="p-2">Customer</th>
@ -218,27 +215,23 @@ export default function Projects() {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{filteredProjects?.map((p: any) => ( {projects?.filter((p: any) => p.archived === showArchived).map((project: any) => (
<tr key={p.id} className={`border-b hover:bg-gray-50 ${!p.active ? 'opacity-50 italic' : ''}`}> <tr key={project.id} className="border-b hover:bg-gray-50">
<td className="p-2"> <td className="p-2">
<input <input type="checkbox" checked={selectedIds.includes(project.id)} onChange={() => toggleSelect(project.id)} />
type="checkbox"
checked={selectedIds.includes(p.id)}
onChange={() => toggleSelect(p.id)}
/>
</td> </td>
<td className="p-2"> <td className="p-2">
<span className="mr-2">{p.icon}</span> <div className="flex items-center gap-2">
{p.name} <span>{project.icon}</span>
<span className="font-medium">{project.name}</span>
</div>
</td> </td>
<td className="p-2 text-gray-600">{p.customer?.name}</td> <td className="p-2 text-gray-600">{project.customer?.name}</td>
<td className="p-2 font-mono"> <td className="p-2 text-gray-600">{project.billingRate / 100}</td>
{p.billingRate ? `${(p.billingRate / 100).toFixed(2)}` : '-'} <td className="p-2 text-right space-x-2">
</td> <button onClick={() => cloneMutation.mutate(project.id)} className="p-1 text-gray-500 hover:text-blue-600" title="Clone"><Copy size={16} /></button>
<td className="p-2 text-right flex justify-end gap-2"> <button onClick={() => setEditingProject({ id: project.id, name: project.name, budget: project.budget || 0 })} className="p-1 text-gray-500 hover:text-green-600" title="Edit"><Edit3 size={16} /></button>
<button onClick={() => cloneMutation.mutate(p.id)} title="Clone" className="p-1 hover:text-blue-600"><Copy className="w-4 h-4" /></button> <button onClick={() => deleteMutation.mutate(project.id)} className="p-1 text-gray-500 hover:text-red-600" title="Delete"><Trash2 size={16} /></button>
<button onClick={() => setEditingProject({ id: p.id, name: p.name, budget: p.budget || 0 })} title="Edit" className="p-1 hover:text-blue-600"><Edit3 className="w-4 h-4" /></button>
<button onClick={() => deleteMutation.mutate(p.id)} title="Delete" className="p-1 hover:text-red-600"><Trash2 className="w-4 h-4" /></button>
</td> </td>
</tr> </tr>
))} ))}
@ -248,36 +241,36 @@ export default function Projects() {
{editingProject && ( {editingProject && (
<div className="fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50"> <div className="fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50">
<div className="bg-white p-6 rounded-lg max-w-md w-full relative"> <div className="bg-white p-6 rounded-lg max-w-md w-full space-y-4">
<button onClick={() => setEditingProject(null)} className="absolute top-4 right-4"><X className="w-5 h-5" /></button> <div className="flex justify-between items-center">
<h2 className="text-xl font-bold mb-4">Edit Project</h2> <h2 className="text-lg font-bold">Edit Project</h2>
<div className="space-y-4"> <button onClick={() => setEditingProject(null)}><X size={20} /></button>
<div> </div>
<label className="block text-sm mb-1">Name</label> <div className="space-y-2">
<label className="text-sm font-medium">Name</label>
<input <input
className="w-full p-2 border rounded"
value={editingProject.name} value={editingProject.name}
onChange={e => setEditingProject({...editingProject, name: e.target.value})} onChange={e => setEditingProject({...editingProject, name: e.target.value})}
className="w-full p-2 border rounded"
/> />
</div> </div>
<div> <div className="space-y-2">
<label className="block text-sm mb-1">Budget (Hours)</label> <label className="text-sm font-medium">Budget (Hours)</label>
<input <input
type="number" type="number"
className="w-full p-2 border rounded"
value={editingProject.budget} value={editingProject.budget}
onChange={e => setEditingProject({...editingProject, budget: parseFloat(e.target.value)})} onChange={e => setEditingProject({...editingProject, budget: parseFloat(e.target.value) || 0})}
className="w-full p-2 border rounded"
/> />
</div> </div>
<button <button
onClick={() => updateMutation.mutate({ id: editingProject.id, data: { name: editingProject.name, budget: editingProject.budget } })} onClick={() => updateMutation.mutate({ id: editingProject.id, data: { name: editingProject.name, budget: editingProject.budget } })}
className="w-full bg-blue-600 text-white p-2 rounded" className="w-full bg-blue-600 text-white p-2 rounded hover:bg-blue-700"
> >
Save Changes Save Changes
</button> </button>
</div> </div>
</div> </div>
</div>
)} )}
</div> </div>
) )

View File

@ -6,6 +6,7 @@ import { EmptyState } from "../components/EmptyState"
import { LoadingSpinner } from "../components/LoadingSpinner" import { LoadingSpinner } from "../components/LoadingSpinner"
import { SuggestionInput } from "../components/SuggestionInput" import { SuggestionInput } from "../components/SuggestionInput"
import { SmartFilters } from "../components/SmartFilters" import { SmartFilters } from "../components/SmartFilters"
import { Breadcrumb } from "../components/Breadcrumb"
import { useToast } from "../hooks/useToast" import { useToast } from "../hooks/useToast"
import type { TimeEntryInsert, SavedView, TimeEntry, TimeEntryTemplate } from "@emberclone/shared" import type { TimeEntryInsert, SavedView, TimeEntry, TimeEntryTemplate } from "@emberclone/shared"
@ -122,245 +123,247 @@ export default function TimeEntries() {
onSuccess: () => { onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["time-entries"] }) queryClient.invalidateQueries({ queryKey: ["time-entries"] })
setSelectedIds([]) setSelectedIds([])
toast.info("Entries deleted") toast.info("Selected entries deleted")
} }
}) })
const handleClone = async (entry: TimeEntry) => {
try {
await api.createTimeEntry({
description: entry.description,
projectId: entry.projectId,
startTime: new Date().toISOString(),
})
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
toast.success("Entry cloned with current time")
} catch (e) {
toast.error("Failed to clone entry")
}
}
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> if (isError) return <div className="p-8 text-red-500">Error loading time entries.</div>
const filteredEntries = useMemo(() => {
if (!entries) return []
return entries.filter(e =>
e.description?.toLowerCase().includes(filters.search.toLowerCase()) ||
e.projectId?.toLowerCase().includes(filters.search.toLowerCase())
)
}, [entries, filters.search])
return ( return (
<div className="p-6 max-w-6xl mx-auto space-y-6"> <div className="p-6 max-w-7xl mx-auto space-y-6">
<div className="flex justify-between items-center"> <Breadcrumb items={[{ label: 'Dashboard', to: '/' }, { label: 'Time Entries' }]} />
<h1 className="text-2xl font-bold">Time Entries</h1>
<div className="flex gap-2">
<SmartFilters
value={filters}
onChange={setFilters}
views={savedViews || []}
/>
</div>
</div>
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
<div className="lg:col-span-1 space-y-6">
<div className="bg-white p-6 rounded-xl border shadow-sm space-y-4"> <div className="bg-white p-6 rounded-xl border shadow-sm space-y-4">
<div className="grid grid-cols-1 md:grid-cols-3 gap-4"> <h2 className="text-lg font-semibold">New Entry</h2>
<SuggestionInput
label="Description"
value={formData.description}
onChange={(v) => setFormData(f => ({ ...f, description: v }))}
suggestions={descriptionSuggestions}
/>
<div className="flex flex-col gap-1">
<label className="text-xs font-medium text-gray-500">Project ID</label>
<input
className="border rounded px-3 py-2 text-sm"
value={formData.projectId}
onChange={(e) => setFormData(f => ({ ...f, projectId: e.target.value }))}
placeholder="Project ID..."
/>
</div>
<div className="flex gap-2">
<div className="flex flex-col gap-1 flex-1">
<label className="text-xs font-medium text-gray-500">Start</label>
<input
type="datetime-local"
className="border rounded px-3 py-2 text-sm"
value={formData.startTime}
onChange={(e) => setFormData(f => ({ ...f, startTime: e.target.value }))}
/>
</div>
<div className="flex flex-col gap-1 flex-1">
<label className="text-xs font-medium text-gray-500">End</label>
<input
type="datetime-local"
className="border rounded px-3 py-2 text-sm"
value={formData.endTime}
onChange={(e) => setFormData(f => ({ ...f, endTime: e.target.value }))}
/>
</div>
</div>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4"> <div className="space-y-3">
<div className="flex flex-col gap-1"> <div>
<label className="text-xs font-medium text-gray-500">Notes</label> <label className="text-xs font-medium text-gray-500 uppercase">Template</label>
<textarea <select
className="border rounded px-3 py-2 text-sm h-20" className="w-full p-2 border rounded-md text-sm"
value={formData.notes} onChange={(e) => handleTemplateChange(e.target.value)}
onChange={(e) => setFormData(f => ({ ...f, notes: e.target.value }))} value=""
/>
</div>
<div className="flex flex-col gap-1">
<label className="text-xs font-medium text-gray-500">External Link</label>
<input
className="border rounded px-3 py-2 text-sm"
value={formData.externalLink}
onChange={(e) => setFormData(f => ({ ...f, externalLink: e.target.value }))}
placeholder="https://..."
/>
</div>
</div>
<div className="flex justify-between items-center pt-2">
<div className="flex gap-2">
{templates?.map(t => (
<button
key={t.id}
onClick={() => handleTemplateChange(t.id)}
className="text-xs bg-gray-100 hover:bg-gray-200 px-2 py-1 rounded border"
> >
{t.name || 'Template'} <option value="">Select template...</option>
</button> {templates?.map(t => (
<option key={t.id} value={t.id}>{t.description}</option>
))} ))}
</select>
</div> </div>
<div>
<label className="text-xs font-medium text-gray-500 uppercase">Description</label>
<SuggestionInput
value={formData.description}
onChange={(val) => setFormData({ ...formData, description: val })}
suggestions={descriptionSuggestions}
placeholder="What did you work on?"
/>
</div>
<div className="grid grid-cols-2 gap-3">
<div>
<label className="text-xs font-medium text-gray-500 uppercase">Start</label>
<input
type="datetime-local"
className="w-full p-2 border rounded-md text-sm"
value={formData.startTime}
onChange={(e) => setFormData({ ...formData, startTime: e.target.value })}
/>
</div>
<div>
<label className="text-xs font-medium text-gray-500 uppercase">End</label>
<input
type="datetime-local"
className="w-full p-2 border rounded-md text-sm"
value={formData.endTime}
onChange={(e) => setFormData({ ...formData, endTime: e.target.value })}
/>
</div>
</div>
<div>
<label className="text-xs font-medium text-gray-500 uppercase">Project</label>
<input
className="w-full p-2 border rounded-md text-sm"
placeholder="Project ID"
value={formData.projectId}
onChange={(e) => setFormData({ ...formData, projectId: e.target.value })}
/>
</div>
<div>
<label className="text-xs font-medium text-gray-500 uppercase">Notes</label>
<textarea
className="w-full p-2 border rounded-md text-sm h-24"
placeholder="Additional details..."
value={formData.notes}
onChange={(e) => setFormData({ ...formData, notes: e.target.value })}
/>
</div>
<button <button
onClick={() => createMutation.mutate(formData)} onClick={() => createMutation.mutate(formData)}
disabled={createMutation.isPending} disabled={createMutation.isPending || !formData.description}
className="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700 disabled:opacity-50" className="w-full py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 disabled:opacity-50 transition-colors font-medium"
> >
{createMutation.isPending ? "Saving..." : "Save Entry"} {createMutation.isPending ? "Saving..." : "Save Entry"}
</button> </button>
</div> </div>
</div> </div>
</div>
<div className="bg-white rounded-xl border shadow-sm overflow-hidden"> <div className="lg:col-span-2 space-y-6">
<div className="bg-white p-6 rounded-xl border shadow-sm space-y-4">
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4">
<h2 className="text-lg font-semibold">Time Log</h2>
<SmartFilters
filters={filters}
setFilters={setFilters}
savedViews={savedViews}
/>
</div>
{isLoading ? (
<div className="flex justify-center py-12">
<LoadingSpinner />
</div>
) : entries && entries.length === 0 ? (
<EmptyState
title="No entries found"
description="Start tracking your time to see entries here."
/>
) : (
<div className="overflow-x-auto"> <div className="overflow-x-auto">
<table className="w-full text-left text-sm"> <table className="w-full text-left text-sm">
<thead className="bg-gray-50 border-b"> <thead>
<tr> <tr className="border-b text-gray-500 font-medium">
<th className="p-3 w-10"> <th className="p-2 w-10">
<input <input
type="checkbox" type="checkbox"
checked={selectedIds.length > 0 && selectedIds.length === filteredEntries.length} className="rounded"
checked={selectedIds.length > 0 && selectedIds.length === entries?.length}
onChange={(e) => { onChange={(e) => {
setSelectedIds(e.target.checked ? filteredEntries.map(en => en.id) : []) setSelectedIds(e.target.checked ? entries?.map(en => en.id) || [] : [])
}} }}
/> />
</th> </th>
<th className="p-3 font-medium text-gray-600">Description</th> <th className="p-2">Description</th>
<th className="p-3 font-medium text-gray-600">Project</th> <th className="p-2">Duration</th>
<th className="p-3 font-medium text-gray-600">Duration</th> <th className="p-2">Date</th>
<th className="p-3 font-medium text-gray-600 text-right">Actions</th> <th className="p-2 text-right">Actions</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{filteredEntries.length === 0 ? ( {entries?.map((entry) => (
<tr> <tr key={entry.id} className={`border-b hover:bg-gray-50 transition-colors ${expandedRows[entry.id] ? 'bg-gray-50' : ''}`}>
<td colSpan={5} className="p-8 text-center text-gray-500">No entries found.</td> <td className="p-2">
</tr>
) : (
filteredEntries.map(entry => (
<tr key={entry.id} className="border-b hover:bg-gray-50 group">
<td className="p-3">
<input <input
type="checkbox" type="checkbox"
className="rounded"
checked={selectedIds.includes(entry.id)} checked={selectedIds.includes(entry.id)}
onChange={(e) => { onChange={(e) => {
setSelectedIds(prev => e.target.checked ? [...prev, entry.id] : prev.filter(id => id !== entry.id)) setSelectedIds(prev =>
e.target.checked ? [...prev, entry.id] : prev.filter(id => id !== entry.id)
)
}} }}
/> />
</td> </td>
<td className="p-3"> <td className="p-2">
{editingId === entry.id ? ( <div className="font-medium">{entry.description}</div>
<div className="flex gap-2"> {expandedRows[entry.id] && (
<input <div className="mt-2 text-xs text-gray-500 space-y-1">
className="border rounded px-2 py-1 w-full" {entry.notes && <div className="flex items-start gap-1"><FileText size={12} className="mt-0.5" /> {entry.notes}</div>}
value={editValue} {entry.externalLink && <a href={entry.externalLink} target="_blank" className="text-indigo-600 hover:underline block truncate">{entry.externalLink}</a>}
onChange={(e) => setEditValue(e.target.value)}
autoFocus
/>
<button onClick={() => updateMutation.mutate({ id: entry.id, data: { description: editValue } })}><Check size={16} className="text-green-600" /></button>
<button onClick={() => setEditingId(null)}><X size={16} className="text-red-600" /></button>
</div>
) : (
<div className="flex items-center gap-2">
<span className="font-medium">{entry.description}</span>
<button
onClick={() => { setEditingId(entry.id); setEditValue(entry.description || ""); }}
className="opacity-0 group-hover:opacity-100 p-1 hover:bg-gray-200 rounded"
>
<Edit2 size={14} />
</button>
</div> </div>
)} )}
</td> </td>
<td className="p-3 text-gray-500">{entry.projectId}</td> <td className="p-2 text-gray-600">
<td className="p-3 text-gray-500"> {entry.durationHours?.toFixed(2)}h
{entry.startTime && entry.endTime ?
`${Math.round((new Date(entry.endTime).getTime() - new Date(entry.startTime).getTime()) / 60000)}m` :
'-'}
</td> </td>
<td className="p-3 text-right"> <td className="p-2 text-gray-600">
<div className="flex justify-end gap-1"> {new Date(entry.startTime).toLocaleDateString()}
</td>
<td className="p-2 text-right space-x-1">
<button <button
onClick={() => handleClone(entry)} onClick={() => setExpandedRows(prev => ({ ...prev, [entry.id]: !prev[entry.id] }))}
title="Clone entry with current time" className="p-1.5 text-gray-400 hover:text-indigo-600 rounded-md hover:bg-indigo-50"
className="p-1.5 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded" title="Details"
>
<Copy size={16} />
</button>
<button
onClick={() => {
setExpandedRows(prev => ({ ...prev, [entry.id]: !prev[entry.id] }))
}}
className="p-1.5 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded"
> >
<FileText size={16} /> <FileText size={16} />
</button> </button>
<button
onClick={() => {
setEditingId(entry.id);
setEditValue(entry.description);
}}
className="p-1.5 text-gray-400 hover:text-indigo-600 rounded-md hover:bg-indigo-50"
title="Edit"
>
<Edit2 size={16} />
</button>
<button <button
onClick={() => deleteMutation.mutate(entry.id)} onClick={() => deleteMutation.mutate(entry.id)}
className="p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded" className="p-1.5 text-gray-400 hover:text-red-600 rounded-md hover:bg-red-50"
title="Delete"
> >
<Trash2 size={16} /> <Trash2 size={16} />
</button> </button>
</div>
</td> </td>
</tr> </tr>
)) ))}
)}
</tbody> </tbody>
</table> </table>
</div> </div>
</div> )}
{selectedIds.length > 0 && ( {selectedIds.length > 0 && (
<div className="fixed bottom-6 left-1/2 -translate-x-1/2 bg-gray-900 text-white px-4 py-3 rounded-full shadow-xl flex items-center gap-4"> <div className="flex items-center justify-between p-3 bg-indigo-50 rounded-lg border border-indigo-100">
<span className="text-sm">{selectedIds.length} entries selected</span> <span className="text-sm text-indigo-700 font-medium">{selectedIds.length} entries selected</span>
<button <button
onClick={() => bulkDeleteMutation.mutate(selectedIds)} onClick={() => bulkDeleteMutation.mutate(selectedIds)}
className="bg-red-500 hover:bg-red-600 px-3 py-1 rounded-full text-xs font-medium transition-colors" className="flex items-center gap-2 px-3 py-1.5 bg-red-600 text-white text-xs font-medium rounded-md hover:bg-red-700 transition-colors"
> >
Delete Selected <Trash2 size={14} /> Delete Selected
</button>
</div>
)}
</div>
</div>
</div>
{editingId && (
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
<div className="bg-white p-6 rounded-xl shadow-xl max-w-md w-full space-y-4">
<h3 className="text-lg font-semibold">Edit Description</h3>
<div className="flex gap-2">
<input
autoFocus
className="flex-1 p-2 border rounded-md text-sm"
value={editValue}
onChange={(e) => setEditValue(e.target.value)}
onKeyDown={(e) => e.key === 'Enter' && updateMutation.mutate({ id: editingId, data: { description: editValue } })}
/>
<button
onClick={() => {
updateMutation.mutate({ id: editingId, data: { description: editValue } });
setEditingId(null);
}}
className="p-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700"
>
<Check size={18} />
</button> </button>
<button <button
onClick={() => setSelectedIds([])} onClick={() => setEditingId(null)}
className="text-xs text-gray-400 hover:text-white" className="p-2 bg-gray-100 text-gray-600 rounded-md hover:bg-gray-200"
> >
Cancel <X size={18} />
</button> </button>
</div> </div>
</div>
</div>
)} )}
</div> </div>
) )