Commit d54622a7 by Adarsh K

getmi-changes

parent f64ce3e9
......@@ -39,7 +39,7 @@
<img [src]="carts.image" onerror="this.src=''" />
</div>
<div class="cart_detail">
<h4>{{carts.prodName}}</h4>
<h4>{{unEscape(carts.prodName)}}</h4>
<h4>{{carts.size}}, {{carts.color}}</h4>
<h5>A$ {{carts.price}}</h5>
</div>
......@@ -81,7 +81,7 @@
<ion-grid class="p0" *ngIf="cartService.carts && cartService.carts.length > 0">
<ion-row *ngFor="let carts of cartService.carts">
<ion-col size="6" class="p0">
<h6 class="textLeft">{{carts.prodName}}</h6>
<h6 class="textLeft">{{unEscape(carts.prodName)}}</h6>
</ion-col>
<ion-col size="2" class="p0">
<h6 class="textRight"><strong>{{carts.qty}} X</strong></h6>
......@@ -116,13 +116,15 @@
<div class="clear"></div>
</h5>
<div class="payment_method">
<input type="radio" name="payments" id="cod" name="radio-group" checked="true" (click)="getwaycod()" />
<input type="radio" name="payments" id="cod" name="radio-group" checked="true"
(click)="getwaycod()" />
<label for="cod">
<p>COD</p>
</label>
</div>
<div class="payment_method">
<input type="radio" name="payments" id="paypal" name="radio-group" (click)="getwaypaypal()" />
<input type="radio" name="payments" id="paypal" name="radio-group"
(click)="getwaypaypal()" />
<label for="paypal">
<p>PayPal</p>
</label>
......@@ -131,7 +133,8 @@
<input class="card_no borderNone widthFull" placeholder="PayPal ID" />
</div> -->
<div class="payment_method">
<input type="radio" name="payments" id="afterpay" name="radio-group" (click)="getwayafterpay()" />
<input type="radio" name="payments" id="afterpay" name="radio-group"
(click)="getwayafterpay()" />
<label for="afterpay">
<p>AfterPay</p>
</label>
......@@ -141,7 +144,8 @@
<input class="cv_number" placeholder="CVV" />
</div> -->
<div class="payment_method">
<input type="radio" name="payments" id="payk" name="radio-group" (click)="getwaypayk()" />
<input type="radio" name="payments" id="payk" name="radio-group"
(click)="getwaypayk()" />
<label for="payk">
<p>PayK</p>
</label>
......@@ -166,7 +170,8 @@
</div> -->
<hr />
<div class="coupon_code">
<input class="" placeholder="COUPON CODE: GET50" #promo /><button class="add_btn" (click)="promoApply(promo.value)">
<input class="" placeholder="COUPON CODE: GET50" #promo /><button class="add_btn"
(click)="promoApply(promo.value)">
APPLY
</button>
<span *ngIf="discountApplied" style="color: red">Promocode applied successfully
......@@ -237,7 +242,8 @@
</div>
<div class="checkout" (click)="next(1)">CHECKOUT</div>
</div>
<div class="footer_btn" *ngIf="cartService.carts && cartService.carts.length > 0" [hidden]="currentIndex != 1" (click)="next(2);">
<div class="footer_btn" *ngIf="cartService.carts && cartService.carts.length > 0" [hidden]="currentIndex != 1"
(click)="next(2);">
PAY
</div>
<!-- <div class="footer_btn" [hidden]="currentIndex != 2" (click)="finishpop()">
......@@ -262,7 +268,8 @@
<div class="clear"></div>
</div>
<ion-content class="sort_wrappper">
<agm-map [zoom]="20" [latitude]="lat" [longitude]="lng" [disableDefaultUI]="false" [zoomControl]="false" [backgroundColor]="'rgba(29, 27, 130,0.2)'">
<agm-map [zoom]="20" [latitude]="lat" [longitude]="lng" [disableDefaultUI]="false" [zoomControl]="false"
[backgroundColor]="'rgba(29, 27, 130,0.2)'">
<agm-marker [latitude]="lat" [longitude]="lng"></agm-marker>
</agm-map>
<div class="add_address_wrapper">
......@@ -271,11 +278,13 @@
<span class="floatRight" (click)="istoggle(); goToPage('nearby')">ADD NEW</span>
<div class="clear"></div>
</h5>
<ul *ngIf="addressService.addressList && addressService.addressList.length > 0">
<li *ngFor="let address of addressService.addressList; let i = index">
<ul *ngIf="addressService.nearestList && addressService.nearestList.length > 0">
<li *ngFor="let address of addressService.nearestList; let i = index">
<div class="floatLeft">
{{address.default}}
<input class="styled-checkbox" name="addressId" id="styled-checkbox-{{i}}" type="radio" (click)="setDefault(address.addressId, i)" [value]="address.addressId" #addressType [checked]="address.defaultVal == 1" />
<input class="styled-checkbox" name="addressId" id="styled-checkbox-{{i}}" type="radio"
(click)="setDefault(address.addressId, i)" [value]="address.addressId" #addressType
[checked]="address.defaultVal == 1" />
<label for="styled-checkbox-{{i}}"> {{address.addressType}} </label>
</div>
<div class="floatLeft">
......@@ -286,6 +295,16 @@
<div class="clear"></div>
</li>
</ul>
<div class="textCenter" *ngIf="addressService.nearestList && addressService.nearestList.length === 0">No
Address Found in the nearest center</div>
</div>
<!-- <div class="loader" *ngIf="loader">
<div class="lds-ripple">
<div></div>
<div></div>
</div>
</div> -->
</ion-content>
</div>
\ No newline at end of file
......@@ -50,6 +50,7 @@ export class CartPage implements OnInit {
totalAmt: number;
bookDate: any;
timeinterval: any;
paymentMethod: any;
constructor(
private router: Router,
......@@ -70,13 +71,17 @@ export class CartPage implements OnInit {
this.taxAmount = 0;
this.discountApplied = false;
this.discount = 0;
this.paymentMethod = 'COD';
// this.cartService.cartList();
this.loader = true;
const users = this.service.get('user').then(data => {
if (data) {
data = JSON.parse(data);
this.custId = data.uid;
this.addressService.addList(data.uid);
this.service.get('cartCenter').then((centerData) => {
this.addressService.defaultAddress(this.custId);
this.addressService.getNearBy(centerData, this.custId);
});
}
});
setTimeout(() => {
......@@ -85,37 +90,51 @@ export class CartPage implements OnInit {
}
ngOnInit() {
console.log(this.addressService.addressList);
this.setAddress();
const This = this;
console.log(this.addressService.nearestList);
setTimeout(() => {
this.setAddress();
}, 1000);
}
ionViewWillEnter() {
const users = this.service.get('user').then(data => {
if (data) {
data = JSON.parse(data);
const This = this;
this.cartService.cartList();
setTimeout(() => {
if (this.cartService.carts.length > 0) {
const cart = this.cartService.carts[0];
}
}, 1000);
}
});
}
setAddress() {
if (this.addressService.addressList.length > 0) {
let address = this.addressService.addressList.find(
console.log(this.addressService.nearestList);
if (this.addressService.nearestList.length > 0) {
let address = this.addressService.nearestList.find(
x => x.defaultVal === 1
);
if (!address) {
address = this.addressService.addressList[0];
address = this.addressService.nearestList[0];
}
this.loader = false;
this.custAddress = address;
}
}
getwaypaypal() {
this.gateway = 1;
this.paymentMethod = 'PayPal';
}
getwayafterpay() {
this.gateway = 2;
this.paymentMethod = 'AfterPay';
}
getDeliveryCharge(amount) {
......@@ -124,19 +143,21 @@ export class CartPage implements OnInit {
} else {
this.deliveryCharge = 10;
}
return this.deliveryCharge;
return this.deliveryCharge.toFixed(2);
}
getTax(amount) {
return (this.taxAmount = (amount * 10) / 100);
return Math.round((this.taxAmount = (amount * 10) / 100)).toFixed(2);
}
getwaypayk() {
this.gateway = 3;
this.paymentMethod = 'PayK';
}
getwaycod() {
this.gateway = 4;
this.paymentMethod = 'COD';
}
async finishpop() {
......@@ -156,10 +177,14 @@ export class CartPage implements OnInit {
}
setDefault(addressId: any, index: number) {
console.log(index);
this.addressService.setDefaultAddress(addressId, this.custId);
console.log(this.addressService.addressList[index]);
this.custAddress = this.addressService.addressList[index];
console.log('loading....');
this.loader = true;
this.custAddress = this.addressService.nearestList[index];
console.log(this.custAddress);
this.istoggle();
setTimeout(() => {
this.loader = false;
}, 1000);
}
next(index: number = null) {
......@@ -177,7 +202,8 @@ export class CartPage implements OnInit {
discount: this.discount,
discountApplied: this.discountApplied,
totalAmt: this.totalAmt,
custAddress: this.custAddress
custAddress: this.custAddress,
paymentMethod: this.paymentMethod
};
const state = this.orderService
.checkOut(this.cartService.carts, otherCharges)
......@@ -255,7 +281,7 @@ export class CartPage implements OnInit {
const actualTotal =
this.deliveryCharge + this.taxAmount + total - this.discount;
this.totalAmt = actualTotal;
return actualTotal;
return actualTotal.toFixed(2);
}
promoApply(code) {
......@@ -267,7 +293,7 @@ export class CartPage implements OnInit {
if (value[0].type === 1) {
const rate = value[0].amount;
const upto = value[0].amount;
const percentage = (this.cartService.cartTotal * rate) / 100;
const percentage = Math.round((this.cartService.cartTotal * rate) / 100).toFixed(2);
this.discount = percentage > upto ? upto : percentage;
} else {
this.discount = value[0].amount;
......@@ -313,4 +339,8 @@ export class CartPage implements OnInit {
strTime
);
}
unEscape(text: string) {
return unescape(text);
}
}
<div class="nav_header">
<button class="nav_btn nav_back floatLeft" (click)="goBack()">
<img src="../assets/Group17_2.png" />
</button>
<img src="../assets/Group17_2.png" />
</button>
<div class="nav_title floatLeft">
<h4>Change Address</h4>
</div>
......@@ -10,17 +10,21 @@
<ion-content>
<div class="nearby_map">
<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)"></agm-marker>
<agm-marker [latitude]="latitude" [longitude]="longitude" [markerDraggable]="true"
(dragEnd)="markerDragEnd($event)"></agm-marker>
</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">
<h5>DELIVERY</h5>
<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">
Building Name is required
</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">
Landmark is required
</div>
......@@ -28,30 +32,37 @@
<ion-row>
<ion-col>
<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>
</h6>
</ion-col>
<ion-col>
<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>
</h6>
</ion-col>
<ion-col>
<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>
</h6>
</ion-col>
</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
</div>
</ion-grid>
<button class="add_btn" type="submit" [disabled]="!addressForm.form.valid">
ADD
</button>
<button class="add_btn" type="submit" [disabled]="!addressForm.form.valid" *ngIf="locationRest()">
CHANGE
</button>
</div>
</form>
</div>
......
......@@ -11,6 +11,7 @@ import { MapsAPILoader, MouseEvent } from '@agm/core';
import { Address } from './../../config/services/address';
import { AddressService } from './../../config/address.service';
import { ServiceService } from './../../config/service.service';
import { MyordersService } from './../../config/myorder.service';
import { NgForm } from '@angular/forms';
import * as firebase from 'firebase';
......@@ -31,6 +32,10 @@ export class ChangeaddressPage implements OnInit {
uid: string;
type: any;
loader: boolean;
order: any;
addressValid: any;
lat: any;
lng: any;
public searchElementRef: ElementRef;
constructor(
......@@ -40,9 +45,13 @@ export class ChangeaddressPage implements OnInit {
private mapsAPILoader: MapsAPILoader,
private ngZone: NgZone,
public addressService: AddressService,
public service: ServiceService
public service: ServiceService,
public myorder: MyordersService
) {
this.addressValid = false;
this.successState = false;
this.lat = '';
this.lng = '';
this.type = 0;
const users = this.service.get('user').then(data => {
if (data) {
......@@ -54,6 +63,9 @@ export class ChangeaddressPage implements OnInit {
this.service.get('type').then(data => {
this.type = data;
});
this.service.get('order').then(val => {
this.order = val;
});
}
ngOnInit() {
......@@ -83,6 +95,22 @@ export class ChangeaddressPage implements OnInit {
this.getAddress(this.latitude, this.longitude);
}
locationRest() {
if (this.latitude && this.longitude && this.order) {
if (this.latitude !== this.lat && this.longitude !== this.lng) {
this.lat = this.latitude;
this.lng = this.longitude;
this.myorder.getNearBy(this.latitude, this.longitude, this.order.orderId).then(resp => {
console.log(resp);
if (resp) {
this.addressValid = resp;
}
});
}
}
return this.addressValid;
}
getAddress(latitude, longitude) {
this.geoCoder.geocode(
{ location: { lat: latitude, lng: longitude } },
......
......@@ -11,19 +11,10 @@
<div class="verification_div">
<div class="form_div">
<div class="row">
<input
class=""
type="email"
placeholder="Type your email Id"
#emailId
required
/>
<input class="" type="email" placeholder="Type your email Id" #emailId required />
</div>
<div class="row">
<button
class="login_btn"
(click)="authService.resetPassword(emailId.value)"
>
<button class="login_btn" (click)="authService.resetPassword(emailId.value);">
RESET PASSWORD
</button>
</div>
......@@ -35,4 +26,4 @@
<div></div>
<div></div>
</div>
</div>
</div>
\ No newline at end of file
......@@ -14,9 +14,9 @@ export class ForgotPage implements OnInit {
private route: ActivatedRoute,
private location: Location,
public authService: AuthService
) {}
) { }
ngOnInit() {}
ngOnInit() { }
goToPage(path, data = null) {
this.router.navigateByUrl(path, { queryParams: data });
......@@ -24,6 +24,6 @@ export class ForgotPage implements OnInit {
}
goBack() {
this.location.back();
this.router.navigateByUrl('login');
}
}
......@@ -134,7 +134,7 @@
<div class="floatLeft">
{{address.default}}
<input class="styled-checkbox" name="addressId" id="styled-checkbox-{{i}}" type="radio"
(click)="setDefault(address.addressId)" [value]="address.addressId" #addressType
(click)="setDefault(address)" [value]="address.addressId" #addressType
[checked]="address.defaultVal == 1" />
<label for="styled-checkbox-{{i}}">
{{address.addressType}}
......
......@@ -112,9 +112,12 @@ export class HomePage implements OnInit {
);
}
setDefault(addressId: any) {
setDefault(address: any) {
this.loader = true;
this.addressService.setDefaultAddress(addressId, this.custId).then(() => {
this.addressService.setDefaultAddress(address.addressId, this.custId).then(() => {
this.address = address.address;
console.log(address.latLng);
this.centerService.getNearBy(address.latLng._lat, address.latLng._long, 10);
this.loader = false;
}).catch(err => {
this.loader = false;
......
......@@ -22,7 +22,7 @@
<img [src]="product.image" onerror="" />
</div>
<div class="order_detail">
<h5 class="floatLeft">{{product.prodName}}</h5>
<h5 class="floatLeft">{{unEscape(product.prodName)}}</h5>
<div class="clear"></div>
<h5>
<span *ngIf="product.color !== 'No-Color'">{{product.color}},
......@@ -33,7 +33,7 @@
<p *ngIf="product.price">A$ {{product.price}}</p>
</div>
<div class="order_other">
<h6 class="floatRight">
<h6 class="floatRight" *ngIf="order.bookDate">
{{ order.bookDate.seconds * 1000 | date:'MMMM dd, y' }}
</h6>
<span class="floatRight" *ngIf="order.orderStatus < 3 || order.orderStatus >= 7"
......
......@@ -115,4 +115,8 @@ export class MyorderPage implements OnInit {
}
}
unEscape(text: string) {
return unescape(text);
}
}
......@@ -18,7 +18,7 @@
<div class="order_status">
<div class="clear"></div>
<div class="status_div go_green">
<h4>Order Placed</h4>
<h4>{{data.orderCode}}</h4>
<h6>{{ data.bookDate.seconds * 1000 | date:'MMMM dd, y' }}</h6>
</div>
<!-- <div class="status_gap go_green">
......@@ -69,7 +69,7 @@
</span>
<div class="clear"></div>
</h5>
<p class="prodName">{{data.product[0].prodName}}</p>
<p class="prodName">{{unEscape(data.product[0].prodName)}}</p>
</div>
<div class="clear"></div>
</li>
......@@ -77,17 +77,21 @@
</div>
<div class="product_detail" *ngFor="let product of data.product">
<h6>
<span *ngIf="product.color !== 'No-Color'">{{product.color}}, </span>
<span *ngIf="product.size !== 'Any-Size'">{{product.size}}</span>
<span *ngIf="product.color !== 'No-Color'">Color: {{product.color}}, </span>
<span *ngIf="product.size !== 'Any-Size'">Size: {{product.size}}</span>
</h6>
<h5>Quantity : <span>{{product.qty}}</span></h5>
<h5>
Amount : <strong>A$ {{product.price}}</strong><span class="afterpay">COD</span>
Amount : <strong>A$ {{product.price}}</strong><span class="afterpay">{{data.paymentMode}}</span>
</h5>
<h5 *ngIf="data.orderStatus >= 3 && data.orderStatus < 7">
Delivery time : <span>{{deliveryTime}}</span>
</h5>
<h5>Order Status : <span>{{getStatus(data.orderStatus)}}</span></h5>
</div>
<div class="product_detail">
<div class="delivery-wrap">
<h4 class="floatLeft">DELIVERY</h4>
<span class="floatRight" *ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8"><img
......@@ -95,6 +99,7 @@
<div class="clear"></div>
</div>
<h5 *ngIf="data.deliveryAddress">
{{data.deliveryAddress.addressType}},<br />{{data.deliveryAddress.address}},
<br />
......
......@@ -41,6 +41,10 @@ export class OrderplacedPage implements OnInit {
});
}
unEscape(text: string) {
return unescape(text);
}
getDeliveryTime(timeStamp) {
// console.log(timeStamp);
const endDate = new Date(timeStamp * 1000);
......
......@@ -97,6 +97,8 @@ export class ProductdetailPage implements OnInit {
color: params.color,
discount: params.discount,
featured: params.featured,
centerId: params.centerId,
centerRef: params.center,
image: params.image,
price: params.price,
qty: params.qty,
......
......@@ -3,6 +3,7 @@ import {
AngularFirestore,
AngularFirestoreCollection
} from '@angular/fire/firestore';
import * as firebase from 'firebase';
import { take } from 'rxjs/operators';
import { Address, AddressList } from './services/address';
......@@ -11,6 +12,8 @@ import { Address, AddressList } from './services/address';
})
export class AddressService {
addressList: AddressList[] = [];
nearestList: AddressList[] = [];
defaultAdd: AddressList;
constructor(public afs: AngularFirestore) { }
public async addList(userId: string) {
......@@ -44,6 +47,36 @@ export class AddressService {
});
}
public async defaultAddress(userId: string) {
const This = this;
const state = true;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
'address',
ref => ref.where('status', '==', state).where('uid', '==', userId).where('defaultVal', '==', 1)
);
orderRef.valueChanges().subscribe(value => {
this.addressList = [];
const res = value;
if (res.length > 0) {
const item = res[0];
// console.log(item);
const address: AddressList = {
address: item.address,
addressType: item.addressType,
latLng: item.latLng,
defaultVal: item.defaultVal,
building: item.building,
landmark: item.landmark,
addressId: item.addressId
};
this.defaultAdd = address;
console.log(this.defaultAdd);
} else {
// alert('No Orders Found');
}
});
}
addressCreate(data: Address) {
console.log(data);
this.afs
......@@ -99,4 +132,70 @@ export class AddressService {
.doc(addId)
.delete();
}
public async getNearBy(centerId, userId) {
// latitude, longitude, distance, userId
console.log(centerId);
if (centerId) {
this.afs.collection('centers').doc(centerId).ref.get().then((doc) => {
if (doc.exists) {
console.log('Document data:', doc.data());
const center = doc.data();
const This = this;
const state = true;
const latitude = center.latLng._lat;
const longitude = center.latLng._long;
const lat = 0.0144927536231884;
const lon = 0.0181818181818182;
const distance = 10;
const lowerLat = latitude - lat * distance;
const lowerLon = longitude - lon * distance;
const greaterLat = latitude + lat * distance;
const greaterLon = longitude + lon * distance;
const lesserGeopoint = new firebase.firestore.GeoPoint(lowerLat, lowerLon);
const greaterGeopoint = new firebase.firestore.GeoPoint(
greaterLat,
greaterLon
);
const addressRef: AngularFirestoreCollection<any> = this.afs.collection(
'address',
ref =>
ref
.where('latLng', '>', lesserGeopoint)
.where('latLng', '<', greaterGeopoint)
.where('status', '==', state)
.where('uid', '==', userId)
);
addressRef.valueChanges().subscribe(value => {
this.nearestList = [];
const res = value;
if (res.length > 0) {
res.forEach(item => {
// console.log(item);
const address: AddressList = {
address: item.address,
addressType: item.addressType,
latLng: item.latLng,
defaultVal: item.defaultVal,
building: item.building,
landmark: item.landmark,
addressId: item.addressId
};
this.nearestList.push(address);
});
console.log(this.nearestList);
} else {
// alert('No Orders Found');
}
});
} else {
console.log('No such document!');
}
});
}
}
}
......@@ -149,9 +149,17 @@ export class AuthService {
this.afAuth.auth
.signInWithPopup(new auth.FacebookAuthProvider())
.then(result => {
this.loader = false;
/* this.loader = false;
console.log('success');
console.log(result); */
console.log('success');
console.log(result);
console.log(result.additionalUserInfo.isNewUser);
if (
result.additionalUserInfo &&
result.additionalUserInfo.isNewUser === true
) {
this.socialSignUp(result);
}
})
.catch(err => {
this.service.showToast(err.message, 'bottom', 'my-error', 1000);
......@@ -327,4 +335,18 @@ export class AuthService {
});
return false;
}
resetPassword(email: string) {
this.loader = true;
this.afAuth.auth.sendPasswordResetEmail(email)
.then(() => {
this.service.showToast('Password reset mail has been sent your mail Id', 'top', 'my-toast', 2000);
this.loader = false;
this.router.navigateByUrl('login');
})
.catch((error) => {
this.service.showToast(error, 'top', 'my-error', 1000);
this.loader = false;
});
}
}
......@@ -51,73 +51,83 @@ export class CartsService {
this.size = this.size === undefined ? product.size[0] : this.size;
this.color = this.color === undefined ? product.color[0] : this.color;
this.service.get('cartCenter').then((centerData) => {
console.log(centerData);
if (centerData === null || (centerData === product.centerId)) {
this.service.set('cartCenter', product.centerId);
const cartRef: AngularFirestoreCollection<any> = this.afs.collection(
'carts',
ref =>
ref
.where('size', '==', this.size)
.where('color', '==', this.color)
.where('custId', '==', this.custId)
.where('product', '==', prodRef)
);
cartRef
.valueChanges()
.pipe(take(1))
.subscribe(value => {
// console.log(value);
const cartRef: AngularFirestoreCollection<any> = this.afs.collection(
'carts',
ref =>
ref
.where('size', '==', this.size)
.where('color', '==', this.color)
.where('custId', '==', this.custId)
.where('product', '==', prodRef)
);
cartRef
.valueChanges()
.pipe(take(1))
.subscribe(value => {
// console.log(value);
if (value.length === 0) {
product.image =
product.image === undefined
? '../assets/[email protected]'
: product.image;
const cart: Cart = {
color: this.color,
custId: this.custId,
shopperId: product.shopperId,
product: firebase.firestore().doc(`products/${this.prodId}`),
image: product.image,
prodId: product.prodId,
price: product.price,
prodName: product.prodName,
shopper: product.shopper,
qty: 1,
size: this.size
};
// console.log(cart);
this.afs
.collection('carts')
.add(cart)
.then(docRef => {
const neworderId = docRef.id;
if (value.length === 0) {
product.image =
product.image === undefined
? '../assets/[email protected]'
: product.image;
const cart: Cart = {
color: this.color,
custId: this.custId,
shopperId: product.shopperId,
product: firebase.firestore().doc(`products/${this.prodId}`),
image: product.image,
prodId: product.prodId,
price: product.price,
prodName: product.prodName,
shopper: product.shopper,
qty: 1,
size: this.size
};
// console.log(cart);
this.afs
.collection('carts')
.add(cart)
.then(docRef => {
const neworderId = docRef.id;
this.afs
.collection('carts')
.doc(neworderId)
.update({ cartId: docRef.id })
.then(() => {
// console.log('Booking Successfully');
document.body.scrollTop = document.documentElement.scrollTop = 0;
});
})
.catch(error => {
console.error('Error adding document: ', error);
});
} else {
// console.log(value);
// alert('Item already added in the cart');
const cartId = value[0].cartId;
// tslint:disable-next-line:radix
const qty = parseInt(value[0].qty) + 1;
this.afs
.collection('carts')
.doc(neworderId)
.update({ cartId: docRef.id })
.doc(cartId)
.update({ qty: `${qty}` })
.then(() => {
// console.log('Booking Successfully');
document.body.scrollTop = document.documentElement.scrollTop = 0;
});
})
.catch(error => {
console.error('Error adding document: ', error);
});
} else {
// console.log(value);
// alert('Item already added in the cart');
const cartId = value[0].cartId;
// tslint:disable-next-line:radix
const qty = parseInt(value[0].qty) + 1;
this.afs
.collection('carts')
.doc(cartId)
.update({ qty: `${qty}` })
.then(() => {
// console.log('Booking Successfully');
document.body.scrollTop = document.documentElement.scrollTop = 0;
});
}
});
}
});
} else {
this.service.showToast('Your cart is not empty', 'top', 'my-error', 2000);
}
});
}
public async cartList() {
......@@ -160,6 +170,7 @@ export class CartsService {
this.carts.push(cartItem);
});
} else {
this.service.remove('cartCenter');
// alert('No Products Found');
}
});
......
......@@ -120,6 +120,7 @@ export class MyordersService {
deliveryLocation: item.deliveryLocation,
pickupLocation: item.pickupLocation,
deliveryAddress: item.deliveryAddress,
paymentMode: item.paymentMethod,
riderName: 'John',
orderId: item.orderId,
orderCode: item.orderCode,
......@@ -225,6 +226,46 @@ export class MyordersService {
return of(this.orders);
}
*/
public async getNearBy(latitude, longitude, orderId) {
const promise = new Promise(resolve => {
const This = this;
const lat = 0.0144927536231884;
const lon = 0.0181818181818182;
const distance = 10;
const lowerLat = latitude - lat * distance;
const lowerLon = longitude - lon * distance;
const greaterLat = latitude + lat * distance;
const greaterLon = longitude + lon * distance;
const lesserGeopoint = new firebase.firestore.GeoPoint(lowerLat, lowerLon);
const greaterGeopoint = new firebase.firestore.GeoPoint(
greaterLat,
greaterLon
);
const addressRef: AngularFirestoreCollection<any> = this.afs.collection(
'orders',
ref =>
ref
.where('pickupLocation', '>', lesserGeopoint)
.where('pickupLocation', '<', greaterGeopoint)
.where('orderId', '==', orderId)
);
addressRef.valueChanges().subscribe(value => {
const res = value;
if (res.length > 0) {
resolve(true);
} else {
resolve(false);
}
});
});
return promise;
}
public async trackOrder(order) {
this.selItem = order;
}
......
......@@ -189,6 +189,7 @@ export class OrdersService {
custName: 'Customer',
riderName: 'John',
shopperState: 0,
paymentMethod: otherCharge.paymentMethod,
shopperName: '',
product: products,
discount: 'A$ ' + otherCharge.discount,
......@@ -204,6 +205,7 @@ export class OrdersService {
.then(() => {
// console.log('Booking Successfully');
// this.router.navigateByUrl('cart');
this.service.remove('cartCenter');
resolve('Cart to Order Successfully');
document.body.scrollTop = document.documentElement.scrollTop = 0;
});
......
......@@ -91,6 +91,8 @@ export class ProductsService {
skuCode: item.skuCode,
status: item.status,
rating: item.rating,
centerId: item.centerId,
centerRef: item.center,
size: this.service.splitSep(item.size),
subCate: item.subCate,
tag: this.service.splitSep(item.tag)
......@@ -163,6 +165,8 @@ export class ProductsService {
rating: item.rating,
shopper: item.shopper,
skuCode: item.skuCode,
centerId: item.centerId,
centerRef: item.center,
status: item.status,
size: this.service.splitSep(item.size),
subCate: item.subCate,
......@@ -216,6 +220,8 @@ export class ProductsService {
shopper: item.shopper,
rating: item.rating,
skuCode: item.skuCode,
centerId: item.centerId,
centerRef: item.center,
status: item.status,
size: this.service.splitSep(item.size),
subCate: item.subCate,
......
......@@ -12,4 +12,5 @@ export interface Myorder {
time: string;
product: any;
orderCode: string;
paymentMode: string;
}
......@@ -52,6 +52,7 @@ export interface Order {
orderStatus: number;
pickupAddress: string;
pickupLocation: object;
paymentMethod: any;
bookDate: any;
orderDate: any;
custId: string;
......
......@@ -14,6 +14,8 @@ export interface Products {
shopperId: string;
qty: number;
shopper: string;
centerId: string;
centerRef: any;
size: string[];
skuCode: string;
status: boolean;
......
......@@ -69,6 +69,8 @@ export class WishService {
prodCode: item.prodCode,
prodDesc: item.prodDesc,
prodStatus: item.prodStatus,
centerId: item.centerId,
centerRef: item.center,
rating: item.rating,
skuCode: item.skuCode,
status: item.status,
......
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