Commit 6ce03859 by Adarsh K

shopper service

parent 3d4110d8
...@@ -70,19 +70,18 @@ export class ShoppersService { ...@@ -70,19 +70,18 @@ export class ShoppersService {
const This = this; const This = this;
const state = true; const state = true;
this.shoppers = []; this.shoppers = [];
const itemsFound = {};
console.log(this.shoppers);
const catRef = this.afs.collection('shopcategories').doc(catId).get().subscribe((data) => { const catRef = this.afs.collection('shopcategories').doc(catId).get().subscribe((data) => {
this.shoppers = []; this.shoppers = [];
console.log(data.data()); console.log(data.data());
const shoppeerList = []; const shoppeerList = [];
const shoppers = data.data(); const shoppers = data.data();
if (shoppers && Object.keys(shoppers).length > 0) { if (shoppers && Object.keys(shoppers).length > 0) {
Object.keys(shoppers) Object.keys(shoppers)
.forEach(function eachKey(key) { .forEach(function eachKey(key) {
shoppeerList.push(key); shoppeerList.push(key);
}); });
console.log(shoppeerList);
if (shoppeerList.length > 0) { if (shoppeerList.length > 0) {
...@@ -96,7 +95,6 @@ export class ShoppersService { ...@@ -96,7 +95,6 @@ export class ShoppersService {
} else { } else {
break; break;
} }
} }
console.log(shopItems); console.log(shopItems);
const orderRef: AngularFirestoreCollection<any> = this.afs.collection( const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
...@@ -108,6 +106,7 @@ export class ShoppersService { ...@@ -108,6 +106,7 @@ export class ShoppersService {
orderRef.valueChanges().subscribe(value => { orderRef.valueChanges().subscribe(value => {
console.log(value);
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach(item => { res.forEach(item => {
...@@ -131,9 +130,12 @@ export class ShoppersService { ...@@ -131,9 +130,12 @@ export class ShoppersService {
rate: item.rate, rate: item.rate,
centerId: item.centerId centerId: item.centerId
}; };
this.shoppers.push(shopper); if (!itemsFound[shopper.uid]) {
this.shoppers.push(shopper);
itemsFound[shopper.uid] = true;
}
}); });
// console.log(this.shoppers);
} else { } else {
// alert('No Orders Found'); // alert('No Orders Found');
} }
...@@ -141,7 +143,6 @@ export class ShoppersService { ...@@ -141,7 +143,6 @@ export class ShoppersService {
} }
} }
} else { } else {
console.log(this.shoppers);
this.shoppers = []; this.shoppers = [];
this.shoppers.length = 0; this.shoppers.length = 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