fix: not able to redirect after creating org from lead/deal

This commit is contained in:
Shariq Ansari 2023-11-16 17:25:39 +05:30
parent e9bbd2fba7
commit c843f68738
2 changed files with 17 additions and 10 deletions

View File

@ -357,7 +357,10 @@
:organization="_organization" :organization="_organization"
:options="{ :options="{
redirect: false, redirect: false,
afterInsert: (doc) => updateField('organization', doc.name), afterInsert: (doc) =>
updateField('organization', doc.name, () => {
organizations.reload()
}),
}" }"
/> />
<ContactModal <ContactModal
@ -413,7 +416,7 @@ import { useRouter } from 'vue-router'
const { getUser } = usersStore() const { getUser } = usersStore()
const { getContactByName, contacts } = contactsStore() const { getContactByName, contacts } = contactsStore()
const { getOrganization, getOrganizationOptions } = organizationsStore() const { organizations, getOrganization } = organizationsStore()
const router = useRouter() const router = useRouter()
const props = defineProps({ const props = defineProps({
@ -648,9 +651,10 @@ const organization = computed(() => {
return getOrganization(deal.data.organization) return getOrganization(deal.data.organization)
}) })
function updateField(name, value) { function updateField(name, value, callback) {
updateDeal(name, value, () => { updateDeal(name, value, () => {
deal.data[name] = value deal.data[name] = value
callback?.()
}) })
} }
</script> </script>

View File

@ -299,7 +299,10 @@
:organization="_organization" :organization="_organization"
:options="{ :options="{
redirect: false, redirect: false,
afterInsert: (doc) => updateField('organization', doc.name), afterInsert: (doc) =>
updateField('organization', doc.name, () => {
organizations.reload()
}),
}" }"
/> />
</template> </template>
@ -347,7 +350,7 @@ import { useRouter } from 'vue-router'
const { getUser } = usersStore() const { getUser } = usersStore()
const { contacts } = contactsStore() const { contacts } = contactsStore()
const { getOrganization } = organizationsStore() const { organizations, getOrganization } = organizationsStore()
const router = useRouter() const router = useRouter()
const props = defineProps({ const props = defineProps({
@ -459,12 +462,11 @@ const detailSections = computed(() => {
showOrganizationModal.value = true showOrganizationModal.value = true
close() close()
}, },
link: () => { link: () =>
router.push({ router.push({
name: 'Organization', name: 'Organization',
params: { organizationId: organization.value?.name }, params: { organizationId: lead.data.organization },
}) }),
},
}, },
{ {
label: 'Website', label: 'Website',
@ -548,9 +550,10 @@ async function convertToDeal() {
} }
} }
function updateField(name, value) { function updateField(name, value, callback) {
updateLead(name, value, () => { updateLead(name, value, () => {
lead.data[name] = value lead.data[name] = value
callback?.()
}) })
} }
</script> </script>