Working cart
This commit is contained in:
		@@ -26,6 +26,7 @@ import {ProductsComponent} from './store/products/products.component';
 | 
			
		||||
import {CartComponent} from './store/cart/cart.component';
 | 
			
		||||
import {ViewComponents} from './formulaManager/viewComponents/viewComponents.component';
 | 
			
		||||
import {NewComponentComponent} from './formulaManager/newComponent/newComponent.component';
 | 
			
		||||
import {HttpModule} from '@angular/http';
 | 
			
		||||
 | 
			
		||||
@NgModule({
 | 
			
		||||
  declarations: [
 | 
			
		||||
@@ -55,6 +56,7 @@ import {NewComponentComponent} from './formulaManager/newComponent/newComponent.
 | 
			
		||||
    BrowserAnimationsModule,
 | 
			
		||||
    BrowserModule,
 | 
			
		||||
    FormsModule,
 | 
			
		||||
    HttpModule,
 | 
			
		||||
    NgxElectronModule,
 | 
			
		||||
    ReactiveFormsModule,
 | 
			
		||||
    RouterModule.forRoot([
 | 
			
		||||
 
 | 
			
		||||
@@ -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