fix: added makeCall & is twilio enabled in global store
This commit is contained in:
parent
3afef2e45b
commit
5d09a046d3
@ -183,11 +183,13 @@ import CountUpTimer from '@/components/CountUpTimer.vue'
|
||||
import NoteModal from '@/components/Modals/NoteModal.vue'
|
||||
import { Device } from '@twilio/voice-sdk'
|
||||
import { useDraggable, useWindowSize } from '@vueuse/core'
|
||||
import { globalStore } from '@/stores/global'
|
||||
import { contactsStore } from '@/stores/contacts'
|
||||
import { Avatar, call } from 'frappe-ui'
|
||||
import { onMounted, ref, watch, getCurrentInstance } from 'vue'
|
||||
import { onMounted, ref, watch } from 'vue'
|
||||
|
||||
const { getContact } = contactsStore()
|
||||
const { setMakeCall, setTwilioEnabled } = globalStore()
|
||||
|
||||
let device = ''
|
||||
let log = ref('Connecting...')
|
||||
@ -197,7 +199,6 @@ const contact = ref({
|
||||
mobile_no: '',
|
||||
})
|
||||
|
||||
let enabled = ref(false)
|
||||
let showCallPopup = ref(false)
|
||||
let showSmallCallWindow = ref(false)
|
||||
let onCall = ref(false)
|
||||
@ -475,8 +476,11 @@ function toggleCallWindow() {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
enabled.value = await is_twilio_enabled()
|
||||
enabled.value && startupClient()
|
||||
let enabled = await is_twilio_enabled()
|
||||
setTwilioEnabled(enabled)
|
||||
enabled && startupClient()
|
||||
|
||||
setMakeCall(makeOutgoingCall)
|
||||
})
|
||||
|
||||
watch(
|
||||
@ -486,10 +490,6 @@ watch(
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const app = getCurrentInstance()
|
||||
app.appContext.config.globalProperties.makeCall = makeOutgoingCall
|
||||
app.appContext.config.globalProperties.is_twilio_enabled = enabled.value
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@ -275,7 +275,7 @@ import {
|
||||
import { ref, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const { $dialog } = globalStore()
|
||||
const { $dialog, makeCall } = globalStore()
|
||||
const { getContactByName, contacts } = contactsStore()
|
||||
const { organizations } = organizationsStore()
|
||||
const { statusOptions, getLeadStatus } = statusesStore()
|
||||
|
||||
@ -1,11 +1,30 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { getCurrentInstance } from 'vue'
|
||||
import { getCurrentInstance, ref } from 'vue'
|
||||
|
||||
export const globalStore = defineStore('crm-global', () => {
|
||||
const app = getCurrentInstance()
|
||||
const { $dialog } = app.appContext.config.globalProperties
|
||||
|
||||
let twilioEnabled = ref(false)
|
||||
let callMethod = () => {}
|
||||
|
||||
function setTwilioEnabled(value) {
|
||||
twilioEnabled.value = value
|
||||
}
|
||||
|
||||
function setMakeCall(value) {
|
||||
callMethod = value
|
||||
}
|
||||
|
||||
function makeCall(number) {
|
||||
callMethod(number)
|
||||
}
|
||||
|
||||
return {
|
||||
$dialog,
|
||||
twilioEnabled,
|
||||
makeCall,
|
||||
setTwilioEnabled,
|
||||
setMakeCall,
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user