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.
This commit is contained in:
Darko Gjorgjijoski
2026-04-06 22:56:41 +02:00
parent 45f347ebef
commit 6106ac8208
4 changed files with 15 additions and 13 deletions

View File

@@ -241,8 +241,8 @@ async function setInitialData() {
estimateMailForm.id = modalStore.id as number
if (admin.data) {
estimateMailForm.from = (admin.data as Record<string, string>).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

View File

@@ -290,8 +290,8 @@ async function setInitialData(): Promise<void> {
form.id = modalStore.id
if (admin?.data) {
form.from = (admin.data as Record<string, unknown>).from_mail as string
if (admin?.from_mail) {
form.from = admin.from_mail as string
}
if (modalData.value?.customer) {

View File

@@ -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<string, string>).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