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