From af7d5edd80f343901df841ad21466af94def6cb4 Mon Sep 17 00:00:00 2001 From: swve Date: Sun, 14 Jan 2024 21:23:32 +0100 Subject: [PATCH] fix: AI config null check --- apps/web/components/AI/Hooks/useGetAIFeatures.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/web/components/AI/Hooks/useGetAIFeatures.tsx b/apps/web/components/AI/Hooks/useGetAIFeatures.tsx index fcd65ca0..0639aa81 100644 --- a/apps/web/components/AI/Hooks/useGetAIFeatures.tsx +++ b/apps/web/components/AI/Hooks/useGetAIFeatures.tsx @@ -11,7 +11,13 @@ function useGetAIFeatures(props: UseGetAIFeatures) { const [isEnabled, setisEnabled] = React.useState(false) function checkAvailableAIFeaturesOnOrg(feature: string) { - const config = org.config.config.AIConfig; + const config = org?.config?.config?.AIConfig; + + if (!config) { + console.log("AI or Organization config is not defined."); + return false; + } + if (!config.enabled) { console.log("AI is not enabled for this Organization."); return false;