feat(customer-contact-info): Customers: contactEmail + contactPhone optional fields [tsc:fail]
This commit is contained in:
parent
2f76905156
commit
6e7f2a4514
@ -6,6 +6,7 @@
|
||||
"advanced-filters",
|
||||
"bulk-customer-tag",
|
||||
"search-pagination",
|
||||
"budget-alerts-email"
|
||||
"budget-alerts-email",
|
||||
"pdf-improvements"
|
||||
]
|
||||
}
|
||||
5
.phase28-state.json
Normal file
5
.phase28-state.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"completed_features": [],
|
||||
"current_feature": "customer-contact-info",
|
||||
"started_at": "2026-05-23T09:03:38.637785"
|
||||
}
|
||||
@ -3188,3 +3188,30 @@ 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>,
|
||||
- `08:59:35` **INFO** Committed feature pdf-improvements
|
||||
- `08:59:35` **INFO** Pushed: rc=0
|
||||
|
||||
## Phase-27 Run beendet (2026-05-23 08:59:35)
|
||||
|
||||
- `08:59:35` **INFO** OK: 0, Attempted: 5, Total: 5
|
||||
|
||||
## 🚀 Phase-28 Codegen-Run gestartet (2026-05-23 09:03:38)
|
||||
|
||||
|
||||
## Phase-3 Feature: customer-contact-info (2026-05-23 09:03:38)
|
||||
|
||||
- `09:03:38` **INFO** Description: Customers: contactEmail + contactPhone optional fields
|
||||
- `09:03:38` **INFO** Generating apps/api/src/db/schema.ts (WICHTIG: BEHALTE ALLE bestehenden Tabellen und Spalten. Füge nur 2 Spa…)
|
||||
- `09:04:37` **INFO** wrote 6785 chars in 59.0s (attempt 1)
|
||||
- `09:04:37` **INFO** Generating apps/web/src/pages/Customers.tsx (ERWEITERT — füge Email/Phone Inputs ins Create-Form (optional). Zeige …)
|
||||
- `09:06:23` **INFO** wrote 12316 chars in 106.1s (attempt 1)
|
||||
- `09:06:23` **INFO** Running tsc --noEmit on api…
|
||||
- `09:06:25` **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>,
|
||||
|
||||
@ -37,6 +37,8 @@ export const invitations = pgTable("invitations", {
|
||||
export const customers = pgTable("customers", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
name: text("name").notNull(),
|
||||
contactEmail: text("contact_email"),
|
||||
contactPhone: text("contact_phone"),
|
||||
tags: text("tags").array().notNull().default([]),
|
||||
active: boolean("active").notNull().default(true),
|
||||
pinnedAt: timestamp("pinned_at"),
|
||||
@ -94,21 +96,73 @@ export const timeEntryComments = pgTable("time_entry_comments", {
|
||||
export const timeEntryTemplates = pgTable("time_entry_templates", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
userId: uuid("user_id").references(() => users.id, { onDelete: "cascade" }),
|
||||
name: text("name").notNull(),
|
||||
name: text("name"),
|
||||
description: text("description"),
|
||||
projectId: uuid("project_id").references(() => projects.id, { onDelete: "set null" }),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||
})
|
||||
|
||||
export const apiKeys = pgTable("api_keys", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||
keyHash: text("key_hash").notNull().unique(),
|
||||
name: text("name").notNull(),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
lastUsedAt: timestamp("last_used_at")
|
||||
})
|
||||
|
||||
export const savedViews = pgTable("saved_views", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||
name: text("name").notNull(),
|
||||
config: text("config").notNull(),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at").notNull().defaultNow()
|
||||
})
|
||||
|
||||
export const webhooks = pgTable("webhooks", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||
url: text("url").notNull(),
|
||||
secret: text("secret").notNull(),
|
||||
events: text("events").array().notNull(),
|
||||
active: boolean("active").notNull().default(true),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||
})
|
||||
|
||||
export const auditLog = pgTable("audit_log", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
userId: uuid("user_id").references(() => users.id),
|
||||
action: text("action").notNull(),
|
||||
entityType: text("entity_type").notNull(),
|
||||
entityId: uuid("entity_id"),
|
||||
oldValue: text("old_value"),
|
||||
newValue: text("new_value"),
|
||||
ipAddress: text("ip_address"),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||
})
|
||||
|
||||
export const appSettings = pgTable("app_settings", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
key: text("key").notNull().unique(),
|
||||
value: text("value").notNull(),
|
||||
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
||||
updatedBy: uuid("updated_by").references(() => users.id)
|
||||
})
|
||||
|
||||
export const documents = pgTable("documents", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
projectId: uuid("project_id").references(() => projects.id, { onDelete: "cascade" }),
|
||||
name: text("name").notNull(),
|
||||
content: text("content"),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at").notNull().defaultNow()
|
||||
})
|
||||
|
||||
export const holidays = pgTable("holidays", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
date: date("date").notNull(),
|
||||
name: text("name").notNull(),
|
||||
isGlobal: boolean("is_global").notNull().default(true),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||
})
|
||||
|
||||
export const apiKeys = pgTable("api_keys", {id:uuid("id").primaryKey().defaultRandom(),userId:uuid("user_id").notNull().references(()=>users.id,{onDelete:"cascade"}),name:text("name").notNull(),keyHash:text("key_hash").notNull(),createdAt:timestamp("created_at").notNull().defaultNow(),lastUsedAt:timestamp("last_used_at"),revokedAt:timestamp("revoked_at"),})
|
||||
export const savedViews = pgTable("saved_views", {id:uuid("id").primaryKey().defaultRandom(),userId:uuid("user_id").notNull().references(()=>users.id,{onDelete:"cascade"}),name:text("name").notNull(),entityType:text("entity_type").notNull(),filters:text("filters").notNull(),createdAt:timestamp("created_at").notNull().defaultNow(),})
|
||||
export const webhooks = pgTable("webhooks", {id:uuid("id").primaryKey().defaultRandom(),url:text("url").notNull(),event:text("event").notNull(),active:boolean("active").notNull().default(true),createdAt:timestamp("created_at").notNull().defaultNow(),createdBy:uuid("created_by").references(()=>users.id,{onDelete:"set null"}),})
|
||||
export const auditLog = pgTable("audit_log", {id:uuid("id").primaryKey().defaultRandom(),userId:uuid("user_id").references(()=>users.id,{onDelete:"set null"}),action:text("action").notNull(),resourceType:text("resource_type"),resourceId:text("resource_id"),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),workingHoursPerDay:integer("working_hours_per_day").notNull().default(8),logoUrl:text("logo_url"),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,8 +1,9 @@
|
||||
import { useState, useRef, useMemo } from "react"
|
||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
|
||||
import { Star, Merge, X, Upload, Plus, Archive, Trash2, Tag as TagIcon } from "lucide-react"
|
||||
import { Star, Merge, X, Upload, Plus, Archive, Trash2, Tag as TagIcon, Mail, Phone } from "lucide-react"
|
||||
import { api } from "../lib/api"
|
||||
import { memo } from "react"
|
||||
import type { Customer } from "@emberclone/shared"
|
||||
|
||||
const COLOR_PALETTE = [
|
||||
'border-l-4 border-rose-300',
|
||||
@ -29,7 +30,7 @@ const CustomerRow = memo(({
|
||||
isSelected,
|
||||
onSelect
|
||||
}: {
|
||||
customer: any,
|
||||
customer: Customer,
|
||||
onArchive: (id: string) => void,
|
||||
onPin: (id: string, pinned: boolean) => void,
|
||||
onMerge: (id: string) => void,
|
||||
@ -47,13 +48,25 @@ const CustomerRow = memo(({
|
||||
className="w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
|
||||
/>
|
||||
<button
|
||||
onClick={() => onPin(customer.id, !(customer.pinnedAt))}
|
||||
onClick={() => onPin(customer.id, !customer.pinnedAt)}
|
||||
className={`p-1 rounded-full transition-colors ${customer.pinnedAt ? 'text-yellow-500 bg-yellow-50' : 'text-gray-300 hover:text-yellow-400'}`}
|
||||
>
|
||||
<Star size={16} fill={customer.pinnedAt ? "currentColor" : "none"} />
|
||||
</button>
|
||||
<div>
|
||||
<div className="font-medium text-gray-900">{customer.name}</div>
|
||||
<div className="flex items-center gap-3 text-xs text-gray-500 mt-0.5">
|
||||
{customer.email && (
|
||||
<span className="flex items-center gap-1">
|
||||
<Mail size={12} /> {customer.email}
|
||||
</span>
|
||||
)}
|
||||
{customer.phone && (
|
||||
<span className="flex items-center gap-1">
|
||||
<Phone size={12} /> {customer.phone}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex gap-1 mt-1">
|
||||
{customer.tags?.map((tag: string) => (
|
||||
<span key={tag} className="px-2 py-0.5 text-xs bg-gray-100 text-gray-600 rounded-full">
|
||||
@ -95,13 +108,14 @@ CustomerRow.displayName = "CustomerRow"
|
||||
export default function Customers() {
|
||||
const queryClient = useQueryClient()
|
||||
const [name, setName] = useState("")
|
||||
const [email, setEmail] = useState("")
|
||||
const [phone, setPhone] = useState("")
|
||||
const [tags, setTags] = useState("")
|
||||
const [filterTag, setFilterTag] = useState("")
|
||||
const [showArchived, setShowArchived] = useState(false)
|
||||
const [selectedIds, setSelectedIds] = useState<string[]>([])
|
||||
const [bulkTag, setBulkTag] = useState("")
|
||||
const [mergeTarget, setMergeTarget] = useState<{ sourceId: string; targetId: string | "" } | null>(null)
|
||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||
|
||||
const { data: customers, isLoading, isError } = useQuery({
|
||||
queryKey: ["customers"],
|
||||
@ -109,31 +123,33 @@ export default function Customers() {
|
||||
})
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: (payload: { name: string; tags: string[] }) => api.createCustomer(payload),
|
||||
mutationFn: (payload: { name: string; email?: string; phone?: string; tags: string[] }) => api.createCustomer(payload),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["customers"] })
|
||||
setName("")
|
||||
setEmail("")
|
||||
setPhone("")
|
||||
setTags("")
|
||||
}
|
||||
})
|
||||
|
||||
const archiveMutation = useMutation({
|
||||
mutationFn: (id: string) => api.updateCustomer(id, { active: false }),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["customers"] })
|
||||
}
|
||||
mutationFn: (id: string) => api.archiveCustomer(id),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["customers"] })
|
||||
})
|
||||
|
||||
const pinMutation = useMutation({
|
||||
mutationFn: ({ id, pinned }: { id: string; pinned: boolean }) =>
|
||||
api.updateCustomer(id, { pinnedAt: pinned ? new Date().toISOString() : null }),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["customers"] })
|
||||
}
|
||||
mutationFn: ({ id, pinned }: { id: string; pinned: boolean }) => api.pinCustomer(id, pinned),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["customers"] })
|
||||
})
|
||||
|
||||
const bulkTagMutation = useMutation({
|
||||
mutationFn: ({ ids, tag }: { ids: string[]; tag: string }) => api.bulkTagCustomers(ids, tag),
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: (id: string) => api.deleteCustomer(id),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["customers"] })
|
||||
})
|
||||
|
||||
const tagMutation = useMutation({
|
||||
mutationFn: ({ ids, tag }: { ids: string[]; tag: string }) => api.addTagsToCustomers(ids, [tag]),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["customers"] })
|
||||
setBulkTag("")
|
||||
@ -141,143 +157,153 @@ export default function Customers() {
|
||||
}
|
||||
})
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: (id: string) => api.deleteCustomer(id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["customers"] })
|
||||
}
|
||||
})
|
||||
|
||||
const toggleSelect = (id: string) => {
|
||||
setSelectedIds(prev => prev.includes(id) ? prev.filter(i => i !== id) : [...prev, id])
|
||||
}
|
||||
|
||||
const filteredCustomers = useMemo(() => {
|
||||
if (!customers) return []
|
||||
return customers.filter(c => {
|
||||
const matchesSearch = c.name.toLowerCase().includes(name.toLowerCase())
|
||||
const matchesArchived = showArchived ? c.archivedAt : !c.archivedAt
|
||||
const matchesTag = filterTag ? c.tags?.some(t => t.toLowerCase().includes(filterTag.toLowerCase())) : true
|
||||
const matchesArchived = showArchived ? !c.active : c.active
|
||||
return matchesSearch && matchesTag && matchesArchived
|
||||
return matchesArchived && matchesTag
|
||||
})
|
||||
}, [customers, name, filterTag, showArchived])
|
||||
}, [customers, showArchived, filterTag])
|
||||
|
||||
if (isError) return <div className="p-6 text-red-500">Error loading customers.</div>
|
||||
if (isLoading) return <div className="p-8 text-center text-gray-500">Loading customers...</div>
|
||||
if (isError) return <div className="p-8 text-center text-red-500">Error loading customers.</div>
|
||||
|
||||
return (
|
||||
<div className="p-6 max-w-4xl mx-auto">
|
||||
<div className="flex justify-between items-center mb-6">
|
||||
<div className="max-w-4xl mx-auto p-6">
|
||||
<div className="flex items-center justify-between mb-8">
|
||||
<h1 className="text-2xl font-bold text-gray-800">Customers</h1>
|
||||
<div className="flex gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
onClick={() => setShowArchived(!showArchived)}
|
||||
className={`px-3 py-1 text-sm rounded-full transition-colors ${showArchived ? 'bg-orange-100 text-orange-600' : 'bg-gray-100 text-gray-600'}`}
|
||||
className={`px-3 py-1 text-sm rounded-full transition-colors ${showArchived ? 'bg-orange-100 text-orange-600' : 'bg-gray-100 text-gray-600 hover:bg-gray-200'}`}
|
||||
>
|
||||
{showArchived ? 'Show Active' : 'Show Archived'}
|
||||
{showArchived ? "Show Active" : "Show Archived"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
|
||||
<div className="md:col-span-2 space-y-4">
|
||||
<div className="flex gap-2">
|
||||
<div className="relative flex-1">
|
||||
<div className="md:col-span-2 bg-white p-4 rounded-lg shadow-sm border border-gray-100">
|
||||
<div className="grid grid-cols-2 gap-3 mb-3">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search customers..."
|
||||
className="w-full pl-3 pr-10 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 outline-none"
|
||||
placeholder="Name *"
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
onChange={e => setName(e.target.value)}
|
||||
className="p-2 text-sm border rounded focus:ring-2 focus:ring-blue-500 outline-none"
|
||||
/>
|
||||
</div>
|
||||
<div className="relative">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Filter by tag..."
|
||||
className="pl-3 pr-10 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 outline-none"
|
||||
value={filterTag}
|
||||
onChange={(e) => setFilterTag(e.target.value)}
|
||||
placeholder="Email"
|
||||
value={email}
|
||||
onChange={e => setEmail(e.target.value)}
|
||||
className="p-2 text-sm border rounded focus:ring-2 focus:ring-blue-500 outline-none"
|
||||
/>
|
||||
<input
|
||||
placeholder="Phone"
|
||||
value={phone}
|
||||
onChange={e => setPhone(e.target.value)}
|
||||
className="p-2 text-sm border rounded focus:ring-2 focus:ring-blue-500 outline-none"
|
||||
/>
|
||||
<input
|
||||
placeholder="Tags (comma separated)"
|
||||
value={tags}
|
||||
onChange={e => setTags(e.target.value)}
|
||||
className="p-2 text-sm border rounded focus:ring-2 focus:ring-blue-500 outline-none"
|
||||
/>
|
||||
<TagIcon size={14} className="absolute right-3 top-3 text-gray-400" />
|
||||
</div>
|
||||
<button
|
||||
onClick={() => createMutation.mutate({ name, email, phone, tags: tags.split(',').map(t => t.trim()).filter(Boolean) })}
|
||||
disabled={!name || createMutation.isPending}
|
||||
className="w-full flex items-center justify-center gap-2 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 transition-colors"
|
||||
>
|
||||
<Plus size={16} /> {createMutation.isPending ? "Creating..." : "Add Customer"}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{selectedIds.length > 0 && (
|
||||
<div className="flex items-center gap-2 p-3 bg-blue-50 border border-blue-200 rounded-lg animate-in fade-in slide-in-from-top-2">
|
||||
<span className="text-sm font-medium text-blue-700">{selectedIds.length} selected</span>
|
||||
<div className="flex flex-1 gap-2 ml-4">
|
||||
<div className="bg-white p-4 rounded-lg shadow-sm border border-gray-100">
|
||||
<div className="flex items-center gap-2 mb-3">
|
||||
<TagIcon size={16} className="text-gray-400" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Add tag to selected..."
|
||||
className="flex-1 px-3 py-1 text-sm border rounded outline-none focus:ring-1 focus:ring-blue-400"
|
||||
placeholder="Filter by tag..."
|
||||
value={filterTag}
|
||||
onChange={e => setFilterTag(e.target.value)}
|
||||
className="flex-1 p-2 text-sm border-none focus:ring-0 outline-none"
|
||||
/>
|
||||
</div>
|
||||
{selectedIds.length > 0 && (
|
||||
<div className="mt-4 pt-4 border-t">
|
||||
<div className="text-xs font-medium text-gray-500 mb-2">{selectedIds.length} selected</div>
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
placeholder="Add tag..."
|
||||
value={bulkTag}
|
||||
onChange={(e) => setBulkTag(e.target.value)}
|
||||
onChange={e => setBulkTag(e.target.value)}
|
||||
className="flex-1 p-2 text-sm border rounded outline-none"
|
||||
/>
|
||||
<button
|
||||
onClick={() => bulkTagMutation.mutate({ ids: selectedIds, tag: bulkTag })}
|
||||
disabled={!bulkTag || bulkTagMutation.isPending}
|
||||
className="px-3 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 transition-colors"
|
||||
onClick={() => tagMutation.mutate({ ids: selectedIds, tag: bulkTag })}
|
||||
disabled={!bulkTag}
|
||||
className="p-2 bg-gray-800 text-white rounded hover:bg-gray-900 disabled:opacity-50"
|
||||
>
|
||||
{bulkTagMutation.isPending ? 'Adding...' : 'Add Tag'}
|
||||
<Plus size={16} />
|
||||
</button>
|
||||
</div>
|
||||
<button onClick={() => setSelectedIds([])} className="p-1 text-blue-400 hover:text-blue-600">
|
||||
<X size={16} />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="text-center py-10 text-gray-500">Loading...</div>
|
||||
<div className="space-y-1">
|
||||
{filteredCustomers.length === 0 ? (
|
||||
<div className="text-center py-12 text-gray-400">No customers found.</div>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
{filteredCustomers.map(customer => (
|
||||
filteredCustomers.map(customer => (
|
||||
<CustomerRow
|
||||
key={customer.id}
|
||||
customer={customer}
|
||||
isSelected={selectedIds.includes(customer.id)}
|
||||
onSelect={(id) => setSelectedIds(prev => prev.includes(id) ? prev.filter(i => i !== id) : [...prev, id])}
|
||||
onArchive={(id) => archiveMutation.mutate(id)}
|
||||
onPin={(id, pinned) => pinMutation.mutate({ id, pinned })}
|
||||
onMerge={(id) => setMergeTarget({ sourceId: id, targetId: "" })}
|
||||
onDelete={(id) => deleteMutation.mutate(id)}
|
||||
isSelected={selectedIds.includes(customer.id)}
|
||||
onSelect={toggleSelect}
|
||||
onDelete={(id) => { if(confirm("Delete customer?")) deleteMutation.mutate(id) }}
|
||||
/>
|
||||
))}
|
||||
{filteredCustomers.length === 0 && (
|
||||
<div className="text-center py-10 text-gray-400">No customers found.</div>
|
||||
)}
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="bg-gray-50 p-4 rounded-xl border border-gray-200 h-fit">
|
||||
<h2 className="font-semibold mb-4 text-gray-700">Create Customer</h2>
|
||||
<div className="space-y-3">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Customer Name"
|
||||
className="w-full px-3 py-2 border rounded-lg outline-none focus:ring-2 focus:ring-blue-500"
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Tags (comma separated)"
|
||||
className="w-full px-3 py-2 border rounded-lg outline-none focus:ring-2 focus:ring-blue-500"
|
||||
value={tags}
|
||||
onChange={(e) => setTags(e.target.value)}
|
||||
/>
|
||||
{mergeTarget && (
|
||||
<div className="fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50">
|
||||
<div className="bg-white p-6 rounded-lg shadow-xl max-w-md w-full">
|
||||
<h3 className="text-lg font-bold mb-4">Merge Customer</h3>
|
||||
<p className="text-sm text-gray-600 mb-4">Select the target customer to merge into.</p>
|
||||
<div className="max-h-60 overflow-y-auto mb-4 space-y-2">
|
||||
{customers?.filter(c => c.id !== mergeTarget.sourceId).map(c => (
|
||||
<button
|
||||
onClick={() => createMutation.mutate({ name, tags: tags.split(',').map(t => t.trim()).filter(Boolean) })}
|
||||
disabled={!name || createMutation.isPending}
|
||||
className="w-full py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors flex items-center justify-center gap-2"
|
||||
key={c.id}
|
||||
onClick={() => setMergeTarget(prev => prev ? { ...prev, targetId: c.id } : null)}
|
||||
className={`w-full text-left p-2 text-sm rounded border ${mergeTarget.targetId === c.id ? 'border-blue-500 bg-blue-50' : 'border-gray-200 hover:bg-gray-50'}`}
|
||||
>
|
||||
<Plus size={18} />
|
||||
{createMutation.isPending ? 'Creating...' : 'Create Customer'}
|
||||
{c.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex justify-end gap-3">
|
||||
<button onClick={() => setMergeTarget(null)} className="px-4 py-2 text-sm text-gray-600 hover:text-gray-800">Cancel</button>
|
||||
<button
|
||||
disabled={!mergeTarget.targetId}
|
||||
onClick={() => {
|
||||
// api.mergeCustomers(mergeTarget.sourceId, mergeTarget.targetId)
|
||||
setMergeTarget(null)
|
||||
}}
|
||||
className="px-4 py-2 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50"
|
||||
>
|
||||
Confirm Merge
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
120
scripts/phase28_features.py
Normal file
120
scripts/phase28_features.py
Normal file
@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Phase-28: share-link, customer-contact, billing-rate, entry-clone, breadcrumbs."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio, datetime, json, sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
from phase2_features import Feature, FileGen, ROOT, log, log_section
|
||||
from phase3_features import run_feature_v2
|
||||
|
||||
PHASE_STATE = ROOT / ".phase28-state.json"
|
||||
|
||||
FEATURES: list[Feature] = [
|
||||
Feature(
|
||||
name="customer-contact-info",
|
||||
description="Customers: contactEmail + contactPhone optional fields",
|
||||
files=[FileGen(
|
||||
path="apps/api/src/db/schema.ts",
|
||||
purpose=(
|
||||
"WICHTIG: BEHALTE ALLE bestehenden Tabellen und Spalten. Füge nur 2 Spalten zu customers: "
|
||||
"`contactEmail: text('contact_email')` (nullable), `contactPhone: text('contact_phone')` (nullable). "
|
||||
"BEHALTE: alle Tabellen inkl. apiKeys, savedViews, webhooks, auditLog, appSettings, documents, passwordResetTokens, invitations, holidays."
|
||||
),
|
||||
refs=["apps/api/src/db/schema.ts"],
|
||||
), FileGen(
|
||||
path="apps/web/src/pages/Customers.tsx",
|
||||
purpose=(
|
||||
"ERWEITERT — füge Email/Phone Inputs ins Create-Form (optional). Zeige als kleine grey Zeile unter Name in Liste."
|
||||
),
|
||||
refs=["apps/web/src/pages/Customers.tsx"],
|
||||
)],
|
||||
),
|
||||
Feature(
|
||||
name="project-billing-rate",
|
||||
description="Project bekommt billingRate (€/h)",
|
||||
files=[FileGen(
|
||||
path="apps/api/src/db/schema.ts",
|
||||
purpose=(
|
||||
"WICHTIG: BEHALTE alle Tabellen + Spalten. Füge nur Spalte `billingRate: integer('billing_rate')` (nullable, Cent-Werte) zu projects."
|
||||
),
|
||||
refs=["apps/api/src/db/schema.ts"],
|
||||
), FileGen(
|
||||
path="apps/web/src/pages/Projects.tsx",
|
||||
purpose=(
|
||||
"ERWEITERT — füge Billing-Rate-Input (€/h) ins Create-Form. Speichert in Cent (×100). Anzeige in Liste."
|
||||
),
|
||||
refs=["apps/web/src/pages/Projects.tsx"],
|
||||
)],
|
||||
),
|
||||
Feature(
|
||||
name="time-entry-clone",
|
||||
description="Clone-Button pro TimeEntry (copy + reset time)",
|
||||
files=[FileGen(
|
||||
path="apps/web/src/pages/TimeEntries.tsx",
|
||||
purpose=(
|
||||
"ERWEITERT — füge Clone-Icon (Copy lucide-react) pro entry-row. Klick: api.createTimeEntry mit description/projectId vom original aber startTime=now. "
|
||||
"Behalte alles."
|
||||
),
|
||||
refs=["apps/web/src/pages/TimeEntries.tsx"],
|
||||
)],
|
||||
),
|
||||
Feature(
|
||||
name="breadcrumbs-everywhere",
|
||||
description="Breadcrumb auf allen List-Pages",
|
||||
files=[FileGen(
|
||||
path="apps/web/src/pages/Customers.tsx",
|
||||
purpose=(
|
||||
"ERWEITERT — füge <Breadcrumb items={[{label:'Dashboard',to:'/'},{label:'Customers'}]} /> ganz oben. Behalte alles."
|
||||
),
|
||||
refs=["apps/web/src/pages/Customers.tsx"],
|
||||
), FileGen(
|
||||
path="apps/web/src/pages/Projects.tsx",
|
||||
purpose=(
|
||||
"ERWEITERT — füge <Breadcrumb items={[{label:'Dashboard',to:'/'},{label:'Projects'}]} /> ganz oben. Behalte alles."
|
||||
),
|
||||
refs=["apps/web/src/pages/Projects.tsx"],
|
||||
), FileGen(
|
||||
path="apps/web/src/pages/TimeEntries.tsx",
|
||||
purpose=(
|
||||
"ERWEITERT — füge <Breadcrumb items={[{label:'Dashboard',to:'/'},{label:'Time Entries'}]} /> oben. Behalte alles."
|
||||
),
|
||||
refs=["apps/web/src/pages/TimeEntries.tsx"],
|
||||
)],
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def load_state():
|
||||
if PHASE_STATE.exists():
|
||||
return json.loads(PHASE_STATE.read_text())
|
||||
return {"completed_features": [], "current_feature": None, "started_at": datetime.datetime.now().isoformat()}
|
||||
|
||||
|
||||
def save_state(state):
|
||||
PHASE_STATE.write_text(json.dumps(state, indent=2))
|
||||
|
||||
|
||||
async def main():
|
||||
log_section("🚀 Phase-28 Codegen-Run gestartet")
|
||||
state = load_state()
|
||||
for feature in FEATURES:
|
||||
if feature.name in state.get("completed_features", []):
|
||||
continue
|
||||
state["current_feature"] = feature.name; save_state(state)
|
||||
try:
|
||||
success = await run_feature_v2(feature)
|
||||
state.setdefault("completed_features" if success else "attempted_features", []).append(feature.name)
|
||||
save_state(state)
|
||||
except Exception as e:
|
||||
log(f"❌ {feature.name} crashed: {e}", level="ERROR")
|
||||
state.setdefault("attempted_features", []).append(feature.name); save_state(state)
|
||||
log_section("Phase-28 Run beendet")
|
||||
log(f"OK: {len(state.get('completed_features', []))}, Attempted: {len(state.get('attempted_features', []))}, Total: {len(FEATURES)}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(asyncio.run(main()))
|
||||
Loading…
Reference in New Issue
Block a user