produzione 1 #9

Merged
JoeKung merged 135 commits from dev into main 2026-03-03 09:58:04 +01:00
6 changed files with 49 additions and 8 deletions
Showing only changes of commit 2e701d5597 - Show all commits

View File

@@ -3,7 +3,7 @@
<p class="subtitle">{{ 'CALC.SUBTITLE' | translate }}</p> <p class="subtitle">{{ 'CALC.SUBTITLE' | translate }}</p>
@if (error()) { @if (error()) {
<app-alert type="error">{{ 'CALC.ERROR_GENERIC' | translate }}</app-alert> <app-alert type="error">{{ errorKey() | translate }}</app-alert>
} }
</div> </div>

View File

@@ -27,6 +27,7 @@ export class CalculatorPageComponent implements OnInit {
uploadProgress = signal(0); uploadProgress = signal(0);
result = signal<QuoteResult | null>(null); result = signal<QuoteResult | null>(null);
error = signal<boolean>(false); error = signal<boolean>(false);
errorKey = signal<string>('CALC.ERROR_GENERIC');
orderSuccess = signal(false); orderSuccess = signal(false);
@@ -64,6 +65,14 @@ export class CalculatorPageComponent implements OnInit {
next: (data) => { next: (data) => {
// 1. Map to Result // 1. Map to Result
const result = this.estimator.mapSessionToQuoteResult(data); const result = this.estimator.mapSessionToQuoteResult(data);
if (this.isInvalidQuote(result)) {
this.setQuoteError('CALC.ERROR_ZERO_PRICE');
this.loading.set(false);
return;
}
this.error.set(false);
this.errorKey.set('CALC.ERROR_GENERIC');
this.result.set(result); this.result.set(result);
this.step.set('quote'); this.step.set('quote');
@@ -79,7 +88,7 @@ export class CalculatorPageComponent implements OnInit {
}, },
error: (err) => { error: (err) => {
console.error('Failed to load session', err); console.error('Failed to load session', err);
this.error.set(true); this.setQuoteError('CALC.ERROR_GENERIC');
this.loading.set(false); this.loading.set(false);
} }
}); });
@@ -146,6 +155,7 @@ export class CalculatorPageComponent implements OnInit {
this.loading.set(true); this.loading.set(true);
this.uploadProgress.set(0); this.uploadProgress.set(0);
this.error.set(false); this.error.set(false);
this.errorKey.set('CALC.ERROR_GENERIC');
this.result.set(null); this.result.set(null);
this.orderSuccess.set(false); this.orderSuccess.set(false);
@@ -163,6 +173,14 @@ export class CalculatorPageComponent implements OnInit {
} else { } else {
// It's the result // It's the result
const res = event as QuoteResult; const res = event as QuoteResult;
if (this.isInvalidQuote(res)) {
this.setQuoteError('CALC.ERROR_ZERO_PRICE');
this.loading.set(false);
return;
}
this.error.set(false);
this.errorKey.set('CALC.ERROR_GENERIC');
this.result.set(res); this.result.set(res);
this.loading.set(false); this.loading.set(false);
this.uploadProgress.set(100); this.uploadProgress.set(100);
@@ -180,7 +198,7 @@ export class CalculatorPageComponent implements OnInit {
} }
}, },
error: () => { error: () => {
this.error.set(true); this.setQuoteError('CALC.ERROR_GENERIC');
this.loading.set(false); this.loading.set(false);
} }
}); });
@@ -216,10 +234,19 @@ export class CalculatorPageComponent implements OnInit {
next: () => { next: () => {
// 3. Fetch the updated session totals from the backend // 3. Fetch the updated session totals from the backend
this.estimator.getQuoteSession(currentSessionId).subscribe({ this.estimator.getQuoteSession(currentSessionId).subscribe({
next: (sessionData) => { next: (sessionData) => {
const newResult = this.estimator.mapSessionToQuoteResult(sessionData); const newResult = this.estimator.mapSessionToQuoteResult(sessionData);
// Preserve notes // Preserve notes
newResult.notes = this.result()?.notes; newResult.notes = this.result()?.notes;
if (this.isInvalidQuote(newResult)) {
this.setQuoteError('CALC.ERROR_ZERO_PRICE');
this.loading.set(false);
return;
}
this.error.set(false);
this.errorKey.set('CALC.ERROR_GENERIC');
this.result.set(newResult); this.result.set(newResult);
this.loading.set(false); this.loading.set(false);
}, },
@@ -282,4 +309,14 @@ export class CalculatorPageComponent implements OnInit {
this.router.navigate(['/contact']); this.router.navigate(['/contact']);
} }
private isInvalidQuote(result: QuoteResult): boolean {
return !Number.isFinite(result.totalPrice) || result.totalPrice <= 0;
}
private setQuoteError(key: string): void {
this.errorKey.set(key);
this.error.set(true);
this.result.set(null);
}
} }

View File

@@ -90,7 +90,8 @@
"PROCESSING": "Verarbeitung...", "PROCESSING": "Verarbeitung...",
"NOTES_PLACEHOLDER": "Spezifische Anweisungen...", "NOTES_PLACEHOLDER": "Spezifische Anweisungen...",
"SETUP_NOTE": "* Beinhaltet {{cost}} als Einrichtungskosten", "SETUP_NOTE": "* Beinhaltet {{cost}} als Einrichtungskosten",
"SHIPPING_NOTE": "** Versandkosten ausgeschlossen, werden im nächsten Schritt berechnet" "SHIPPING_NOTE": "** Versandkosten ausgeschlossen, werden im nächsten Schritt berechnet",
"ERROR_ZERO_PRICE": "Etwas ist schiefgelaufen. Versuche ein anderes Format oder kontaktiere uns."
}, },
"SHOP": { "SHOP": {
"TITLE": "Technische Lösungen", "TITLE": "Technische Lösungen",

View File

@@ -90,7 +90,8 @@
"PROCESSING": "Processing...", "PROCESSING": "Processing...",
"NOTES_PLACEHOLDER": "Specific instructions...", "NOTES_PLACEHOLDER": "Specific instructions...",
"SETUP_NOTE": "* Includes {{cost}} as setup cost", "SETUP_NOTE": "* Includes {{cost}} as setup cost",
"SHIPPING_NOTE": "** Shipping costs excluded, calculated at the next step" "SHIPPING_NOTE": "** Shipping costs excluded, calculated at the next step",
"ERROR_ZERO_PRICE": "Something went wrong. Try another format or contact us."
}, },
"SHOP": { "SHOP": {
"TITLE": "Technical solutions", "TITLE": "Technical solutions",

View File

@@ -115,7 +115,8 @@
"REMOVE_FILE": "Supprimer le fichier", "REMOVE_FILE": "Supprimer le fichier",
"FALLBACK_MATERIAL": "PLA (fallback)", "FALLBACK_MATERIAL": "PLA (fallback)",
"FALLBACK_QUALITY_STANDARD": "Standard", "FALLBACK_QUALITY_STANDARD": "Standard",
"ERR_FILE_TOO_LARGE": "Certains fichiers dépassent la limite de 200MB et n'ont pas été ajoutés." "ERR_FILE_TOO_LARGE": "Certains fichiers dépassent la limite de 200MB et n'ont pas été ajoutés.",
"ERROR_ZERO_PRICE": "Quelque chose s'est mal passé. Essayez un autre format ou contactez-nous."
}, },
"QUOTE": { "QUOTE": {
"PROCEED_ORDER": "Procéder à la commande", "PROCEED_ORDER": "Procéder à la commande",

View File

@@ -115,7 +115,8 @@
"REMOVE_FILE": "Rimuovi file", "REMOVE_FILE": "Rimuovi file",
"FALLBACK_MATERIAL": "PLA (fallback)", "FALLBACK_MATERIAL": "PLA (fallback)",
"FALLBACK_QUALITY_STANDARD": "Standard", "FALLBACK_QUALITY_STANDARD": "Standard",
"ERR_FILE_TOO_LARGE": "Alcuni file superano il limite di 200MB e non sono stati aggiunti." "ERR_FILE_TOO_LARGE": "Alcuni file superano il limite di 200MB e non sono stati aggiunti.",
"ERROR_ZERO_PRICE": "Qualcosa è andato storto. Prova con un altro formato oppure contattaci."
}, },
"QUOTE": { "QUOTE": {
"PROCEED_ORDER": "Procedi con l'ordine", "PROCEED_ORDER": "Procedi con l'ordine",