92 lines
4.0 KiB
TypeScript
92 lines
4.0 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
import { Action } from '@ngrx/store';
|
|
import { Effect, Actions, ofType } from '@ngrx/effects';
|
|
import { Observable } from 'rxjs';
|
|
import { tap } from 'rxjs/operators';
|
|
import * as subActions from '@app/actions/subscription.actions';
|
|
import { SUB } from '../profile/common';
|
|
import { AC } from '@app/shared/global';
|
|
|
|
@Injectable()
|
|
export class RoutingEffects {
|
|
|
|
constructor(
|
|
private router: Router,
|
|
private actions$: Actions
|
|
) { }
|
|
|
|
@Effect({ dispatch: false })
|
|
gotoMyservices$: Observable<Action> = this.actions$.pipe(
|
|
ofType<subActions.GotoMyServices>(subActions.GOTO_MY_SERVICES),
|
|
tap(() => this.router.navigate([SUB.PROFILE, SUB.MY_SERVICES]).then(() => window.location.reload()))
|
|
);
|
|
|
|
@Effect({ dispatch: false })
|
|
gotoServices$: Observable<Action> = this.actions$.pipe(
|
|
ofType<subActions.GotoServices>(subActions.GOTO_SERVICES),
|
|
tap(() => this.router.navigate([SUB.PROFILE, SUB.SERVICES]))
|
|
);
|
|
|
|
@Effect({ dispatch: false })
|
|
gotPaymentHistory$: Observable<Action> = this.actions$.pipe(
|
|
ofType<subActions.GotoPaymentHistory>(subActions.GOTO_PAYMENT_HISTORY),
|
|
tap(() => this.router.navigate([SUB.PROFILE, SUB.PM_HISTORY]))
|
|
);
|
|
|
|
@Effect({ dispatch: false })
|
|
gotPaymentDetail$: Observable<Action> = this.actions$.pipe(
|
|
ofType<subActions.GotoPaymentDetail>(subActions.GOTO_PAYMENT_DETAIL),
|
|
tap((action: subActions.GotoPaymentDetail) => this.router.navigate([SUB.PROFILE, SUB.PM_DETAIL, action.payload.paymentId]))
|
|
);
|
|
|
|
@Effect({ dispatch: false })
|
|
gotoUnpaidSub$: Observable<Action> = this.actions$.pipe(
|
|
ofType<subActions.ShowUnpaidSubscription>(subActions.SHOW_UNPAID_SUBSCRIPTION),
|
|
tap(() => this.router.navigate([SUB.PROFILE, SUB.UNPAID_SUB]))
|
|
);
|
|
|
|
@Effect({ dispatch: false })
|
|
gotoBillingAddr$: Observable<Action> = this.actions$.pipe(
|
|
ofType<subActions.StartBillingInfoSuccess | subActions.GotoBillingAddress>(subActions.START_BILLING_INFO_SUCCESS, subActions.GOTO_BILLING_ADDRESS),
|
|
tap(() => this.router.navigate([SUB.PROFILE, SUB.BILL_ADR]))
|
|
);
|
|
|
|
@Effect({ dispatch: false })
|
|
gotoCheckout$: Observable<Action> = this.actions$.pipe(
|
|
ofType<subActions.UpdateBillingAddressSuccess | subActions.GotoCheckout | subActions.StartCheckoutSuccess>(subActions.UPDATE_BILLING_ADDRESS_SUCCESS, subActions.GOTO_CHECK_OUT, subActions.START_CHECKOUT_SUCCESS),
|
|
tap(() => this.router.navigate([SUB.PROFILE, SUB.CHKOUT]))
|
|
);
|
|
|
|
@Effect({ dispatch: false })
|
|
gotoCheckoutReview$: Observable<Action> = this.actions$.pipe(
|
|
ofType<subActions.Checkout | subActions.ResolvePayment | subActions.GotoCheckoutReview>(subActions.CHECK_OUT, subActions.RESOLVE_PAYMENT, subActions.GOTO_CHECK_OUT_REVIEW),
|
|
tap(() => this.router.navigate([SUB.PROFILE, SUB.CHKOUT_REV]))
|
|
);
|
|
|
|
@Effect({ dispatch: false })
|
|
gotoCheckoutConfirm$: Observable<Action> = this.actions$.pipe(
|
|
ofType<subActions.GotoCheckoutConfirm | subActions.PayUnpaidSubscriptionSuccess | subActions.ConfirmActionSuccess | subActions.ConfirmPaymentSuccess | subActions.CheckoutTrialSuccess>(subActions.GOTO_CHECK_OUT_CONFIRM, subActions.PAY_UNPAID_SUBSCRIPTION_SUCCESS, subActions.CONFIRM_ACTION_SUCCESS, subActions.CONFIRM_PAYMENT_SUCCESS,
|
|
subActions.CHECK_OUT_TRIAL_SUCCESS),
|
|
tap(() => this.router.navigate([SUB.PROFILE, SUB.CHKOUT_CONF]))
|
|
);
|
|
|
|
@Effect({ dispatch: false })
|
|
gotoHome$: Observable<Action> = this.actions$.pipe(
|
|
ofType<subActions.GotoHome>(subActions.GOTO_HOME),
|
|
tap(() => this.router.navigate(['/', SUB.HOME]))
|
|
);
|
|
|
|
@Effect({ dispatch: false })
|
|
gotoUsageDetail$: Observable<Action> = this.actions$.pipe(
|
|
ofType<subActions.GotoUsageDetail>(subActions.GOTO_USAGE_DETAIL),
|
|
tap(() => this.router.navigate([SUB.PROFILE, SUB.USAGE_DETAIL]))
|
|
);
|
|
|
|
@Effect({ dispatch: false })
|
|
gotoAircraftList$: Observable<Action> = this.actions$.pipe(
|
|
ofType<subActions.GotoAircraftList>(subActions.GOTO_AIRCRAFT_LIST),
|
|
tap(() => this.router.navigate(['entities', AC]))
|
|
);
|
|
}
|