fix: fetch side panel sections & deal contacts if not already fetched

This commit is contained in:
Shariq Ansari 2025-03-15 14:46:48 +05:30
parent 46776b4a4b
commit 5c5b2cdce1

View File

@ -564,10 +564,11 @@ const sections = createResource({
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_sidepanel_sections',
cache: ['sidePanelSections', 'CRM Deal'],
params: { doctype: 'CRM Deal' },
auto: true,
transform: (data) => getParsedSections(data),
})
if (!sections.data) sections.fetch()
function getParsedSections(_sections) {
_sections.forEach((section) => {
if (section.name == 'contacts_section') return
@ -670,7 +671,6 @@ const dealContacts = createResource({
url: 'crm.fcrm.doctype.crm_deal.api.get_deal_contacts',
params: { name: props.dealId },
cache: ['deal_contacts', props.dealId],
auto: true,
transform: (data) => {
data.forEach((contact) => {
contact.opened = false
@ -679,6 +679,8 @@ const dealContacts = createResource({
},
})
if (!dealContacts.data) dealContacts.fetch()
function triggerCall() {
let primaryContact = dealContacts.data?.find((c) => c.is_primary)
let mobile_no = primaryContact.mobile_no || null