Commit f215b4c0 by amalk

Merge branch 'master' into amal

parents b8de975f d8f289e1
......@@ -3,16 +3,18 @@
<ion-menu>
<ion-content>
<div class="side_menu_wrapper">
<ion-menu-toggle>
<div class="top_banner">
<div class="top_image">
</div>
<div class="top_detail">
<div class="top_detail" >
<h4>John Doe</h4>
<p>[email protected]</p>
</div>
<div class="clear"></div>
</div>
</ion-menu-toggle>
<div class="sidemenu_list">
<ul>
<ion-menu-toggle>
......
......@@ -2,6 +2,8 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { AgmCoreModule } from '@agm/core';
import { AgmDirectionModule } from 'agm-direction';
import { IonicModule } from '@ionic/angular';
......@@ -19,6 +21,10 @@ const routes: Routes = [
CommonModule,
FormsModule,
IonicModule,
AgmDirectionModule,
AgmCoreModule.forRoot({
apiKey: 'AIzaSyBn6hOlr6YHcZAmbptlsmbhvH5iQllWflE'
}),
RouterModule.forChild(routes)
],
declarations: [CartPage]
......
......@@ -134,7 +134,7 @@
<div class="card_div" [hidden]="gateway !=3">
<input class="card_no borderNone widthFull" placeholder="PafyK ID">
</div> -->
<div class="delivery_time">
<!-- <div class="delivery_time">
<ul>
<li>
Delivery 10 Mnt<br>
......@@ -145,10 +145,12 @@
<strong>FREE</strong>
</li>
</ul>
</div>
</div> -->
<hr>
<div class="coupon_code">
<input class="" placeholder="COUPON CODE"><button class="add_btn">ADD</button>
<input class="" placeholder="COUPON CODE" #promo><button class="add_btn" (click)="promoApply(promo.value)">ADD</button>
<br/>&nbsp;<h6>GET50</h6>
<span *ngIf="discountApplied" style="color: red">Promocode applied successfully </span>
</div>
<br/>
......@@ -220,3 +222,4 @@
<div></div>
</div>
</div>
......@@ -128,7 +128,15 @@ export class CartPage implements OnInit {
}, 500);
console.log(index);
if (index === 2) {
const state = this.orderService.checkOut(this.cartService.carts).then((data) => {
const otherCharges = {
deliveryCharge : this.deliveryCharge,
taxAmount: this.taxAmount,
discount: this.discount,
discountApplied: this.discountApplied,
totalAmt: this.totalAmt,
custAddress: this.custAddress
};
const state = this.orderService.checkOut(this.cartService.carts, otherCharges).then((data) => {
console.log('ready for slide');
this.slides.slideNext();
});
......@@ -175,4 +183,22 @@ export class CartPage implements OnInit {
return actualTotal;
}
promoApply(code) {
console.log(code);
this.cartService.checkPromo(code).subscribe((value) => {
if (value.length > 0) {
const promo = value[0];
this.discountApplied = true;
if (value[0].type === 1) {
const rate = value[0].amount;
const upto = value[0].amount;
const percentage = (this.cartService.cartTotal * rate) / 100;
this.discount = percentage > upto ? upto : percentage;
} else {
this.discount = value[0].amount;
}
}
});
}
}
......@@ -15,7 +15,7 @@
<button class="order_track floatRight" *ngIf="order.orderStatus >= 3 && order.orderStatus < 7" (click)="orderDetails(i)">Track Order</button>
<div class="clear"></div>
</div>
<div *ngFor="let product of order.product">
<div *ngFor="let product of order.product" (click)="viewOrder(order)">
<div class="order_image"><img [src]="product.image" onerror="" /></div>
<div class="order_detail">
<h5 class="floatLeft">{{product.prodName}}</h5>
......
......@@ -4,6 +4,7 @@ import { Router, ActivatedRoute } from '@angular/router';
import { MyordersService } from './../../config/myorder.service';
import { ModalController } from '@ionic/angular';
import { DeliverypopPage } from '../deliverypop/deliverypop.page';
import { ServiceService } from './../../config/service.service';
@Component({
selector: 'app-myorder',
......@@ -18,7 +19,8 @@ export class MyorderPage implements OnInit {
private route: ActivatedRoute,
private location: Location,
public myorder: MyordersService,
public modalController: ModalController
public modalController: ModalController,
public service: ServiceService
) { }
ngOnInit() {
......@@ -59,6 +61,13 @@ export class MyorderPage implements OnInit {
}
}
viewOrder(data) {
console.log(data);
this.service.set('order', data);
this.router.navigateByUrl('orderplaced', { queryParams: data });
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
getStatus(status: number) {
switch (status) {
case 1:
......
<div class="nav_header">
<button class="nav_btn nav_back floatLeft" (click)="goBack()">
<button class="nav_btn nav_back floatLeft" (click)="goBack()" *ngIf="type === 0">
<img src="../assets/Group17_2.png">
</button>
<div class="nav_title floatLeft">
......
......@@ -7,7 +7,7 @@ import { AddressService } from './../../config/address.service';
import { ServiceService } from './../../config/service.service';
import { NgForm } from '@angular/forms';
import * as firebase from 'firebase';
import { google } from '@agm/core/services/google-maps-types';
/* import { google } from '@agm/core/services/google-maps-types'; */
@Component({
selector: 'app-nearby',
......@@ -25,6 +25,7 @@ export class NearbyPage implements OnInit {
addressData = new Address('', '', '', '', true, '', 0, '');
successState: boolean;
uid: string;
type: any;
public searchElementRef: ElementRef;
constructor(
......@@ -37,12 +38,17 @@ export class NearbyPage implements OnInit {
public service: ServiceService
) {
this.successState = false;
this.type = 0;
const users = this.service.get('user').then((data) => {
if (data) {
data = JSON.parse(data);
this.uid = data.uid;
}
});
this.service.get('type').then((data) => {
this.type = data;
});
}
ngOnInit() {
......@@ -118,6 +124,10 @@ export class NearbyPage implements OnInit {
this.successState = true;
setTimeout(() => {
this.successState = false;
if (this.type === 1) {
this.service.set('type', 0);
this.router.navigateByUrl('home', { queryParams: null });
}
}, 3000);
}
}
......
<ion-content>
<div class="cart_wrapper">
<div class="cart_wrapper" *ngIf="data">
<div class="cart_head">
<div class="nav_header">
<button class="nav_btn nav_back_white floatLeft" (click)="goBack()">
......@@ -14,16 +14,16 @@
</div>
<img src="../assets/white_tick.png">
<h4>ORDER IS PLACED</h4>
<p>June 26th 2019, 03:00 PM</p>
<p>{{ data.bookDate.seconds * 1000 | date:'MMMM dd, y' }}</p>
</div>
<div class="order_status">
<div class="clear"></div>
<div class="status_div go_green">
<h4>Order Placed</h4>
<h6>June 26th 2019, 03:00PM</h6>
<h6>{{ data.bookDate.seconds * 1000 | date:'MMMM dd, y' }}</h6>
</div>
<div class="status_gap go_green">
<!-- <div class="status_gap go_green">
</div>
<div class="status_div go_green">
<h4>Retailer Accepted</h4>
......@@ -55,7 +55,7 @@
</div>
<div class="status_div">
<h4>Your product is delivered</h4>
</div>
</div> -->
</div>
<div class="nearby_shop_list">
<ul>
......@@ -65,8 +65,8 @@
</div>
<div class="nearby_detail">
<h5>
<span class="floatLeft">Carnival Life</span>
<span class="floatRight">4
<span class="floatLeft">{{data.shopperName}}</span>
<span class="floatRight">0
<img src="../assets/Path61_2.png">
</span>
<div class="clear"></div>
......@@ -77,20 +77,20 @@
</li>
</ul>
</div>
<div class="product_detail">
<h6>Green, Small</h6>
<h5>Quantity : <span>3</span></h5>
<h5>Amount : <strong>AU$99.00</strong><span class="afterpay">After Pay</span></h5>
<div class="product_detail" *ngFor="let product of data.product">
<h6>{{product.color}}, {{product.size}}</h6>
<h5>Quantity : <span>{{product.qty}}</span></h5>
<h5>Amount : <strong>A$ {{product.price}}</strong><span class="afterpay">COD</span></h5>
<h5>Delivery time : <span>Delivery in 1 hour</span></h5>
<h4>DELIVERY</h4>
<h5>
Shamjith KS<br> +00 0000 888 888<br> Carnival Infopark Infopark Kochi<br> 682030, Kerala, India
{{deliveryAddress}}
</h5>
<button class="cancel_btn" (click)="goToPage('ordercancelled')">CANCEL THIS ORDER</button>
<hr>
</div>
<div class="related_product_slider">
<!-- <div class="related_product_slider">
<h5>
<span class="floatLeft">Related Products</span><span class="floatRight">MORE</span>
<div class="clear"></div>
......@@ -144,6 +144,6 @@
</ion-slide>
</ion-slides>
</ul>
</div>
</div> -->
</div>
</ion-content>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { ServiceService } from './../../config/service.service';
@Component({
selector: 'app-orderplaced',
......@@ -8,12 +9,18 @@ import { Router, ActivatedRoute } from '@angular/router';
styleUrls: ['./orderplaced.page.scss'],
})
export class OrderplacedPage implements OnInit {
data: any;
constructor(
private router: Router,
private route: ActivatedRoute,
private location: Location
) { }
private location: Location,
private service: ServiceService
) {
this.service.get('order').then(val => {
this.data = val;
});
}
ngOnInit() {
}
......
......@@ -79,7 +79,7 @@
</ion-slides>
</ul>
</div>
<h5>Color</h5>
<!-- <h5>Color</h5>
<div class="color_div">
<ul>
<ion-slides pager="false" [options]="slideOpts">
......@@ -135,7 +135,7 @@
</ion-slide>
</ion-slides>
</ul>
</div>
</div> -->
<h5>Description</h5>
<p>{{product.prodDesc}}
</p>
......
import { Component, OnInit } from "@angular/core";
import { Location } from "@angular/common";
import { Router, ActivatedRoute } from "@angular/router";
import { Products } from "./../../config/services/product";
import { Order } from "./../../config/services/order";
import { CartsService } from "./../../config/cart.service";
import { ProductsService } from "./../../config/products.service";
import { ServiceService } from "./../../config/service.service";
import { map } from "rxjs/operators";
import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { Products } from './../../config/services/product';
import { Order } from './../../config/services/order';
import { CartsService } from './../../config/cart.service';
import { ProductsService } from './../../config/products.service';
import { ServiceService } from './../../config/service.service';
import { map } from 'rxjs/operators';
@Component({
selector: "app-productdetail",
templateUrl: "./productdetail.page.html",
styleUrls: ["./productdetail.page.scss"]
selector: 'app-productdetail',
templateUrl: './productdetail.page.html',
styleUrls: ['./productdetail.page.scss']
})
export class ProductdetailPage implements OnInit {
product: Products;
......@@ -47,7 +47,7 @@ export class ProductdetailPage implements OnInit {
params.subCate,
params.prodId
);
this.service.get("params").then(val => {
this.service.get('params').then(val => {
this.data = val;
});
this.cartService.cartList();
......@@ -112,7 +112,7 @@ export class ProductdetailPage implements OnInit {
buyNow(product: any, type: number) {
this.cartService.buyNow(product).then(() => {
if (type === 1) {
this.router.navigateByUrl("cart");
this.router.navigateByUrl('cart');
} else {
// alert('Product added to cart');
}
......@@ -126,7 +126,7 @@ export class ProductdetailPage implements OnInit {
checkFavStatus(index) {
const state = this.prodService.fav.findIndex(x => x === index);
return state > -1 ? "fav_fill" : "fav_icon";
return state > -1 ? 'fav_fill' : 'fav_icon';
}
changeFav(index) {
......@@ -135,10 +135,10 @@ export class ProductdetailPage implements OnInit {
console.log(this.prodService.fav);
if (state > -1) {
this.prodService.fav.splice(state, 1);
this.prodService.changeFav(index, "yes");
this.prodService.changeFav(index, 'yes');
} else {
this.prodService.fav.push(index);
this.prodService.changeFav(index, "no");
this.prodService.changeFav(index, 'no');
}
return;
console.log(this.prodService.fav);
......
......@@ -63,7 +63,8 @@ export class AuthService {
custRef.valueChanges().pipe(take(1)).subscribe((value: User[]) => {
if (value.length > 0) {
this.afs.collection('customers').doc(this.userData.uid).update({otp: ''});
this.router.navigateByUrl('addaddresss');
this.service.set('type', 1);
this.router.navigateByUrl('nearby');
} else {
window.alert('Please input valid OTP');
}
......
import { Injectable } from "@angular/core";
import {
AngularFirestore,
AngularFirestoreDocument,
AngularFirestoreCollection
} from "@angular/fire/firestore";
import { Router, ActivatedRoute } from "@angular/router";
import { Products } from "./services/product";
import { Cart, CartItem } from "./services/cart";
import { ServiceService } from "./service.service";
import * as firebase from "firebase";
import { take } from "rxjs/operators";
import { User } from "./services/user";
import { from } from "rxjs";
import { Injectable } from '@angular/core';
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore';
import { Router, ActivatedRoute } from '@angular/router';
import { Products } from './services/product';
import { Cart, CartItem } from './services/cart';
import { ServiceService } from './service.service';
import * as firebase from 'firebase';
import { take } from 'rxjs/operators';
import { User } from './services/user';
import { from } from 'rxjs';
@Injectable({
providedIn: "root"
providedIn: 'root'
})
export class CartsService {
size: string;
......@@ -31,15 +27,13 @@ export class CartsService {
public router: Router,
public service: ServiceService
) {
this.custId = "";
this.custId = '';
this.carts = [];
const users = this.service.get("user").then(data => {
const users = this.service.get('user').then(data => {
if (data) {
data = JSON.parse(data);
this.custId = data.uid;
console.log(this.custId);
} else {
this.custId = "WwHnLICVY2dvZGUHuKqasiTB91a2";
}
});
}
......@@ -48,20 +42,20 @@ export class CartsService {
this.prodId = product.prodId;
const prodRef = firebase
.firestore()
.collection("products")
.collection('products')
.doc(this.prodId);
this.size = this.size === undefined ? product.size[0] : this.size;
this.color = this.color === undefined ? product.color[0] : this.color;
const cartRef: AngularFirestoreCollection<any> = this.afs.collection(
"carts",
'carts',
ref =>
ref
.where("size", "==", this.size)
.where("color", "==", this.color)
.where("custId", "==", this.custId)
.where("product", "==", prodRef)
.where('size', '==', this.size)
.where('color', '==', this.color)
.where('custId', '==', this.custId)
.where('product', '==', prodRef)
);
cartRef
.valueChanges()
......@@ -71,7 +65,7 @@ export class CartsService {
if (value.length === 0) {
product.image =
product.image === undefined
? "../assets/[email protected]"
? '../assets/[email protected]'
: product.image;
const cart: Cart = {
color: this.color,
......@@ -88,21 +82,21 @@ export class CartsService {
};
console.log(cart);
this.afs
.collection("carts")
.collection('carts')
.add(cart)
.then(docRef => {
const neworderId = docRef.id;
this.afs
.collection("carts")
.collection('carts')
.doc(neworderId)
.update({ cartId: docRef.id })
.then(() => {
console.log("Booking Successfully");
console.log('Booking Successfully');
document.body.scrollTop = document.documentElement.scrollTop = 0;
});
})
.catch(error => {
console.error("Error adding document: ", error);
console.error('Error adding document: ', error);
});
} else {
console.log(value);
......@@ -111,11 +105,11 @@ export class CartsService {
// tslint:disable-next-line:radix
const qty = parseInt(value[0].qty) + 1;
this.afs
.collection("carts")
.collection('carts')
.doc(cartId)
.update({ qty: `${qty}` })
.then(() => {
console.log("Booking Successfully");
console.log('Booking Successfully');
document.body.scrollTop = document.documentElement.scrollTop = 0;
});
}
......@@ -124,8 +118,8 @@ export class CartsService {
public async cartList() {
const cartRef: AngularFirestoreCollection<any> = this.afs.collection(
"carts",
ref => ref.where("custId", "==", this.custId)
'carts',
ref => ref.where('custId', '==', this.custId)
);
cartRef.valueChanges().subscribe(value => {
this.carts = [];
......@@ -183,7 +177,7 @@ export class CartsService {
this.carts[index].qty = qty;
console.log(this.carts[index].qty);
this.afs
.collection("carts")
.collection('carts')
.doc(this.carts[index].cartId)
.update({
qty: this.carts[index].qty
......@@ -195,7 +189,7 @@ export class CartsService {
this.cartTotal = 0;
this.carts[index].qty = qty;
this.afs
.collection("carts")
.collection('carts')
.doc(this.carts[index].cartId)
.update({
qty: this.carts[index].qty
......@@ -204,8 +198,21 @@ export class CartsService {
removeItem(index) {
this.afs
.collection("carts")
.collection('carts')
.doc(this.carts[index].cartId)
.delete();
}
checkPromo(promoCode: string) {
console.log(promoCode);
const state = true;
const promoRef: AngularFirestoreCollection<any> = this.afs.collection('promocode', ref => ref.where('promoCode', '==', promoCode)
.where('status', '==', state));
return promoRef.valueChanges();
}
}
......@@ -102,6 +102,7 @@ export class MyordersService {
bookDate: item.bookDate,
deliveryLocation: item.deliveryLocation,
pickupLocation: item.pickupLocation,
deliveryAddress: item.deliveryAddress,
riderName: 'John',
orderId: item.orderId,
orderCode: item.orderCode,
......
......@@ -104,7 +104,7 @@ export class OrdersService {
}*/
public async checkOut(cart: CartItem[]) {
public async checkOut(cart: CartItem[], otherCharge) {
console.log(cart);
console.log(this.users);
const cartGroup = [];
......@@ -112,7 +112,7 @@ export class OrdersService {
const distinctShops = [];
const map = new Map();
for (const item of cart) {
if (!map.has(item.shopperId)){
if (!map.has(item.shopperId)) {
map.set(item.shopperId, true); // set any value to Map
distinctShops.push(item.shopperId);
}
......@@ -157,11 +157,11 @@ export class OrdersService {
console.log(products);
const product = cartItem[0];
const orderItem: Order = {
amount: 'A$ ' + prodPrice,
amount: 'A$ ' + otherCharge.totalAmt,
customer: firebase.firestore().doc('/customer/' + this.custId),
shopper: product.shopper,
deliveryAddress: 'Techware Software solution, Carnival Infopark, Kochi',
deliveryCharge: 'A$ 0.5',
deliveryAddress: otherCharge.custAddress,
deliveryCharge: 'A$ ' + otherCharge.deliveryCharge,
deliveryLocation: delivery,
bookDate: firebase.firestore.FieldValue.serverTimestamp(),
orderCode: this.orderCode(),
......@@ -179,7 +179,10 @@ export class OrdersService {
riderName: 'John',
shopperState: 0,
shopperName: 'Witchery',
product: products
product: products,
discount: 'A$ ' + otherCharge.discount,
promoApplied: otherCharge.discountApplied,
tax: 'A$ ' + otherCharge.taxAmount
};
console.log(orderItem);
......
......@@ -3,6 +3,7 @@ export interface Myorder {
bookDate: any;
pickupLocation: any;
deliveryLocation: any;
deliveryAddress: any;
status: number;
orderStatus: number;
riderName: string;
......
......@@ -64,6 +64,9 @@ export interface Order {
status: number;
shopperState: number;
product: any;
tax: string;
discount: string;
promoApplied: boolean;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment