refactor(arch): eliminate direct service calls in components — route all through hooks
New hook files: - useAuth.ts: useLogin, useSwitchDemoRole, useSwitchOrganization - useAI.ts: useParseNeed, useGenerateOfferEmail, useGenerateDecisionBrief, useParseListingText - useAssistant.ts: useAssistantSuggestions (useQuery), useAssistantAnswer (useMutation) - useOfferReport.ts: useOfferReportByInquiry, useCreateOfferReport, useUpdateOfferReport, useGenerateOfferReportPdf - useInquiryReport.ts: useInquiryReportByInquiry, useCreateInquiryReport, useUpdateInquiryReport, useFinalizeInquiryReport - useMarketReport.ts: useMarketReport - useWeighting.ts: useDefaultWeights (synchronous wrapper) - useUnitMatches.ts: useUnitMatchesMap, useUnitBundle, useBundleMatches (useMemo wrappers) Extended hooks: useProperties (add update/create/remove mutations), useNeeds (add useCreateNeed), useMatches (add useNeedMatchesForProperty, useAdditionalMatchesForInquiry), useReviewQueue (add useCreateReviewTask) Updated 21 components/pages: all direct service imports replaced with hooks. Deliberate exception: getRecommendedActions in DataQuality.tsx (pure sync utility, no provider access). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -54,3 +54,24 @@ export function useMatchDetail(id: string) {
|
||||
select: (res) => res.data ?? null,
|
||||
})
|
||||
}
|
||||
|
||||
export function useNeedMatchesForProperty(propertyId: string, opts?: { minScore?: number }) {
|
||||
return useQuery({
|
||||
queryKey: ['need-matches-for-property', propertyId, opts ?? {}],
|
||||
queryFn: () => matchService.getNeedMatchesForProperty(propertyId, opts),
|
||||
staleTime: STALE_MATCHES,
|
||||
enabled: Boolean(propertyId),
|
||||
})
|
||||
}
|
||||
|
||||
export function useAdditionalMatchesForInquiry(
|
||||
inquiryId: string | null,
|
||||
opts?: { minScore?: number; excludePropertyId?: string },
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: ['additional-matches-for-inquiry', inquiryId, opts ?? {}],
|
||||
queryFn: () => matchService.getAdditionalMatchesForInquiry(inquiryId!, opts),
|
||||
staleTime: STALE_MATCHES,
|
||||
enabled: !!inquiryId,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user