Finish send mail dialog, fixes #12

This commit is contained in:
2025-11-19 14:30:24 +01:00
parent d6e58a762c
commit ed017e0510
5 changed files with 57 additions and 31 deletions
@@ -163,7 +163,6 @@ watch(invoice,
if (newValue.customerId && newValue.customerId !== 0) {
// if (importCustomer.value != newValue.customer)
// console.warn('trigger importCustomer watcher')
console.log(newValue, newValue.customerId)
customers.value.find(customer => {
if (customer.id === newValue.customerId) {
if (invoice.value) invoice.value.customer = customer as Customer
@@ -413,8 +412,8 @@ const openReminderDialog = function () {
reminderDialogOpen.value = true
}
const sendReminder = async function (recipient: string | undefined) {
if (!recipient) return
const sendReminder = async function (to: string | undefined, cc: string | undefined) {
if (!to) return
if (!invoice.value || !invoice.value.id) return
// Close dialog
@@ -425,8 +424,12 @@ const sendReminder = async function (recipient: string | undefined) {
try {
// await axios call
await axios.get('/api/invoices/' + invoice.value.id + '/remind/' + recipient)
toast.success("Zahlungserinnerung gesendet", { description: recipient })
let request = '/api/invoices/' + invoice.value.id + '/remind?to=' + to
if (cc) request += '&cc=' + cc
await axios.get(request)
invoice.value.paymentStatus = 'reminded'
save()
toast.success("Zahlungserinnerung gesendet", { description: to })
} catch (error: any) {
toast.error(error?.title || 'Fehler', { description: error?.message || String(error) })
} finally {
@@ -819,7 +822,7 @@ const updateLineItems = (newItems: LineItem[]) => {
</Dialog>
<SendMailDialog v-model:open="reminderDialogOpen" title="Zahlungserinnerung senden?" description=""
:recipient="billingContactEmail" @send="(recipient: string | undefined) => sendReminder(recipient)" />
:to="billingContactEmail" @send="(to, cc) => sendReminder(to, cc)" />
</template>