fix: MarketLeads zeigt 0 Leads — Provider liest live aus Mock-Daten
MockupFutureSignalProvider kopierte mockFutureSignals einmalig in einen store-Array beim Modulload. Vite HMR und React Query Cache (staleTime 5min) führten dazu, dass signalDirection-Feld in gecachten Resultaten fehlte. Lösung: Provider liest jetzt immer direkt aus dem lebenden mockFutureSignals- Import via resolve()-Helper. Mutationen (verify, updateStatus) werden in einer Map gespeichert und beim Lesen überlagert. Damit sind HMR-Änderungen an Mock-Daten sofort sichtbar ohne Browser-Neustart. Ausserdem: irreführenden CircularProgress aus Empty-State entfernt. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Chip,
|
Chip,
|
||||||
CircularProgress,
|
|
||||||
Divider,
|
Divider,
|
||||||
Paper,
|
Paper,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
@@ -283,8 +282,8 @@ export default function MarketLeads() {
|
|||||||
</>
|
</>
|
||||||
) : leads.length === 0 ? (
|
) : leads.length === 0 ? (
|
||||||
<Paper sx={{ p: 4, textAlign: 'center' }}>
|
<Paper sx={{ p: 4, textAlign: 'center' }}>
|
||||||
<CircularProgress size={24} sx={{ mb: 2, color: '#94a3b8' }} />
|
<Target size={32} color="#94a3b8" style={{ marginBottom: 12 }} />
|
||||||
<Typography variant="body1" color="text.secondary">Keine aktiven Markt-Leads gefunden.</Typography>
|
<Typography variant="body1" color="text.secondary" sx={{ mb: 0.5 }}>Keine aktiven Markt-Leads gefunden.</Typography>
|
||||||
<Typography variant="caption" color="text.disabled">Signale werden laufend aus öffentlichen Quellen erkannt.</Typography>
|
<Typography variant="caption" color="text.disabled">Signale werden laufend aus öffentlichen Quellen erkannt.</Typography>
|
||||||
</Paper>
|
</Paper>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -3,11 +3,21 @@ import type { FutureSignal } from '../domain/futureSignal'
|
|||||||
import type { ReviewStatus } from '../domain/enums'
|
import type { ReviewStatus } from '../domain/enums'
|
||||||
import { mockFutureSignals } from '../mock-data/futureSignals'
|
import { mockFutureSignals } from '../mock-data/futureSignals'
|
||||||
|
|
||||||
const store: FutureSignal[] = [...mockFutureSignals]
|
// Mutation overrides — applied on top of the live mockFutureSignals import.
|
||||||
|
// Reading directly from mockFutureSignals (not a copied store) ensures that
|
||||||
|
// Vite HMR changes to the mock data are always reflected immediately.
|
||||||
|
const mutationOverrides = new Map<string, Partial<FutureSignal>>()
|
||||||
|
|
||||||
|
function resolve(): FutureSignal[] {
|
||||||
|
return mockFutureSignals.map(s => {
|
||||||
|
const override = mutationOverrides.get(s.id)
|
||||||
|
return override ? { ...s, ...override } : s
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const MockupFutureSignalProvider: IFutureSignalProvider = {
|
export const MockupFutureSignalProvider: IFutureSignalProvider = {
|
||||||
async getAll(filters?: FutureSignalFilters) {
|
async getAll(filters?: FutureSignalFilters) {
|
||||||
let results = [...store]
|
let results = resolve()
|
||||||
if (filters?.signalType) results = results.filter(s => s.signalType === filters.signalType)
|
if (filters?.signalType) results = results.filter(s => s.signalType === filters.signalType)
|
||||||
if (filters?.minProbability !== undefined) results = results.filter(s => s.probability >= filters.minProbability!)
|
if (filters?.minProbability !== undefined) results = results.filter(s => s.probability >= filters.minProbability!)
|
||||||
if (filters?.organizationId) results = results.filter(s => s.organizationId === filters.organizationId)
|
if (filters?.organizationId) results = results.filter(s => s.organizationId === filters.organizationId)
|
||||||
@@ -18,19 +28,19 @@ export const MockupFutureSignalProvider: IFutureSignalProvider = {
|
|||||||
return results.sort((a, b) => b.probability - a.probability)
|
return results.sort((a, b) => b.probability - a.probability)
|
||||||
},
|
},
|
||||||
async getById(id) {
|
async getById(id) {
|
||||||
return store.find(s => s.id === id) ?? null
|
return resolve().find(s => s.id === id) ?? null
|
||||||
},
|
},
|
||||||
async getByProperty(propertyId) {
|
async getByProperty(propertyId) {
|
||||||
return store.filter(s => s.propertyId === propertyId)
|
return resolve().filter(s => s.propertyId === propertyId)
|
||||||
},
|
},
|
||||||
async verify(id, verifiedBy) {
|
async verify(id, verifiedBy) {
|
||||||
const idx = store.findIndex(s => s.id === id)
|
const existing = mutationOverrides.get(id) ?? {}
|
||||||
store[idx] = { ...store[idx], isVerified: true, verifiedBy, verifiedAt: new Date().toISOString(), updatedAt: new Date().toISOString() }
|
mutationOverrides.set(id, { ...existing, isVerified: true, verifiedBy, verifiedAt: new Date().toISOString(), updatedAt: new Date().toISOString() })
|
||||||
return store[idx]
|
return resolve().find(s => s.id === id)!
|
||||||
},
|
},
|
||||||
async updateReviewStatus(id, status: ReviewStatus) {
|
async updateReviewStatus(id, status: ReviewStatus) {
|
||||||
const idx = store.findIndex(s => s.id === id)
|
const existing = mutationOverrides.get(id) ?? {}
|
||||||
store[idx] = { ...store[idx], reviewStatus: status, updatedAt: new Date().toISOString() }
|
mutationOverrides.set(id, { ...existing, reviewStatus: status, updatedAt: new Date().toISOString() })
|
||||||
return store[idx]
|
return resolve().find(s => s.id === id)!
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user