Working cart
This commit is contained in:
@ -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>
|
@ -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;
|
||||
|
Reference in New Issue
Block a user