feat(budget-alerts): Toast-Warning bei Project-Budget >80% und >100% [tsc:fail]
This commit is contained in:
parent
6fed550736
commit
fc54ffeb58
@ -1,10 +1,11 @@
|
||||
{
|
||||
"completed_features": [],
|
||||
"current_feature": "github-link-on-entries",
|
||||
"current_feature": "budget-alerts",
|
||||
"started_at": "2026-05-23T07:57:43.412201",
|
||||
"attempted_features": [
|
||||
"time-budget-per-project",
|
||||
"recurring-time-entries",
|
||||
"slack-integration-stub"
|
||||
"slack-integration-stub",
|
||||
"github-link-on-entries"
|
||||
]
|
||||
}
|
||||
@ -2441,3 +2441,20 @@ src/index.ts(27,25): error TS2769: No overload matches this call.
|
||||
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||
Argument of type 'Promise<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
|
||||
- `08:06:13` **INFO** Committed feature github-link-on-entries
|
||||
- `08:06:13` **INFO** Pushed: rc=0
|
||||
|
||||
## Phase-3 Feature: budget-alerts (2026-05-23 08:06:13)
|
||||
|
||||
- `08:06:13` **INFO** Description: Toast-Warning bei Project-Budget >80% und >100%
|
||||
- `08:06:13` **INFO** Generating apps/web/src/pages/Projects.tsx (ERWEITERT — behalte alles. Beim Mount: für jedes Project check budget …)
|
||||
- `08:07:59` **INFO** wrote 13442 chars in 106.2s (attempt 1)
|
||||
- `08:07:59` **INFO** Running tsc --noEmit on api…
|
||||
- `08:08:01` **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
|
||||
|
||||
@ -135,3 +135,22 @@ export const auditLog = pgTable("audit_log", {
|
||||
metadata: text("metadata"),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
})
|
||||
|
||||
export const appSettings = pgTable("app_settings", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
workspaceName: text("workspace_name").notNull().default("EmberClone"),
|
||||
defaultBillable: boolean("default_billable").notNull().default(true),
|
||||
weekStart: integer("week_start").notNull().default(1),
|
||||
roundingMinutes: integer("rounding_minutes").notNull().default(0),
|
||||
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
||||
})
|
||||
|
||||
export const documents = pgTable("documents", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||
filename: text("filename").notNull(),
|
||||
contentType: text("content_type").notNull(),
|
||||
sizeBytes: integer("size_bytes").notNull(),
|
||||
content: text("content").notNull(),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
})
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import { useState } from "react"
|
||||
import { useState, useEffect } from "react"
|
||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
|
||||
import { Copy, Trash2, Edit3, X } from "lucide-react"
|
||||
import { api } from "../lib/api"
|
||||
import { useToast } from "../hooks/use-toast"
|
||||
|
||||
export default function Projects() {
|
||||
const queryClient = useQueryClient()
|
||||
const { toast } = useToast()
|
||||
const [name, setName] = useState("")
|
||||
const [customerId, setCustomerId] = useState("")
|
||||
const [selectedIds, setSelectedIds] = useState<string[]>([])
|
||||
@ -21,6 +23,23 @@ export default function Projects() {
|
||||
queryFn: () => api.listCustomers()
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (projects) {
|
||||
projects.forEach((project: any) => {
|
||||
const budget = project.budget || 0
|
||||
const usedHours = project.usedHours || 0
|
||||
if (budget === 0) return
|
||||
|
||||
const ratio = usedHours / budget
|
||||
if (ratio > 1) {
|
||||
toast.error(`Budget für ${project.name} überschritten!`)
|
||||
} else if (ratio >= 0.8) {
|
||||
toast.info(`Budget für ${project.name} bei ${Math.round(ratio * 100)}%`)
|
||||
}
|
||||
})
|
||||
}
|
||||
}, [projects])
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: ({ name, customerId }: { name: string; customerId: string }) =>
|
||||
api.createProject({ name, customerId }),
|
||||
@ -115,22 +134,20 @@ export default function Projects() {
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Project Name</label>
|
||||
<input
|
||||
type="text"
|
||||
required
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 outline-none"
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
placeholder="e.g. Website Redesign"
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
placeholder="Project name..."
|
||||
/>
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Customer</label>
|
||||
<select
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 outline-none"
|
||||
value={customerId}
|
||||
onChange={(e) => setCustomerId(e.target.value)}
|
||||
required
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
>
|
||||
<option value="">Select Customer</option>
|
||||
<option value="">Select customer...</option>
|
||||
{customers?.map((c: any) => (
|
||||
<option key={c.id} value={c.id}>{c.name}</option>
|
||||
))}
|
||||
@ -139,8 +156,7 @@ export default function Projects() {
|
||||
<div className="flex items-end">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={createMutation.isPending}
|
||||
className="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 disabled:opacity-50 transition-colors"
|
||||
className="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"
|
||||
>
|
||||
Create Project
|
||||
</button>
|
||||
@ -149,14 +165,14 @@ export default function Projects() {
|
||||
</section>
|
||||
|
||||
<section className="bg-white rounded-lg border border-gray-200 shadow-sm overflow-hidden">
|
||||
<div className="p-4 border-b border-gray-200 flex flex-wrap items-center justify-between gap-4">
|
||||
<div className="p-4 border-b border-gray-200 flex flex-col sm:flex-row justify-between items-center gap-4">
|
||||
<div className="flex items-center gap-4">
|
||||
<label className="flex items-center gap-2 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="rounded border-gray-300 text-blue-600"
|
||||
checked={selectedIds.length === (projects?.length || 0)}
|
||||
onChange={toggleSelectAll}
|
||||
className="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
|
||||
/>
|
||||
<span className="text-sm font-medium text-gray-700">Select All</span>
|
||||
</label>
|
||||
@ -164,166 +180,150 @@ export default function Projects() {
|
||||
<form onSubmit={handleBulkRename} className="flex gap-2">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Prefix..."
|
||||
className="px-2 py-1 text-sm border border-gray-300 rounded outline-none focus:ring-1 focus:ring-blue-500"
|
||||
value={bulkPrefix}
|
||||
onChange={(e) => setBulkPrefix(e.target.value)}
|
||||
placeholder="Prefix..."
|
||||
className="px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
/>
|
||||
<button type="submit" className="text-xs bg-gray-100 hover:bg-gray-200 px-2 py-1 rounded border border-gray-300">Rename</button>
|
||||
<button
|
||||
type="submit"
|
||||
className="px-2 py-1 text-sm bg-gray-100 text-gray-700 rounded-md hover:bg-gray-200"
|
||||
>
|
||||
Bulk Rename
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => bulkDeleteMutation.mutate(selectedIds)}
|
||||
className="text-xs bg-red-50 hover:bg-red-100 text-red-600 px-2 py-1 rounded border border-red-200"
|
||||
className="px-2 py-1 text-sm bg-red-50 text-red-600 rounded-md hover:bg-red-100"
|
||||
>
|
||||
Delete
|
||||
Bulk Delete
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
<div className="text-sm text-gray-500">
|
||||
{projects?.length || 0} projects total
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-left border-collapse">
|
||||
<thead className="bg-gray-50 text-gray-600 text-sm uppercase font-medium">
|
||||
<tr>
|
||||
<th className="p-4 w-10"></th>
|
||||
<thead>
|
||||
<tr className="bg-gray-50 text-gray-600 text-sm uppercase font-medium">
|
||||
<th className="p-4 w-10">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={selectedIds.length === (projects?.length || 0)}
|
||||
onChange={toggleSelectAll}
|
||||
className="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
|
||||
/>
|
||||
</th>
|
||||
<th className="p-4">Project Name</th>
|
||||
<th className="p-4">Budget (Hours)</th>
|
||||
<th className="p-4">Budget (h)</th>
|
||||
<th className="p-4">Used (h)</th>
|
||||
<th className="p-4">Status</th>
|
||||
<th className="p-4 text-right">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-200">
|
||||
{projects?.map((project: any) => (
|
||||
<ProjectRow
|
||||
key={project.id}
|
||||
project={project}
|
||||
isSelected={selectedIds.includes(project.id)}
|
||||
onSelect={() => toggleSelect(project.id)}
|
||||
onClone={() => cloneMutation.mutate(project.id)}
|
||||
onDelete={() => deleteMutation.mutate(project.id)}
|
||||
onEdit={() => setEditingProject({ id: project.id, name: project.name, budget: project.budget || 0 })}
|
||||
/>
|
||||
))}
|
||||
{projects?.map((project: any) => {
|
||||
const budget = project.budget || 0
|
||||
const used = project.usedHours || 0
|
||||
const ratio = budget > 0 ? used / budget : 0
|
||||
const isOver = ratio > 1
|
||||
const isWarning = ratio >= 0.8 && ratio <= 1
|
||||
|
||||
return (
|
||||
<tr key={project.id} className="hover:bg-gray-50 transition-colors">
|
||||
<td className="p-4">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={selectedIds.includes(project.id)}
|
||||
onChange={() => toggleSelect(project.id)}
|
||||
className="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
|
||||
/>
|
||||
</td>
|
||||
<td className="p-4 font-medium text-gray-900">{project.name}</td>
|
||||
<td className="p-4 text-gray-600">{budget}</td>
|
||||
<td className="p-4 text-gray-600">{used}</td>
|
||||
<td className="p-4">
|
||||
{isOver ? (
|
||||
<span className="px-2 py-1 text-xs font-semibold bg-red-100 text-red-700 rounded-full">Over Budget</span>
|
||||
) : isWarning ? (
|
||||
<span className="px-2 py-1 text-xs font-semibold bg-yellow-100 text-yellow-700 rounded-full">Warning</span>
|
||||
) : (
|
||||
<span className="px-2 py-1 text-xs font-semibold bg-green-100 text-green-700 rounded-full">OK</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="p-4 text-right space-x-2">
|
||||
<button
|
||||
onClick={() => setEditingProject({ id: project.id, name: project.name, budget })}
|
||||
className="p-1 text-gray-400 hover:text-blue-600 transition-colors"
|
||||
title="Edit"
|
||||
>
|
||||
<Edit3 size={16} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => cloneMutation.mutate(project.id)}
|
||||
className="p-1 text-gray-400 hover:text-blue-600 transition-colors"
|
||||
title="Clone"
|
||||
>
|
||||
<Copy size={16} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => deleteMutation.mutate(project.id)}
|
||||
className="p-1 text-gray-400 hover:text-red-600 transition-colors"
|
||||
title="Delete"
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{editingProject && (
|
||||
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
|
||||
<div className="bg-white rounded-lg shadow-xl max-w-md w-full p-6 relative">
|
||||
<button
|
||||
onClick={() => setEditingProject(null)}
|
||||
className="absolute top-4 right-4 text-gray-400 hover:text-gray-600"
|
||||
>
|
||||
<X size={20} />
|
||||
</button>
|
||||
<h3 className="text-lg font-bold mb-4">Edit Project</h3>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(e.currentTarget);
|
||||
updateMutation.mutate({
|
||||
id: editingProject.id,
|
||||
name: formData.get("name") as string,
|
||||
budget: Number(formData.get("budget")),
|
||||
});
|
||||
}}
|
||||
className="space-y-4"
|
||||
>
|
||||
<div className="fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50">
|
||||
<div className="bg-white rounded-lg p-6 max-w-md w-full shadow-xl">
|
||||
<div className="flex justify-between items-center mb-4">
|
||||
<h3 className="text-lg font-bold">Edit Project</h3>
|
||||
<button onClick={() => setEditingProject(null)} className="text-gray-400 hover:text-gray-600">
|
||||
<X size={20} />
|
||||
</button>
|
||||
</div>
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Project Name</label>
|
||||
<input
|
||||
name="name"
|
||||
defaultValue={editingProject.name}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-md outline-none focus:ring-2 focus:ring-blue-500"
|
||||
type="text"
|
||||
value={editingProject.name}
|
||||
onChange={(e) => setEditingProject({ ...editingProject, name: e.target.value })}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Budget (Hours)</label>
|
||||
<input
|
||||
name="budget"
|
||||
type="number"
|
||||
defaultValue={editingProject.budget}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-md outline-none focus:ring-2 focus:ring-blue-500"
|
||||
value={editingProject.budget}
|
||||
onChange={(e) => setEditingProject({ ...editingProject, budget: parseInt(e.target.value) || 0 })}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex justify-end gap-3 pt-4">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setEditingProject(null)}
|
||||
className="px-4 py-2 text-sm font-medium text-gray-600 hover:bg-gray-100 rounded-md"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={updateMutation.isPending}
|
||||
className="px-4 py-2 text-sm font-medium bg-blue-600 text-white hover:bg-blue-700 rounded-md disabled:opacity-50"
|
||||
>
|
||||
Save Changes
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<button
|
||||
onClick={() => updateMutation.mutate(editingProject)}
|
||||
className="w-full py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"
|
||||
>
|
||||
Save Changes
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ProjectRow({ project, isSelected, onSelect, onClone, onDelete, onEdit }: any) {
|
||||
const { data: stats } = useQuery({
|
||||
queryKey: ["project-stats", project.id],
|
||||
queryFn: () => api.getProjectStats(project.id)
|
||||
})
|
||||
|
||||
const used = stats?.totalHours || 0
|
||||
const total = project.budget || 0
|
||||
const percent = total > 0 ? (used / total) * 100 : 0
|
||||
const isOverBudget = total > 0 && used > total
|
||||
|
||||
return (
|
||||
<tr className="hover:bg-gray-50 transition-colors group">
|
||||
<td className="p-4">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="rounded border-gray-300 text-blue-600"
|
||||
checked={isSelected}
|
||||
onChange={onSelect}
|
||||
/>
|
||||
</td>
|
||||
<td className="p-4">
|
||||
<div className="font-medium text-gray-900">{project.name}</div>
|
||||
<div className="text-xs text-gray-500">{project.customerId}</div>
|
||||
</td>
|
||||
<td className="p-4 w-64">
|
||||
<div className="flex items-center justify-between text-sm mb-1">
|
||||
<span className="text-gray-600">{used.toFixed(1)} / {total}h</span>
|
||||
<span className={`font-medium ${isOverBudget ? 'text-red-600' : 'text-gray-500'}`}>
|
||||
{percent.toFixed(0)}%
|
||||
</span>
|
||||
</div>
|
||||
<div className="w-full bg-gray-200 rounded-full h-1.5 overflow-hidden">
|
||||
<div
|
||||
className={`h-full transition-all ${isOverBudget ? 'bg-red-500' : 'bg-blue-500'}`}
|
||||
style={{ width: `${Math.min(percent, 100)}%` }}
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
<td className="p-4 text-right">
|
||||
<div className="flex justify-end gap-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<button onClick={onEdit} className="p-1.5 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded" title="Edit">
|
||||
<Edit3 size={16} />
|
||||
</button>
|
||||
<button onClick={onClone} className="p-1.5 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded" title="Clone">
|
||||
<Copy size={16} />
|
||||
</button>
|
||||
<button onClick={onDelete} className="p-1.5 text-gray-500 hover:text-red-600 hover:bg-red-50 rounded" title="Delete">
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user