Commit 0681483b by Adarsh K

new changes

parent 847ae234
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
<ion-menu> <ion-menu>
<ion-content> <ion-content>
<div class="side_menu_wrapper"> <div class="side_menu_wrapper">
<div class="top_banner"> <div class="top_banner" (click)="vieworder('profile')">
<div class="top_image"> <div class="top_image">
</div> </div>
<div class="top_detail"> <div class="top_detail" >
<h4>John Doe</h4> <h4>John Doe</h4>
<p>[email protected]</p> <p>[email protected]</p>
</div> </div>
......
...@@ -2,6 +2,8 @@ import { NgModule } from '@angular/core'; ...@@ -2,6 +2,8 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router'; import { Routes, RouterModule } from '@angular/router';
import { AgmCoreModule } from '@agm/core';
import { AgmDirectionModule } from 'agm-direction';
import { IonicModule } from '@ionic/angular'; import { IonicModule } from '@ionic/angular';
...@@ -19,6 +21,10 @@ const routes: Routes = [ ...@@ -19,6 +21,10 @@ const routes: Routes = [
CommonModule, CommonModule,
FormsModule, FormsModule,
IonicModule, IonicModule,
AgmDirectionModule,
AgmCoreModule.forRoot({
apiKey: 'AIzaSyBn6hOlr6YHcZAmbptlsmbhvH5iQllWflE'
}),
RouterModule.forChild(routes) RouterModule.forChild(routes)
], ],
declarations: [CartPage] declarations: [CartPage]
......
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
<div class="card_div" [hidden]="gateway !=3"> <div class="card_div" [hidden]="gateway !=3">
<input class="card_no borderNone widthFull" placeholder="PafyK ID"> <input class="card_no borderNone widthFull" placeholder="PafyK ID">
</div> --> </div> -->
<div class="delivery_time"> <!-- <div class="delivery_time">
<ul> <ul>
<li> <li>
Delivery 10 Mnt<br> Delivery 10 Mnt<br>
...@@ -145,10 +145,12 @@ ...@@ -145,10 +145,12 @@
<strong>FREE</strong> <strong>FREE</strong>
</li> </li>
</ul> </ul>
</div> </div> -->
<hr> <hr>
<div class="coupon_code"> <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> </div>
<br/> <br/>
...@@ -219,4 +221,5 @@ ...@@ -219,4 +221,5 @@
<div></div> <div></div>
<div></div> <div></div>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -128,7 +128,15 @@ export class CartPage implements OnInit { ...@@ -128,7 +128,15 @@ export class CartPage implements OnInit {
}, 500); }, 500);
console.log(index); console.log(index);
if (index === 2) { 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'); console.log('ready for slide');
this.slides.slideNext(); this.slides.slideNext();
}); });
...@@ -175,4 +183,22 @@ export class CartPage implements OnInit { ...@@ -175,4 +183,22 @@ export class CartPage implements OnInit {
return actualTotal; 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'; ...@@ -7,7 +7,7 @@ import { AddressService } from './../../config/address.service';
import { ServiceService } from './../../config/service.service'; import { ServiceService } from './../../config/service.service';
import { NgForm } from '@angular/forms'; import { NgForm } from '@angular/forms';
import * as firebase from 'firebase'; import * as firebase from 'firebase';
import { google } from '@agm/core/services/google-maps-types'; /* import { google } from '@agm/core/services/google-maps-types'; */
@Component({ @Component({
selector: 'app-nearby', selector: 'app-nearby',
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
</ion-slides> </ion-slides>
</ul> </ul>
</div> </div>
<h5>Color</h5> <!-- <h5>Color</h5>
<div class="color_div"> <div class="color_div">
<ul> <ul>
<ion-slides pager="false" [options]="slideOpts"> <ion-slides pager="false" [options]="slideOpts">
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
</ion-slide> </ion-slide>
</ion-slides> </ion-slides>
</ul> </ul>
</div> </div> -->
<h5>Description</h5> <h5>Description</h5>
<p>{{product.prodDesc}} <p>{{product.prodDesc}}
</p> </p>
......
...@@ -63,7 +63,7 @@ export class AuthService { ...@@ -63,7 +63,7 @@ export class AuthService {
custRef.valueChanges().pipe(take(1)).subscribe((value: User[]) => { custRef.valueChanges().pipe(take(1)).subscribe((value: User[]) => {
if (value.length > 0) { if (value.length > 0) {
this.afs.collection('customers').doc(this.userData.uid).update({otp: ''}); this.afs.collection('customers').doc(this.userData.uid).update({otp: ''});
this.router.navigateByUrl('addaddresss'); this.router.navigateByUrl('nearby');
} else { } else {
window.alert('Please input valid OTP'); window.alert('Please input valid OTP');
} }
......
...@@ -8,7 +8,6 @@ import * as firebase from 'firebase'; ...@@ -8,7 +8,6 @@ import * as firebase from 'firebase';
import { take } from 'rxjs/operators'; import { take } from 'rxjs/operators';
import { User } from './services/user'; import { User } from './services/user';
import { from } from 'rxjs'; import { from } from 'rxjs';
import undefined = require('firebase/empty-import');
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -35,8 +34,6 @@ export class CartsService { ...@@ -35,8 +34,6 @@ export class CartsService {
data = JSON.parse(data); data = JSON.parse(data);
this.custId = data.uid; this.custId = data.uid;
console.log(this.custId); console.log(this.custId);
} else {
this.custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2';
} }
}); });
} }
...@@ -167,6 +164,14 @@ export class CartsService { ...@@ -167,6 +164,14 @@ export class CartsService {
this.afs.collection('carts').doc(this.carts[index].cartId).delete(); 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 { ...@@ -104,7 +104,7 @@ export class OrdersService {
}*/ }*/
public async checkOut(cart: CartItem[]) { public async checkOut(cart: CartItem[], otherCharge) {
console.log(cart); console.log(cart);
console.log(this.users); console.log(this.users);
const cartGroup = []; const cartGroup = [];
...@@ -112,7 +112,7 @@ export class OrdersService { ...@@ -112,7 +112,7 @@ export class OrdersService {
const distinctShops = []; const distinctShops = [];
const map = new Map(); const map = new Map();
for (const item of cart) { 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 map.set(item.shopperId, true); // set any value to Map
distinctShops.push(item.shopperId); distinctShops.push(item.shopperId);
} }
...@@ -157,11 +157,11 @@ export class OrdersService { ...@@ -157,11 +157,11 @@ export class OrdersService {
console.log(products); console.log(products);
const product = cartItem[0]; const product = cartItem[0];
const orderItem: Order = { const orderItem: Order = {
amount: 'A$ ' + prodPrice, amount: 'A$ ' + otherCharge.totalAmt,
customer: firebase.firestore().doc('/customer/' + this.custId), customer: firebase.firestore().doc('/customer/' + this.custId),
shopper: product.shopper, shopper: product.shopper,
deliveryAddress: 'Techware Software solution, Carnival Infopark, Kochi', deliveryAddress: otherCharge.custAddress,
deliveryCharge: 'A$ 0.5', deliveryCharge: 'A$ ' + otherCharge.deliveryCharge,
deliveryLocation: delivery, deliveryLocation: delivery,
bookDate: firebase.firestore.FieldValue.serverTimestamp(), bookDate: firebase.firestore.FieldValue.serverTimestamp(),
orderCode: this.orderCode(), orderCode: this.orderCode(),
...@@ -179,7 +179,10 @@ export class OrdersService { ...@@ -179,7 +179,10 @@ export class OrdersService {
riderName: 'John', riderName: 'John',
shopperState: 0, shopperState: 0,
shopperName: 'Witchery', shopperName: 'Witchery',
product: products product: products,
discount: 'A$ ' + otherCharge.discount,
promoApplied: otherCharge.discountApplied,
tax: 'A$ ' + otherCharge.taxAmount
}; };
console.log(orderItem); console.log(orderItem);
......
...@@ -64,6 +64,9 @@ export interface Order { ...@@ -64,6 +64,9 @@ export interface Order {
status: number; status: number;
shopperState: number; shopperState: number;
product: any; 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