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>
</div>
<div
v-else-if="section.contacts.length"
v-for="(contact, i) in section.contacts"
v-else-if="deal_contacts?.data?.length"
v-for="(contact, i) in deal_contacts.data"
:key="contact.name"
>
<div
@ -251,7 +251,7 @@
</Section>
</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"
/>
</div>
@ -603,22 +603,11 @@ const deal_contacts = createResource({
params: { name: props.dealId },
cache: ['deal_contacts', props.dealId],
auto: true,
onSuccess: (data) => {
let contactSection = fieldsLayout.data?.find(
(section) => section.name == 'contacts_section',
)
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,
}
transform: (data) => {
data.forEach((contact) => {
contact.opened = false
})
return data
},
})