Skip to content

Commit

Permalink
fix: removed organization store from lead/deal page
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik committed Sep 17, 2024
1 parent b1bfeca commit cc15309
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 40 deletions.
37 changes: 20 additions & 17 deletions frontend/src/pages/Deal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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()
Expand All @@ -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,
Expand All @@ -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({
Expand All @@ -412,7 +416,10 @@ onMounted(() => {
})
})
if (deal.data) return
if (deal.data) {
organization.data = deal.data._organizationObj
return
}
deal.fetch()
})
Expand All @@ -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
Expand Down Expand Up @@ -498,15 +501,15 @@ 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
})
usePageMeta(() => {
return {
title: organization.value?.name || deal.data?.name,
title: organization.data?.name || deal.data?.name,
}
})
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/pages/Lead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
Expand Down Expand Up @@ -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 } })
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/pages/Leads.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
Expand Down Expand Up @@ -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,
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/pages/MobileDeal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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()
Expand All @@ -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,
Expand All @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/pages/MobileLead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down Expand Up @@ -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 } })
Expand Down

0 comments on commit cc15309

Please sign in to comment.