Working cart

This commit is contained in:
2018-07-22 19:52:58 -04:00
parent b0019c0c4b
commit 88dd66188e
4 changed files with 17 additions and 8 deletions

View File

@ -33,7 +33,7 @@
<td class="pl-3">{{total() | currency}}</td>
</tr>
</table>
<button mat-raised-button class="float-right mt-3" color="primary">Checkout</button>
<button mat-raised-button class="float-right mt-3" color="primary" (click)="checkout()">Checkout</button>
</div>
</mat-card>
</div>

View File

@ -1,6 +1,8 @@
import {Component} from '@angular/core';
import {LocalStorage} from 'webstorage-decorators';
import {access} from 'fs';
import {Http} from '../../../../node_modules/@angular/http';
import {Router} from '../../../../node_modules/@angular/router';
@Component({
selector: 'cart',
@ -16,7 +18,17 @@ export class CartComponent {
province: string;
postal: string;
constructor() {}
constructor(private http: Http, private router: Router) {}
async checkout() {
let cart = this.cart.map(row => {
return {id: row.id, quantity: row.quantity};
});
let link = await this.http
.post('https://us-central1-fhsons-7e90b.cloudfunctions.net/checkout', {cart: cart})
.toPromise();
window.location.href = link.url;
}
remove(i: number) {
let c = this.cart;