feat(project-billing-rate): Project bekommt billingRate (€/h) [tsc:fail]
This commit is contained in:
parent
6e7f2a4514
commit
969f7be8f6
@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"completed_features": [],
|
"completed_features": [],
|
||||||
"current_feature": "customer-contact-info",
|
"current_feature": "project-billing-rate",
|
||||||
"started_at": "2026-05-23T09:03:38.637785"
|
"started_at": "2026-05-23T09:03:38.637785",
|
||||||
|
"attempted_features": [
|
||||||
|
"customer-contact-info"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@ -3215,3 +3215,23 @@ 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:06:25` **INFO** Committed feature customer-contact-info
|
||||||
|
- `09:06:25` **INFO** Pushed: rc=0
|
||||||
|
|
||||||
|
## Phase-3 Feature: project-billing-rate (2026-05-23 09:06:25)
|
||||||
|
|
||||||
|
- `09:06:25` **INFO** Description: Project bekommt billingRate (€/h)
|
||||||
|
- `09:06:25` **INFO** Generating apps/api/src/db/schema.ts (WICHTIG: BEHALTE alle Tabellen + Spalten. Füge nur Spalte `billingRate…)
|
||||||
|
- `09:07:02` **INFO** wrote 4298 chars in 36.7s (attempt 1)
|
||||||
|
- `09:07:02` **INFO** Generating apps/web/src/pages/Projects.tsx (ERWEITERT — füge Billing-Rate-Input (€/h) ins Create-Form. Speichert i…)
|
||||||
|
- `09:08:34` **INFO** wrote 11072 chars in 92.4s (attempt 1)
|
||||||
|
- `09:08:34` **INFO** Running tsc --noEmit on api…
|
||||||
|
- `09:08:36` **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>,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { pgTable, text, timestamp, boolean, uuid, integer, customType, date } from "drizzle-orm/pg-core"
|
import { pgTable, text, timestamp, boolean, uuid, integer, customType } from "drizzle-orm/pg-core"
|
||||||
|
|
||||||
const bytea = customType<{ data: Buffer }>({
|
const bytea = customType<{ data: Buffer }>({
|
||||||
dataType() {
|
dataType() {
|
||||||
@ -52,6 +52,7 @@ export const projects = pgTable("projects", {
|
|||||||
icon: text("icon"),
|
icon: text("icon"),
|
||||||
customerId: uuid("customer_id").notNull().references(() => customers.id, { onDelete: "cascade" }),
|
customerId: uuid("customer_id").notNull().references(() => customers.id, { onDelete: "cascade" }),
|
||||||
budgetHours: integer("budget_hours"),
|
budgetHours: integer("budget_hours"),
|
||||||
|
billingRate: integer("billing_rate"),
|
||||||
active: boolean("active").notNull().default(true),
|
active: boolean("active").notNull().default(true),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||||
})
|
})
|
||||||
@ -95,74 +96,73 @@ export const timeEntryComments = pgTable("time_entry_comments", {
|
|||||||
|
|
||||||
export const timeEntryTemplates = pgTable("time_entry_templates", {
|
export const timeEntryTemplates = pgTable("time_entry_templates", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
userId: uuid("user_id").references(() => users.id, { onDelete: "cascade" }),
|
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||||
name: text("name"),
|
description: text("description").notNull(),
|
||||||
description: text("description"),
|
projectId: uuid("project_id").references(() => projects.id, { onDelete: "cascade" }),
|
||||||
projectId: uuid("project_id").references(() => projects.id, { onDelete: "set null" }),
|
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||||
})
|
})
|
||||||
|
|
||||||
export const apiKeys = pgTable("api_keys", {
|
export const apiKeys = pgTable("api_keys", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||||
keyHash: text("key_hash").notNull().unique(),
|
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
|
keyHash: text("key_hash").notNull(),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||||
lastUsedAt: timestamp("last_used_at")
|
lastUsedAt: timestamp("last_used_at"),
|
||||||
|
revokedAt: timestamp("revoked_at"),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const savedViews = pgTable("saved_views", {
|
export const savedViews = pgTable("saved_views", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
config: text("config").notNull(),
|
entityType: text("entity_type").notNull(),
|
||||||
|
filters: text("filters").notNull(),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||||
updatedAt: timestamp("updated_at").notNull().defaultNow()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const webhooks = pgTable("webhooks", {
|
export const webhooks = pgTable("webhooks", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
||||||
url: text("url").notNull(),
|
url: text("url").notNull(),
|
||||||
secret: text("secret").notNull(),
|
event: text("event").notNull(),
|
||||||
events: text("events").array().notNull(),
|
|
||||||
active: boolean("active").notNull().default(true),
|
active: boolean("active").notNull().default(true),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||||
|
createdBy: uuid("created_by").references(() => users.id, { onDelete: "set null" }),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const auditLog = pgTable("audit_log", {
|
export const auditLog = pgTable("audit_log", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
userId: uuid("user_id").references(() => users.id),
|
userId: uuid("user_id").references(() => users.id, { onDelete: "set null" }),
|
||||||
action: text("action").notNull(),
|
action: text("action").notNull(),
|
||||||
entityType: text("entity_type").notNull(),
|
resourceType: text("resource_type"),
|
||||||
entityId: uuid("entity_id"),
|
resourceId: text("resource_id"),
|
||||||
oldValue: text("old_value"),
|
metadata: text("metadata"),
|
||||||
newValue: text("new_value"),
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||||
ipAddress: text("ip_address"),
|
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const appSettings = pgTable("app_settings", {
|
export const appSettings = pgTable("app_settings", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
key: text("key").notNull().unique(),
|
workspaceName: text("workspace_name").notNull().default("EmberClone"),
|
||||||
value: text("value").notNull(),
|
defaultBillable: boolean("default_billable").notNull().default(true),
|
||||||
|
weekStart: integer("week_start").notNull().default(1),
|
||||||
|
roundingMinutes: integer("rounding_minutes").notNull().default(0),
|
||||||
|
workingHoursPerDay: integer("working_hours_per_day").notNull().default(8),
|
||||||
|
logoUrl: text("logo_url"),
|
||||||
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
||||||
updatedBy: uuid("updated_by").references(() => users.id)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const documents = pgTable("documents", {
|
export const documents = pgTable("documents", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
projectId: uuid("project_id").references(() => projects.id, { onDelete: "cascade" }),
|
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||||
name: text("name").notNull(),
|
filename: text("filename").notNull(),
|
||||||
content: text("content"),
|
contentType: text("content_type").notNull(),
|
||||||
|
sizeBytes: integer("size_bytes").notNull(),
|
||||||
|
content: text("content").notNull(),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||||
updatedAt: timestamp("updated_at").notNull().defaultNow()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const holidays = pgTable("holidays", {
|
export const holidays = pgTable("holidays", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
date: date("date").notNull(),
|
date: text("date").notNull(),
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
isGlobal: boolean("is_global").notNull().default(true),
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
})
|
||||||
})
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { useState, useEffect } from "react"
|
import { useState, useEffect } from "react"
|
||||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
|
||||||
import { Copy, Trash2, Edit3, X, Plus, Archive, ArchiveRestore } 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"
|
||||||
|
|
||||||
@ -10,6 +10,7 @@ export default function Projects() {
|
|||||||
const [name, setName] = useState("")
|
const [name, setName] = useState("")
|
||||||
const [icon, setIcon] = useState("")
|
const [icon, setIcon] = useState("")
|
||||||
const [customerId, setCustomerId] = useState("")
|
const [customerId, setCustomerId] = useState("")
|
||||||
|
const [billingRate, setBillingRate] = useState("")
|
||||||
const [selectedIds, setSelectedIds] = useState<string[]>([])
|
const [selectedIds, setSelectedIds] = useState<string[]>([])
|
||||||
const [bulkPrefix, setBulkPrefix] = useState("")
|
const [bulkPrefix, setBulkPrefix] = useState("")
|
||||||
const [editingProject, setEditingProject] = useState<{ id: string; name: string; budget: number } | null>(null)
|
const [editingProject, setEditingProject] = useState<{ id: string; name: string; budget: number } | null>(null)
|
||||||
@ -43,13 +44,14 @@ export default function Projects() {
|
|||||||
}, [projects])
|
}, [projects])
|
||||||
|
|
||||||
const createMutation = useMutation({
|
const createMutation = useMutation({
|
||||||
mutationFn: ({ name, customerId, icon }: { name: string; customerId: string; icon: string }) =>
|
mutationFn: ({ name, customerId, icon, billingRate }: { name: string; customerId: string; icon: string; billingRate: number }) =>
|
||||||
api.createProject({ name, customerId, icon }),
|
api.createProject({ name, customerId, icon, billingRate }),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["projects"] })
|
queryClient.invalidateQueries({ queryKey: ["projects"] })
|
||||||
setName("")
|
setName("")
|
||||||
setCustomerId("")
|
setCustomerId("")
|
||||||
setIcon("")
|
setIcon("")
|
||||||
|
setBillingRate("")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -97,7 +99,8 @@ export default function Projects() {
|
|||||||
const handleSubmit = (e: React.FormEvent) => {
|
const handleSubmit = (e: React.FormEvent) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if (!name.trim() || !customerId) return
|
if (!name.trim() || !customerId) return
|
||||||
createMutation.mutate({ name, customerId, icon })
|
const rateInCents = Math.round(parseFloat(billingRate || "0") * 100)
|
||||||
|
createMutation.mutate({ name, customerId, icon, billingRate: rateInCents })
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleBulkRename = (e: React.FormEvent) => {
|
const handleBulkRename = (e: React.FormEvent) => {
|
||||||
@ -122,41 +125,33 @@ export default function Projects() {
|
|||||||
|
|
||||||
const filteredProjects = projects?.filter((p: any) =>
|
const filteredProjects = projects?.filter((p: any) =>
|
||||||
showArchived ? true : p.active !== false
|
showArchived ? true : p.active !== false
|
||||||
) || []
|
)
|
||||||
|
|
||||||
if (projectsLoading) return <div className="p-6 text-gray-500">Loading projects...</div>
|
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">
|
||||||
<div className="flex justify-between items-center mb-6">
|
<div className="flex justify-between items-center mb-6">
|
||||||
<h1 className="text-2xl font-bold">Projects</h1>
|
<h1 className="text-2xl font-bold">Projects</h1>
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex gap-2">
|
||||||
<label className="flex items-center gap-2 text-sm cursor-pointer">
|
<button
|
||||||
<input
|
onClick={() => setShowArchived(!showArchived)}
|
||||||
type="checkbox"
|
className={`px-3 py-1 text-sm rounded border ${showArchived ? 'bg-gray-200' : 'bg-white'}`}
|
||||||
checked={showArchived}
|
>
|
||||||
onChange={(e) => setShowArchived(e.target.checked)}
|
{showArchived ? <ArchiveRestore className="inline w-4 h-4 mr-1" /> : <Archive className="inline w-4 h-4 mr-1" />}
|
||||||
className="rounded border-gray-300"
|
{showArchived ? "Show Active" : "Show Archived"}
|
||||||
/>
|
</button>
|
||||||
Archivierte zeigen
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form onSubmit={handleSubmit} className="grid grid-cols-1 md:grid-cols-4 gap-4 mb-8 p-4 bg-gray-50 rounded-lg border">
|
<form onSubmit={handleSubmit} className="grid grid-cols-1 md:grid-cols-5 gap-3 mb-8 p-4 bg-gray-50 rounded-lg border">
|
||||||
<input
|
<input
|
||||||
placeholder="Project Name"
|
placeholder="Project Name"
|
||||||
value={name}
|
value={name}
|
||||||
onChange={e => setName(e.target.value)}
|
onChange={e => setName(e.target.value)}
|
||||||
className="p-2 border rounded"
|
className="p-2 border rounded"
|
||||||
/>
|
/>
|
||||||
<input
|
|
||||||
placeholder="Icon (emoji/text)"
|
|
||||||
value={icon}
|
|
||||||
onChange={e => setIcon(e.target.value)}
|
|
||||||
className="p-2 border rounded"
|
|
||||||
/>
|
|
||||||
<select
|
<select
|
||||||
value={customerId}
|
value={customerId}
|
||||||
onChange={e => setCustomerId(e.target.value)}
|
onChange={e => setCustomerId(e.target.value)}
|
||||||
@ -167,31 +162,46 @@ export default function Projects() {
|
|||||||
<option key={c.id} value={c.id}>{c.name}</option>
|
<option key={c.id} value={c.id}>{c.name}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
|
<input
|
||||||
|
placeholder="Icon (emoji)"
|
||||||
|
value={icon}
|
||||||
|
onChange={e => setIcon(e.target.value)}
|
||||||
|
className="p-2 border rounded"
|
||||||
|
/>
|
||||||
|
<div className="relative">
|
||||||
|
<Euro className="absolute left-2 top-2.5 w-4 h-4 text-gray-400" />
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
step="0.01"
|
||||||
|
placeholder="Rate/h"
|
||||||
|
value={billingRate}
|
||||||
|
onChange={e => setBillingRate(e.target.value)}
|
||||||
|
className="p-2 pl-7 border rounded w-full"
|
||||||
|
/>
|
||||||
|
</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 flex items-center justify-center gap-2 hover:bg-blue-700">
|
||||||
<Plus size={18} /> Create Project
|
<Plus className="w-4 h-4" /> Create
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{selectedIds.length > 0 && (
|
{selectedIds.length > 0 && (
|
||||||
<div className="mb-6 p-4 bg-blue-50 border border-blue-200 rounded-lg flex items-center gap-4">
|
<form onSubmit={handleBulkRename} className="flex gap-2 mb-4 p-2 bg-blue-50 border border-blue-200 rounded items-center">
|
||||||
<span className="text-sm font-medium">{selectedIds.length} selected</span>
|
<span className="text-sm text-blue-700 mr-2">{selectedIds.length} selected</span>
|
||||||
<form onSubmit={handleBulkRename} className="flex gap-2">
|
<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 text-sm border rounded"
|
/>
|
||||||
/>
|
<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>
|
|
||||||
</form>
|
|
||||||
<button
|
<button
|
||||||
onClick={() => { if(confirm("Delete selected?")) bulkDeleteMutation.mutate(selectedIds) }}
|
type="button"
|
||||||
className="text-sm bg-red-600 text-white px-3 py-1 rounded hover:bg-red-700"
|
onClick={() => bulkDeleteMutation.mutate(selectedIds)}
|
||||||
|
className="text-sm bg-red-600 text-white px-3 py-1 rounded"
|
||||||
>
|
>
|
||||||
Delete
|
Delete Selected
|
||||||
</button>
|
</button>
|
||||||
<button onClick={() => setSelectedIds([]) className="text-gray-500 hover:text-gray-700"><X size={18} /></button>
|
</form>
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="overflow-x-auto">
|
<div className="overflow-x-auto">
|
||||||
@ -199,76 +209,76 @@ 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 && filteredProjects.length > 0} />
|
<input type="checkbox" onChange={toggleSelectAll} checked={selectedIds.length === (filteredProjects?.length || 0)} />
|
||||||
</th>
|
</th>
|
||||||
<th className="p-2">Project</th>
|
<th className="p-2">Project</th>
|
||||||
<th className="p-2">Budget</th>
|
<th className="p-2">Customer</th>
|
||||||
|
<th className="p-2">Rate</th>
|
||||||
<th className="p-2 text-right">Actions</th>
|
<th className="p-2 text-right">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{filteredProjects.map((project: any) => (
|
{filteredProjects?.map((p: any) => (
|
||||||
<tr
|
<tr key={p.id} className={`border-b hover:bg-gray-50 ${!p.active ? 'opacity-50 italic' : ''}`}>
|
||||||
key={project.id}
|
|
||||||
className={`border-b hover:bg-gray-50 transition-opacity ${project.active === false ? 'opacity-50' : ''}`}
|
|
||||||
>
|
|
||||||
<td className="p-2">
|
<td className="p-2">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={selectedIds.includes(project.id)}
|
checked={selectedIds.includes(p.id)}
|
||||||
onChange={() => toggleSelect(project.id)}
|
onChange={() => toggleSelect(p.id)}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td className="p-2">
|
<td className="p-2">
|
||||||
<div className="flex items-center gap-2">
|
<span className="mr-2">{p.icon}</span>
|
||||||
<span className="text-lg">{project.icon || "📁"}</span>
|
{p.name}
|
||||||
<span className="font-medium">{project.name}</span>
|
|
||||||
{project.active === false && <span className="text-xs bg-gray-200 px-1 rounded text-gray-600">Archived</span>}
|
|
||||||
</div>
|
|
||||||
</td>
|
</td>
|
||||||
<td className="p-2">
|
<td className="p-2 text-gray-600">{p.customer?.name}</td>
|
||||||
{editingProject?.id === project.id ? (
|
<td className="p-2 font-mono">
|
||||||
<input
|
{p.billingRate ? `${(p.billingRate / 100).toFixed(2)} €` : '-'}
|
||||||
type="number"
|
|
||||||
value={editingProject.budget}
|
|
||||||
onChange={e => setEditingProject({...editingProject, budget: parseFloat(e.target.value)})}
|
|
||||||
className="p-1 border rounded w-24"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
`${project.budget || 0}h`
|
|
||||||
)}
|
|
||||||
</td>
|
</td>
|
||||||
<td className="p-2 text-right">
|
<td className="p-2 text-right flex justify-end gap-2">
|
||||||
<div className="flex justify-end gap-2">
|
<button onClick={() => cloneMutation.mutate(p.id)} title="Clone" className="p-1 hover:text-blue-600"><Copy className="w-4 h-4" /></button>
|
||||||
<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>
|
||||||
onClick={() => editingProject?.id === project.id
|
<button onClick={() => deleteMutation.mutate(p.id)} title="Delete" className="p-1 hover:text-red-600"><Trash2 className="w-4 h-4" /></button>
|
||||||
? updateMutation.mutate({ id: project.id, data: { budget: editingProject.budget } })
|
|
||||||
: setEditingProject({ id: project.id, name: project.name, budget: project.budget || 0 })
|
|
||||||
}
|
|
||||||
className="p-1 text-gray-600 hover:text-blue-600"
|
|
||||||
>
|
|
||||||
{editingProject?.id === project.id ? <X size={16} /> : <Edit3 size={16} />}
|
|
||||||
</button>
|
|
||||||
<button onClick={() => cloneMutation.mutate(project.id)} className="p-1 text-gray-600 hover:text-blue-600">
|
|
||||||
<Copy size={16} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => updateMutation.mutate({ id: project.id, data: { active: project.active === false } })}
|
|
||||||
className="p-1 text-gray-600 hover:text-orange-600"
|
|
||||||
title={project.active === false ? "Restore" : "Archive"}
|
|
||||||
>
|
|
||||||
{project.active === false ? <ArchiveRestore size={16} /> : <Archive size={16} />}
|
|
||||||
</button>
|
|
||||||
<button onClick={() => { if(confirm("Delete?")) deleteMutation.mutate(project.id) }} className="p-1 text-gray-600 hover:text-red-600">
|
|
||||||
<Trash2 size={16} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{editingProject && (
|
||||||
|
<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">
|
||||||
|
<button onClick={() => setEditingProject(null)} className="absolute top-4 right-4"><X className="w-5 h-5" /></button>
|
||||||
|
<h2 className="text-xl font-bold mb-4">Edit Project</h2>
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm mb-1">Name</label>
|
||||||
|
<input
|
||||||
|
className="w-full p-2 border rounded"
|
||||||
|
value={editingProject.name}
|
||||||
|
onChange={e => setEditingProject({...editingProject, name: e.target.value})}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm mb-1">Budget (Hours)</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
className="w-full p-2 border rounded"
|
||||||
|
value={editingProject.budget}
|
||||||
|
onChange={e => setEditingProject({...editingProject, budget: parseFloat(e.target.value)})}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={() => updateMutation.mutate({ id: editingProject.id, data: { name: editingProject.name, budget: editingProject.budget } })}
|
||||||
|
className="w-full bg-blue-600 text-white p-2 rounded"
|
||||||
|
>
|
||||||
|
Save Changes
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user