Initial commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import type { ListResponse, ItemResponse } from './types'
|
||||
|
||||
export type ActivityEventType =
|
||||
| 'PROPERTY_CREATED'
|
||||
| 'PROPERTY_UPDATED'
|
||||
| 'MATCH_APPROVED'
|
||||
| 'MATCH_REJECTED'
|
||||
| 'SIGNAL_VERIFIED'
|
||||
| 'NEED_CREATED'
|
||||
| 'REVIEW_REQUESTED'
|
||||
|
||||
export interface ActivityEvent {
|
||||
id: string
|
||||
type: ActivityEventType
|
||||
entityId: string
|
||||
entityType: 'PROPERTY' | 'MATCH' | 'NEED' | 'SIGNAL'
|
||||
performedBy: string
|
||||
organizationId: string
|
||||
notes?: string
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
const mockActivityLog: ActivityEvent[] = [
|
||||
{ id: 'evt-001', type: 'PROPERTY_CREATED', entityId: 'prop-001', entityType: 'PROPERTY', performedBy: 'admin@ideal-sharing.ch', organizationId: 'org-wincasa', createdAt: '2025-01-10T08:00:00Z' },
|
||||
{ id: 'evt-002', type: 'MATCH_APPROVED', entityId: 'match-003', entityType: 'MATCH', performedBy: 'admin@ideal-sharing.ch', organizationId: 'org-wincasa', notes: 'Starker Match bestätigt', createdAt: '2025-05-10T09:00:00Z' },
|
||||
{ id: 'evt-003', type: 'SIGNAL_VERIFIED', entityId: 'signal-003', entityType: 'SIGNAL', performedBy: 'admin@ideal-sharing.ch', organizationId: 'org-wincasa', createdAt: '2025-05-05T09:00:00Z' },
|
||||
]
|
||||
|
||||
const store = [...mockActivityLog]
|
||||
|
||||
export const governanceService = {
|
||||
async getActivityLog(organizationId?: string): Promise<ListResponse<ActivityEvent>> {
|
||||
const data = organizationId ? store.filter(e => e.organizationId === organizationId) : [...store]
|
||||
return { data: data.sort((a, b) => b.createdAt.localeCompare(a.createdAt)), meta: { total: data.length, page: 1, pageSize: data.length, hasMore: false } }
|
||||
},
|
||||
async logEvent(event: Omit<ActivityEvent, 'id' | 'createdAt'>): Promise<ItemResponse<ActivityEvent>> {
|
||||
const data: ActivityEvent = { id: crypto.randomUUID(), ...event, createdAt: new Date().toISOString() }
|
||||
store.push(data)
|
||||
return { data }
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user