Commit 0681483b by Adarsh K

new changes

parent 847ae234
......@@ -3,11 +3,11 @@
<ion-menu>
<ion-content>
<div class="side_menu_wrapper">
<div class="top_banner">
<div class="top_banner" (click)="vieworder('profile')">
<div class="top_image">
</div>
<div class="top_detail">
<div class="top_detail" >
<h4>John Doe</h4>
<p>[email protected]</p>
</div>
......
......@@ -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/>
......@@ -219,4 +221,5 @@
<div></div>
<div></div>
</div>
</div>
\ No newline at end of file
</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;
}
}
});
}
}
......@@ -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',
......
......@@ -67,7 +67,7 @@
</ion-slides>
</ul>
</div>
<h5>Color</h5>
<!-- <h5>Color</h5>
<div class="color_div">
<ul>
<ion-slides pager="false" [options]="slideOpts">
......@@ -123,7 +123,7 @@
</ion-slide>
</ion-slides>
</ul>
</div>
</div> -->
<h5>Description</h5>
<p>{{product.prodDesc}}
</p>
......
......@@ -63,7 +63,7 @@ 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.router.navigateByUrl('nearby');
} else {
window.alert('Please input valid OTP');
}
......
......@@ -8,7 +8,6 @@ import * as firebase from 'firebase';
import { take } from 'rxjs/operators';
import { User } from './services/user';
import { from } from 'rxjs';
import undefined = require('firebase/empty-import');
@Injectable({
providedIn: 'root'
......@@ -35,8 +34,6 @@ export class CartsService {
data = JSON.parse(data);
this.custId = data.uid;
console.log(this.custId);
} else {
this.custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2';
}
});
}
......@@ -167,6 +164,14 @@ export class CartsService {
this.afs.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();
}
......
......@@ -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);
......
......@@ -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