fix: removed organization store from lead/deal page

This commit is contained in:
Shariq Ansari 2024-09-17 12:18:47 +05:30
parent b1bfeca712
commit cc15309f9c
5 changed files with 32 additions and 40 deletions

View File

@ -59,15 +59,15 @@
<Avatar
size="3xl"
class="size-12"
:label="organization?.name || __('Untitled')"
:image="organization?.organization_logo"
:label="organization.data?.name || __('Untitled')"
:image="organization.data?.organization_logo"
/>
</div>
</Tooltip>
<div class="flex flex-col gap-2.5 truncate">
<Tooltip :text="organization?.name || __('Set an organization')">
<Tooltip :text="organization.data?.name || __('Set an organization')">
<div class="truncate text-2xl font-medium">
{{ organization?.name || __('Untitled') }}
{{ organization.data?.name || __('Untitled') }}
</div>
</Tooltip>
<div class="flex gap-1.5">
@ -275,10 +275,7 @@
v-model:organization="_organization"
:options="{
redirect: false,
afterInsert: (doc) =>
updateField('organization', doc.name, () => {
organizations.reload()
}),
afterInsert: (doc) => updateField('organization', doc.name),
}"
/>
<ContactModal
@ -342,7 +339,6 @@ import {
} from '@/utils'
import { getView } from '@/utils/view'
import { globalStore } from '@/stores/global'
import { organizationsStore } from '@/stores/organizations'
import { statusesStore } from '@/stores/statuses'
import { usersStore } from '@/stores/users'
import { whatsappEnabled, callEnabled } from '@/composables/settings'
@ -360,7 +356,6 @@ import { ref, computed, h, onMounted, onBeforeUnmount } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const { $dialog, $socket, makeCall } = globalStore()
const { organizations, getOrganization } = organizationsStore()
const { statusOptions, getDealStatus } = statusesStore()
const { isManager } = usersStore()
const route = useRoute()
@ -381,6 +376,10 @@ const deal = createResource({
params: { name: props.dealId },
cache: ['deal', props.dealId],
onSuccess: async (data) => {
organization.update({
params: { doctype: 'CRM Organization', name: data.organization },
})
organization.fetch()
let obj = {
doc: data,
$dialog,
@ -403,6 +402,11 @@ const deal = createResource({
},
})
const organization = createResource({
url: 'frappe.client.get',
onSuccess: (data) => (deal.data._organizationObj = data),
})
onMounted(() => {
$socket.on('crm_customer_created', () => {
createToast({
@ -412,7 +416,10 @@ onMounted(() => {
})
})
if (deal.data) return
if (deal.data) {
organization.data = deal.data._organizationObj
return
}
deal.fetch()
})
@ -426,10 +433,6 @@ const showAssignmentModal = ref(false)
const showSidePanelModal = ref(false)
const _organization = ref({})
const organization = computed(() => {
return deal.data?.organization && getOrganization(deal.data.organization)
})
function updateDeal(fieldname, value, callback) {
value = Array.isArray(fieldname) ? '' : value
@ -498,7 +501,7 @@ const breadcrumbs = computed(() => {
}
items.push({
label: organization.value?.name || __('Untitled'),
label: organization.data?.name || __('Untitled'),
route: { name: 'Deal', params: { dealId: deal.data.name } },
})
return items
@ -506,7 +509,7 @@ const breadcrumbs = computed(() => {
usePageMeta(() => {
return {
title: organization.value?.name || deal.data?.name,
title: organization.data?.name || deal.data?.name,
}
})

View File

@ -312,7 +312,6 @@ import {
import { getView } from '@/utils/view'
import { globalStore } from '@/stores/global'
import { contactsStore } from '@/stores/contacts'
import { organizationsStore } from '@/stores/organizations'
import { statusesStore } from '@/stores/statuses'
import { usersStore } from '@/stores/users'
import { whatsappEnabled, callEnabled } from '@/composables/settings'
@ -334,7 +333,6 @@ import { useRouter, useRoute } from 'vue-router'
const { $dialog, $socket, makeCall } = globalStore()
const { getContactByName, contacts } = contactsStore()
const { organizations } = organizationsStore()
const { statusOptions, getLeadStatus } = statusesStore()
const { isManager } = usersStore()
const route = useRoute()
@ -621,7 +619,6 @@ async function convertToDeal(updated) {
if (deal) {
capture('convert_lead_to_deal')
if (updated) {
await organizations.reload()
await contacts.reload()
}
router.push({ name: 'Deal', params: { dealId: deal } })

View File

@ -305,7 +305,6 @@ import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
import ViewControls from '@/components/ViewControls.vue'
import { globalStore } from '@/stores/global'
import { usersStore } from '@/stores/users'
import { organizationsStore } from '@/stores/organizations'
import { statusesStore } from '@/stores/statuses'
import { callEnabled } from '@/composables/settings'
import { dateFormat, dateTooltipFormat, timeAgo, formatTime } from '@/utils'
@ -315,7 +314,6 @@ import { ref, computed, reactive, h } from 'vue'
const { makeCall } = globalStore()
const { getUser } = usersStore()
const { getOrganization } = organizationsStore()
const { getLeadStatus } = statusesStore()
const route = useRoute()
@ -412,10 +410,7 @@ function parseRows(rows) {
image_label: lead.first_name,
}
} else if (row == 'organization') {
_rows[row] = {
label: lead.organization,
logo: getOrganization(lead.organization)?.organization_logo,
}
_rows[row] = lead.organization
} else if (row == 'status') {
_rows[row] = {
label: lead.status,

View File

@ -224,10 +224,7 @@
v-model:organization="_organization"
:options="{
redirect: false,
afterInsert: (doc) =>
updateField('organization', doc.name, () => {
organizations.reload()
}),
afterInsert: (doc) => updateField('organization', doc.name),
}"
/>
<ContactModal
@ -275,7 +272,6 @@ import CustomActions from '@/components/CustomActions.vue'
import { createToast, setupAssignees, setupCustomizations } from '@/utils'
import { getView } from '@/utils/view'
import { globalStore } from '@/stores/global'
import { organizationsStore } from '@/stores/organizations'
import { statusesStore } from '@/stores/statuses'
import {
whatsappEnabled,
@ -294,7 +290,6 @@ import { ref, computed, h, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const { $dialog, $socket } = globalStore()
const { organizations, getOrganization } = organizationsStore()
const { statusOptions, getDealStatus } = statusesStore()
const route = useRoute()
const router = useRouter()
@ -314,6 +309,10 @@ const deal = createResource({
params: { name: props.dealId },
cache: ['deal', props.dealId],
onSuccess: async (data) => {
organization.update({
params: { doctype: 'CRM Organization', name: data.organization },
})
organization.fetch()
let obj = {
doc: data,
$dialog,
@ -336,6 +335,11 @@ const deal = createResource({
},
})
const organization = createResource({
url: 'frappe.client.get',
onSuccess: (data) => (deal.data._organizationObj = data),
})
onMounted(() => {
if (deal.data) return
deal.fetch()
@ -346,10 +350,6 @@ const showOrganizationModal = ref(false)
const showAssignmentModal = ref(false)
const _organization = ref({})
const organization = computed(() => {
return deal.data?.organization && getOrganization(deal.data.organization)
})
function updateDeal(fieldname, value, callback) {
value = Array.isArray(fieldname) ? '' : value
@ -418,7 +418,7 @@ const breadcrumbs = computed(() => {
}
items.push({
label: organization.value?.name || __('Untitled'),
label: organization.data?.name || __('Untitled'),
route: { name: 'Deal', params: { dealId: deal.data.name } },
})
return items

View File

@ -197,7 +197,6 @@ import { createToast, setupAssignees, setupCustomizations } from '@/utils'
import { getView } from '@/utils/view'
import { globalStore } from '@/stores/global'
import { contactsStore } from '@/stores/contacts'
import { organizationsStore } from '@/stores/organizations'
import { statusesStore } from '@/stores/statuses'
import {
whatsappEnabled,
@ -217,7 +216,6 @@ import { useRouter, useRoute } from 'vue-router'
const { $dialog, $socket } = globalStore()
const { getContactByName, contacts } = contactsStore()
const { organizations } = organizationsStore()
const { statusOptions, getLeadStatus } = statusesStore()
const route = useRoute()
const router = useRouter()
@ -494,7 +492,6 @@ async function convertToDeal(updated) {
)
if (deal) {
if (updated) {
await organizations.reload()
await contacts.reload()
}
router.push({ name: 'Deal', params: { dealId: deal } })