feat(smart-rounding-on-input): Bei Time-Entry-Submit: round endTime auf appSettings.roundin [tsc:fail]
This commit is contained in:
parent
2d04a9ae8c
commit
dc905cdf10
@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"completed_features": [],
|
"completed_features": [],
|
||||||
"current_feature": "snippet-shortcuts",
|
"current_feature": "smart-rounding-on-input",
|
||||||
"started_at": "2026-05-23T08:09:40.135892",
|
"started_at": "2026-05-23T08:09:40.135892",
|
||||||
"attempted_features": [
|
"attempted_features": [
|
||||||
"keyboard-undo-stack"
|
"keyboard-undo-stack",
|
||||||
|
"snippet-shortcuts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -2516,3 +2516,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:10:14` **INFO** Committed feature snippet-shortcuts
|
||||||
|
- `08:10:15` **INFO** Pushed: rc=0
|
||||||
|
|
||||||
|
## Phase-3 Feature: smart-rounding-on-input (2026-05-23 08:10:15)
|
||||||
|
|
||||||
|
- `08:10:15` **INFO** Description: Bei Time-Entry-Submit: round endTime auf appSettings.roundingMinutes
|
||||||
|
- `08:10:15` **INFO** Generating apps/web/src/pages/TimeEntries.tsx (ERWEITERT — behalte alles. Im handleSubmit: vor mutate, runde endTime …)
|
||||||
|
- `08:12:08` **INFO** wrote 14477 chars in 113.6s (attempt 1)
|
||||||
|
- `08:12:08` **INFO** Running tsc --noEmit on api…
|
||||||
|
- `08:12:10` **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
|
||||||
|
|||||||
@ -44,6 +44,11 @@ export default function TimeEntries() {
|
|||||||
const [editingId, setEditingId] = useState<string | null>(null)
|
const [editingId, setEditingId] = useState<string | null>(null)
|
||||||
const [editValue, setEditValue] = useState("")
|
const [editValue, setEditValue] = useState("")
|
||||||
|
|
||||||
|
const { data: settings } = useQuery({
|
||||||
|
queryKey: ["settings"],
|
||||||
|
queryFn: () => api.getSettings()
|
||||||
|
})
|
||||||
|
|
||||||
const { data: entries, isLoading, isError } = useQuery({
|
const { data: entries, isLoading, isError } = useQuery({
|
||||||
queryKey: ["time-entries", filters.from, filters.to],
|
queryKey: ["time-entries", filters.from, filters.to],
|
||||||
queryFn: () => api.listTimeEntries({
|
queryFn: () => api.listTimeEntries({
|
||||||
@ -119,27 +124,37 @@ export default function TimeEntries() {
|
|||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
alert(`Successfully imported ${data.count} entries.`)
|
alert(`Successfully imported ${data.count} entries.`)
|
||||||
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
||||||
},
|
|
||||||
onError: (error: any) => {
|
|
||||||
alert(`Import failed: ${error.message}`)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const filteredEntries = useMemo(() => {
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
if (!entries) return []
|
e.preventDefault()
|
||||||
return entries.filter(e => {
|
let finalEndTime = formData.endTime
|
||||||
const matchesSearch = !filters.search ||
|
const roundingMinutes = settings?.roundingMinutes || 0
|
||||||
e.description.toLowerCase().includes(filters.search.toLowerCase()) ||
|
|
||||||
e.notes?.toLowerCase().includes(filters.search.toLowerCase())
|
if (finalEndTime && roundingMinutes > 0) {
|
||||||
return matchesSearch
|
const date = new Date(finalEndTime)
|
||||||
})
|
const ms = roundingMinutes * 60000
|
||||||
}, [entries, filters.search])
|
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 (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>
|
||||||
|
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-6">
|
<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-2xl font-bold">Time Entries</h1>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
@ -159,228 +174,203 @@ export default function TimeEntries() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-4 gap-6">
|
<form onSubmit={handleSubmit} className="grid grid-cols-1 md:grid-cols-3 gap-4 p-4 bg-gray-50 rounded-lg border">
|
||||||
<div className="lg:col-span-1 space-y-4 bg-gray-50 p-4 rounded-lg border">
|
<div className="md:col-span-2">
|
||||||
<h2 className="font-semibold mb-2">New Entry</h2>
|
<SuggestionInput
|
||||||
|
label="Description"
|
||||||
<div className="space-y-3">
|
value={formData.description}
|
||||||
<div>
|
onChange={(val) => setFormData({ ...formData, description: val })}
|
||||||
<label className="text-xs font-medium text-gray-500">Template</label>
|
suggestions={descriptionSuggestions}
|
||||||
<select
|
placeholder="What did you work on?"
|
||||||
className="w-full p-2 text-sm border rounded bg-white"
|
|
||||||
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>
|
|
||||||
|
|
||||||
<SuggestionInput
|
|
||||||
label="Description"
|
|
||||||
value={formData.description}
|
|
||||||
onChange={v => setFormData({...formData, description: v})}
|
|
||||||
suggestions={descriptionSuggestions}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-2">
|
|
||||||
<div>
|
|
||||||
<label className="text-xs font-medium text-gray-500">Start</label>
|
|
||||||
<input
|
|
||||||
type="datetime-local"
|
|
||||||
className="w-full p-2 text-sm border rounded"
|
|
||||||
value={formData.startTime}
|
|
||||||
onChange={e => setFormData({...formData, startTime: e.target.value})}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label className="text-xs font-medium text-gray-500">End</label>
|
|
||||||
<input
|
|
||||||
type="datetime-local"
|
|
||||||
className="w-full p-2 text-sm border rounded"
|
|
||||||
value={formData.endTime}
|
|
||||||
onChange={e => setFormData({...formData, endTime: e.target.value})}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label className="text-xs font-medium text-gray-500">Project ID</label>
|
|
||||||
<input
|
|
||||||
className="w-full p-2 text-sm border rounded"
|
|
||||||
value={formData.projectId}
|
|
||||||
onChange={e => setFormData({...formData, projectId: e.target.value})}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label className="text-xs font-medium text-gray-500">GitHub / External Link</label>
|
|
||||||
<input
|
|
||||||
className="w-full p-2 text-sm border rounded"
|
|
||||||
placeholder="https://github.com/..."
|
|
||||||
value={formData.externalLink}
|
|
||||||
onChange={e => setFormData({...formData, externalLink: e.target.value})}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label className="text-xs font-medium text-gray-500">Notes</label>
|
|
||||||
<textarea
|
|
||||||
className="w-full p-2 text-sm border rounded h-20"
|
|
||||||
value={formData.notes}
|
|
||||||
onChange={e => setFormData({...formData, notes: e.target.value})}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
|
||||||
onClick={() => createMutation.mutate(formData)}
|
|
||||||
disabled={!formData.description || !formData.startTime || !formData.endTime}
|
|
||||||
className="w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50"
|
|
||||||
>
|
|
||||||
Save Entry
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="lg:col-span-3 space-y-4">
|
|
||||||
<SmartFilters
|
|
||||||
filters={filters}
|
|
||||||
setFilters={setFilters}
|
|
||||||
savedViews={savedViews || []}
|
|
||||||
/>
|
/>
|
||||||
|
</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>
|
||||||
|
|
||||||
<div className="bg-white border rounded-lg overflow-hidden">
|
<SmartFilters
|
||||||
<table className="w-full text-left text-sm">
|
filters={filters}
|
||||||
<thead className="bg-gray-50 border-b">
|
setFilters={setFilters}
|
||||||
<tr>
|
savedViews={savedViews || []}
|
||||||
<th className="p-3 w-10">
|
onApplyView={(view) => setFilters({ search: view.search || "", from: view.from || "", to: view.to || "" })}
|
||||||
<input
|
/>
|
||||||
type="checkbox"
|
|
||||||
checked={selectedIds.length > 0 && selectedIds.length === filteredEntries.length}
|
{entries && entries.length === 0 ? (
|
||||||
onChange={e => {
|
<EmptyState message="No time entries found." />
|
||||||
setSelectedIds(e.target.checked ? filteredEntries.map(en => en.id) : [])
|
) : (
|
||||||
}}
|
<div className="overflow-x-auto border rounded-lg">
|
||||||
/>
|
<table className="w-full text-left text-sm">
|
||||||
</th>
|
<thead className="bg-gray-50 border-b">
|
||||||
<th className="p-3">Description</th>
|
<tr>
|
||||||
<th className="p-3">Duration</th>
|
<th className="p-3 w-10">
|
||||||
<th className="p-3">Project</th>
|
<input
|
||||||
<th className="p-3 text-right">Actions</th>
|
type="checkbox"
|
||||||
</tr>
|
checked={selectedIds.length > 0 && selectedIds.length === entries?.length}
|
||||||
</thead>
|
onChange={(e) => setSelectedIds(e.target.checked ? (entries?.map(en => en.id) || []) : [])}
|
||||||
<tbody>
|
/>
|
||||||
{filteredEntries.length === 0 ? (
|
</th>
|
||||||
<tr>
|
<th className="p-3">Description</th>
|
||||||
<td colSpan={5} className="p-8 text-center text-gray-500">
|
<th className="p-3">Start</th>
|
||||||
<EmptyState message="No time entries found." />
|
<th className="p-3">End</th>
|
||||||
|
<th className="p-3">Duration</th>
|
||||||
|
<th className="p-3">Project</th>
|
||||||
|
<th className="p-3 text-right">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{entries?.map(entry => {
|
||||||
|
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 (
|
||||||
|
<tr key={entry.id} className={`border-b hover:bg-gray-50 ${expandedRows[entry.id] ? 'bg-blue-50/30' : ''}`}>
|
||||||
|
<td className="p-3">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={selectedIds.includes(entry.id)}
|
||||||
|
onChange={(e) => setSelectedIds(prev => e.target.checked ? [...prev, entry.id] : prev.filter(id => id !== entry.id))}
|
||||||
|
/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
<td className="p-3">
|
||||||
) : (
|
<div
|
||||||
filteredEntries.map(entry => (
|
className="cursor-pointer"
|
||||||
<tr key={entry.id} className="border-b hover:bg-gray-50 group">
|
onClick={() => setExpandedRows(prev => ({ ...prev, [entry.id]: !prev[entry.id] }))}
|
||||||
<td className="p-3">
|
>
|
||||||
<input
|
<div className="font-medium">{entry.description}</div>
|
||||||
type="checkbox"
|
|
||||||
checked={selectedIds.includes(entry.id)}
|
|
||||||
onChange={e => {
|
|
||||||
setSelectedIds(prev => e.target.checked ? [...prev, entry.id] : prev.filter(id => id !== entry.id))
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td className="p-3">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<span className="font-medium">{entry.description}</span>
|
|
||||||
{entry.externalLink && (
|
|
||||||
<a
|
|
||||||
href={entry.externalLink}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="text-blue-500 hover:text-blue-700"
|
|
||||||
title={entry.externalLink}
|
|
||||||
>
|
|
||||||
<svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{expandedRows[entry.id] && (
|
{expandedRows[entry.id] && (
|
||||||
<div className="mt-2 text-xs text-gray-600 bg-gray-50 p-2 rounded border">
|
<div className="mt-2 text-xs text-gray-500 max-w-xs">
|
||||||
{renderSimpleMarkdown(entry.notes)}
|
{renderSimpleMarkdown(entry.notes)}
|
||||||
|
{entry.externalLink && (
|
||||||
|
<a href={entry.externalLink} target="_blank" className="block mt-1 text-blue-500 underline">Link</a>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</td>
|
</div>
|
||||||
<td className="p-3 text-gray-500">
|
</td>
|
||||||
{entry.startTime && entry.endTime ?
|
<td className="p-3 text-gray-500">{start.toLocaleString()}</td>
|
||||||
`${Math.round((new Date(entry.endTime).getTime() - new Date(entry.startTime).getTime()) / 60000)}m`
|
<td className="p-3 text-gray-500">{end.toLocaleString()}</td>
|
||||||
: '-'}
|
<td className="p-3">{durationHours}h</td>
|
||||||
</td>
|
<td className="p-3">{entry.projectId}</td>
|
||||||
<td className="p-3 text-gray-500">{entry.projectId}</td>
|
<td className="p-3 text-right space-x-2">
|
||||||
<td className="p-3 text-right space-x-2">
|
<button
|
||||||
<button
|
onClick={() => {
|
||||||
onClick={() => {
|
setEditingId(entry.id)
|
||||||
setExpandedRows(prev => ({...prev, [entry.id]: !prev[entry.id]}))
|
setEditValue(entry.description)
|
||||||
}}
|
}}
|
||||||
className="text-xs text-gray-400 hover:text-gray-600"
|
className="text-blue-600 hover:underline"
|
||||||
>
|
>
|
||||||
{expandedRows[entry.id] ? 'Hide' : 'Notes'}
|
Edit
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setEditingId(entry.id)
|
if (confirm("Delete this entry?")) deleteMutation.mutate(entry.id)
|
||||||
setEditValue(entry.description)
|
}}
|
||||||
}}
|
className="text-red-600 hover:underline"
|
||||||
className="text-xs text-blue-500 hover:underline"
|
>
|
||||||
>
|
Delete
|
||||||
Edit
|
</button>
|
||||||
</button>
|
</td>
|
||||||
<button
|
</tr>
|
||||||
onClick={() => deleteMutation.mutate(entry.id)}
|
)
|
||||||
className="text-xs text-red-500 hover:underline"
|
})}
|
||||||
>
|
</tbody>
|
||||||
Delete
|
</table>
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{selectedIds.length > 0 && (
|
|
||||||
<div className="flex justify-between items-center p-3 bg-blue-50 border border-blue-200 rounded-lg">
|
|
||||||
<span className="text-sm text-blue-700">{selectedIds.length} entries selected</span>
|
|
||||||
<button
|
|
||||||
onClick={() => {
|
|
||||||
if (confirm(`Delete ${selectedIds.length} entries?`)) {
|
|
||||||
bulkDeleteMutation.mutate(selectedIds)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="px-3 py-1 text-sm bg-red-600 text-white rounded hover:bg-red-700"
|
|
||||||
>
|
|
||||||
Delete Selected
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
|
|
||||||
|
{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">
|
||||||
|
<span>{selectedIds.length} entries selected</span>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
if (confirm(`Delete ${selectedIds.length} entries?`)) bulkDeleteMutation.mutate(selectedIds)
|
||||||
|
}}
|
||||||
|
className="bg-red-600 px-3 py-1 rounded-full text-xs hover:bg-red-700"
|
||||||
|
>
|
||||||
|
Delete Selected
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{editingId && (
|
{editingId && (
|
||||||
<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 space-y-4">
|
<div className="bg-white p-6 rounded-lg max-w-md w-full shadow-xl">
|
||||||
<h3 className="font-bold">Edit Description</h3>
|
<h3 className="text-lg font-bold mb-4">Edit Description</h3>
|
||||||
<input
|
<input
|
||||||
className="w-full p-2 border rounded"
|
className="w-full p-2 border rounded mb-4"
|
||||||
value={editValue}
|
value={editValue}
|
||||||
onChange={e => setEditValue(e.target.value)}
|
onChange={(e) => setEditValue(e.target.value)}
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
<div className="flex justify-end gap-2">
|
<div className="flex justify-end gap-2">
|
||||||
<button onClick={() => setEditingId(null)} className="px-4 py-2 text-sm">Cancel</button>
|
<button onClick={() => setEditingId(null)} className="px-4 py-2 text-gray-600">Cancel</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => updateMutation.mutate({ id: editingId, data: { description: editValue } })}
|
onClick={() => updateMutation.mutate({ id: editingId, data: { description: editValue } })}
|
||||||
className="px-4 py-2 text-sm bg-blue-600 text-white rounded"
|
className="px-4 py-2 bg-blue-600 text-white rounded"
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user