TorbatYar/frontend/modules/communication/hooks/useCommunicationCapabilities.ts
Mortezakoohjani 10c3c43a75 feat(communication): add SMS MVP frontend with governance artifacts.
Ship the full Communication portal (real SMS API, feature-locked future channels), BFF proxy, docs, snapshot, and phase handover.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 11:11:25 +03:30

62 lines
1.6 KiB
TypeScript

"use client";
import { useQuery } from "@tanstack/react-query";
import {
communicationApi,
normalizeCapabilities,
} from "@/modules/communication/services/communication-api";
export function useCommunicationCapabilities() {
return useQuery({
queryKey: ["communication", "capabilities"],
queryFn: async () => normalizeCapabilities(await communicationApi.capabilities()),
staleTime: 60_000,
});
}
export function useCommunicationHealth() {
return useQuery({
queryKey: ["communication", "health"],
queryFn: () => communicationApi.health(),
});
}
export function useCommunicationHealthReady() {
return useQuery({
queryKey: ["communication", "health-ready"],
queryFn: () => communicationApi.healthReady(),
});
}
export function useCommunicationMetrics() {
return useQuery({
queryKey: ["communication", "metrics"],
queryFn: () => communicationApi.metrics(),
staleTime: 30_000,
});
}
export function useCommunicationMonitoring(tenantId: string | null) {
return useQuery({
queryKey: ["communication", tenantId, "monitoring-stats"],
queryFn: () => communicationApi.monitoring.stats(tenantId!),
enabled: !!tenantId,
staleTime: 15_000,
});
}
export function useCommunicationLookups(_tenantId: string | null) {
return {
isLoading: false,
data: { providers: [] as Record<string, unknown>[] },
};
}
export function isFeatureEnabled(
features: Record<string, boolean> | undefined,
feature: string
): boolean {
if (!features) return false;
return features[feature] === true;
}