feat(screen-recording-attach-stub): 'Screen-Recording aufnehmen' Stub-Button (kein echtes record [tsc:fail]
This commit is contained in:
parent
bfae276a1e
commit
7651e9777b
@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"completed_features": [],
|
"completed_features": [],
|
||||||
"current_feature": "ui-polish",
|
"current_feature": "screen-recording-attach-stub",
|
||||||
"started_at": "2026-05-23T08:17:40.778724",
|
"started_at": "2026-05-23T08:17:40.778724",
|
||||||
"attempted_features": [
|
"attempted_features": [
|
||||||
"voice-input-stub",
|
"voice-input-stub",
|
||||||
"popout-tracker",
|
"popout-tracker",
|
||||||
"project-favicons"
|
"project-favicons",
|
||||||
|
"ui-polish"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -2663,3 +2663,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.
|
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>'.
|
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
|
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
|
||||||
|
- `08:21:45` **INFO** Committed feature ui-polish
|
||||||
|
- `08:21:46` **INFO** Pushed: rc=0
|
||||||
|
|
||||||
|
## Phase-3 Feature: screen-recording-attach-stub (2026-05-23 08:21:46)
|
||||||
|
|
||||||
|
- `08:21:46` **INFO** Description: 'Screen-Recording aufnehmen' Stub-Button (kein echtes recording)
|
||||||
|
- `08:21:46` **INFO** Generating apps/web/src/pages/TimeEntries.tsx (ERWEITERT — füge im Create-Form 'Screen-Recording'-Button (Camera-Icon…)
|
||||||
|
- `08:23:45` **INFO** wrote 16225 chars in 119.2s (attempt 1)
|
||||||
|
- `08:23:45` **INFO** Running tsc --noEmit on api…
|
||||||
|
- `08:23:47` **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
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import { useState, useMemo, useRef } from "react"
|
import { useState, useMemo, useRef } from "react"
|
||||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
|
||||||
|
import { Camera, Trash2, Edit2, Check, X, Upload, FileText, Search, Filter } from "lucide-react"
|
||||||
import { api } from "../lib/api"
|
import { api } from "../lib/api"
|
||||||
import { EmptyState } from "../components/EmptyState"
|
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 { useToast } from "../hooks/useToast"
|
||||||
import type { TimeEntryInsert, SavedView, TimeEntry, TimeEntryTemplate } from "@emberclone/shared"
|
import type { TimeEntryInsert, SavedView, TimeEntry, TimeEntryTemplate } from "@emberclone/shared"
|
||||||
|
|
||||||
function renderSimpleMarkdown(text: string | null) {
|
function renderSimpleMarkdown(text: string | null) {
|
||||||
@ -22,6 +24,7 @@ function renderSimpleMarkdown(text: string | null) {
|
|||||||
|
|
||||||
export default function TimeEntries() {
|
export default function TimeEntries() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const toast = useToast()
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||||
|
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
@ -93,6 +96,7 @@ export default function TimeEntries() {
|
|||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
||||||
setFormData({ description: "", startTime: "", endTime: "", projectId: "", notes: "", externalLink: "" })
|
setFormData({ description: "", startTime: "", endTime: "", projectId: "", notes: "", externalLink: "" })
|
||||||
|
toast.success("Time entry created")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -101,6 +105,7 @@ export default function TimeEntries() {
|
|||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
||||||
setEditingId(null)
|
setEditingId(null)
|
||||||
|
toast.success("Time entry updated")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -108,6 +113,7 @@ export default function TimeEntries() {
|
|||||||
mutationFn: (id: string) => api.deleteTimeEntry(id),
|
mutationFn: (id: string) => api.deleteTimeEntry(id),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
||||||
|
toast.info("Time entry deleted")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -116,53 +122,34 @@ export default function TimeEntries() {
|
|||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
||||||
setSelectedIds([])
|
setSelectedIds([])
|
||||||
|
toast.info("Selected entries deleted")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const importMutation = useMutation({
|
const importMutation = useMutation({
|
||||||
mutationFn: (file: File) => api.importTimeEntriesCsv(file),
|
mutationFn: (file: File) => api.importTimeEntriesCsv(file),
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
alert(`Successfully imported ${data.count} entries.`)
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
||||||
|
toast.success(`Successfully imported ${data.count} entries`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
const handleScreenRecordingClick = () => {
|
||||||
e.preventDefault()
|
toast.info('Screen-Recording kommt in v2. Aktuell: upload manuell via Documents-Page')
|
||||||
let finalEndTime = formData.endTime
|
|
||||||
const roundingMinutes = settings?.roundingMinutes || 0
|
|
||||||
|
|
||||||
if (finalEndTime && roundingMinutes > 0) {
|
|
||||||
const date = new Date(finalEndTime)
|
|
||||||
const ms = roundingMinutes * 60000
|
|
||||||
const roundedMs = Math.ceil(date.getTime() / ms) * ms
|
|
||||||
const roundedDate = new Date(roundedMs)
|
|
||||||
|
|
||||||
if (roundedDate.getTime() !== date.getTime()) {
|
|
||||||
finalEndTime = roundedDate.toISOString()
|
|
||||||
alert(`Auf ${roundingMinutes}min gerundet`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
createMutation.mutate({
|
|
||||||
...formData,
|
|
||||||
endTime: finalEndTime
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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>
|
||||||
if (isLoading) return <div className="p-8 flex justify-center"><LoadingSpinner /></div>
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6 max-w-7xl mx-auto space-y-8">
|
<div className="p-6 max-w-7xl mx-auto space-y-8">
|
||||||
<div className="flex justify-between items-center">
|
<div className="flex justify-between items-center">
|
||||||
<h1 className="text-2xl font-bold">Time Entries</h1>
|
<h1 className="text-3xl font-bold tracking-tight">Time Entries</h1>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<button
|
<button
|
||||||
onClick={() => fileInputRef.current?.click()}
|
onClick={() => fileInputRef.current?.click()}
|
||||||
className="px-3 py-2 text-sm bg-gray-100 hover:bg-gray-200 rounded"
|
className="flex items-center gap-2 px-4 py-2 bg-white border rounded-lg hover:bg-gray-50 transition-colors text-sm font-medium"
|
||||||
>
|
>
|
||||||
Import CSV
|
<Upload size={16} /> Import CSV
|
||||||
</button>
|
</button>
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
@ -174,210 +161,223 @@ export default function TimeEntries() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form onSubmit={handleSubmit} className="grid grid-cols-1 md:grid-cols-3 gap-4 p-4 bg-gray-50 rounded-lg border">
|
<div className="grid grid-cols-1 lg:grid-cols-4 gap-8">
|
||||||
<div className="md:col-span-2">
|
<div className="lg:col-span-1 space-y-6">
|
||||||
<SuggestionInput
|
<div className="p-6 bg-white border rounded-xl shadow-sm space-y-4">
|
||||||
label="Description"
|
<h2 className="text-lg font-semibold mb-4">New Entry</h2>
|
||||||
value={formData.description}
|
|
||||||
onChange={(val) => setFormData({ ...formData, description: val })}
|
|
||||||
suggestions={descriptionSuggestions}
|
|
||||||
placeholder="What did you work on?"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label className="block text-xs font-medium text-gray-500 mb-1">Template</label>
|
|
||||||
<select
|
|
||||||
className="w-full p-2 border rounded text-sm"
|
|
||||||
onChange={(e) => handleTemplateChange(e.target.value)}
|
|
||||||
value=""
|
|
||||||
>
|
|
||||||
<option value="">Select Template...</option>
|
|
||||||
{templates?.map(t => <option key={t.id} value={t.id}>{t.description}</option>)}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<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"
|
|
||||||
value={formData.startTime}
|
|
||||||
onChange={(e) => setFormData({ ...formData, startTime: e.target.value })}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<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"
|
|
||||||
value={formData.endTime}
|
|
||||||
onChange={(e) => setFormData({ ...formData, endTime: e.target.value })}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label className="block text-xs font-medium text-gray-500 mb-1">Project ID</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="w-full p-2 border rounded text-sm"
|
|
||||||
value={formData.projectId}
|
|
||||||
onChange={(e) => setFormData({ ...formData, projectId: e.target.value })}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="md:col-span-2">
|
|
||||||
<label className="block text-xs font-medium text-gray-500 mb-1">Notes</label>
|
|
||||||
<textarea
|
|
||||||
className="w-full p-2 border rounded text-sm"
|
|
||||||
value={formData.notes}
|
|
||||||
onChange={(e) => setFormData({ ...formData, notes: e.target.value })}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label className="block text-xs font-medium text-gray-500 mb-1">External Link</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="w-full p-2 border rounded text-sm"
|
|
||||||
value={formData.externalLink}
|
|
||||||
onChange={(e) => setFormData({ ...formData, externalLink: e.target.value })}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-end">
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
disabled={createMutation.isPending}
|
|
||||||
className="w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50"
|
|
||||||
>
|
|
||||||
{createMutation.isPending ? "Saving..." : "Add Entry"}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<SmartFilters
|
<div className="space-y-3">
|
||||||
filters={filters}
|
<SuggestionInput
|
||||||
setFilters={setFilters}
|
label="Description"
|
||||||
savedViews={savedViews || []}
|
value={formData.description}
|
||||||
onApplyView={(view) => setFilters({ search: view.search || "", from: view.from || "", to: view.to || "" })}
|
onChange={(val) => setFormData({ ...formData, description: val })}
|
||||||
/>
|
suggestions={descriptionSuggestions}
|
||||||
|
placeholder="What are you working on?"
|
||||||
|
/>
|
||||||
|
|
||||||
{entries && entries.length === 0 ? (
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<EmptyState message="No time entries found." />
|
<div className="space-y-1">
|
||||||
) : (
|
<label className="text-xs font-medium text-gray-500">Start</label>
|
||||||
<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
|
<input
|
||||||
type="checkbox"
|
type="datetime-local"
|
||||||
checked={selectedIds.length > 0 && selectedIds.length === entries?.length}
|
className="w-full p-2 text-sm border rounded-md"
|
||||||
onChange={(e) => setSelectedIds(e.target.checked ? (entries?.map(en => en.id) || []) : [])}
|
value={formData.startTime}
|
||||||
|
onChange={(e) => setFormData({ ...formData, startTime: e.target.value })}
|
||||||
/>
|
/>
|
||||||
</th>
|
</div>
|
||||||
<th className="p-3">Description</th>
|
<div className="space-y-1">
|
||||||
<th className="p-3">Start</th>
|
<label className="text-xs font-medium text-gray-500">End</label>
|
||||||
<th className="p-3">End</th>
|
<input
|
||||||
<th className="p-3">Duration</th>
|
type="datetime-local"
|
||||||
<th className="p-3">Project</th>
|
className="w-full p-2 text-sm border rounded-md"
|
||||||
<th className="p-3 text-right">Actions</th>
|
value={formData.endTime}
|
||||||
</tr>
|
onChange={(e) => setFormData({ ...formData, endTime: e.target.value })}
|
||||||
</thead>
|
/>
|
||||||
<tbody>
|
</div>
|
||||||
{entries?.map(entry => {
|
</div>
|
||||||
const start = new Date(entry.startTime)
|
|
||||||
const end = new Date(entry.endTime)
|
|
||||||
const durationMs = end.getTime() - start.getTime()
|
|
||||||
const durationHours = (durationMs / 3600000).toFixed(2)
|
|
||||||
|
|
||||||
return (
|
<div className="space-y-1">
|
||||||
<tr key={entry.id} className={`border-b hover:bg-gray-50 ${expandedRows[entry.id] ? 'bg-blue-50/30' : ''}`}>
|
<label className="text-xs font-medium text-gray-500">Project ID</label>
|
||||||
<td className="p-3">
|
<input
|
||||||
<input
|
className="w-full p-2 text-sm border rounded-md"
|
||||||
type="checkbox"
|
value={formData.projectId}
|
||||||
checked={selectedIds.includes(entry.id)}
|
onChange={(e) => setFormData({ ...formData, projectId: e.target.value })}
|
||||||
onChange={(e) => setSelectedIds(prev => e.target.checked ? [...prev, entry.id] : prev.filter(id => id !== entry.id))}
|
placeholder="Project ID..."
|
||||||
/>
|
/>
|
||||||
</td>
|
</div>
|
||||||
<td className="p-3">
|
|
||||||
<div
|
|
||||||
className="cursor-pointer"
|
|
||||||
onClick={() => setExpandedRows(prev => ({ ...prev, [entry.id]: !prev[entry.id] }))}
|
|
||||||
>
|
|
||||||
<div className="font-medium">{entry.description}</div>
|
|
||||||
{expandedRows[entry.id] && (
|
|
||||||
<div className="mt-2 text-xs text-gray-500 max-w-xs">
|
|
||||||
{renderSimpleMarkdown(entry.notes)}
|
|
||||||
{entry.externalLink && (
|
|
||||||
<a href={entry.externalLink} target="_blank" className="block mt-1 text-blue-500 underline">Link</a>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td className="p-3 text-gray-500">{start.toLocaleString()}</td>
|
|
||||||
<td className="p-3 text-gray-500">{end.toLocaleString()}</td>
|
|
||||||
<td className="p-3">{durationHours}h</td>
|
|
||||||
<td className="p-3">{entry.projectId}</td>
|
|
||||||
<td className="p-3 text-right space-x-2">
|
|
||||||
<button
|
|
||||||
onClick={() => {
|
|
||||||
setEditingId(entry.id)
|
|
||||||
setEditValue(entry.description)
|
|
||||||
}}
|
|
||||||
className="text-blue-600 hover:underline"
|
|
||||||
>
|
|
||||||
Edit
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => {
|
|
||||||
if (confirm("Delete this entry?")) deleteMutation.mutate(entry.id)
|
|
||||||
}}
|
|
||||||
className="text-red-600 hover:underline"
|
|
||||||
>
|
|
||||||
Delete
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{selectedIds.length > 0 && (
|
<div className="space-y-1">
|
||||||
<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">
|
<label className="text-xs font-medium text-gray-500">Notes</label>
|
||||||
<span>{selectedIds.length} entries selected</span>
|
<textarea
|
||||||
<button
|
className="w-full p-2 text-sm border rounded-md h-20"
|
||||||
onClick={() => {
|
value={formData.notes}
|
||||||
if (confirm(`Delete ${selectedIds.length} entries?`)) bulkDeleteMutation.mutate(selectedIds)
|
onChange={(e) => setFormData({ ...formData, notes: e.target.value })}
|
||||||
}}
|
/>
|
||||||
className="bg-red-600 px-3 py-1 rounded-full text-xs hover:bg-red-700"
|
</div>
|
||||||
>
|
|
||||||
Delete Selected
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{editingId && (
|
<div className="flex gap-2 pt-2">
|
||||||
<div className="fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50">
|
<button
|
||||||
<div className="bg-white p-6 rounded-lg max-w-md w-full shadow-xl">
|
onClick={() => createMutation.mutate(formData)}
|
||||||
<h3 className="text-lg font-bold mb-4">Edit Description</h3>
|
disabled={createMutation.isPending}
|
||||||
<input
|
className="flex-1 bg-indigo-600 text-white py-2 rounded-md hover:bg-indigo-700 transition-colors font-medium disabled:opacity-50"
|
||||||
className="w-full p-2 border rounded mb-4"
|
>
|
||||||
value={editValue}
|
{createMutation.isPending ? "Saving..." : "Save Entry"}
|
||||||
onChange={(e) => setEditValue(e.target.value)}
|
</button>
|
||||||
autoFocus
|
<button
|
||||||
/>
|
onClick={handleScreenRecordingClick}
|
||||||
<div className="flex justify-end gap-2">
|
title="Screen Recording"
|
||||||
<button onClick={() => setEditingId(null)} className="px-4 py-2 text-gray-600">Cancel</button>
|
className="p-2 bg-gray-100 text-gray-600 rounded-md hover:bg-gray-200 transition-colors"
|
||||||
<button
|
>
|
||||||
onClick={() => updateMutation.mutate({ id: editingId, data: { description: editValue } })}
|
<Camera size={20} />
|
||||||
className="px-4 py-2 bg-blue-600 text-white rounded"
|
</button>
|
||||||
>
|
</div>
|
||||||
Save
|
</div>
|
||||||
</button>
|
</div>
|
||||||
|
|
||||||
|
<div className="p-6 bg-white border rounded-xl shadow-sm space-y-4">
|
||||||
|
<h2 className="text-lg font-semibold">Templates</h2>
|
||||||
|
<div className="space-y-2">
|
||||||
|
{templates?.map(t => (
|
||||||
|
<button
|
||||||
|
key={t.id}
|
||||||
|
onClick={() => handleTemplateChange(t.id)}
|
||||||
|
className="w-full text-left p-2 text-sm border rounded-md hover:border-indigo-300 hover:bg-indigo-50 transition-all"
|
||||||
|
>
|
||||||
|
{t.description}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
{templates?.length === 0 && <p className="text-sm text-gray-400">No templates found.</p>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
|
<div className="lg:col-span-3 space-y-6">
|
||||||
|
<div className="flex flex-col md:flex-row gap-4 items-start md:items-center justify-between">
|
||||||
|
<SmartFilters
|
||||||
|
filters={filters}
|
||||||
|
setFilters={setFilters}
|
||||||
|
entityType="time-entries"
|
||||||
|
savedViews={savedViews}
|
||||||
|
/>
|
||||||
|
{selectedIds.length > 0 && (
|
||||||
|
<button
|
||||||
|
onClick={() => bulkDeleteMutation.mutate(selectedIds)}
|
||||||
|
className="flex items-center gap-2 px-4 py-2 bg-red-50 text-red-600 border border-red-200 rounded-lg hover:bg-red-100 transition-colors text-sm font-medium"
|
||||||
|
>
|
||||||
|
<Trash2 size={16} /> Delete Selected ({selectedIds.length})
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isLoading ? (
|
||||||
|
<div className="flex justify-center py-20"><LoadingSpinner /></div>
|
||||||
|
) : entries && entries.length > 0 ? (
|
||||||
|
<div className="bg-white border rounded-xl shadow-sm overflow-hidden">
|
||||||
|
<table className="w-full text-left border-collapse">
|
||||||
|
<thead className="bg-gray-50 border-b">
|
||||||
|
<tr>
|
||||||
|
<th className="p-4 w-10">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="rounded"
|
||||||
|
checked={selectedIds.length === entries.length}
|
||||||
|
onChange={(e) => setSelectedIds(e.target.checked ? entries.map(en => en.id) : [])}
|
||||||
|
/>
|
||||||
|
</th>
|
||||||
|
<th className="p-4 text-sm font-semibold text-gray-600">Description</th>
|
||||||
|
<th className="p-4 text-sm font-semibold text-gray-600">Duration</th>
|
||||||
|
<th className="p-4 text-sm font-semibold text-gray-600">Project</th>
|
||||||
|
<th className="p-4 text-sm font-semibold text-gray-600 text-right">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody className="divide-y">
|
||||||
|
{entries.map((entry) => (
|
||||||
|
<tr key={entry.id} className="hover:bg-gray-50 group">
|
||||||
|
<td className="p-4">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="rounded"
|
||||||
|
checked={selectedIds.includes(entry.id)}
|
||||||
|
onChange={(e) => {
|
||||||
|
if (e.target.checked) setSelectedIds([...selectedIds, entry.id])
|
||||||
|
else setSelectedIds(selectedIds.filter(id => id !== entry.id))
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td className="p-4">
|
||||||
|
<div className="flex flex-col">
|
||||||
|
{editingId === entry.id ? (
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<input
|
||||||
|
className="border rounded px-2 py-1 text-sm w-full"
|
||||||
|
value={editValue}
|
||||||
|
onChange={(e) => setEditValue(e.target.value)}
|
||||||
|
autoFocus
|
||||||
|
/>
|
||||||
|
<button onClick={() => updateMutation.mutate({ id: entry.id, data: { description: editValue } })} className="text-green-600"><Check size={16}/></button>
|
||||||
|
<button onClick={() => setEditingId(null)} className="text-red-600"><X size={16}/></button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<span
|
||||||
|
className="text-sm font-medium cursor-pointer hover:text-indigo-600"
|
||||||
|
onClick={() => { setEditingId(entry.id); setEditValue(entry.description); }}
|
||||||
|
>
|
||||||
|
{entry.description}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{expandedRows[entry.id] && (
|
||||||
|
<div className="mt-2 p-3 bg-gray-50 rounded-lg text-xs text-gray-600 space-y-2 border">
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<span className="font-bold">Notes:</span>
|
||||||
|
<div>{renderSimpleMarkdown(entry.notes)}</div>
|
||||||
|
</div>
|
||||||
|
{entry.externalLink && (
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<span className="font-bold">Link:</span>
|
||||||
|
<a href={entry.externalLink} target="_blank" rel="noreferrer" className="text-indigo-600 underline truncate max-w-xs">{entry.externalLink}</a>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td className="p-4 text-sm text-gray-500">
|
||||||
|
{entry.startTime && entry.endTime ?
|
||||||
|
`${Math.round((new Date(entry.endTime).getTime() - new Date(entry.startTime).getTime()) / 60000)}m`
|
||||||
|
: "—"}
|
||||||
|
</td>
|
||||||
|
<td className="p-4 text-sm text-gray-500">{entry.projectId || "—"}</td>
|
||||||
|
<td className="p-4 text-right">
|
||||||
|
<div className="flex justify-end gap-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||||
|
<button
|
||||||
|
onClick={() => setExpandedRows(prev => ({ ...prev, [entry.id]: !prev[entry.id] }))}
|
||||||
|
className="p-1.5 text-gray-400 hover:text-indigo-600 rounded"
|
||||||
|
title="Toggle Details"
|
||||||
|
>
|
||||||
|
<FileText size={16} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => deleteMutation.mutate(entry.id)}
|
||||||
|
className="p-1.5 text-gray-400 hover:text-red-600 rounded"
|
||||||
|
title="Delete"
|
||||||
|
>
|
||||||
|
<Trash2 size={16} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<EmptyState
|
||||||
|
title="No time entries found"
|
||||||
|
description="Start tracking your time or import a CSV file to get started."
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user