| @@ -4,11 +4,26 @@ import { MallService } from '../services/mall.service'; | |||
| import { Router } from '@angular/router'; | |||
| import { ToastController } from '@ionic/angular'; | |||
| export type ICart = { | |||
| orderedlist: Array<{ | |||
| mall_id: number, | |||
| outlet_id: number, | |||
| item_id: number, | |||
| quantity: number, | |||
| pickup_time: string, | |||
| take_away: boolean, | |||
| order_status: boolean, | |||
| total_price: number, | |||
| soft_delete: boolean | |||
| }> | |||
| }; | |||
| @Component({ | |||
| selector: 'app-cart', | |||
| templateUrl: './cart.page.html', | |||
| styleUrls: ['./cart.page.scss'], | |||
| }) | |||
| export class CartPage implements OnInit { | |||
| constructor( | |||
| private location: Location, | |||
| @@ -62,7 +62,7 @@ | |||
| <div class="menu-card-holder"> | |||
| <header> | |||
| <div> | |||
| <button color="default" fill="clear" (click)="show_filter_popup = true"> FILTER </button> | |||
| <!-- <button color="default" fill="clear" (click)="show_filter_popup = true"> FILTER </button> --> | |||
| <button color="default" fill="clear" (click)="show_sort_popup = true"> SORT </button> | |||
| </div> | |||
| <div class="toggle" (click)="show_only_veg = !show_only_veg"> VEG MENU <ion-toggle [(ngModel)]="show_only_veg"></ion-toggle> | |||
| @@ -113,7 +113,7 @@ | |||
| <div class="price"> | |||
| <span> ₹ {{ item.item_price - item.item_discount }} </span> | |||
| <button class="cart-button"> | |||
| <button class="cart-button" (click)="addToCart(item)" *ngIf="!isItemPresentInCart(item.menuitem_id)"> | |||
| <ion-icon name="cart"></ion-icon> | |||
| </button> | |||
| </div> | |||
| @@ -150,22 +150,22 @@ | |||
| </div> | |||
| </div> | |||
| <div class="common-semi-modal filter-holder" [ngClass]="{'active' : show_filter_popup }"> | |||
| <!-- <div class="common-semi-modal filter-holder" [ngClass]="{'active' : show_filter_popup }"> | |||
| <header> | |||
| FILTER <button (click)="show_filter_popup = false"> Done </button> | |||
| </header> | |||
| <ion-list> | |||
| <ion-item *ngFor="let tag of outlet_details.item_categories"> | |||
| <!-- <ion-checkbox slot="start" [checked]="selected_tag === tag"></ion-checkbox> --> | |||
| <!-- <ion-label> {{ tag }} </ion-label> --> | |||
| <ion-checkbox slot="start" [checked]="selected_tag === tag"></ion-checkbox> --> | |||
| <!-- <ion-label> {{ tag }} </ion-label> | |||
| </ion-item> | |||
| </ion-list> | |||
| </div> | |||
| </div> --> | |||
| <!-- <ion-fab *ngIf="cart_items.length > 0" (click)="goToCart()"> | |||
| <ion-fab *ngIf="userCart.orderedlist.length > 0" (click)="goToCart()"> | |||
| <ion-fab-button> | |||
| <ion-icon name="cart"></ion-icon> | |||
| </ion-fab-button> | |||
| </ion-fab> --> | |||
| </ion-fab> | |||
| </ion-content> | |||
| @@ -1,6 +1,8 @@ | |||
| import { Component, OnInit } from '@angular/core'; | |||
| import { ActivatedRoute, Router } from '@angular/router'; | |||
| import { Location } from '@angular/common'; | |||
| import { ICart } from '../cart/cart.page'; | |||
| import * as moment from 'moment'; | |||
| @Component({ | |||
| selector: 'app-outlet-details', | |||
| @@ -11,12 +13,15 @@ export class OutletDetailsPage implements OnInit { | |||
| show_top_bar: boolean = false; | |||
| show_only_veg: boolean = false; | |||
| selected_tag: string = null; | |||
| selected_description: string = null; | |||
| show_sort_popup: boolean = false; | |||
| selected_sort: string = null; | |||
| show_grid: boolean = true; | |||
| show_filter_popup: boolean = false; | |||
| outlet_details: any; | |||
| mallId: number; | |||
| userCart: ICart = { | |||
| orderedlist: [] | |||
| }; | |||
| constructor( | |||
| private route: ActivatedRoute, | |||
| @@ -26,13 +31,41 @@ export class OutletDetailsPage implements OnInit { | |||
| ngOnInit() { | |||
| } | |||
| getFormatterDateTime(date: any, format: string) { | |||
| return moment(date).format(format); | |||
| } | |||
| ionViewDidEnter() { | |||
| this.outlet_details = JSON.parse(this.route.snapshot.paramMap.get('outlet')); | |||
| // console.log(this.route.snapshot.paramMap.get('mallId')); | |||
| this.mallId = Number(this.route.snapshot.paramMap.get('mallId')); | |||
| } | |||
| addToCart(item: any) { | |||
| this.userCart.orderedlist.push({ | |||
| mall_id: this.mallId, | |||
| outlet_id: this.outlet_details.outlet_id, | |||
| item_id: item.menuitem_id, | |||
| quantity: 1, | |||
| pickup_time: moment().add(moment.duration(item.wait_duration).asMinutes(), 'minutes').format(), | |||
| take_away: true, | |||
| order_status: false, | |||
| total_price: item.item_price, | |||
| soft_delete: false | |||
| }); | |||
| console.log(this.userCart); | |||
| } | |||
| isItemPresentInCart(itemId: number) { | |||
| let item = this.userCart.orderedlist.find((order) => { | |||
| return order.item_id === itemId; | |||
| }); | |||
| return item ? true : false; | |||
| } | |||
| back() { | |||
| this.location.back(); | |||
| } | |||