-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Ziel
Abstraktionsschicht bauen, die den Wechsel von Mock-Daten zu Supabase ermöglicht, ohne die UI zu ändern.
Was gebaut werden soll
1. Service Interfaces (src/lib/services/types.ts)
interface AuthService {
signIn(email: string, password: string): Promise<User>
signUp(email: string, password: string, role: UserRole): Promise<User>
signOut(): Promise<void>
getCurrentUser(): Promise<User | null>
}
interface BeneficiaryService {
getAll(filters?: BeneficiaryFilters): Promise<Beneficiary[]>
getByCodeword(codeword: string): Promise<Beneficiary | null>
create(data: CreateBeneficiary): Promise<Beneficiary>
update(id: string, data: Partial<Beneficiary>): Promise<Beneficiary>
}
interface DonationService {
create(data: CreateDonation): Promise<Donation>
getForDonor(donorId: string): Promise<Donation[]>
getForBeneficiary(beneficiaryId: string): Promise<Donation[]>
}
interface PayoutService {
request(data: CreatePayout): Promise<Payout>
approve(id: string): Promise<Payout>
getForWorker(workerId: string): Promise<Payout[]>
}2. Mock Implementierung (src/lib/services/mock/)
mock-auth.ts,mock-beneficiary.ts,mock-donation.ts,mock-payout.ts- Wrappen den bestehenden Zustand-Store in die Service-Interfaces
- 1:1 gleiches Verhalten wie aktuell, nur hinter Interface
3. Service Provider (src/lib/services/index.ts)
- Factory die Mock- oder Supabase-Services liefert
- Konfiguration via Environment Variable:
NEXT_PUBLIC_BACKEND=mock|supabase - Default:
mock
4. Pages migrieren
- Dashboard, Donate, Beneficiaries → Service-Layer statt direktem Store-Zugriff
- Bestehende Funktionalität bleibt identisch
Tests
- Jedes Service-Interface: mindestens 3 Tests pro Service
- Integration: Pages funktionieren mit Mock-Service wie vorher
- Mindestens 12 neue Tests
Acceptance Criteria
- Service Interfaces definiert
- Mock-Implementierung wrapping Zustand Store
- Alle Pages nutzen Service Layer
- NEXT_PUBLIC_BACKEND=mock funktioniert identisch wie vorher
- Alle bestehenden Tests laufen noch
- Mindestens 12 neue Tests
Reactions are currently unavailable