This commit is contained in:
Le Deng
2017-03-08 15:51:13 -05:00
parent c6504d3616
commit e9304c950a
2 changed files with 33 additions and 21 deletions

View File

@@ -73,6 +73,7 @@
<br>
<br>
<div>
<p *ngIf="defaultPaymentSet">Default payment set successfully!</p>
<md-tab-group (selectedIndexChange)="selectedIndexChange($event)" [selectedIndex]="selectedBillingTab">
<md-tab label="List of Credit Cards">
<form (ngSubmit)="setDefaultPayment()" method="post">

View File

@@ -40,6 +40,7 @@ export class MyProfileComponent implements OnInit {
private selectedBillingTab:number = 0;
private defaultUserPaymentId:number;
private defaultPaymentSet:boolean;
constructor (private paymentService:PaymentService, private loginService: LoginService, private userService: UserService, private router: Router){
}
@@ -103,7 +104,8 @@ export class MyProfileComponent implements OnInit {
onNewPayment () {
this.paymentService.newPayment(this.userPayment).subscribe(
res => {
location.reload();
this.getCurrentUser();
this.selectedBillingTab = 0;
},
error => {
console.log(error.text());
@@ -120,7 +122,8 @@ export class MyProfileComponent implements OnInit {
onRemovePayment(id:number) {
this.paymentService.removePayment(id).subscribe(
res => {
location.reload();
this.getCurrentUser();
},
error => {
console.log(error.text());
@@ -129,10 +132,13 @@ export class MyProfileComponent implements OnInit {
}
setDefaultPayment() {
this.defaultPaymentSet=false;
this.paymentService.setDefaultPayment(this.defaultUserPaymentId).subscribe(
res => {
console.log(res.text());
location.reload();
this.getCurrentUser();
this.defaultPaymentSet=true;
// this.selectedProfileTab = 2;
// this.selectedBillingTab = 0;
},
error => {
console.log(error.text());
@@ -140,16 +146,7 @@ export class MyProfileComponent implements OnInit {
);
}
ngOnInit() {
this.loginService.checkSession().subscribe(
res => {
this.loggedIn=true;
},
error => {
this.loggedIn=false;
}
);
getCurrentUser() {
this.userService.getCurrentUser().subscribe(
res => {
this.user=res.json();
@@ -166,6 +163,19 @@ export class MyProfileComponent implements OnInit {
console.log(error);
}
);
}
ngOnInit() {
this.loginService.checkSession().subscribe(
res => {
this.loggedIn=true;
},
error => {
this.loggedIn=false;
}
);
this.getCurrentUser();
for (let s in AppConst.usStates) {
this.stateList.push(s);
@@ -176,6 +186,7 @@ export class MyProfileComponent implements OnInit {
this.userPayment.expiryMonth="";
this.userPayment.expiryYear="";
this.userPayment.userBilling = this.userBilling;
this.defaultPaymentSet=false;
}
}