From 6106ac8208bd1040955f101e036c47da0b5f43e9 Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski Date: Mon, 6 Apr 2026 22:56:41 +0200 Subject: [PATCH] Fix send modals: from email and preview rendering fetchBasicMailConfig() was calling the wrong endpoint (company-config instead of default config). Also, the response has no .data wrapper so from_mail was never extracted. Fixed in all three send modals. Estimate and payment preview blob construction now falls back to the raw response when .data is undefined, matching the invoice modal. --- .../estimates/components/SendEstimateModal.vue | 11 ++++++----- .../company/invoices/components/SendInvoiceModal.vue | 4 ++-- .../company/payments/components/SendPaymentModal.vue | 11 ++++++----- resources/scripts-v2/stores/company.store.ts | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/resources/scripts-v2/features/company/estimates/components/SendEstimateModal.vue b/resources/scripts-v2/features/company/estimates/components/SendEstimateModal.vue index fa31f52e..3843ccad 100644 --- a/resources/scripts-v2/features/company/estimates/components/SendEstimateModal.vue +++ b/resources/scripts-v2/features/company/estimates/components/SendEstimateModal.vue @@ -241,8 +241,8 @@ async function setInitialData() { estimateMailForm.id = modalStore.id as number - if (admin.data) { - estimateMailForm.from = (admin.data as Record).from_mail + if (admin.from_mail) { + estimateMailForm.from = admin.from_mail as string } if (modalData.value) { @@ -274,9 +274,10 @@ async function submitForm() { isLoading.value = false isPreview.value = true - const blob = new Blob([(previewResponse as { data: string }).data], { - type: 'text/html', - }) + const blob = new Blob( + [(previewResponse as { data: string }).data ?? previewResponse], + { type: 'text/html' }, + ) templateUrl.value = URL.createObjectURL(blob) return diff --git a/resources/scripts-v2/features/company/invoices/components/SendInvoiceModal.vue b/resources/scripts-v2/features/company/invoices/components/SendInvoiceModal.vue index f3e4440f..2b04b115 100644 --- a/resources/scripts-v2/features/company/invoices/components/SendInvoiceModal.vue +++ b/resources/scripts-v2/features/company/invoices/components/SendInvoiceModal.vue @@ -290,8 +290,8 @@ async function setInitialData(): Promise { form.id = modalStore.id - if (admin?.data) { - form.from = (admin.data as Record).from_mail as string + if (admin?.from_mail) { + form.from = admin.from_mail as string } if (modalData.value?.customer) { diff --git a/resources/scripts-v2/features/company/payments/components/SendPaymentModal.vue b/resources/scripts-v2/features/company/payments/components/SendPaymentModal.vue index 2083caed..2cb1a7c9 100644 --- a/resources/scripts-v2/features/company/payments/components/SendPaymentModal.vue +++ b/resources/scripts-v2/features/company/payments/components/SendPaymentModal.vue @@ -244,8 +244,8 @@ async function setInitialData() { const admin = await companyStore.fetchBasicMailConfig() paymentMailForm.id = modalStore.id as number - if (admin.data) { - paymentMailForm.from = (admin.data as Record).from_mail + if (admin.from_mail) { + paymentMailForm.from = admin.from_mail as string } if (modalData.value) { @@ -275,9 +275,10 @@ async function sendPaymentData() { isLoading.value = false isPreview.value = true - const blob = new Blob([(previewResponse as { data: string }).data], { - type: 'text/html', - }) + const blob = new Blob( + [(previewResponse as { data: string }).data ?? previewResponse], + { type: 'text/html' }, + ) templateUrl.value = URL.createObjectURL(blob) return diff --git a/resources/scripts-v2/stores/company.store.ts b/resources/scripts-v2/stores/company.store.ts index 56d1a6bc..27d140bb 100644 --- a/resources/scripts-v2/stores/company.store.ts +++ b/resources/scripts-v2/stores/company.store.ts @@ -47,7 +47,7 @@ export const useCompanyStore = defineStore('company', () => { async function fetchBasicMailConfig(): Promise> { try { - return await companyService.getMailConfig() + return await companyService.getMailDefaultConfig() } catch (err: unknown) { handleApiError(err) throw err