fix: contacts not loading in deal on first load

This commit is contained in:
Shariq Ansari 2024-07-26 20:57:45 +05:30
parent 24d335d8c7
commit 244f1b85cc

View File

@ -174,8 +174,8 @@
<span>{{ __('Loading...') }}</span> <span>{{ __('Loading...') }}</span>
</div> </div>
<div <div
v-else-if="section.contacts.length" v-else-if="deal_contacts?.data?.length"
v-for="(contact, i) in section.contacts" v-for="(contact, i) in deal_contacts.data"
:key="contact.name" :key="contact.name"
> >
<div <div
@ -251,7 +251,7 @@
</Section> </Section>
</div> </div>
<div <div
v-if="i != section.contacts.length - 1" v-if="i != deal_contacts.data.length - 1"
class="mx-2 h-px border-t border-gray-200" class="mx-2 h-px border-t border-gray-200"
/> />
</div> </div>
@ -603,22 +603,11 @@ const deal_contacts = createResource({
params: { name: props.dealId }, params: { name: props.dealId },
cache: ['deal_contacts', props.dealId], cache: ['deal_contacts', props.dealId],
auto: true, auto: true,
onSuccess: (data) => { transform: (data) => {
let contactSection = fieldsLayout.data?.find( data.forEach((contact) => {
(section) => section.name == 'contacts_section', contact.opened = false
)
if (!contactSection) return
contactSection.contacts = data.map((contact) => {
return {
name: contact.name,
full_name: contact.full_name,
email: contact.email,
mobile_no: contact.mobile_no,
image: contact.image,
is_primary: contact.is_primary,
opened: false,
}
}) })
return data
}, },
}) })