fix: added integrations section and show settings if installed
This commit is contained in:
parent
e99d6ecaa5
commit
852d398461
@ -96,6 +96,12 @@ def is_whatsapp_enabled():
|
|||||||
return False
|
return False
|
||||||
return frappe.get_cached_value("WhatsApp Settings", "WhatsApp Settings", "enabled")
|
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()
|
@frappe.whitelist()
|
||||||
def get_whatsapp_messages(reference_doctype, reference_name):
|
def get_whatsapp_messages(reference_doctype, reference_name):
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
<h1 class="px-2 pt-2 text-lg font-semibold">
|
<h1 class="px-2 pt-2 text-lg font-semibold">
|
||||||
{{ __('Settings') }}
|
{{ __('Settings') }}
|
||||||
</h1>
|
</h1>
|
||||||
<div class="mt-3 space-y-1">
|
<nav class="mt-3 space-y-1">
|
||||||
<SidebarLink
|
<SidebarLink
|
||||||
v-for="tab in tabs"
|
v-for="tab in tabs"
|
||||||
:icon="tab.icon"
|
:icon="tab.icon"
|
||||||
@ -19,7 +19,26 @@
|
|||||||
"
|
"
|
||||||
@click="activeTab = tab"
|
@click="activeTab = tab"
|
||||||
/>
|
/>
|
||||||
|
</nav>
|
||||||
|
<div
|
||||||
|
class="mb-2 mt-3 flex cursor-pointer gap-1.5 px-1 text-base font-medium text-gray-600 transition-all duration-300 ease-in-out"
|
||||||
|
>
|
||||||
|
<span>{{ __('Integrations') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<nav class="space-y-1">
|
||||||
|
<SidebarLink
|
||||||
|
v-for="i in integrations"
|
||||||
|
:icon="i.icon"
|
||||||
|
:label="__(i.label)"
|
||||||
|
class="w-full"
|
||||||
|
:class="
|
||||||
|
activeTab?.label == i.label
|
||||||
|
? 'bg-white shadow-sm'
|
||||||
|
: 'hover:bg-gray-100'
|
||||||
|
"
|
||||||
|
@click="activeTab = i"
|
||||||
|
/>
|
||||||
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-1 flex-col overflow-y-auto p-12 pt-10">
|
<div class="flex flex-1 flex-col overflow-y-auto p-12 pt-10">
|
||||||
<component :is="activeTab.component" v-if="activeTab" />
|
<component :is="activeTab.component" v-if="activeTab" />
|
||||||
@ -29,13 +48,15 @@
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, markRaw } from 'vue'
|
|
||||||
import { Dialog } from 'frappe-ui'
|
|
||||||
import SidebarLink from '@/components/SidebarLink.vue'
|
|
||||||
import ProfileSettings from '@/components/Settings/ProfileSettings.vue'
|
|
||||||
import AgentSettings from '@/components/Settings/AgentSettings.vue'
|
|
||||||
import LeadsIcon from '@/components/Icons/LeadsIcon.vue'
|
|
||||||
import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
|
import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
|
||||||
|
import WhatsAppIcon from '@/components/Icons/WhatsAppIcon.vue'
|
||||||
|
import ProfileSettings from '@/components/Settings/ProfileSettings.vue'
|
||||||
|
import WhatsAppSettings from '@/components/Settings/WhatsAppSettings.vue'
|
||||||
|
import TwilioSettings from '@/components/Settings/TwilioSettings.vue'
|
||||||
|
import SidebarLink from '@/components/SidebarLink.vue'
|
||||||
|
import { isWhatsappInstalled } from '@/composables/settings'
|
||||||
|
import { Dialog, FeatherIcon } from 'frappe-ui'
|
||||||
|
import { ref, markRaw, h, computed } from 'vue'
|
||||||
|
|
||||||
const show = defineModel()
|
const show = defineModel()
|
||||||
|
|
||||||
@ -45,12 +66,27 @@ let tabs = [
|
|||||||
icon: ContactsIcon,
|
icon: ContactsIcon,
|
||||||
component: markRaw(ProfileSettings),
|
component: markRaw(ProfileSettings),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: 'Agents',
|
|
||||||
icon: LeadsIcon,
|
|
||||||
component: markRaw(AgentSettings),
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
let integrations = computed(() => {
|
||||||
|
let items = [
|
||||||
|
{
|
||||||
|
label: 'Twilio',
|
||||||
|
icon: h(FeatherIcon, { name: 'phone' }),
|
||||||
|
component: markRaw(TwilioSettings),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
if (isWhatsappInstalled.value) {
|
||||||
|
items.push({
|
||||||
|
label: 'WhatsApp',
|
||||||
|
icon: WhatsAppIcon,
|
||||||
|
component: markRaw(WhatsAppSettings),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return items
|
||||||
|
})
|
||||||
|
|
||||||
const activeTab = ref(tabs[0])
|
const activeTab = ref(tabs[0])
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
<template>
|
<template>
|
||||||
Agent Settings
|
Twilio Settings
|
||||||
</template>
|
</template>
|
||||||
3
frontend/src/components/Settings/WhatsAppSettings.vue
Normal file
3
frontend/src/components/Settings/WhatsAppSettings.vue
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<template>
|
||||||
|
WhatsApp Settings
|
||||||
|
</template>
|
||||||
@ -2,6 +2,7 @@ import { createResource } from 'frappe-ui'
|
|||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
export const whatsappEnabled = ref(false)
|
export const whatsappEnabled = ref(false)
|
||||||
|
export const isWhatsappInstalled = ref(false)
|
||||||
createResource({
|
createResource({
|
||||||
url: 'crm.api.whatsapp.is_whatsapp_enabled',
|
url: 'crm.api.whatsapp.is_whatsapp_enabled',
|
||||||
cache: 'Is Whatsapp Enabled',
|
cache: 'Is Whatsapp Enabled',
|
||||||
@ -10,6 +11,15 @@ createResource({
|
|||||||
whatsappEnabled.value = Boolean(data)
|
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)
|
export const callEnabled = ref(false)
|
||||||
createResource({
|
createResource({
|
||||||
url: 'crm.integrations.twilio.api.is_enabled',
|
url: 'crm.integrations.twilio.api.is_enabled',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user