Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 1x 1x 1x 1x 9x 9x 3x 6x 6x 6x 6x 6x 6x 6x 6x 6x | import { inject } from '@angular/core';
import { ActivatedRouteSnapshot } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { SelectQuoteRequestModalComponent } from '../shared/select-quote-request-modal/select-quote-request-modal.component';
/**
* Opens the quote request selection dialog: the user picks an existing "New" quote request or names a new one.
* Aborts without opening the dialog when the required `sku` query param is missing.
* A missing or invalid `quantity` query param defaults to 1.
*/
export function productAddToQuoteRequestGuard(route: ActivatedRouteSnapshot): boolean {
const sku = route.queryParamMap.get('sku')?.trim();
if (!sku) {
return false;
}
const parsedQuantity = Number(route.queryParamMap.get('quantity'));
const quantity = Number.isInteger(parsedQuantity) && parsedQuantity > 0 ? parsedQuantity : 1;
const modalService = inject(NgbModal);
const ref = modalService.open(SelectQuoteRequestModalComponent, {
ariaLabelledBy: 'select-quote-request-modal-title',
});
const component = ref.componentInstance as SelectQuoteRequestModalComponent;
component.sku = sku;
component.quantity = quantity;
component.modalRef = ref;
return false;
}
|