Commit c51e9b66 by Adarsh K

Merge branch 'adarsh' into 'master'

Adarsh See merge request !76
parents b96e3946 0173e664
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
<div class="sub_menu"> <div class="sub_menu">
<ul *ngIf="categoryService.activecategories"> <ul *ngIf="categoryService.activecategories">
<ion-menu-toggle> <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 }} {{ category.catName }}
</li> </li>
</ion-menu-toggle> </ion-menu-toggle>
......
...@@ -51,8 +51,12 @@ export class ContactPage implements OnInit { ...@@ -51,8 +51,12 @@ export class ContactPage implements OnInit {
this.submitted = true; this.submitted = true;
console.log(form.value); console.log(form.value);
if (form.valid && form.value.message !== '') { if (form.valid && form.value.message !== '') {
const contData = { ...this.contactData, from: this.userData.emailId }; this.service.get('orderId').then((orderId) => {
const newOrder = orderId;
const contData = { ...this.contactData, from: this.userData.emailId, orderId: newOrder };
this.contactService.contactCreate(contData); this.contactService.contactCreate(contData);
});
} else { } else {
console.log('form not valid'); console.log('form not valid');
this.submitted = false; this.submitted = false;
......
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
{{data.deliveryAddress.building}}, <br /> {{data.deliveryAddress.building}}, <br />
{{data.deliveryAddress.landmark}} {{data.deliveryAddress.landmark}}
</h5> </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"> *ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8">
CANCEL THIS ORDER CANCEL THIS ORDER
</button> </button>
......
...@@ -78,6 +78,11 @@ export class OrderplacedPage implements OnInit { ...@@ -78,6 +78,11 @@ export class OrderplacedPage implements OnInit {
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
} }
cancelOrder(orderId) {
this.service.set('orderId', orderId);
this.router.navigateByUrl('contact');
}
changeAddress(orderId) { changeAddress(orderId) {
this.service.set('orderId', orderId); this.service.set('orderId', orderId);
this.router.navigateByUrl('changeaddress'); this.router.navigateByUrl('changeaddress');
......
...@@ -46,7 +46,7 @@ export class PreferencePage implements OnInit { ...@@ -46,7 +46,7 @@ export class PreferencePage implements OnInit {
}); });
} }
ngOnInit() {} ngOnInit() { }
selectPrefernce(preferenceId) { selectPrefernce(preferenceId) {
console.log(this.userPrefence); console.log(this.userPrefence);
...@@ -72,8 +72,8 @@ export class PreferencePage implements OnInit { ...@@ -72,8 +72,8 @@ export class PreferencePage implements OnInit {
setTimeout(() => { setTimeout(() => {
this.loader = false; this.loader = false;
this.successState = false; this.successState = false;
if (this.type === 1) {
this.service.set('type', 0); this.service.set('type', 0);
if (this.type === 1) {
this.router.navigateByUrl('home', { queryParams: null }); this.router.navigateByUrl('home', { queryParams: null });
} else { } else {
this.goBack(); this.goBack();
......
...@@ -55,7 +55,6 @@ export class AddressService { ...@@ -55,7 +55,6 @@ export class AddressService {
ref => ref.where('status', '==', state).where('uid', '==', userId).where('defaultVal', '==', 1) ref => ref.where('status', '==', state).where('uid', '==', userId).where('defaultVal', '==', 1)
); );
orderRef.valueChanges().subscribe(value => { orderRef.valueChanges().subscribe(value => {
this.addressList = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
const item = res[0]; const item = res[0];
......
...@@ -25,13 +25,13 @@ export class ContactService { ...@@ -25,13 +25,13 @@ export class ContactService {
this.loader = true; this.loader = true;
this.afs this.afs
.collection('contacts') .collection('contacts')
.add({}) .add(data)
.then(docRef => { .then(docRef => {
data.contactId = docRef.id; data.contactId = docRef.id;
this.afs this.afs
.collection('contacts') .collection('contacts')
.doc(data.contactId) .doc(data.contactId)
.set(data) .update({ contactId: data.contactId })
.then(() => { .then(() => {
this.service this.service
.showToast('Thank you for your feedback!', 'top', 'my-toast', 500) .showToast('Thank you for your feedback!', 'top', 'my-toast', 500)
......
...@@ -134,14 +134,7 @@ export class OrdersService { ...@@ -134,14 +134,7 @@ export class OrdersService {
const promise = new Promise(resolve => { const promise = new Promise(resolve => {
distinctShops.forEach(item => { distinctShops.forEach(item => {
console.log(item); console.log(item);
this.afs
.collection('orders')
.add({
shopper: firebase.firestore().doc('/shoppers/' + item),
bookDate: firebase.firestore.FieldValue.serverTimestamp()
})
.then(docRef => {
const neworderId = docRef.id;
const pickup = new firebase.firestore.GeoPoint(10.7231, 76.1234); const pickup = new firebase.firestore.GeoPoint(10.7231, 76.1234);
const products = {}; const products = {};
const cartItem = cartGroup[item]; const cartItem = cartGroup[item];
...@@ -174,7 +167,7 @@ export class OrdersService { ...@@ -174,7 +167,7 @@ export class OrdersService {
bookDate: firebase.firestore.FieldValue.serverTimestamp(), bookDate: firebase.firestore.FieldValue.serverTimestamp(),
orderDate: Math.floor(Date.now() / 1000), orderDate: Math.floor(Date.now() / 1000),
orderCode: this.orderCode(), orderCode: this.orderCode(),
orderId: neworderId, orderId: '',
orderStatus: 1, orderStatus: 1,
pickupAddress: '', pickupAddress: '',
pickupLocation: pickup, pickupLocation: pickup,
...@@ -200,8 +193,13 @@ export class OrdersService { ...@@ -200,8 +193,13 @@ export class OrdersService {
this.afs this.afs
.collection('orders') .collection('orders')
.add(orderItem)
.then(docRef => {
const neworderId = docRef.id;
this.afs
.collection('orders')
.doc(neworderId) .doc(neworderId)
.set(orderItem) .update({ orderId: neworderId })
.then(() => { .then(() => {
// console.log('Booking Successfully'); // console.log('Booking Successfully');
// this.router.navigateByUrl('cart'); // this.router.navigateByUrl('cart');
...@@ -209,8 +207,7 @@ export class OrdersService { ...@@ -209,8 +207,7 @@ export class OrdersService {
resolve('Cart to Order Successfully'); resolve('Cart to Order Successfully');
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
}); });
}) }).catch(error => {
.catch(error => {
console.error('Error adding document: ', 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