Initial commit

This commit is contained in:
Benjamin Sutter
2026-05-15 00:48:18 +02:00
commit 9e827c50f9
72 changed files with 10477 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import type { INeedProvider, NeedFilters } from './INeedProvider'
import type { Need, CreateNeedInput, UpdateNeedInput } from '../domain/need'
import { mockNeeds } from '../mock-data/needs'
const store: Need[] = [...mockNeeds]
export const MockupNeedProvider: INeedProvider = {
async getAll(filters?: NeedFilters) {
let results = [...store]
if (filters?.assetType) results = results.filter(n => n.assetType === filters.assetType)
if (filters?.organizationId) results = results.filter(n => n.organizationId === filters.organizationId)
if (filters?.companyName) results = results.filter(n => n.companyName.toLowerCase().includes(filters.companyName!.toLowerCase()))
return results
},
async getById(id) {
return store.find(n => n.id === id) ?? null
},
async create(data: CreateNeedInput) {
const next: Need = { id: crypto.randomUUID(), ...data, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString() }
store.push(next)
return next
},
async update(id, data: UpdateNeedInput) {
const idx = store.findIndex(n => n.id === id)
store[idx] = { ...store[idx], ...data, updatedAt: new Date().toISOString() }
return store[idx]
},
async remove(id) {
const idx = store.findIndex(n => n.id === id)
store.splice(idx, 1)
},
}