Merge branch 'worktree-agent-a5f48334696288159'

# Conflicts:
#	gerbil-manager-web/e2e/mock-data.ts
This commit is contained in:
2026-06-22 22:54:50 +02:00
16 changed files with 2360 additions and 0 deletions

View File

@@ -533,6 +533,50 @@ export async function installMockApi(page: Page): Promise<MockDb> {
return json(route, 200, db.rpro3.execute)
}
// ERWERB: Erwerb/Kauf je Tier — GET ?gerbilId= (Array, kein Gridify-Paging),
// POST/PUT/DELETE. Vor den generischen Kollektionen, weil GET kein {items}-Objekt
// liefert und nach gerbilId statt Gridify-filter selektiert.
const acqMatch = path.match(/^\/acquisitions(?:\/([^/]+))?$/)
if (acqMatch) {
const acqId = acqMatch[1] ? decodeURIComponent(acqMatch[1]) : null
if (!acqId) {
if (method === 'GET') {
const gid = url.searchParams.get('gerbilId')
const rows = db.acquisitions.filter((a) => !gid || a.gerbilId === gid)
return json(route, 200, [...rows].reverse())
}
if (method === 'POST') {
const created = {
id: newId('acq'),
sourceContactId: null,
date: null,
price: null,
note: null,
...(request.postDataJSON() as Row),
createdAt: new Date().toISOString(),
}
db.acquisitions.push(created)
return json(route, 201, created)
}
return json(route, 405)
}
const ai = db.acquisitions.findIndex((a) => a.id === acqId)
if (method === 'GET') {
return ai >= 0 ? json(route, 200, db.acquisitions[ai]) : json(route, 404, { title: 'Not Found' })
}
if (method === 'PUT') {
if (ai < 0) return json(route, 404, { title: 'Not Found' })
Object.assign(db.acquisitions[ai], request.postDataJSON() as Row)
return json(route, 204)
}
if (method === 'DELETE') {
if (ai < 0) return json(route, 404, { title: 'Not Found' })
db.acquisitions.splice(ai, 1)
return json(route, 204)
}
return json(route, 405)
}
// Generische Kollektionen: /<resource> und /<resource>/<id>
m = path.match(/^\/([a-z-]+)(?:\/([^/]+))?$/)
const col = m ? collections[m[1]] : undefined