e36c5bc979
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>
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { useQuery, useMutation } from '@tanstack/react-query'
|
|
import { inquiryReportService } from '../services/inquiryReportService'
|
|
import type { InquiryPreparationReportDraft } from '../domain/inquiryReport'
|
|
|
|
export function useInquiryReportByInquiry(inquiryId: string | null) {
|
|
return useQuery({
|
|
queryKey: ['inquiry-report', inquiryId],
|
|
queryFn: () => inquiryReportService.getByInquiry(inquiryId!),
|
|
enabled: !!inquiryId,
|
|
})
|
|
}
|
|
|
|
export function useCreateInquiryReport() {
|
|
return useMutation({
|
|
mutationFn: ({
|
|
inquiryId,
|
|
selectedPropertyIds,
|
|
}: {
|
|
inquiryId: string
|
|
selectedPropertyIds: string[]
|
|
}) => inquiryReportService.create(inquiryId, selectedPropertyIds),
|
|
})
|
|
}
|
|
|
|
export function useUpdateInquiryReport() {
|
|
return useMutation({
|
|
mutationFn: ({
|
|
draftId,
|
|
data,
|
|
}: {
|
|
draftId: string
|
|
data: Partial<InquiryPreparationReportDraft>
|
|
}) => inquiryReportService.update(draftId, data),
|
|
})
|
|
}
|
|
|
|
export function useFinalizeInquiryReport() {
|
|
return useMutation({
|
|
mutationFn: (draftId: string) => inquiryReportService.finalize(draftId),
|
|
})
|
|
}
|