Commit ccfca2f5 by Adarsh K

Merge branch 'adarsh' into 'master'

Adarsh See merge request !89
parents eed252b7 74b674bd
...@@ -94,7 +94,8 @@ export class AppComponent { ...@@ -94,7 +94,8 @@ export class AppComponent {
}); });
} }
ionViewDidEnter() {} ionViewWillEnter() {
}
initializeApp() { initializeApp() {
this.platform.ready().then(() => { this.platform.ready().then(() => {
...@@ -241,6 +242,9 @@ export class AppComponent { ...@@ -241,6 +242,9 @@ export class AppComponent {
} else { } else {
this.orderId = data.orderCode; this.orderId = data.orderCode;
this.isShow = true; this.isShow = true;
setTimeout(() => {
this.isShow = false;
}, 3000);
} }
} }
}); });
......
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
<hr /> <hr />
<h5> <h5>
<span class="floatLeft">DELIVERY</span> <span class="floatLeft">DELIVERY</span>
<span class="floatRight" (click)="istoggle()">EDIT</span> <span class="floatRight" (click)="istoggle()">CHANGE</span>
<div class="clear"></div> <div class="clear"></div>
</h5> </h5>
<ion-grid class="p0" *ngIf="addressService.custAddress"> <ion-grid class="p0" *ngIf="addressService.custAddress">
...@@ -182,8 +182,9 @@ ...@@ -182,8 +182,9 @@
APPLY APPLY
</button> </button>
</div> </div>
<span *ngIf="discountApplied" class="promo-success">Promocode applied successfully <span *ngIf="discountApplied == 1" class="promo-success">Promocode applied successfully
</span> </span>
<span *ngIf="discountApplied == 2" class="promo-error">Invalid Promocode</span>
</div> </div>
<br /> <br />
......
...@@ -242,9 +242,16 @@ ...@@ -242,9 +242,16 @@
} }
} }
.promo-success { .promo-success {
color: #00f;
font-size: 16px;
text-align: center;
display: block;
margin-top: 5px;
}
.promo-error {
color: #31b131; color: #31b131;
font-size: 16px; font-size: 16px;
text-align: left; text-align: center;
display: block; display: block;
margin-top: 5px; margin-top: 5px;
} }
......
...@@ -46,12 +46,14 @@ export class CartPage implements OnInit { ...@@ -46,12 +46,14 @@ export class CartPage implements OnInit {
}; };
deliveryCharge: number; deliveryCharge: number;
taxAmount: number; taxAmount: number;
discountApplied: boolean; discountApplied: number;
discount: number; discount: number;
totalAmt: number; totalAmt: number;
bookDate: any; bookDate: any;
timeinterval: any; timeinterval: any;
paymentMethod: any; paymentMethod: any;
lat: number;
lng: number;
constructor( constructor(
private router: Router, private router: Router,
...@@ -71,7 +73,7 @@ export class CartPage implements OnInit { ...@@ -71,7 +73,7 @@ export class CartPage implements OnInit {
this.gateway = 1; this.gateway = 1;
this.deliveryCharge = 0; this.deliveryCharge = 0;
this.taxAmount = 0; this.taxAmount = 0;
this.discountApplied = false; this.discountApplied = 0;
this.discount = 0; this.discount = 0;
this.paymentMethod = 'PayPal'; this.paymentMethod = 'PayPal';
// this.cartService.cartList(); // this.cartService.cartList();
...@@ -89,6 +91,7 @@ export class CartPage implements OnInit { ...@@ -89,6 +91,7 @@ export class CartPage implements OnInit {
setTimeout(() => { setTimeout(() => {
this.loader = false; this.loader = false;
}, 1000); }, 1000);
this.setCurrentLocation();
} }
ngOnInit() { ngOnInit() {
...@@ -99,6 +102,16 @@ export class CartPage implements OnInit { ...@@ -99,6 +102,16 @@ export class CartPage implements OnInit {
}, 1000); */ }, 1000); */
} }
private setCurrentLocation() {
const This = this;
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition(position => {
this.lat = position.coords.latitude;
this.lng = position.coords.longitude;
});
}
}
ionViewWillEnter() { ionViewWillEnter() {
const users = this.service.get('user').then(data => { const users = this.service.get('user').then(data => {
if (data) { if (data) {
...@@ -155,6 +168,9 @@ export class CartPage implements OnInit { ...@@ -155,6 +168,9 @@ export class CartPage implements OnInit {
} }
goToPage(path, data = null) { goToPage(path, data = null) {
if (path === 'nearby') {
this.addressService.addressState = 1;
}
this.router.navigateByUrl(path, { queryParams: data, replaceUrl: true }); this.router.navigateByUrl(path, { queryParams: data, replaceUrl: true });
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
} }
...@@ -188,7 +204,7 @@ export class CartPage implements OnInit { ...@@ -188,7 +204,7 @@ export class CartPage implements OnInit {
deliveryCharge: this.deliveryCharge, deliveryCharge: this.deliveryCharge,
taxAmount: this.taxAmount, taxAmount: this.taxAmount,
discount: this.discount, discount: this.discount,
discountApplied: this.discountApplied, discountApplied: this.discountApplied === 1 ? true : false,
totalAmt: this.totalAmt, totalAmt: this.totalAmt,
custAddress: this.addressService.custAddress, custAddress: this.addressService.custAddress,
paymentMethod: this.paymentMethod paymentMethod: this.paymentMethod
...@@ -211,7 +227,7 @@ export class CartPage implements OnInit { ...@@ -211,7 +227,7 @@ export class CartPage implements OnInit {
this.slides.slideNext(); this.slides.slideNext();
}); });
} else { } else {
alert('Please choose delivery location'); this.istoggle();
} }
} else { } else {
this.slides.slideNext(); this.slides.slideNext();
...@@ -292,7 +308,7 @@ export class CartPage implements OnInit { ...@@ -292,7 +308,7 @@ export class CartPage implements OnInit {
this.cartService.checkPromo(code).subscribe(value => { this.cartService.checkPromo(code).subscribe(value => {
if (value.length > 0) { if (value.length > 0) {
const promo = value[0]; const promo = value[0];
this.discountApplied = true; this.discountApplied = 1;
if (value[0].type === 1) { if (value[0].type === 1) {
const rate = value[0].amount; const rate = value[0].amount;
const upto = value[0].amount; const upto = value[0].amount;
...@@ -304,6 +320,8 @@ export class CartPage implements OnInit { ...@@ -304,6 +320,8 @@ export class CartPage implements OnInit {
this.discount = value[0].amount; this.discount = value[0].amount;
} }
this.discount.toFixed(2); this.discount.toFixed(2);
} else {
this.discountApplied = 2;
} }
}); });
} }
......
...@@ -123,8 +123,9 @@ export class MyorderPage implements OnInit { ...@@ -123,8 +123,9 @@ export class MyorderPage implements OnInit {
getProductTotal(products) { getProductTotal(products) {
let amtPrice = 0; let amtPrice = 0;
products.forEach(element => { products.forEach(element => {
amtPrice += element.price * element.qty; amtPrice += (element.price * element.qty);
}); });
return 'A$' + this.service.formatNumber(amtPrice); const totalAmt: number = parseFloat(amtPrice.toFixed(2));
return 'A$' + (this.service.formatNumber(totalAmt));
} }
} }
...@@ -17,8 +17,10 @@ ...@@ -17,8 +17,10 @@
</ion-header> </ion-header>
<ion-content> <ion-content>
<div class="nearby_map"> <div class="nearby_map">
<agm-map [latitude]="latitude" [longitude]="longitude" [zoom]="8" [backgroundColor]="'rgba(29, 27, 130,0.2)'"> <agm-map [latitude]="latitude" [longitude]="longitude" [zoom]="8" [backgroundColor]="'rgba(29, 27, 130,0.2)'"
<agm-marker [latitude]="latitude" [longitude]="longitude" [markerDraggable]="true" (dragEnd)="markerDragEnd($event)" [iconUrl]=" (mapReady)="mapReady($event)" (centerChange)="centerChange($event)">
<agm-marker [latitude]="latitude" [longitude]="longitude" [markerDraggable]="true"
(dragEnd)="markerDragEnd($event)" [iconUrl]="
{ {
url: './assets/pin.svg', url: './assets/pin.svg',
scaledSize: { scaledSize: {
...@@ -26,15 +28,18 @@ ...@@ -26,15 +28,18 @@
height: 40 height: 40
}}"></agm-marker> }}"></agm-marker>
</agm-map> </agm-map>
<form (ngSubmit)="onSubmit(addressForm.value); addressForm.reset()" #addressForm="ngForm" method="post" class="form-horizontal"> <form (ngSubmit)="onSubmit(addressForm.value); addressForm.reset()" #addressForm="ngForm" method="post"
class="form-horizontal">
<div class="add_address_wrapper"> <div class="add_address_wrapper">
<h5>DELIVERY</h5> <h5>DELIVERY</h5>
<p>{{address}}</p> <p>{{address}}</p>
<input [(ngModel)]="addressForm.building" name="building" #building="ngModel" name="building" required placeholder="House No./ Building No" /> <input [(ngModel)]="addressForm.building" name="building" #building="ngModel" name="building" required
placeholder="House No./ Building No" />
<div class="md-errors-spacer" [hidden]="building.valid || landmark.pristine" class="ion-padding-start"> <div class="md-errors-spacer" [hidden]="building.valid || landmark.pristine" class="ion-padding-start">
Building Name is required Building Name is required
</div> </div>
<input [(ngModel)]="addressForm.landmark" name="landmark" #landmark="ngModel" name="landmark" required placeholder="Landmark" /> <input [(ngModel)]="addressForm.landmark" name="landmark" #landmark="ngModel" name="landmark" required
placeholder="Landmark" />
<div class="md-errors-spacer" [hidden]="landmark.valid || landmark.pristine" class="ion-padding-start"> <div class="md-errors-spacer" [hidden]="landmark.valid || landmark.pristine" class="ion-padding-start">
Landmark is required Landmark is required
</div> </div>
...@@ -42,24 +47,31 @@ ...@@ -42,24 +47,31 @@
<ion-row> <ion-row>
<ion-col> <ion-col>
<h6> <h6>
<input class="styled-checkbox" id="styled-check-1" type="radio" value="Home" [(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel" required /> <input class="styled-checkbox" id="styled-check-1" type="radio" value="Home"
[(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel"
required />
<label for="styled-check-1"><span>Home</span></label> <label for="styled-check-1"><span>Home</span></label>
</h6> </h6>
</ion-col> </ion-col>
<ion-col> <ion-col>
<h6> <h6>
<input class="styled-checkbox" id="styled-check-2" type="radio" value="Work" [(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel" required /> <input class="styled-checkbox" id="styled-check-2" type="radio" value="Work"
[(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel"
required />
<label for="styled-check-2"><span>Office</span></label> <label for="styled-check-2"><span>Office</span></label>
</h6> </h6>
</ion-col> </ion-col>
<ion-col> <ion-col>
<h6> <h6>
<input class="styled-checkbox" id="styled-check-3" type="radio" value="Other" [(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel" required /> <input class="styled-checkbox" id="styled-check-3" type="radio" value="Other"
[(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel"
required />
<label for="styled-check-3"><span>Others</span></label> <label for="styled-check-3"><span>Others</span></label>
</h6> </h6>
</ion-col> </ion-col>
</ion-row> </ion-row>
<div class="md-errors-spacer" [hidden]="addressType.valid || addressType.pristine" class="ion-padding-start"> <div class="md-errors-spacer" [hidden]="addressType.valid || addressType.pristine"
class="ion-padding-start">
Address Type is required Address Type is required
</div> </div>
</ion-grid> </ion-grid>
......
...@@ -35,6 +35,9 @@ export class NearbyPage implements OnInit { ...@@ -35,6 +35,9 @@ export class NearbyPage implements OnInit {
loader: boolean; loader: boolean;
public searchElementRef: ElementRef; public searchElementRef: ElementRef;
newCenterLat: number;
newCenterLng: number;
constructor( constructor(
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
...@@ -114,6 +117,17 @@ export class NearbyPage implements OnInit { ...@@ -114,6 +117,17 @@ export class NearbyPage implements OnInit {
); );
} }
mapReady(map) {
map.addListener('dragend', () => {
console.log(this.newCenterLat, this.newCenterLng);
});
}
centerChange(e) {
console.log(e);
this.newCenterLat = e.lat;
this.newCenterLng = e.lng;
}
goToPage(path, data = null) { goToPage(path, data = null) {
this.router.navigateByUrl(path, { queryParams: data }); this.router.navigateByUrl(path, { queryParams: data });
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
...@@ -145,7 +159,12 @@ export class NearbyPage implements OnInit { ...@@ -145,7 +159,12 @@ export class NearbyPage implements OnInit {
if (this.authService.regState === false) { if (this.authService.regState === false) {
this.router.navigateByUrl('preference', { queryParams: null }); this.router.navigateByUrl('preference', { queryParams: null });
} else { } else {
this.goBack(); if (this.addressService.addressState === 1) {
this.addressService.addressState = 0;
this.router.navigateByUrl('cart', { replaceUrl: true });
} else {
this.goBack();
}
} }
}, 3000); }, 3000);
} }
......
...@@ -153,7 +153,7 @@ export class ProductdetailPage implements OnInit { ...@@ -153,7 +153,7 @@ export class ProductdetailPage implements OnInit {
this.cartService.buyNow(product).then((data) => { this.cartService.buyNow(product).then((data) => {
if (data === true) { if (data === true) {
if (type === 1) { if (type === 1) {
this.router.navigateByUrl('cart', { replaceUrl: true }); this.router.navigateByUrl('cart');
} else { } else {
this.service.showToast('Added into cart', 'top', 'my-toast', 2000); this.service.showToast('Added into cart', 'top', 'my-toast', 2000);
} }
......
...@@ -81,6 +81,7 @@ export class WishlistPage implements OnInit { ...@@ -81,6 +81,7 @@ export class WishlistPage implements OnInit {
.then(datas => { .then(datas => {
this.loader = false; this.loader = false;
this.service.showToast('Added to cart', 'top', 'my-toast', 2000); this.service.showToast('Added to cart', 'top', 'my-toast', 2000);
this.router.navigateByUrl('cart', { replaceUrl: true, queryParams: data });
}) })
.catch(err => { .catch(err => {
this.loader = false; this.loader = false;
......
...@@ -17,7 +17,10 @@ export class AddressService { ...@@ -17,7 +17,10 @@ export class AddressService {
defaultAdd: AddressList; defaultAdd: AddressList;
custAddress: AddressList; custAddress: AddressList;
centerLoc: CenterData; centerLoc: CenterData;
constructor(public afs: AngularFirestore) { } addressState: number;
constructor(public afs: AngularFirestore) {
this.addressState = 0;
}
public async addList(userId: string) { public async addList(userId: string) {
const This = this; const This = this;
...@@ -220,13 +223,13 @@ export class AddressService { ...@@ -220,13 +223,13 @@ export class AddressService {
setAddress() { setAddress() {
console.log(this.nearestList); console.log(this.nearestList);
if (this.nearestList.length > 0) { if (this.nearestList.length > 0) {
let address = this.nearestList.find( this.custAddress = this.nearestList.find(
x => x.defaultVal === 1 x => x.defaultVal === 1
); );
if (!address) { /* if (!address) {
address = this.nearestList[0]; address = this.nearestList[0];
} }
this.custAddress = address; this.custAddress = address; */
} }
} }
} }
...@@ -261,6 +261,10 @@ export class AuthService { ...@@ -261,6 +261,10 @@ export class AuthService {
this.afAuth.auth this.afAuth.auth
.createUserWithEmailAndPassword(userData.emailId, userData.password) .createUserWithEmailAndPassword(userData.emailId, userData.password)
.then(result => { .then(result => {
result.user.updateProfile({
displayName: userData.name,
photoURL: ''
});
console.log(result.user); console.log(result.user);
this.afAuth.auth.currentUser.sendEmailVerification(); this.afAuth.auth.currentUser.sendEmailVerification();
const currencyData = { const currencyData = {
...@@ -367,4 +371,13 @@ export class AuthService { ...@@ -367,4 +371,13 @@ export class AuthService {
this.loader = false; this.loader = false;
}); });
} }
resend() {
this.service.showToast(
'OTP sent successfully',
'top',
'my-toast',
1000
);
}
} }
...@@ -103,7 +103,7 @@ export class MyordersService { ...@@ -103,7 +103,7 @@ export class MyordersService {
ref => ref.where('custId', '==', custId).orderBy('orderDate', 'desc') ref => ref.where('custId', '==', custId).orderBy('orderDate', 'desc')
); );
orderRef.stateChanges().subscribe(value => { orderRef.stateChanges().subscribe(value => {
// console.log(value); console.log(value);
const res = value; const res = value;
// console.log(res); // console.log(res);
if (res.length > 0) { if (res.length > 0) {
......
...@@ -141,8 +141,7 @@ export class OrdersService { ...@@ -141,8 +141,7 @@ export class OrdersService {
// console.log(cartCount); // console.log(cartCount);
const promise = new Promise(resolve => { const promise = new Promise(resolve => {
distinctShops.forEach(item => { distinctShops.forEach(item => {
console.log(item); const pickup = new firebase.firestore.GeoPoint(centerLoc.latLng.latitude, centerLoc.latLng.longitude);
const pickup = new firebase.firestore.GeoPoint(centerLoc.latLng.longitude, centerLoc.latLng.longitude);
const products = {}; const products = {};
const cartItem = cartGroup[item]; const cartItem = cartGroup[item];
let prodPrice = 0; let prodPrice = 0;
......
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