fix: make call from deal doesn't work if contact is updated

This commit is contained in:
Shariq Ansari 2024-03-18 16:38:40 +05:30
parent 7b8a15d224
commit 080c07b22b
3 changed files with 23 additions and 24 deletions

View File

@ -60,7 +60,10 @@
</div>
</Tooltip>
<div class="flex items-center gap-2 text-base text-gray-700">
<div v-if="contact.data.email_id" class="flex items-center gap-1.5">
<div
v-if="contact.data.email_id"
class="flex items-center gap-1.5"
>
<EmailIcon class="h-4 w-4" />
<span class="">{{ contact.data.email_id }}</span>
</div>
@ -93,7 +96,8 @@
size="xs"
:label="contact.data.company_name"
:image="
getOrganization(contact.data.company_name)?.organization_logo
getOrganization(contact.data.company_name)
?.organization_logo
"
/>
<span class="">{{ contact.data.company_name }}</span>
@ -106,7 +110,9 @@
</span>
<Button
v-if="
contact.data.email_id || contact.data.mobile_no || contact.data.company_name
contact.data.email_id ||
contact.data.mobile_no ||
contact.data.company_name
"
variant="ghost"
label="More"

View File

@ -70,15 +70,7 @@
</Tooltip>
<div class="flex gap-1.5">
<Tooltip text="Make a call...">
<Button
class="h-7 w-7"
@click="
() =>
deal.data.mobile_no
? makeCall(deal.data.mobile_no)
: errorMessage('No mobile number set')
"
>
<Button class="h-7 w-7" @click="triggerCall">
<PhoneIcon class="h-4 w-4" />
</Button>
</Tooltip>
@ -563,6 +555,18 @@ async function setPrimaryContact(contact) {
}
}
function triggerCall() {
let primaryContact = deal.data.contacts.find((c) => c.is_primary)
let contact = primaryContact
? getContactByName(primaryContact.contact)
: deal.data.contacts[0]
? getContactByName(deal.data.contacts[0].contact)
: null
primaryContact
? makeCall(contact.mobile_no)
: errorMessage('No primary contact set')
}
function updateField(name, value, callback) {
updateDeal(name, value, () => {
deal.data[name] = value

View File

@ -1,6 +1,6 @@
import { defineStore } from 'pinia'
import { createResource } from 'frappe-ui'
import { reactive, computed } from 'vue'
import { reactive } from 'vue'
export const organizationsStore = defineStore('crm-organizations', () => {
let organizationsByName = reactive({})
@ -27,19 +27,8 @@ export const organizationsStore = defineStore('crm-organizations', () => {
return organizationsByName[name]
}
function getOrganizationOptions() {
return [
{ label: '---', value: '' },
...organizations.data?.map((org) => ({
label: org.name,
value: org.name,
})),
]
}
return {
organizations,
getOrganizationOptions,
getOrganization,
}
})