1
0
forked from test/crm

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

View File

@ -70,15 +70,7 @@
</Tooltip> </Tooltip>
<div class="flex gap-1.5"> <div class="flex gap-1.5">
<Tooltip text="Make a call..."> <Tooltip text="Make a call...">
<Button <Button class="h-7 w-7" @click="triggerCall">
class="h-7 w-7"
@click="
() =>
deal.data.mobile_no
? makeCall(deal.data.mobile_no)
: errorMessage('No mobile number set')
"
>
<PhoneIcon class="h-4 w-4" /> <PhoneIcon class="h-4 w-4" />
</Button> </Button>
</Tooltip> </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) { function updateField(name, value, callback) {
updateDeal(name, value, () => { updateDeal(name, value, () => {
deal.data[name] = value deal.data[name] = value

View File

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