feat: enhance inner pages header with back button functionality and emit event on back click

fix: update total price info handling in correction form and ensure accurate calculations

refactor: streamline sale invoice single view component by extracting info card into a separate component

style: adjust button sizes in payment forms for better UI consistency

feat: implement season picker navigation controls to prevent out-of-bounds selection

fix: improve price formatting utility to handle undefined values gracefully

chore: update environment configuration for API base URL

feat: add navigation service to manage routing history and back navigation
This commit is contained in:
2026-06-11 16:13:48 +03:30
parent 88f45eee38
commit b4cd4c05f2
28 changed files with 526 additions and 310 deletions
@@ -0,0 +1,51 @@
import { Injectable } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { filter } from 'rxjs/operators';
@Injectable({
providedIn: 'root',
})
export class NavigationService {
private readonly CURRENT_URL_KEY = 'currentUrl';
private readonly PREVIOUS_URL_KEY = 'previousUrl';
currentUrl: string | null;
previousUrl: string | null;
constructor(private router: Router) {
this.currentUrl = sessionStorage.getItem(this.CURRENT_URL_KEY);
this.previousUrl = sessionStorage.getItem(this.PREVIOUS_URL_KEY);
this.router.events
.pipe(filter((event): event is NavigationEnd => event instanceof NavigationEnd))
.subscribe((event) => {
const newUrl = event.urlAfterRedirects;
// Ignore duplicate events
if (newUrl === this.currentUrl) {
return;
}
this.previousUrl = this.currentUrl;
this.currentUrl = newUrl;
if (this.previousUrl) {
sessionStorage.setItem(this.PREVIOUS_URL_KEY, this.previousUrl);
}
sessionStorage.setItem(this.CURRENT_URL_KEY, this.currentUrl);
});
}
canGoBack(): boolean {
return !!this.previousUrl;
}
back(fallbackUrl = '/'): void {
if (this.canGoBack()) {
window.history.back();
} else {
this.router.navigateByUrl(fallbackUrl);
}
}
}