iachat/app/javascript/dashboard/components/widgets/conversation/WhatsappTemplates/Modal.vue
Gabriel Jablonski da466c88a6
feat(scheduled-messages): add WhatsApp templates (#205)
* feat(scheduled-messages): add WhatsApp templates

* fix: update inboxId prop type to accept both Number and String; localize template labels in conversation.json
2026-02-02 19:50:17 -03:00

98 lines
2.1 KiB
Vue

<script>
import TemplatesPicker from './TemplatesPicker.vue';
import WhatsAppTemplateReply from './WhatsAppTemplateReply.vue';
export default {
components: {
TemplatesPicker,
WhatsAppTemplateReply,
},
props: {
show: {
type: Boolean,
default: false,
},
inboxId: {
type: [Number, String],
default: undefined,
},
sendButtonLabel: {
type: String,
default: '',
},
},
emits: ['onSend', 'cancel', 'update:show'],
data() {
return {
selectedWaTemplate: null,
};
},
computed: {
localShow: {
get() {
return this.show;
},
set(value) {
this.$emit('update:show', value);
},
},
modalHeaderContent() {
return this.selectedWaTemplate
? this.$t('WHATSAPP_TEMPLATES.MODAL.TEMPLATE_SELECTED_SUBTITLE', {
templateName: this.selectedWaTemplate.name,
})
: this.$t('WHATSAPP_TEMPLATES.MODAL.SUBTITLE');
},
},
watch: {
show(newVal) {
if (newVal) {
this.selectedWaTemplate = null;
}
},
},
methods: {
pickTemplate(template) {
this.selectedWaTemplate = template;
},
onResetTemplate() {
this.selectedWaTemplate = null;
},
onSendMessage(message) {
this.$emit('onSend', message);
},
onClose() {
this.$emit('cancel');
},
},
};
</script>
<template>
<woot-modal v-model:show="localShow" :on-close="onClose" size="modal-big">
<woot-modal-header
:header-title="$t('WHATSAPP_TEMPLATES.MODAL.TITLE')"
:header-content="modalHeaderContent"
/>
<div class="row modal-content">
<TemplatesPicker
v-if="!selectedWaTemplate"
:inbox-id="inboxId"
@on-select="pickTemplate"
/>
<WhatsAppTemplateReply
v-else
:template="selectedWaTemplate"
:send-button-label="sendButtonLabel"
@reset-template="onResetTemplate"
@send-message="onSendMessage"
/>
</div>
</woot-modal>
</template>
<style scoped>
.modal-content {
padding: 1.5625rem 2rem;
}
</style>