Commit c51e9b66 by Adarsh K

Merge branch 'adarsh' into 'master'

Adarsh See merge request !76
parents b96e3946 0173e664
......@@ -28,7 +28,8 @@
<div class="sub_menu">
<ul *ngIf="categoryService.activecategories">
<ion-menu-toggle>
<li *ngFor="let category of categoryService.activecategories" (click)="goToPage('catstorelist', category)">
<li *ngFor="let category of categoryService.activecategories"
(click)="goToPage('catstorelist', category)">
{{ category.catName }}
</li>
</ion-menu-toggle>
......
......@@ -51,8 +51,12 @@ export class ContactPage implements OnInit {
this.submitted = true;
console.log(form.value);
if (form.valid && form.value.message !== '') {
const contData = { ...this.contactData, from: this.userData.emailId };
this.contactService.contactCreate(contData);
this.service.get('orderId').then((orderId) => {
const newOrder = orderId;
const contData = { ...this.contactData, from: this.userData.emailId, orderId: newOrder };
this.contactService.contactCreate(contData);
});
} else {
console.log('form not valid');
this.submitted = false;
......
......@@ -106,7 +106,7 @@
{{data.deliveryAddress.building}}, <br />
{{data.deliveryAddress.landmark}}
</h5>
<button class="cancel_btn" (click)="goToPage('contact')"
<button class="cancel_btn" (click)="cancelOrder(data.orderId)"
*ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8">
CANCEL THIS ORDER
</button>
......
......@@ -78,6 +78,11 @@ export class OrderplacedPage implements OnInit {
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
cancelOrder(orderId) {
this.service.set('orderId', orderId);
this.router.navigateByUrl('contact');
}
changeAddress(orderId) {
this.service.set('orderId', orderId);
this.router.navigateByUrl('changeaddress');
......
......@@ -46,7 +46,7 @@ export class PreferencePage implements OnInit {
});
}
ngOnInit() {}
ngOnInit() { }
selectPrefernce(preferenceId) {
console.log(this.userPrefence);
......@@ -72,8 +72,8 @@ export class PreferencePage implements OnInit {
setTimeout(() => {
this.loader = false;
this.successState = false;
this.service.set('type', 0);
if (this.type === 1) {
this.service.set('type', 0);
this.router.navigateByUrl('home', { queryParams: null });
} else {
this.goBack();
......
......@@ -55,7 +55,6 @@ export class AddressService {
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];
......
......@@ -25,13 +25,13 @@ export class ContactService {
this.loader = true;
this.afs
.collection('contacts')
.add({})
.add(data)
.then(docRef => {
data.contactId = docRef.id;
this.afs
.collection('contacts')
.doc(data.contactId)
.set(data)
.update({ contactId: data.contactId })
.then(() => {
this.service
.showToast('Thank you for your feedback!', 'top', 'my-toast', 500)
......
......@@ -134,74 +134,72 @@ export class OrdersService {
const promise = new Promise(resolve => {
distinctShops.forEach(item => {
console.log(item);
const pickup = new firebase.firestore.GeoPoint(10.7231, 76.1234);
const products = {};
const cartItem = cartGroup[item];
let prodPrice = 0;
cartItem.forEach(prodItem => {
prodPrice += prodItem.price;
products[prodItem.prodId] = {
prodId: prodItem.prodId,
prodName: prodItem.prodName,
image: prodItem.image,
price: prodItem.price,
color: prodItem.color,
size: prodItem.size,
qty: prodItem.qty,
discount: ''
};
this.afs.doc(`carts/${prodItem.cartId}`).delete();
});
// console.log(cartItem);
// console.log(products);
const product = cartItem[0];
this.custId = this.custId.trim();
const orderItem: Order = {
amount: 'A$ ' + otherCharge.totalAmt,
customer: firebase.firestore().doc('/customer/' + this.custId),
shopper: product.shopper,
deliveryAddress: otherCharge.custAddress,
deliveryCharge: 'A$ ' + otherCharge.deliveryCharge,
deliveryLocation: otherCharge.custAddress.latLng,
bookDate: firebase.firestore.FieldValue.serverTimestamp(),
orderDate: Math.floor(Date.now() / 1000),
orderCode: this.orderCode(),
orderId: '',
orderStatus: 1,
pickupAddress: '',
pickupLocation: pickup,
promoId: null,
rider: firebase
.firestore()
.doc('/riders/qbTKza18mWVzYG9NLIbmjMbrYjG2'),
status: 1,
custId: this.custId,
riderId: 'qbTKza18mWVzYG9NLIbmjMbrYjG2',
shopperId: product.shopperId,
custName: 'Customer',
riderName: 'John',
shopperState: 0,
paymentMethod: otherCharge.paymentMethod,
shopperName: '',
product: products,
discount: 'A$ ' + otherCharge.discount,
promoApplied: otherCharge.discountApplied,
tax: 'A$ ' + otherCharge.taxAmount
};
// console.log(orderItem);
this.afs
.collection('orders')
.add({
shopper: firebase.firestore().doc('/shoppers/' + item),
bookDate: firebase.firestore.FieldValue.serverTimestamp()
})
.add(orderItem)
.then(docRef => {
const neworderId = docRef.id;
const pickup = new firebase.firestore.GeoPoint(10.7231, 76.1234);
const products = {};
const cartItem = cartGroup[item];
let prodPrice = 0;
cartItem.forEach(prodItem => {
prodPrice += prodItem.price;
products[prodItem.prodId] = {
prodId: prodItem.prodId,
prodName: prodItem.prodName,
image: prodItem.image,
price: prodItem.price,
color: prodItem.color,
size: prodItem.size,
qty: prodItem.qty,
discount: ''
};
this.afs.doc(`carts/${prodItem.cartId}`).delete();
});
// console.log(cartItem);
// console.log(products);
const product = cartItem[0];
this.custId = this.custId.trim();
const orderItem: Order = {
amount: 'A$ ' + otherCharge.totalAmt,
customer: firebase.firestore().doc('/customer/' + this.custId),
shopper: product.shopper,
deliveryAddress: otherCharge.custAddress,
deliveryCharge: 'A$ ' + otherCharge.deliveryCharge,
deliveryLocation: otherCharge.custAddress.latLng,
bookDate: firebase.firestore.FieldValue.serverTimestamp(),
orderDate: Math.floor(Date.now() / 1000),
orderCode: this.orderCode(),
orderId: neworderId,
orderStatus: 1,
pickupAddress: '',
pickupLocation: pickup,
promoId: null,
rider: firebase
.firestore()
.doc('/riders/qbTKza18mWVzYG9NLIbmjMbrYjG2'),
status: 1,
custId: this.custId,
riderId: 'qbTKza18mWVzYG9NLIbmjMbrYjG2',
shopperId: product.shopperId,
custName: 'Customer',
riderName: 'John',
shopperState: 0,
paymentMethod: otherCharge.paymentMethod,
shopperName: '',
product: products,
discount: 'A$ ' + otherCharge.discount,
promoApplied: otherCharge.discountApplied,
tax: 'A$ ' + otherCharge.taxAmount
};
// console.log(orderItem);
this.afs
.collection('orders')
.doc(neworderId)
.set(orderItem)
.update({ orderId: neworderId })
.then(() => {
// console.log('Booking Successfully');
// this.router.navigateByUrl('cart');
......@@ -209,8 +207,7 @@ export class OrdersService {
resolve('Cart to Order Successfully');
document.body.scrollTop = document.documentElement.scrollTop = 0;
});
})
.catch(error => {
}).catch(error => {
console.error('Error adding document: ', error);
});
});
......
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