Skip to content

Commit

Permalink
Remplissage auto de l'adresse
Browse files Browse the repository at this point in the history
  • Loading branch information
madoci committed Sep 18, 2020
1 parent e5662d0 commit 1f9049f
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/main/webapp/app/order/order-info/order-info.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { IBook } from '../../shared/model/book.model';
import * as moment from 'moment';
import { flatMap, map } from 'rxjs/operators';
import { Router } from '@angular/router';
import { AccountService } from 'app/core/auth/account.service';

@Component({
selector: 'jhi-order-info',
templateUrl: './order-info.component.html',
Expand All @@ -32,6 +34,7 @@ export class OrderInfoComponent implements OnInit {
private orderLineService: OrderLineService,
private customerService: CustomerService,
private orderedService: OrderedService,
private accountService: AccountService,
private router: Router
) {}

Expand All @@ -42,6 +45,28 @@ export class OrderInfoComponent implements OnInit {
alert("Votre panier est vide vous ne pouvez pas passez de commande ajoutez des livres dans votre panier d'abord.");
this.router.navigateByUrl('');
}

this.accountService
.identity()
.pipe(
map(account => {
if (account) {
return account.login;
}
return '';
}),
flatMap(login => {
return this.customerService.findByLogin(login);
}),
map(customer => {
if (customer.body) {
this.user = customer.body;
this.order.delevryAddress = this.user.address;
}
})
)
.subscribe();

this.next(false);
this.loading = false;
}
Expand Down Expand Up @@ -160,7 +185,7 @@ export class OrderInfoComponent implements OnInit {
});
});
this.shoppingCartService.clearCart();
alert('Merci pour votre achat et a bientôt chez Ebraire !');
alert("Merci pour votre achat et à bientôt chez l'eBraire !");
this.router.navigateByUrl('');
})
)
Expand Down

0 comments on commit 1f9049f

Please sign in to comment.