UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

50 lines (48 loc) 1.33 kB
import { useAppStore } from "./chunk-C2KAIQ4I.mjs"; // src/hooks/useSupportFeatureFlag.ts import { useEffect, useState } from "react"; var useSupportFeatureFlag = (config) => { const [supportType, setSupportType] = useState( "NATIVE" /* NATIVE */ ); const [loading, setLoading] = useState(true); const { institutionId } = useAppStore(); useEffect(() => { if (!institutionId) { setLoading(false); return; } const fetchSupportFlag = async () => { try { const { data: response } = await config.apiClient.get(`/featureFlags/institution/${institutionId}/page/SUPPORT`); const type = response?.data?.featureFlags?.version?.supportType; if (type) { setSupportType(type); } } catch { setSupportType("NATIVE" /* NATIVE */); } finally { setLoading(false); } }; fetchSupportFlag(); }, [institutionId]); const openZendeskChat = () => { if (typeof globalThis !== "undefined" && globalThis.zE) { globalThis.zE("messenger", "open"); } }; return { supportType, loading, isZendesk: supportType === "ZENDESK" /* ZENDESK */, isNative: supportType === "NATIVE" /* NATIVE */, openZendeskChat }; }; export { useSupportFeatureFlag }; //# sourceMappingURL=chunk-KLC43OD7.mjs.map