feat(F020): frontend infrastructure foundation

- src/lib/constants.ts: centralized route paths, labels, thresholds
- src/lib/utils.ts: formatting, color helpers, math utils
- src/hooks/: useProperties, useMatches, useFutureSignals, useNeeds
- src/components/scores/MatchScoreRing
- src/components/data-quality/DataQualityBar
- src/components/future-signals/SignalTypeBadge
- src/components/cards/SourceTypeBadge
- src/provider/AuthProvider (placeholder, swappable)
- main.tsx: AuthProvider + centralized stale time

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Sutter
2026-05-15 10:50:26 +02:00
parent e20e0e9a2e
commit 3b45b0c121
17 changed files with 600 additions and 2 deletions
+4
View File
@@ -0,0 +1,4 @@
export { useProperties, useProperty } from './useProperties'
export { useMatches, useMatchesByNeed, useMatchesByProperty, useApproveMatch } from './useMatches'
export { useFutureSignals, useFutureSignalsByProperty, useVerifySignal } from './useFutureSignals'
export { useNeeds, useNeed } from './useNeeds'
+32
View File
@@ -0,0 +1,32 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { futureSignalService } from '../services/futureSignalService'
import { STALE_SIGNALS } from '../lib/constants'
export function useFutureSignals() {
return useQuery({
queryKey: ['futureSignals'],
queryFn: () => futureSignalService.getAll(),
staleTime: STALE_SIGNALS,
select: (res) => res.data ?? [],
})
}
export function useFutureSignalsByProperty(propertyId: string) {
return useQuery({
queryKey: ['futureSignals', 'property', propertyId],
queryFn: () => futureSignalService.getByProperty(propertyId),
staleTime: STALE_SIGNALS,
enabled: Boolean(propertyId),
select: (res) => res.data ?? [],
})
}
export function useVerifySignal() {
const queryClient = useQueryClient()
return useMutation({
mutationFn: (signalId: string) => futureSignalService.verify(signalId, 'current-user'),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['futureSignals'] })
},
})
}
+42
View File
@@ -0,0 +1,42 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { matchService } from '../services/matchService'
import { STALE_MATCHES } from '../lib/constants'
export function useMatches() {
return useQuery({
queryKey: ['matches'],
queryFn: () => matchService.getAll(),
staleTime: STALE_MATCHES,
select: (res) => res.data ?? [],
})
}
export function useMatchesByNeed(needId: string) {
return useQuery({
queryKey: ['matches', 'need', needId],
queryFn: () => matchService.getByNeed(needId),
staleTime: STALE_MATCHES,
enabled: Boolean(needId),
select: (res) => res.data ?? [],
})
}
export function useMatchesByProperty(propertyId: string) {
return useQuery({
queryKey: ['matches', 'property', propertyId],
queryFn: () => matchService.getByProperty(propertyId),
staleTime: STALE_MATCHES,
enabled: Boolean(propertyId),
select: (res) => res.data ?? [],
})
}
export function useApproveMatch() {
const queryClient = useQueryClient()
return useMutation({
mutationFn: (matchId: string) => matchService.approve(matchId, 'current-user'),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['matches'] })
},
})
}
+19
View File
@@ -0,0 +1,19 @@
import { useQuery } from '@tanstack/react-query'
import { needService } from '../services/needService'
export function useNeeds() {
return useQuery({
queryKey: ['needs'],
queryFn: () => needService.getAll(),
select: (res) => res.data ?? [],
})
}
export function useNeed(id: string) {
return useQuery({
queryKey: ['need', id],
queryFn: () => needService.getById(id),
enabled: Boolean(id),
select: (res) => res.data ?? null,
})
}
+32
View File
@@ -0,0 +1,32 @@
import { useQuery } from '@tanstack/react-query'
import { propertyService } from '../services/propertyService'
import type { AssetType, ResultType } from '../domain/enums'
import { STALE_PROPERTIES } from '../lib/constants'
interface PropertyFilter {
assetType?: AssetType
resultType?: ResultType
city?: string
minAreaSqm?: number
maxRentPerSqm?: number
organizationId?: string
}
export function useProperties(filter?: PropertyFilter) {
return useQuery({
queryKey: ['properties', filter ?? {}],
queryFn: () => propertyService.getAll(filter),
staleTime: STALE_PROPERTIES,
select: (res) => res.data ?? [],
})
}
export function useProperty(id: string) {
return useQuery({
queryKey: ['property', id],
queryFn: () => propertyService.getById(id),
staleTime: STALE_PROPERTIES,
enabled: Boolean(id),
select: (res) => res.data ?? null,
})
}