From 852d39846159ad1be5533b6a43b60eeb16a99b00 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 11 Jun 2024 13:08:51 +0530 Subject: [PATCH] fix: added integrations section and show settings if installed --- crm/api/whatsapp.py | 6 ++ .../src/components/Settings/SettingsModal.vue | 60 +++++++++++++++---- .../{AgentSettings.vue => TwilioSettings.vue} | 2 +- .../components/Settings/WhatsAppSettings.vue | 3 + frontend/src/composables/settings.js | 10 ++++ 5 files changed, 68 insertions(+), 13 deletions(-) rename frontend/src/components/Settings/{AgentSettings.vue => TwilioSettings.vue} (52%) create mode 100644 frontend/src/components/Settings/WhatsAppSettings.vue diff --git a/crm/api/whatsapp.py b/crm/api/whatsapp.py index d871fc90..6bbc2424 100644 --- a/crm/api/whatsapp.py +++ b/crm/api/whatsapp.py @@ -96,6 +96,12 @@ def is_whatsapp_enabled(): return False return frappe.get_cached_value("WhatsApp Settings", "WhatsApp Settings", "enabled") +@frappe.whitelist() +def is_whatsapp_installed(): + if not frappe.db.exists("DocType", "WhatsApp Settings"): + return False + return True + @frappe.whitelist() def get_whatsapp_messages(reference_doctype, reference_name): diff --git a/frontend/src/components/Settings/SettingsModal.vue b/frontend/src/components/Settings/SettingsModal.vue index 981d848c..3233b999 100644 --- a/frontend/src/components/Settings/SettingsModal.vue +++ b/frontend/src/components/Settings/SettingsModal.vue @@ -6,7 +6,7 @@

{{ __('Settings') }}

-
+ +
+ {{ __('Integrations') }}
+
@@ -29,13 +48,15 @@ diff --git a/frontend/src/components/Settings/AgentSettings.vue b/frontend/src/components/Settings/TwilioSettings.vue similarity index 52% rename from frontend/src/components/Settings/AgentSettings.vue rename to frontend/src/components/Settings/TwilioSettings.vue index 093063ee..ba955dc3 100644 --- a/frontend/src/components/Settings/AgentSettings.vue +++ b/frontend/src/components/Settings/TwilioSettings.vue @@ -1,3 +1,3 @@ \ No newline at end of file diff --git a/frontend/src/components/Settings/WhatsAppSettings.vue b/frontend/src/components/Settings/WhatsAppSettings.vue new file mode 100644 index 00000000..cd50fdb3 --- /dev/null +++ b/frontend/src/components/Settings/WhatsAppSettings.vue @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/frontend/src/composables/settings.js b/frontend/src/composables/settings.js index 1033bec8..53022bc2 100644 --- a/frontend/src/composables/settings.js +++ b/frontend/src/composables/settings.js @@ -2,6 +2,7 @@ import { createResource } from 'frappe-ui' import { computed, ref } from 'vue' export const whatsappEnabled = ref(false) +export const isWhatsappInstalled = ref(false) createResource({ url: 'crm.api.whatsapp.is_whatsapp_enabled', cache: 'Is Whatsapp Enabled', @@ -10,6 +11,15 @@ createResource({ whatsappEnabled.value = Boolean(data) }, }) +createResource({ + url: 'crm.api.whatsapp.is_whatsapp_installed', + cache: 'Is Whatsapp Installed', + auto: true, + onSuccess: (data) => { + isWhatsappInstalled.value = Boolean(data) + }, +}) + export const callEnabled = ref(false) createResource({ url: 'crm.integrations.twilio.api.is_enabled',