fix: delete contact

This commit is contained in:
Shariq Ansari 2023-10-15 09:10:10 +05:30
parent d7ccf13617
commit c8b13d16f3

View File

@ -79,7 +79,12 @@
<EditIcon class="h-4 w-4" /> <EditIcon class="h-4 w-4" />
</template> </template>
</Button> </Button>
<Button label="Add lead" size="sm"> <Button label="Delete" theme="red" size="sm" @click="deleteContact">
<template #prefix>
<FeatherIcon name="trash-2" class="h-4 w-4" />
</template>
</Button>
<!-- <Button label="Add lead" size="sm">
<template #prefix> <template #prefix>
<FeatherIcon name="plus" class="h-4 w-4" /> <FeatherIcon name="plus" class="h-4 w-4" />
</template> </template>
@ -88,7 +93,7 @@
<template #prefix> <template #prefix>
<FeatherIcon name="plus" class="h-4 w-4" /> <FeatherIcon name="plus" class="h-4 w-4" />
</template> </template>
</Button> </Button> -->
</div> </div>
</div> </div>
<ContactModal <ContactModal
@ -104,9 +109,9 @@ import {
FeatherIcon, FeatherIcon,
Avatar, Avatar,
FileUploader, FileUploader,
createResource,
ErrorMessage, ErrorMessage,
Dropdown, Dropdown,
call,
} from 'frappe-ui' } from 'frappe-ui'
import ContactModal from '@/components/ContactModal.vue' import ContactModal from '@/components/ContactModal.vue'
import EmailIcon from '@/components/Icons/EmailIcon.vue' import EmailIcon from '@/components/Icons/EmailIcon.vue'
@ -134,19 +139,35 @@ function validateFile(file) {
} }
} }
function changeContactImage(file) { async function changeContactImage(file) {
createResource({ await call('frappe.client.set_value', {
url: 'frappe.client.set_value', doctype: 'Contact',
params: { name: props.contact.name,
doctype: 'Contact', fieldname: 'image',
name: props.contact.name, value: file?.file_url || '',
fieldname: 'image', })
value: file?.file_url || '', contacts.reload()
}, }
auto: true,
onSuccess: () => { async function deleteContact() {
contacts.reload() $dialog({
}, title: 'Delete contact',
message: 'Are you sure you want to delete this contact?',
actions: [
{
label: 'Delete',
theme: 'red',
variant: 'solid',
async onClick({ close }) {
await call('frappe.client.delete', {
doctype: 'Contact',
name: props.contact.name,
})
contacts.reload()
close()
},
},
],
}) })
} }
</script> </script>