fix: added template selector modal in activity and added sendtemplate functionality
This commit is contained in:
parent
7047b8c343
commit
cc47eb976e
@ -62,6 +62,22 @@ def create_whatsapp_message(reference_doctype, reference_name, message, to, atta
|
||||
doc.insert(ignore_permissions=True)
|
||||
return doc.name
|
||||
|
||||
@frappe.whitelist()
|
||||
def send_whatsapp_template(reference_doctype, reference_name, template, to):
|
||||
doc = frappe.new_doc("WhatsApp Message")
|
||||
doc.update({
|
||||
"reference_doctype": reference_doctype,
|
||||
"reference_name": reference_name,
|
||||
"message_type": "Template",
|
||||
"message": "Template message",
|
||||
"content_type": "text",
|
||||
"use_template": True,
|
||||
"template": template,
|
||||
"to": to,
|
||||
})
|
||||
doc.insert(ignore_permissions=True)
|
||||
return doc.name
|
||||
|
||||
@frappe.whitelist()
|
||||
def react_on_whatsapp_message(emoji, reply_to_name):
|
||||
reply_to_doc = frappe.get_doc("WhatsApp Message", reply_to_name)
|
||||
|
||||
@ -45,6 +45,10 @@
|
||||
<RefreshIcon class="h-4 w-4" />
|
||||
</template>
|
||||
</Button>
|
||||
<Button
|
||||
:label="__('Select Template')"
|
||||
@click="showWhatsappTemplates = true"
|
||||
/>
|
||||
<Button variant="solid" @click="$refs.whatsappBox.show()">
|
||||
<template #prefix>
|
||||
<FeatherIcon name="plus" class="h-4 w-4" />
|
||||
@ -802,6 +806,10 @@
|
||||
:doctype="doctype"
|
||||
:doc="doc.data?.name"
|
||||
/>
|
||||
<WhatsappTemplateSelectorModal
|
||||
v-model="showWhatsappTemplates"
|
||||
@send="(t) => sendTemplate(t)"
|
||||
/>
|
||||
</template>
|
||||
<script setup>
|
||||
import UserAvatar from '@/components/UserAvatar.vue'
|
||||
@ -833,6 +841,7 @@ import AttachmentItem from '@/components/AttachmentItem.vue'
|
||||
import CommunicationArea from '@/components/CommunicationArea.vue'
|
||||
import NoteModal from '@/components/Modals/NoteModal.vue'
|
||||
import TaskModal from '@/components/Modals/TaskModal.vue'
|
||||
import WhatsappTemplateSelectorModal from '@/components/Modals/WhatsappTemplateSelectorModal.vue'
|
||||
import {
|
||||
timeAgo,
|
||||
dateFormat,
|
||||
@ -923,6 +932,8 @@ const all_activities = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
const showWhatsappTemplates = ref(false)
|
||||
|
||||
const whatsappMessages = createListResource({
|
||||
type: 'list',
|
||||
doctype: 'WhatsApp Message',
|
||||
@ -993,6 +1004,23 @@ const whatsappMessages = createListResource({
|
||||
onSuccess: () => nextTick(() => scroll()),
|
||||
})
|
||||
|
||||
function sendTemplate(template) {
|
||||
showWhatsappTemplates.value = false
|
||||
createResource({
|
||||
url: 'crm.api.whatsapp.send_whatsapp_template',
|
||||
params: {
|
||||
reference_doctype: props.doctype,
|
||||
reference_name: doc.value.data.name,
|
||||
to: doc.value.data.mobile_no,
|
||||
template,
|
||||
},
|
||||
auto: true,
|
||||
onSuccess() {
|
||||
whatsappMessages.reload()
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const replyMessage = ref({})
|
||||
|
||||
function get_activities() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user