From 819e00e067eb124f2dc3f95ae1a3cd11d8b30893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20K=C3=BCng?= Date: Fri, 27 Feb 2026 20:22:18 +0100 Subject: [PATCH] feat(back-end): fix order page --- .../features/calculator/calculator-page.component.ts | 11 ++++++++--- .../src/app/features/checkout/checkout.component.ts | 8 +++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/features/calculator/calculator-page.component.ts b/frontend/src/app/features/calculator/calculator-page.component.ts index d8284a5..718ab03 100644 --- a/frontend/src/app/features/calculator/calculator-page.component.ts +++ b/frontend/src/app/features/calculator/calculator-page.component.ts @@ -11,6 +11,7 @@ import { QuoteResultComponent } from './components/quote-result/quote-result.com import { QuoteRequest, QuoteResult, QuoteEstimatorService } from './services/quote-estimator.service'; import { SuccessStateComponent } from '../../shared/components/success-state/success-state.component'; import { Router, ActivatedRoute } from '@angular/router'; +import { LanguageService } from '../../core/services/language.service'; @Component({ selector: 'app-calculator-page', @@ -37,7 +38,8 @@ export class CalculatorPageComponent implements OnInit { constructor( private estimator: QuoteEstimatorService, private router: Router, - private route: ActivatedRoute + private route: ActivatedRoute, + private languageService: LanguageService ) {} ngOnInit() { @@ -207,7 +209,10 @@ export class CalculatorPageComponent implements OnInit { onProceed() { const res = this.result(); if (res && res.sessionId) { - this.router.navigate(['/checkout'], { queryParams: { session: res.sessionId } }); + this.router.navigate( + ['/', this.languageService.selectedLang(), 'checkout'], + { queryParams: { session: res.sessionId } } + ); } else { console.error('No session ID found in quote result'); // Fallback or error handling @@ -302,7 +307,7 @@ export class CalculatorPageComponent implements OnInit { message: details }); - this.router.navigate(['/contact']); + this.router.navigate(['/', this.languageService.selectedLang(), 'contact']); } private isInvalidQuote(result: QuoteResult): boolean { diff --git a/frontend/src/app/features/checkout/checkout.component.ts b/frontend/src/app/features/checkout/checkout.component.ts index bd343e4..0bb9ea0 100644 --- a/frontend/src/app/features/checkout/checkout.component.ts +++ b/frontend/src/app/features/checkout/checkout.component.ts @@ -206,7 +206,13 @@ export class CheckoutComponent implements OnInit { this.quoteService.createOrder(this.sessionId, orderRequest).subscribe({ next: (order) => { - this.router.navigate(['/order', order.id]); + const orderId = order?.id ?? order?.orderId; + if (!orderId) { + this.isSubmitting.set(false); + this.error = 'CHECKOUT.ERR_CREATE_ORDER'; + return; + } + this.router.navigate(['/', this.languageService.selectedLang(), 'order', orderId]); }, error: (err) => { console.error('Order creation failed', err);