added confirmation email for eshop

This commit is contained in:
2024-09-10 13:43:32 +02:00
parent 39c1604db4
commit 11e2b6f2e2
5 changed files with 137 additions and 17 deletions
@@ -103,10 +103,10 @@ Vue.component('warehouse-e-shop', {
const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/createOrder`, {
shoppingCart: this.shoppingCart,
deliveryMode: this.createOrderDialogData.deliveryMode,
deliveryAddressName: this.createOrderDialogData.deliveryAddressName,
deliveryAddressLine: this.createOrderDialogData.deliveryAddressLine,
deliveryAddressPLZ: this.createOrderDialogData.deliveryAddressPLZ,
deliveryAddressCity: this.createOrderDialogData.deliveryAddressCity,
deliveryAddressName: this.createOrderDialogData.deliveryAddressName.trim(),
deliveryAddressLine: this.createOrderDialogData.deliveryAddressLine.trim(),
deliveryAddressPLZ: this.createOrderDialogData.deliveryAddressPLZ.trim(),
deliveryAddressCity: this.createOrderDialogData.deliveryAddressCity.trim(),
});
if (response.data.success) {
this.window.notify('success', response.data.message || 'Erfolgreich gespeichert');
@@ -3,7 +3,9 @@ Vue.component('warehouse-e-shop-order', {
//language=Vue
template: `
<tt-card>
<tt-table-crud @openHistory="historyModal = true; historyModalId = $event.id" ref="table">
<tt-table-crud @openHistory="historyModal = true; historyModalId = $event.id"
@openSingleOrderEmail="openSingleOrderEmailModal = true; singleOrderEmailModalId = $event.id"
ref="table">
<template v-slot:table-top-buttons>
<button @click="createCSVExportAndMarkAsAccepted" type="button" class="btn btn-outline-success">
@@ -28,10 +30,29 @@ Vue.component('warehouse-e-shop-order', {
</tt-table-crud>
<warehouse-history-modal :show.sync="historyModal" :id="historyModalId"/>
<!-- add a tt-modal which just shows some text from the api to show a email for a single order-->
<tt-modal :show.sync="openSingleOrderEmailModal"
:title="'Email für Bestellung ' + singleOrderEmailModalId"
@close="openSingleOrderEmailModal = false"
save-text="E-Mail senden"
@submit="sendSingleOrderEmail"
:delete="false"
>
<div v-if="singleOrderEmailModalId && singleOrderEmailModalText">
<p v-html="singleOrderEmailModalText.body.replaceAll('\\n', '<br>')"></p>
</div>
<!-- else show loader-->
<div v-else>
<tt-loader/>
</div>
</tt-modal>
</tt-card>
`, data() {
return {
window: window, historyModal: false, historyModalId: null, articleItems: null
window: window, historyModal: false, historyModalId: null, articleItems: null, openSingleOrderEmailModal: false, singleOrderEmailModalId: null, singleOrderEmailModalText: null
}
},
async mounted() {
@@ -40,11 +61,20 @@ Vue.component('warehouse-e-shop-order', {
this.articleItems = response.data;
},
methods: {
async sendSingleOrderEmail() {
const response = await axios.get(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/singleOrderEmail?id=${this.singleOrderEmailModalId}`);
if (response.data.message) {
window.notify(response.data.success === true ? 'success' : 'error', response.data.message);
this.openSingleOrderEmailModal = false;
} else {
window.notify('error', 'Ein Fehler ist aufgetreten');
}
},
async createCSVExportAndMarkAsAccepted() {
const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/CSVExportNewOrdersMarkAccepted`);
if (response.data.message) {
window.notify('info', response.data.message);
window.notify('success', response.data.message);
return;
}
@@ -77,5 +107,16 @@ Vue.component('warehouse-e-shop-order', {
await this.$refs.table.$refs.table.fetchData();
}
},
watch: {
singleOrderEmailModalId() {
this.openSingleOrderEmailModal = !!this.singleOrderEmailModalId;
this.singleOrderEmailModalText = null;
if (this.singleOrderEmailModalId) {
axios.get(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/singleOrderEmail?id=${this.singleOrderEmailModalId}&dryRun=true`)
.then(response => this.singleOrderEmailModalText = response.data)
.catch(error => window.notify('error', error.response?.data?.message || 'Ein Fehler ist aufgetreten'));
}
}
}
})