@@ -80,7 +76,7 @@
{
icon: 'trash-2',
label: 'Remove image',
- onClick: () => changeLeadImage(''),
+ onClick: () => updateField('image', ''),
},
],
}
@@ -254,37 +250,6 @@
/>
-
-
-
-
-
{
createToast({
@@ -459,11 +427,6 @@ const tabs = [
},
]
-function changeLeadImage(file) {
- lead.data.image = file.file_url
- updateLead('image', file.file_url)
-}
-
function validateFile(file) {
let extn = file.name.split('.').pop().toLowerCase()
if (!['png', 'jpg', 'jpeg'].includes(extn)) {
@@ -519,10 +482,7 @@ const detailSections = computed(() => {
{ label: 'Web', value: 'Web' },
{ label: 'Others', value: 'Others' },
],
- change: (data) => {
- lead.data.source = data.value
- updateLead('source', data.value)
- },
+ change: (data) => updateField('source', data.value),
},
{
label: 'Industry',
@@ -535,10 +495,7 @@ const detailSections = computed(() => {
{ label: 'Banking', value: 'Banking' },
{ label: 'Others', value: 'Others' },
],
- change: (data) => {
- lead.data.industry = data.value
- updateLead('industry', data.value)
- },
+ change: (data) => updateField('industry', data.value),
},
],
},
@@ -562,10 +519,7 @@ const detailSections = computed(() => {
{ label: 'Madam', value: 'Madam' },
{ label: 'Miss', value: 'Miss' },
],
- change: (data) => {
- lead.data.salutation = data.value
- updateLead('salutation', data.value)
- },
+ change: (data) => updateField('salutation', data.value),
},
{
label: 'First name',
@@ -597,9 +551,11 @@ const organization = computed(() => {
})
function convertToDeal() {
- lead.data.status = 'Qualified'
- lead.data.converted = 1
- createDeal(lead.data)
+ updateLead({ status: 'Qualified', converted: 1 }, '', () => {
+ lead.data.status = 'Qualified'
+ lead.data.converted = 1
+ createDeal(lead.data)
+ })
}
async function createDeal(lead) {
@@ -618,8 +574,9 @@ async function createDeal(lead) {
}
function updateField(name, value) {
- lead.data[name] = value
- updateLead(name, value)
+ updateLead(name, value, () => {
+ lead.data[name] = value
+ })
}
diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js
index 6467cd01..97ec41c7 100644
--- a/frontend/src/utils/index.js
+++ b/frontend/src/utils/index.js
@@ -78,7 +78,6 @@ export function statusDropdownOptions(data, doctype, action) {
label: statuses[status].label,
icon: () => h(IndicatorIcon, { class: statuses[status].color }),
onClick: () => {
- data.status = statuses[status].label
action && action('status', statuses[status].label)
},
})