Unverified Commit 02a659d6 authored by Ruslan Konviser's avatar Ruslan Konviser Committed by GitHub
Browse files

Merge pull request #1109 from ever-co/fix/#1108-edit-carrier-error

fix: edit carrier throws error
parents d48fa086 5a832b5e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
<toaster-container></toaster-container>

<div>
	<nb-card *ngIf="carrier$ | async as carrier">
	<nb-card *ngIf="currentCarrier">
		<nb-card-header>
			<!-- back -->
			<div class="d-inline-flex">
				<svg
					viewBox="0 0 24 24"
					class="control-icon control-icon-left"
					[routerLink]="['/carriers/' + carrier.id]"
					[routerLink]="['/carriers/' + currentCarrier.id]"
				>
					<path
						d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"
+10 −13
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ import { CarrierRouter } from '@modules/client.common.angular2/routers/carrier-r
import Carrier from '@modules/server.common/entities/Carrier';
import IGeoLocation from '@modules/server.common/interfaces/IGeoLocation';
import { ToasterService } from 'angular2-toaster';
import { first, map, switchMap } from 'rxjs/operators';
import { map, first } from 'rxjs/operators';

@Component({
	selector: 'ea-carrier-edit',
@@ -39,13 +39,7 @@ export class CarrierEditComponent implements OnInit {

	readonly carrierId$ = this.activatedRoute.params.pipe(map((p) => p['id']));
	
	readonly carrier$ = this.carrierId$.pipe(
		switchMap((id) => {
			return this.carrierRouter.get(id).pipe(first());
		})
	);

	private currentCarrier: Carrier;
	public currentCarrier: Carrier;

	constructor(
		private readonly toasterService: ToasterService,
@@ -60,9 +54,12 @@ export class CarrierEditComponent implements OnInit {
	}

	ngOnInit() {		
		this.carrier$
			.withLatestFrom(this.carrierId$)
			.subscribe(([carrier, id]) => {
		const id = this.activatedRoute.snapshot.params.id;

		this.carrierRouter
			.get(id)
			.pipe(first())
			.subscribe((carrier) => {
				if (!carrier) {
					this.toasterService.pop(
						'error',