Commit a271ff43 by Adarsh K

Merge branch 'muhsin' into 'master'

Muhsin See merge request !41
parents e76b0c87 e0f80096
...@@ -13,41 +13,41 @@ ...@@ -13,41 +13,41 @@
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@agm/core": "^1.0.0-beta.7", "@agm/core": "^1.1.0",
"@angular/animations": "^8.2.11", "@angular/animations": "^8.2.14",
"@angular/common": "~8.1.2", "@angular/common": "~8.1.2",
"@angular/compiler": "~8.1.2", "@angular/compiler": "~8.1.2",
"@angular/core": "~8.1.2", "@angular/core": "~8.1.2",
"@angular/fire": "^5.2.1", "@angular/fire": "^5.3.0",
"@angular/forms": "~8.1.2", "@angular/forms": "~8.1.2",
"@angular/platform-browser": "~8.1.2", "@angular/platform-browser": "~8.1.2",
"@angular/platform-browser-dynamic": "~8.1.2", "@angular/platform-browser-dynamic": "~8.1.2",
"@angular/router": "~8.1.2", "@angular/router": "~8.1.2",
"@ionic-native/core": "^5.0.0", "@ionic-native/core": "^5.19.1",
"@ionic-native/geolocation": "^5.15.1", "@ionic-native/geolocation": "^5.19.1",
"@ionic-native/google-plus": "^5.0.0-beta.0", "@ionic-native/google-plus": "^5.19.1",
"@ionic-native/native-geocoder": "^5.15.1", "@ionic-native/native-geocoder": "^5.19.1",
"@ionic-native/splash-screen": "^5.0.0", "@ionic-native/splash-screen": "^5.19.1",
"@ionic-native/status-bar": "^5.12.0", "@ionic-native/status-bar": "^5.19.1",
"@ionic/angular": "^4.7.1", "@ionic/angular": "^4.11.8",
"@ionic/storage": "^2.2.0", "@ionic/storage": "^2.2.0",
"@types/googlemaps": "^3.38.0", "@types/googlemaps": "^3.39.2",
"agm-direction": "^0.7.8", "agm-direction": "^0.7.9",
"cordova-android": "8.0.0", "cordova-android": "8.0.0",
"cordova-plugin-device": "^2.0.3", "cordova-plugin-device": "^2.0.3",
"cordova-plugin-geolocation": "^4.0.2", "cordova-plugin-geolocation": "^4.0.2",
"cordova-plugin-googleplus": "^8.2.0", "cordova-plugin-googleplus": "^8.2.1",
"cordova-plugin-ionic-keyboard": "^2.2.0", "cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^4.1.3", "cordova-plugin-ionic-webview": "^4.1.3",
"cordova-plugin-nativegeocoder": "^3.2.2", "cordova-plugin-nativegeocoder": "^3.2.2",
"cordova-plugin-splashscreen": "^5.0.3", "cordova-plugin-splashscreen": "^5.0.3",
"cordova-plugin-statusbar": "^2.4.3", "cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4", "cordova-plugin-whitelist": "^1.3.4",
"cordova-sqlite-storage": "^3.4.0", "cordova-sqlite-storage": "^3.4.1",
"core-js": "^2.5.4", "core-js": "^2.6.11",
"firebase": "^6.4.0", "firebase": "^6.6.2",
"rxjs": "~6.5.1", "rxjs": "^6.5.4",
"rxjs-compat": "^6.5.3", "rxjs-compat": "^6.5.4",
"tslib": "^1.9.0", "tslib": "^1.9.0",
"zone.js": "~0.9.1" "zone.js": "~0.9.1"
}, },
...@@ -62,16 +62,16 @@ ...@@ -62,16 +62,16 @@
"@angular/language-service": "~8.1.2", "@angular/language-service": "~8.1.2",
"@ionic/angular-toolkit": "~2.0.0", "@ionic/angular-toolkit": "~2.0.0",
"@types/jasmine": "~3.3.8", "@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3", "@types/jasminewd2": "^2.0.8",
"@types/node": "~8.9.4", "@types/node": "~8.9.4",
"codelyzer": "^5.0.0", "codelyzer": "^5.2.1",
"jasmine-core": "~3.4.0", "jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1", "jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0", "karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0", "karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1", "karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1", "karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0", "karma-jasmine-html-reporter": "^1.5.1",
"protractor": "~5.4.0", "protractor": "~5.4.0",
"ts-node": "~7.0.0", "ts-node": "~7.0.0",
"tslint": "~5.15.0", "tslint": "~5.15.0",
......
...@@ -5,10 +5,8 @@ ...@@ -5,10 +5,8 @@
<div class="side_menu_wrapper"> <div class="side_menu_wrapper">
<ion-menu-toggle> <ion-menu-toggle>
<div class="top_banner"> <div class="top_banner">
<div class="top_image"> <div class="top_image"></div>
<div class="top_detail">
</div>
<div class="top_detail" >
<h4>John Doe</h4> <h4>John Doe</h4>
<p>[email protected]</p> <p>[email protected]</p>
</div> </div>
...@@ -28,7 +26,12 @@ ...@@ -28,7 +26,12 @@
<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)">{{category.catName}}</li> <li
*ngFor="let category of categoryService.activecategories"
(click)="goToPage('catstorelist', category)"
>
{{ category.catName }}
</li>
</ion-menu-toggle> </ion-menu-toggle>
<!-- <li>Women's Fashion</li> <!-- <li>Women's Fashion</li>
<li>Features</li> <li>Features</li>
...@@ -39,7 +42,9 @@ ...@@ -39,7 +42,9 @@
</div> </div>
<li>Complaints & Feedback</li> <li>Complaints & Feedback</li>
<li> <li>
<span class="floatLeft" (click)="authService.SignOut()">Logout</span> <span class="floatLeft" (click)="authService.SignOut()"
>Logout</span
>
<span class="floatRight version">Version 0.1.0.2</span> <span class="floatRight version">Version 0.1.0.2</span>
<div class="clear"></div> <div class="clear"></div>
</li> </li>
...@@ -54,22 +59,42 @@ ...@@ -54,22 +59,42 @@
<div class="common_tab" [hidden]="getState()"> <div class="common_tab" [hidden]="getState()">
<ul> <ul>
<li (click)="goToPage('home')"> <li (click)="goToPage('home')">
<div class="icon_sec m1_icon" [class.m1_icon_act]="sec_active1" (click)="setActive1()"></div> <div
class="icon_sec m1_icon"
[class.m1_icon_act]="sec_active1"
(click)="setActive1()"
></div>
</li> </li>
<li (click)="goToPage('catagory')"> <li (click)="goToPage('catagory')">
<div class="icon_sec m2_icon" [class.m2_icon_act]="sec_active2" (click)="setActive2()"></div> <div
class="icon_sec m2_icon"
[class.m2_icon_act]="sec_active2"
(click)="setActive2()"
></div>
</li> </li>
<li (click)="goToPage('catagory')"> <li (click)="goToPage('catagory')">
<div class="icon_sec m3_icon" [class.m3_icon_act]="sec_active3" (click)="setActive3()"></div> <div
class="icon_sec m3_icon"
[class.m3_icon_act]="sec_active3"
(click)="setActive3()"
></div>
</li> </li>
<!-- <li (click)="goToPage('cart')"> <!-- <li (click)="goToPage('cart')">
<div class="icon_sec m4_icon" [class.m4_icon_act]="sec_active4" (click)="setActive4()"></div> <div class="icon_sec m4_icon" [class.m4_icon_act]="sec_active4" (click)="setActive4()"></div>
</li> --> </li> -->
<li (click)="goToPage('myorder')"> <li (click)="goToPage('myorder')">
<div class="icon_sec m5_icon" [class.m5_icon_act]="sec_active5" (click)="setActive5()"></div> <div
class="icon_sec m5_icon"
[class.m5_icon_act]="sec_active5"
(click)="setActive5()"
></div>
</li> </li>
<li (click)="goToPage('profile')"> <li (click)="goToPage('profile')">
<div class="icon_sec m6_icon" [class.m6_icon_act]="sec_active6" (click)="setActive6()"></div> <div
class="icon_sec m6_icon"
[class.m6_icon_act]="sec_active6"
(click)="setActive6()"
></div>
</li> </li>
</ul> </ul>
</div> </div>
<div class="nav_header"> <div class="nav_header">
<button class="nav_btn nav_back floatLeft" (click)="goBack()"> <button class="nav_btn nav_back floatLeft" (click)="goBack()">
<img src="../assets/Group17_2.png"> <img src="../assets/Group17_2.png" />
</button> </button>
<div class="nav_title floatLeft"> <div class="nav_title floatLeft">
<h4>CHANGE DETAILS</h4> <h4>CHANGE DETAILS</h4>
...@@ -9,34 +9,93 @@ ...@@ -9,34 +9,93 @@
</div> </div>
<ion-content> <ion-content>
<div class="login_wrapper"> <div class="login_wrapper">
<div class="form_div"> <form class="form_div" #updateForm="ngForm" novalidate>
<div class="row"> <div class="row">
<h6>Personal Details</h6> <h6>Personal Details</h6>
</div> </div>
<div class="row"> <div class="row">
<input class="" type="text" placeholder="John Doe"> <input
name="name"
required
class=""
type="text"
[(ngModel)]="updateData.name"
placeholder="John Doe"
#name="ngModel"
/>
<div
class="md-errors-spacer"
[hidden]="name.valid || submitted == false"
class="ion-padding-start"
>
Name is required
</div>
</div> </div>
<div class="row"> <div class="row">
<input class="" type="mail" placeholder="[email protected]"> <input
required
class=""
name="emailId"
type="mail"
[(ngModel)]="updateData.emailId"
placeholder="[email protected]"
pattern="[a-zA-Z0-9.-_]{1,}@[a-zA-Z.-]{2,}[.]{1}[a-zA-Z]{2,}"
#emailId="ngModel"
/>
<div
class="md-errors-spacer"
[hidden]="emailId.valid || submitted == false"
>
<div *ngIf="emailId.errors && emailId.errors.required">
Email is required
</div>
<div *ngIf="emailId.errors && emailId.errors.pattern">
Email is invalid
</div>
</div> </div>
</div>
<div class="row"> <div class="row">
<input class="" type="number" placeholder="+00 9851 5871 6985"> <input
required
class=""
name="phone"
type="number"
pattern="(\(+61\)|\+61|\(0[1-9]\)|0[1-9])?( ?-?[0-9]){6,9}"
maxlength="10"
[(ngModel)]="updateData.phone"
placeholder="+00 9851 5871 6985"
#phone="ngModel"
/>
<div
class="md-errors-spacer"
[hidden]="phone.valid || submitted == false"
>
<div *ngIf="phone.errors && phone.errors.required">
Phone number is required
</div>
<div *ngIf="phone.errors && phone.errors.pattern">
Phone is invalid
</div>
</div>
</div> </div>
<div class="row"> <div class="row">
<h6>Change Password</h6> <h6>Change Password</h6>
</div> </div>
<div class="row"> <div class="row">
<input class="" type="password" placeholder="Current Password"> <input class="" type="password" placeholder="Current Password" />
</div> </div>
<div class="row"> <div class="row">
<input class="" type="password" placeholder="New Password"> <input class="" type="password" placeholder="New Password" />
</div> </div>
<div class="row"> <div class="row">
<input class="" type="password" placeholder="Confirm Password"> <input class="" type="password" placeholder="Confirm Password" />
</div> </div>
<div class="row"> <div class="row">
<button class="login_btn">UPDATE</button> <button class="login_btn" (click)="onFormSubmit(updateForm)">
</div> UPDATE
</button>
</div> </div>
</form>
</div> </div>
</ion-content> </ion-content>
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from "@angular/core";
import { Location } from '@angular/common'; import { Location } from "@angular/common";
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from "@angular/router";
import { UpdateUserDetails } from "../../config/services/user";
import { UpdateService } from "../../config/update.service";
import { ServiceService } from "../../config/service.service";
import { NgForm } from "@angular/forms";
@Component({ @Component({
selector: 'app-changedetails', selector: "app-changedetails",
templateUrl: './changedetails.page.html', templateUrl: "./changedetails.page.html",
styleUrls: ['./changedetails.page.scss'], styleUrls: ["./changedetails.page.scss"]
}) })
export class ChangedetailsPage implements OnInit { export class ChangedetailsPage implements OnInit {
userData: any;
updateData: UpdateUserDetails = {
emailId: "",
name: "",
phone: ""
};
submitted = false;
constructor( constructor(
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private location: Location private location: Location,
) { } public register: UpdateService,
private service: ServiceService
ngOnInit() { ) {
this.service.get("params").then(val => {
this.userData = val;
});
} }
ngOnInit() {}
goToPage(path, data = null) { goToPage(path, data = null) {
this.router.navigateByUrl(path, { queryParams: data }); this.router.navigateByUrl(path, { queryParams: data });
...@@ -29,4 +43,11 @@ export class ChangedetailsPage implements OnInit { ...@@ -29,4 +43,11 @@ export class ChangedetailsPage implements OnInit {
this.location.back(); this.location.back();
} }
onFormSubmit(form: NgForm) {
this.submitted = true;
if (form.valid) {
console.log("valid form values", form.value);
this.register.updateData(form.value, this.userData.uid);
}
}
} }
<div class="nav_header"> <div class="nav_header">
<button class="nav_btn nav_back floatLeft" (click)="goBack()"> <button class="nav_btn nav_back floatLeft" (click)="goBack()">
<img src="../assets/Group17_2.png"> <img src="../assets/Group17_2.png" />
</button> </button>
<div class="nav_title floatLeft"> <div class="nav_title floatLeft"></div>
</div>
<button class="nav_btn nav_cart floatRight" (click)="goToPage('cart')"> <button class="nav_btn nav_cart floatRight" (click)="goToPage('cart')">
<div class="not" *ngIf="cartService.carts">{{cartService.carts.length}}</div> <div class="not" *ngIf="cartService.carts">
{{cartService.carts.length}}
</div>
</button> </button>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<ion-content> <ion-content>
<div class="product_detail_wrapper" *ngIf="product"> <div class="product_detail_wrapper" *ngIf="product">
<div class="product_banner"> <div class="product_banner">
<div [ngClass]="checkFavStatus(product.prodId)" (click)="changeFav(product.prodId)"></div> <div
[ngClass]="checkFavStatus(product.prodId)"
(click)="changeFav(product.prodId)"
></div>
<div class="featured_badge" *ngIf="product.featured">Featured</div> <div class="featured_badge" *ngIf="product.featured">Featured</div>
<ion-slides pager="true" [options]="bannerOptions"> <ion-slides pager="true" [options]="bannerOptions">
<ion-slide> <ion-slide>
<img [src]="product.image" onerror="this.src='../assets/[email protected]'"> <img
[src]="product.image"
onerror="this.src='../assets/[email protected]'"
/>
</ion-slide> </ion-slide>
<ion-slide> <ion-slide>
<img [src]="product.image" onerror="this.src='../assets/[email protected]'"> <img
[src]="product.image"
onerror="this.src='../assets/[email protected]'"
/>
</ion-slide> </ion-slide>
<ion-slide> <ion-slide>
<img [src]="product.image" onerror="this.src='../assets/[email protected]'"> <img
[src]="product.image"
onerror="this.src='../assets/[email protected]'"
/>
</ion-slide> </ion-slide>
</ion-slides> </ion-slides>
</div> </div>
...@@ -30,14 +43,21 @@ ...@@ -30,14 +43,21 @@
<ion-row> <ion-row>
<ion-col size="8"> <ion-col size="8">
<h3>{{product.prodName}}</h3> <h3>{{product.prodName}}</h3>
<p><strong><span><img src="../assets/Path61_2.png"></span>0</strong>&nbsp; {{product.category}}, {{product.subCate}} <p>
<strong
><span><img src="../assets/Path61_2.png"/></span>0</strong
>&nbsp; {{product.category}}, {{product.subCate}}
<br /> <br />
<span *ngFor="let tag of product.tag">#{{tag}}&nbsp;</span> <span *ngFor="let tag of product.tag">#{{tag}}&nbsp;</span>
</p> </p>
</ion-col> </ion-col>
<ion-col size="4"> <ion-col size="4">
<h5>A$ {{product.price}}</h5> <h5>A$ {{product.price}}</h5>
<p><span class="offer" *ngIf="product.discount > 0">-{{product.discount}}%</span></p> <p>
<span class="offer" *ngIf="product.discount > 0"
>-{{product.discount}}%</span
>
</p>
</ion-col> </ion-col>
</ion-row> </ion-row>
</div> </div>
...@@ -51,8 +71,14 @@ ...@@ -51,8 +71,14 @@
<li> <li>
<button id="custom_check_button"> <button id="custom_check_button">
<label> <label>
<input id="{{color}}" type="radio" name="color" value="{{color}}" <input
(click)="cartService.choose_color(color)" [checked]="i==0"> id="{{color}}"
type="radio"
name="color"
value="{{color}}"
(click)="cartService.choose_color(color)"
[checked]="i==0"
/>
<p>{{color}}</p> <p>{{color}}</p>
</label> </label>
</button> </button>
...@@ -69,8 +95,14 @@ ...@@ -69,8 +95,14 @@
<li> <li>
<button id="custom_check_button"> <button id="custom_check_button">
<label> <label>
<input id="{{size}}" type="radio" name="services" value="{{size}}" <input
(click)="cartService.choose_size(size)" [checked]="i==0"> id="{{size}}"
type="radio"
name="services"
value="{{size}}"
(click)="cartService.choose_size(size)"
[checked]="i==0"
/>
<p>{{size}}</p> <p>{{size}}</p>
</label> </label>
</button> </button>
...@@ -137,8 +169,7 @@ ...@@ -137,8 +169,7 @@
</ul> </ul>
</div> --> </div> -->
<h5>Description</h5> <h5>Description</h5>
<p>{{product.prodDesc}} <p>{{product.prodDesc}}</p>
</p>
<!--<h5> <!--<h5>
<span class="floatLeft">Reviews</span><span class="floatRight" (click)="goToPage('reviewlist')">MORE</span> <span class="floatLeft">Reviews</span><span class="floatRight" (click)="goToPage('reviewlist')">MORE</span>
<div class="clear"></div> <div class="clear"></div>
...@@ -204,7 +235,10 @@ ...@@ -204,7 +235,10 @@
</ul> </ul>
</div> --> </div> -->
<h5 *ngIf="product.similar && product.similar.length > 0"> <h5 *ngIf="product.similar && product.similar.length > 0">
<span class="floatLeft">Related Products</span><span class="floatRight" (click)="goToPage('productlist', data)">MORE</span> <span class="floatLeft">Related Products</span
><span class="floatRight" (click)="goToPage('productlist', data)"
>MORE</span
>
<div class="clear"></div> <div class="clear"></div>
</h5> </h5>
<div class="related_product_slider"> <div class="related_product_slider">
...@@ -213,9 +247,14 @@ ...@@ -213,9 +247,14 @@
<ion-slide *ngFor="let similar of product.similar"> <ion-slide *ngFor="let similar of product.similar">
<li (click)="viewProd(similar)"> <li (click)="viewProd(similar)">
<div class="product_image"> <div class="product_image">
<img [src]="similar.image" onerror="this.src='../assets/[email protected]'"> <img
<div [ngClass]="checkFavStatus(similar.prodId)" (click)="changeFav(similar.prodId)"> [src]="similar.image"
</div> onerror="this.src='../assets/[email protected]'"
/>
<div
[ngClass]="checkFavStatus(similar.prodId)"
(click)="changeFav(similar.prodId)"
></div>
</div> </div>
<h5>{{similar.prodName}}</h5> <h5>{{similar.prodName}}</h5>
<p>{{similar.price}}</p> <p>{{similar.price}}</p>
...@@ -226,7 +265,6 @@ ...@@ -226,7 +265,6 @@
</div> </div>
</div> </div>
</div> </div>
</ion-content> </ion-content>
<ion-footer> <ion-footer>
<div class="footer_div"> <div class="footer_div">
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from "@angular/core";
import { Location } from '@angular/common'; import { Location } from "@angular/common";
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from "@angular/router";
import { Products } from './../../config/services/product'; import { Products } from "./../../config/services/product";
import { Order } from './../../config/services/order'; import { Slides } from "./../../config/services/slides";
import { CartsService } from './../../config/cart.service';
import { ProductsService } from './../../config/products.service'; import { Order } from "./../../config/services/order";
import { ServiceService } from './../../config/service.service'; import { CartsService } from "./../../config/cart.service";
import { map } from 'rxjs/operators'; import { ProductsService } from "./../../config/products.service";
import { ServiceService } from "./../../config/service.service";
import { map } from "rxjs/operators";
@Component({ @Component({
selector: 'app-productdetail', selector: "app-productdetail",
templateUrl: './productdetail.page.html', templateUrl: "./productdetail.page.html",
styleUrls: ['./productdetail.page.scss'] styleUrls: ["./productdetail.page.scss"]
}) })
export class ProductdetailPage implements OnInit { export class ProductdetailPage implements OnInit {
slide: Slides;
product: Products; product: Products;
order: Order; order: Order;
data: any; data: any;
slideData: any;
bannerOptions = { bannerOptions = {
slidesPerView: 1, slidesPerView: 1,
...@@ -47,15 +51,25 @@ export class ProductdetailPage implements OnInit { ...@@ -47,15 +51,25 @@ export class ProductdetailPage implements OnInit {
params.subCate, params.subCate,
params.prodId params.prodId
); );
this.service.get('params').then(val => { this.service.get("params").then(val => {
this.data = val; this.data = val;
}); });
//
this.prodService
.getProdSlide(this.prodService.selItem.skuCode)
.then(res => {
this.slideData = res;
// console.log("resData", res);
});
this.cartService.cartList(); this.cartService.cartList();
console.log(this.prodService.fav); // console.log(this.prodService.fav);
} }
ngOnInit() { ngOnInit() {
console.log(this.prodService.selItem); // console.log("[qwe]", this.prodService.selItem);
const params = this.prodService.selItem; const params = this.prodService.selItem;
this.getProd(params); this.getProd(params);
} }
...@@ -88,14 +102,14 @@ export class ProductdetailPage implements OnInit { ...@@ -88,14 +102,14 @@ export class ProductdetailPage implements OnInit {
} else { } else {
this.product = undefined; this.product = undefined;
} }
console.log(this.product); // console.log(this.product.image);
} }
stringObject(items: any) { stringObject(items: any) {
items.forEach(element => { items.forEach(element => {
console.log(element.sizeId); // console.log(element.sizeId);
element = JSON.parse(element); element = JSON.parse(element);
console.log(element); // console.log(element);
}); });
} }
...@@ -112,7 +126,7 @@ export class ProductdetailPage implements OnInit { ...@@ -112,7 +126,7 @@ export class ProductdetailPage implements OnInit {
buyNow(product: any, type: number) { buyNow(product: any, type: number) {
this.cartService.buyNow(product).then(() => { this.cartService.buyNow(product).then(() => {
if (type === 1) { if (type === 1) {
this.router.navigateByUrl('cart'); this.router.navigateByUrl("cart");
} else { } else {
// alert('Product added to cart'); // alert('Product added to cart');
} }
...@@ -126,21 +140,21 @@ export class ProductdetailPage implements OnInit { ...@@ -126,21 +140,21 @@ export class ProductdetailPage implements OnInit {
checkFavStatus(index) { checkFavStatus(index) {
const state = this.prodService.fav.findIndex(x => x === index); const state = this.prodService.fav.findIndex(x => x === index);
return state > -1 ? 'fav_fill' : 'fav_icon'; return state > -1 ? "fav_fill" : "fav_icon";
} }
changeFav(index) { changeFav(index) {
const state = this.prodService.fav.findIndex(x => x === index); const state = this.prodService.fav.findIndex(x => x === index);
console.log(state); // console.log(state);
console.log(this.prodService.fav); // console.log(this.prodService.fav);
if (state > -1) { if (state > -1) {
this.prodService.fav.splice(state, 1); this.prodService.fav.splice(state, 1);
this.prodService.changeFav(index, 'yes'); this.prodService.changeFav(index, "yes");
} else { } else {
this.prodService.fav.push(index); this.prodService.fav.push(index);
this.prodService.changeFav(index, 'no'); this.prodService.changeFav(index, "no");
} }
return; return;
console.log(this.prodService.fav); // console.log(this.prodService.fav);
} }
} }
<div class="nav_header"> <div class="nav_header">
<ion-menu-toggle> <ion-menu-toggle>
<button class="nav_btn nav_menu floatLeft"> <button class="nav_btn nav_menu floatLeft"></button>
</button>
</ion-menu-toggle> </ion-menu-toggle>
<div class="nav_title floatLeft"> <div class="nav_title floatLeft">
<img src="../../assets/Group [email protected]"> <img src="../../assets/Group [email protected]" />
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
...@@ -14,36 +13,48 @@ ...@@ -14,36 +13,48 @@
<div class="profile_circle"> <div class="profile_circle">
<div class="edit"></div> <div class="edit"></div>
</div> </div>
<h5>JOHN DOE</h5> <h5>{{user && user.name}}</h5>
<p>LOGOUT</p> <p>LOGOUT</p>
</div> </div>
<div class="account_wrapper"> <div class="account_wrapper">
<div class="account_header"> <div class="account_header">
<h5 class="floatLeft">ACCOUNT INFORMATION</h5> <h5 class="floatLeft">ACCOUNT INFORMATION</h5>
<span class="floatRight"><img src="../../assets/edit.png"></span> <span
class="floatRight"
(click)="goToPage('changedetails', user && user)"
><img src="../../assets/edit.png"
/></span>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<div class="row"> <div class="row">
<ion-row> <ion-row>
<ion-col class="textLeft p0"> <ion-col class="textLeft p0">
<p>Name<span>Verfied</span></p> <p>
Name<span
>{{user && phoneVerified? "Verified": "Not Verified yet"}}</span
>
</p>
</ion-col> </ion-col>
<ion-col class="textRight p0"> <ion-col class="textRight p0">
<h6>John Doe</h6> <h6>{{user && user.name}}</h6>
</ion-col> </ion-col>
</ion-row> </ion-row>
</div> </div>
<div class="row"> <div class="row">
<ion-row> <ion-row>
<ion-col class="textLeft p0"> <ion-col class="textLeft p0">
<p>Email<span>Not Verfied yet</span></p> <p>
Email<span
>{{user && emailVerified? "Verified": "Not Verified yet"}}</span
>
</p>
</ion-col> </ion-col>
<ion-col class="textRight p0"> <ion-col class="textRight p0">
<h6>[email protected]</h6> <h6>{{user && user.emailId}}</h6>
</ion-col> </ion-col>
</ion-row> </ion-row>
</div> </div>
<hr> <hr />
<ion-row> <ion-row>
<ion-col class="textLeft p0"> <ion-col class="textLeft p0">
<p>Wishlist</p> <p>Wishlist</p>
...@@ -52,7 +63,7 @@ ...@@ -52,7 +63,7 @@
<h6>(3)</h6> <h6>(3)</h6>
</ion-col> </ion-col>
</ion-row> </ion-row>
<hr> <hr />
<ion-row> <ion-row>
<ion-col class="textLeft p0"> <ion-col class="textLeft p0">
<p>Address</p> <p>Address</p>
...@@ -61,7 +72,7 @@ ...@@ -61,7 +72,7 @@
<h6>(1)</h6> <h6>(1)</h6>
</ion-col> </ion-col>
</ion-row> </ion-row>
<hr> <hr />
<ion-row> <ion-row>
<ion-col class="textLeft p0"> <ion-col class="textLeft p0">
<p>My Cards</p> <p>My Cards</p>
...@@ -72,7 +83,7 @@ ...@@ -72,7 +83,7 @@
</h6> </h6>
</ion-col> </ion-col>
</ion-row> </ion-row>
<hr> <hr />
<ion-row> <ion-row>
<ion-col class="textLeft p0"> <ion-col class="textLeft p0">
<p>My Order</p> <p>My Order</p>
...@@ -83,7 +94,7 @@ ...@@ -83,7 +94,7 @@
</h6> </h6>
</ion-col> </ion-col>
</ion-row> </ion-row>
<hr> <hr />
<ion-row> <ion-row>
<ion-col class="textLeft p0"> <ion-col class="textLeft p0">
<p>Currency</p> <p>Currency</p>
...@@ -94,9 +105,6 @@ ...@@ -94,9 +105,6 @@
</h6> </h6>
</ion-col> </ion-col>
</ion-row> </ion-row>
</div> </div>
</div> </div>
</ion-content> </ion-content>
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from "@angular/core";
import { User } from "../../config/services/user";
import { UserService } from "../../config/user.service";
import { ServiceService } from "../../config/service.service";
import { Router, ActivatedRoute } from "@angular/router";
@Component({ @Component({
selector: 'app-profile', selector: "app-profile",
templateUrl: './profile.page.html', templateUrl: "./profile.page.html",
styleUrls: ['./profile.page.scss'], styleUrls: ["./profile.page.scss"]
}) })
export class ProfilePage implements OnInit { export class ProfilePage implements OnInit {
user: User;
userdata: any;
custId: String;
constructor() { } constructor(
private router: Router,
private useService: UserService,
private service: ServiceService
) {
const params = this.useService.users;
const userdata = this.service.get("user").then(data => {
if (data) {
data = JSON.parse(data);
this.service.set("params", data);
ngOnInit() { this.custId = data.uid;
}
});
this.useService.getUserData("9cYSZwGvVpgkUHVcz8Dm6oqGX152");
// .then(res => {
// console.log("asdasda", res);
// this.userdata = res;
// });
} }
goToPage(path, data = null) {
this.router.navigateByUrl(path, { queryParams: data });
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
ngOnInit() {
let This = this;
setTimeout(() => {
this.user = this.useService.users;
console.log("[users]", this.user);
this.service.set("params", this.user);
}, 500);
}
} }
<div class="nav_header"> <div class="nav_header">
<button class="nav_btn nav_back floatLeft" (click)="goBack()"> <button class="nav_btn nav_back floatLeft" (click)="goBack()">
<img src="../assets/Group17_2.png"> <img src="../assets/Group17_2.png" />
</button> </button>
<div class="nav_title floatLeft"> <div class="nav_title floatLeft">
<h4>SIGN UP</h4> <h4>SIGN UP</h4>
...@@ -10,19 +10,44 @@ ...@@ -10,19 +10,44 @@
<ion-content> <ion-content>
<div class="login_wrapper"> <div class="login_wrapper">
<div class="logo_wrapper"> <div class="logo_wrapper">
<img src="../assets/logo.png"> <img src="../assets/logo.png" />
</div> </div>
<div class="form_div"> <div class="form_div">
<form #signupForm="ngForm" novalidate> <form #signupForm="ngForm" novalidate>
<div class="row"> <div class="row">
<input class="" type="text" placeholder="Your name" [(ngModel)]="signup.name" name="name" #name="ngModel" required> <input
<div class="md-errors-spacer" [hidden]="name.valid || submitted == false" class="ion-padding-start"> class=""
type="text"
placeholder="Your name"
[(ngModel)]="signup.name"
name="name"
#name="ngModel"
required
/>
<div
class="md-errors-spacer"
[hidden]="name.valid || submitted == false"
class="ion-padding-start"
>
Name is required Name is required
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<input class="" type="email" placeholder="Email Address" [(ngModel)]="signup.emailId" name="emailId" #emailId="ngModel" email pattern="[a-zA-Z0-9.-_]{1,}@[a-zA-Z.-]{2,}[.]{1}[a-zA-Z]{2,}" required> <input
<div class="md-errors-spacer" [hidden]="emailId.valid || submitted == false"> class=""
type="email"
placeholder="Email Address"
[(ngModel)]="signup.emailId"
name="emailId"
#emailId="ngModel"
email
pattern="[a-zA-Z0-9.-_]{1,}@[a-zA-Z.-]{2,}[.]{1}[a-zA-Z]{2,}"
required
/>
<div
class="md-errors-spacer"
[hidden]="emailId.valid || submitted == false"
>
<div *ngIf="emailId.errors && emailId.errors.required"> <div *ngIf="emailId.errors && emailId.errors.required">
Email is required Email is required
</div> </div>
...@@ -32,8 +57,21 @@ ...@@ -32,8 +57,21 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<input class="" type="text" placeholder="Phone number" [(ngModel)]="signup.phone" name="phone" #phone="ngModel" pattern="(\(+61\)|\+61|\(0[1-9]\)|0[1-9])?( ?-?[0-9]){6,9}" maxlength="10" required> <input
<div class="md-errors-spacer" [hidden]="phone.valid || submitted == false"> class=""
type="text"
placeholder="Phone number"
[(ngModel)]="signup.phone"
name="phone"
#phone="ngModel"
pattern="(\(+61\)|\+61|\(0[1-9]\)|0[1-9])?( ?-?[0-9]){6,9}"
maxlength="10"
required
/>
<div
class="md-errors-spacer"
[hidden]="phone.valid || submitted == false"
>
<div *ngIf="phone.errors && phone.errors.required"> <div *ngIf="phone.errors && phone.errors.required">
Phone number is required Phone number is required
</div> </div>
...@@ -43,38 +81,90 @@ ...@@ -43,38 +81,90 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<input class="" type="password" placeholder="Create A Password" [(ngModel)]="signup.password" name="password" #password="ngModel" minlength="6" required> <input
<div class="md-errors-spacer" [hidden]="password.valid || submitted == false"> class=""
<div *ngIf="password.errors && password.errors.required">Password is required</div> type="password"
<div *ngIf="password.errors && password.errors.minlength">Password must be at least 6 characters</div> placeholder="Create A Password"
[(ngModel)]="signup.password"
name="password"
#password="ngModel"
minlength="6"
required
/>
<div
class="md-errors-spacer"
[hidden]="password.valid || submitted == false"
>
<div *ngIf="password.errors && password.errors.required">
Password is required
</div>
<div *ngIf="password.errors && password.errors.minlength">
Password must be at least 6 characters
</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<ion-datetime displayFormat="DD-MM-YYYY" [(ngModel)]="signup.dob" name="dob" #dob="ngModel" placeholder="Date of Birth" max="{{minDate}}" required></ion-datetime> <ion-datetime
<div class="md-errors-spacer" [hidden]="dob.valid || submitted == false"> displayFormat="DD-MM-YYYY"
[(ngModel)]="signup.dob"
name="dob"
#dob="ngModel"
placeholder="Date of Birth"
max="{{minDate}}"
required
></ion-datetime>
<div
class="md-errors-spacer"
[hidden]="dob.valid || submitted == false"
>
<div *ngIf="dob.errors && dob.errors.required">DOB is required</div> <div *ngIf="dob.errors && dob.errors.required">DOB is required</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<h6> <h6>
<input class="styled-checkbox" id="styled-checkbox-1" type="checkbox" value="true" [(ngModel)]="signup.terms" required name="terms" #terms="ngModel"> <input
<label for="styled-checkbox-1"><span>I agree with <a (click)="menuToggle()">Terms and class="styled-checkbox"
Conditions</a></span></label></h6> id="styled-checkbox-1"
<div class="md-errors-spacer" [hidden]="terms.valid || submitted == false"> type="checkbox"
<div *ngIf="terms.errors && terms.errors.required">Please accept Terms and Conditions</div> value="true"
[(ngModel)]="signup.terms"
required
name="terms"
#terms="ngModel"
/>
<label for="styled-checkbox-1"
><span
>I agree with
<a (click)="menuToggle()">Terms and Conditions</a></span
></label
>
</h6>
<div
class="md-errors-spacer"
[hidden]="terms.valid || submitted == false"
>
<div *ngIf="terms.errors && terms.errors.required">
Please accept Terms and Conditions
</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<button class="login_btn" (click)="onSignup(signupForm)">SIGN UP</button> <button class="login_btn" (click)="onSignup(signupForm)">
SIGN UP
</button>
</div> </div>
</form> </form>
<div class="row"> <div class="row">
<hr> <hr />
<p><span>OR</span></p> <p><span>OR</span></p>
</div> </div>
<div class="row"> <div class="row">
<div class="social_div"> <div class="social_div">
<div class="social_btn" style="border-right:1px solid rgba(215, 213, 228, 1);" (click)="register.facebook()"> <div
class="social_btn"
style="border-right:1px solid rgba(215, 213, 228, 1);"
(click)="register.facebook()"
>
Facebook Facebook
</div> </div>
<div class="social_btn" (click)="register.google(2)"> <div class="social_btn" (click)="register.google(2)">
...@@ -84,15 +174,20 @@ ...@@ -84,15 +174,20 @@
</div> </div>
</div> </div>
</div> </div>
</ion-content> </ion-content>
<div class="terms_wrapper" *ngIf="menuShow" [@slideInOut]> <div class="terms_wrapper" *ngIf="menuShow" [@slideInOut]>
<div class="terms_inner"> <div class="terms_inner">
<h5>Terms & Conditions</h5> <h5>Terms & Conditions</h5>
<p> <p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has Lorem Ipsum is simply dummy text of the printing and typesetting industry.
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop Lorem Ipsum has been the industry's standard dummy text ever since the
publishing software like Aldus PageMaker including versions of Lorem Ipsum. 1500s, when an unknown printer took a galley of type and scrambled it to
make a type specimen book. It has survived not only five centuries, but
also the leap into electronic typesetting, remaining essentially
unchanged. It was popularised in the 1960s with the release of Letraset
sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem
Ipsum.
</p> </p>
<button class="accept" (click)="menuToggle()">I Accept</button> <button class="accept" (click)="menuToggle()">I Accept</button>
</div> </div>
......
import { Injectable } from '@angular/core'; import { Injectable } from "@angular/core";
import { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore'; import {
import { AddressList, Address } from './services/address'; AngularFirestore,
import { database } from 'firebase'; AngularFirestoreCollection
import { take } from 'rxjs/operators'; } from "@angular/fire/firestore";
import { AddressList, Address } from "./services/address";
import { database } from "firebase";
import { take } from "rxjs/operators";
@Injectable({ @Injectable({
providedIn: 'root' providedIn: "root"
}) })
export class AddressService { export class AddressService {
addressList: AddressList[] = []; addressList: AddressList[] = [];
constructor( constructor(public afs: AngularFirestore) {}
public afs: AngularFirestore
) {
}
public async addList(userId: string) { public async addList(userId: string) {
const This = this; const This = this;
const state = true; const state = true;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('address', ref => ref.where('status', '==', state) const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
.where('uid', '==', userId)); "address",
orderRef.valueChanges().pipe( ref => ref.where("status", "==", state).where("uid", "==", userId)
);
orderRef
.valueChanges()
.pipe(
take(1) // Here you can limit to only emit once, using the take operator take(1) // Here you can limit to only emit once, using the take operator
).subscribe((value) => { )
.subscribe(value => {
this.addressList = []; this.addressList = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach(item => {
console.log(item); // console.log(item);
const address: AddressList = { const address: AddressList = {
address: item.address, address: item.address,
addressType: item.addressType, addressType: item.addressType,
latLng: item.latLng, latLng: item.latLng,
defaultVal: item.defaultVal, defaultVal: item.defaultVal,
building: item. building, building: item.building,
landmark: item.landmark, landmark: item.landmark,
addressId: item.addressId addressId: item.addressId
}; };
this.addressList.push(address); this.addressList.push(address);
}); });
console.log(this.addressList); // console.log(this.addressList);
} else { } else {
// alert('No Orders Found'); // alert('No Orders Found');
} }
...@@ -46,22 +51,36 @@ export class AddressService { ...@@ -46,22 +51,36 @@ export class AddressService {
} }
addressCreate(data: Address) { addressCreate(data: Address) {
this.afs.collection('address').add({}).then((docRef) => { this.afs
.collection("address")
.add({})
.then(docRef => {
data.addressId = docRef.id; data.addressId = docRef.id;
this.afs.collection('address').doc(data.addressId).set(data).then(() => { this.afs
console.log('Address created Successfully'); .collection("address")
.doc(data.addressId)
.set(data)
.then(() => {
// console.log('Address created Successfully');
}); });
}); });
} }
setDefaultAddress(addId: string, userId: string) { setDefaultAddress(addId: string, userId: string) {
this.afs.collection('address', ref => ref.where('uid', '==', userId)).get().forEach((item) => { this.afs
.collection("address", ref => ref.where("uid", "==", userId))
.get()
.forEach(item => {
return item.docs.map(m => { return item.docs.map(m => {
return this.afs.doc(`address/${m.id}`).update({defaultVal: 0}); return this.afs.doc(`address/${m.id}`).update({ defaultVal: 0 });
}); });
}); });
this.afs.collection('address').doc(addId).update({defaultVal: 1}).then(() => { this.afs
console.log('Address updated Successfully'); .collection("address")
.doc(addId)
.update({ defaultVal: 1 })
.then(() => {
// console.log('Address updated Successfully');
}); });
} }
} }
import { Injectable } from '@angular/core'; import { Injectable } from "@angular/core";
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore'; import {
import { Router, ActivatedRoute } from '@angular/router'; AngularFirestore,
import { Products } from './services/product'; AngularFirestoreDocument,
import { Cart, CartItem } from './services/cart'; AngularFirestoreCollection
import { ServiceService } from './service.service'; } from "@angular/fire/firestore";
import * as firebase from 'firebase'; import { Router, ActivatedRoute } from "@angular/router";
import { take } from 'rxjs/operators'; import { Products } from "./services/product";
import { User } from './services/user'; import { Cart, CartItem } from "./services/cart";
import { from } from 'rxjs'; import { ServiceService } from "./service.service";
import * as firebase from "firebase";
import { take } from "rxjs/operators";
import { User } from "./services/user";
import { from } from "rxjs";
@Injectable({ @Injectable({
providedIn: 'root' providedIn: "root"
}) })
export class CartsService { export class CartsService {
size: string; size: string;
...@@ -27,13 +31,13 @@ export class CartsService { ...@@ -27,13 +31,13 @@ export class CartsService {
public router: Router, public router: Router,
public service: ServiceService public service: ServiceService
) { ) {
this.custId = ''; this.custId = "";
this.carts = []; this.carts = [];
const users = this.service.get('user').then(data => { const users = this.service.get("user").then(data => {
if (data) { if (data) {
data = JSON.parse(data); data = JSON.parse(data);
this.custId = data.uid; this.custId = data.uid;
console.log(this.custId); // console.log(this.custId);
} }
}); });
} }
...@@ -42,30 +46,30 @@ export class CartsService { ...@@ -42,30 +46,30 @@ export class CartsService {
this.prodId = product.prodId; this.prodId = product.prodId;
const prodRef = firebase const prodRef = firebase
.firestore() .firestore()
.collection('products') .collection("products")
.doc(this.prodId); .doc(this.prodId);
this.size = this.size === undefined ? product.size[0] : this.size; this.size = this.size === undefined ? product.size[0] : this.size;
this.color = this.color === undefined ? product.color[0] : this.color; this.color = this.color === undefined ? product.color[0] : this.color;
const cartRef: AngularFirestoreCollection<any> = this.afs.collection( const cartRef: AngularFirestoreCollection<any> = this.afs.collection(
'carts', "carts",
ref => ref =>
ref ref
.where('size', '==', this.size) .where("size", "==", this.size)
.where('color', '==', this.color) .where("color", "==", this.color)
.where('custId', '==', this.custId) .where("custId", "==", this.custId)
.where('product', '==', prodRef) .where("product", "==", prodRef)
); );
cartRef cartRef
.valueChanges() .valueChanges()
.pipe(take(1)) .pipe(take(1))
.subscribe(value => { .subscribe(value => {
console.log(value); // console.log(value);
if (value.length === 0) { if (value.length === 0) {
product.image = product.image =
product.image === undefined product.image === undefined
? '../assets/[email protected]' ? "../assets/[email protected]"
: product.image; : product.image;
const cart: Cart = { const cart: Cart = {
color: this.color, color: this.color,
...@@ -80,36 +84,36 @@ export class CartsService { ...@@ -80,36 +84,36 @@ export class CartsService {
qty: 1, qty: 1,
size: this.size size: this.size
}; };
console.log(cart); // console.log(cart);
this.afs this.afs
.collection('carts') .collection("carts")
.add(cart) .add(cart)
.then(docRef => { .then(docRef => {
const neworderId = docRef.id; const neworderId = docRef.id;
this.afs this.afs
.collection('carts') .collection("carts")
.doc(neworderId) .doc(neworderId)
.update({ cartId: docRef.id }) .update({ cartId: docRef.id })
.then(() => { .then(() => {
console.log('Booking Successfully'); // console.log('Booking 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);
}); });
} else { } else {
console.log(value); // console.log(value);
// alert('Item already added in the cart'); // alert('Item already added in the cart');
const cartId = value[0].cartId; const cartId = value[0].cartId;
// tslint:disable-next-line:radix // tslint:disable-next-line:radix
const qty = parseInt(value[0].qty) + 1; const qty = parseInt(value[0].qty) + 1;
this.afs this.afs
.collection('carts') .collection("carts")
.doc(cartId) .doc(cartId)
.update({ qty: `${qty}` }) .update({ qty: `${qty}` })
.then(() => { .then(() => {
console.log('Booking Successfully'); // console.log('Booking Successfully');
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
}); });
} }
...@@ -118,8 +122,8 @@ export class CartsService { ...@@ -118,8 +122,8 @@ export class CartsService {
public async cartList() { public async cartList() {
const cartRef: AngularFirestoreCollection<any> = this.afs.collection( const cartRef: AngularFirestoreCollection<any> = this.afs.collection(
'carts', "carts",
ref => ref.where('custId', '==', this.custId) ref => ref.where("custId", "==", this.custId)
); );
cartRef.valueChanges().subscribe(value => { cartRef.valueChanges().subscribe(value => {
this.carts = []; this.carts = [];
...@@ -139,7 +143,7 @@ export class CartsService { ...@@ -139,7 +143,7 @@ export class CartsService {
qty: item.qty, qty: item.qty,
size: item.size size: item.size
}; };
console.log(item.price, item.qty); // console.log(item.price, item.qty);
if (item.price) { if (item.price) {
this.cartTotal += item.price * item.qty; this.cartTotal += item.price * item.qty;
} }
...@@ -175,9 +179,9 @@ export class CartsService { ...@@ -175,9 +179,9 @@ export class CartsService {
? this.carts[index].qty - 1 ? this.carts[index].qty - 1
: this.carts[index].qty; : this.carts[index].qty;
this.carts[index].qty = qty; this.carts[index].qty = qty;
console.log(this.carts[index].qty); // console.log(this.carts[index].qty);
this.afs this.afs
.collection('carts') .collection("carts")
.doc(this.carts[index].cartId) .doc(this.carts[index].cartId)
.update({ .update({
qty: this.carts[index].qty qty: this.carts[index].qty
...@@ -189,7 +193,7 @@ export class CartsService { ...@@ -189,7 +193,7 @@ export class CartsService {
this.cartTotal = 0; this.cartTotal = 0;
this.carts[index].qty = qty; this.carts[index].qty = qty;
this.afs this.afs
.collection('carts') .collection("carts")
.doc(this.carts[index].cartId) .doc(this.carts[index].cartId)
.update({ .update({
qty: this.carts[index].qty qty: this.carts[index].qty
...@@ -198,21 +202,19 @@ export class CartsService { ...@@ -198,21 +202,19 @@ export class CartsService {
removeItem(index) { removeItem(index) {
this.afs this.afs
.collection('carts') .collection("carts")
.doc(this.carts[index].cartId) .doc(this.carts[index].cartId)
.delete(); .delete();
} }
checkPromo(promoCode: string) { checkPromo(promoCode: string) {
console.log(promoCode); // console.log(promoCode);
const state = true; const state = true;
const promoRef: AngularFirestoreCollection<any> = this.afs.collection('promocode', ref => ref.where('promoCode', '==', promoCode) const promoRef: AngularFirestoreCollection<any> = this.afs.collection(
.where('status', '==', state)); "promocode",
ref =>
ref.where("promoCode", "==", promoCode).where("status", "==", state)
);
return promoRef.valueChanges(); return promoRef.valueChanges();
} }
} }
import { Injectable } from '@angular/core'; import { Injectable } from "@angular/core";
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore'; import {
import { Category } from './services/category'; AngularFirestore,
import * as firebase from 'firebase'; AngularFirestoreDocument,
import { ServiceService } from './service.service'; AngularFirestoreCollection
} from "@angular/fire/firestore";
import { Category } from "./services/category";
import * as firebase from "firebase";
import { ServiceService } from "./service.service";
@Injectable({ @Injectable({
providedIn: 'root' providedIn: "root"
}) })
export class CategoriesService { export class CategoriesService {
categories: Category[] = []; categories: Category[] = [];
activecategories: Category[] = []; activecategories: Category[] = [];
constructor( constructor(public afs: AngularFirestore, public service: ServiceService) {
public afs: AngularFirestore,
public service: ServiceService
) {
this.categoryList(); this.categoryList();
this.activeCategory(); this.activeCategory();
} }
public async categoryList() { public async categoryList() {
const This = this; const This = this;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('shopcategory'); const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
orderRef.valueChanges().subscribe((value) => { "shopcategory"
);
orderRef.valueChanges().subscribe(value => {
this.categories = []; this.categories = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach(item => {
console.log(item); // console.log(item);
const category: Category = { const category: Category = {
catId: item.catId, catId: item.catId,
catName: item.catName, catName: item.catName,
...@@ -36,7 +39,7 @@ export class CategoriesService { ...@@ -36,7 +39,7 @@ export class CategoriesService {
}; };
this.categories.push(category); this.categories.push(category);
}); });
console.log(this.categories); // console.log(this.categories);
} else { } else {
// alert('No Orders Found'); // alert('No Orders Found');
} }
...@@ -46,13 +49,16 @@ export class CategoriesService { ...@@ -46,13 +49,16 @@ export class CategoriesService {
public async activeCategory() { public async activeCategory() {
const This = this; const This = this;
const state = true; const state = true;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('shopcategory', ref => ref.where('status', '==', state)); const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
orderRef.valueChanges().subscribe((value) => { "shopcategory",
ref => ref.where("status", "==", state)
);
orderRef.valueChanges().subscribe(value => {
this.activecategories = []; this.activecategories = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach(item => {
console.log(item); // console.log(item);
const category: Category = { const category: Category = {
catId: item.catId, catId: item.catId,
catName: item.catName, catName: item.catName,
...@@ -62,7 +68,7 @@ export class CategoriesService { ...@@ -62,7 +68,7 @@ export class CategoriesService {
}; };
this.activecategories.push(category); this.activecategories.push(category);
}); });
console.log(this.activecategories); // console.log(this.activecategories);
} else { } else {
// alert('No Orders Found'); // alert('No Orders Found');
} }
......
import { Injectable } from '@angular/core'; import { Injectable } from "@angular/core";
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore'; import {
import { Centers, CenterData } from './services/center'; AngularFirestore,
import * as firebase from 'firebase'; AngularFirestoreDocument,
AngularFirestoreCollection
} from "@angular/fire/firestore";
import { Centers, CenterData } from "./services/center";
import * as firebase from "firebase";
@Injectable({ @Injectable({
providedIn: 'root' providedIn: "root"
}) })
export class CenterService { export class CenterService {
centers: Centers[] = []; centers: Centers[] = [];
nearcenters: Centers[] = []; nearcenters: Centers[] = [];
constructor( constructor(public afs: AngularFirestore) {
public afs: AngularFirestore
) {
this.centerList(); this.centerList();
this.getNearBy(10.0159, 76.3419, 10); this.getNearBy(10.0159, 76.3419, 10);
} }
...@@ -19,14 +21,16 @@ export class CenterService { ...@@ -19,14 +21,16 @@ export class CenterService {
public async centerList() { public async centerList() {
const This = this; const This = this;
const state = true; const state = true;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('centers', ref => ref.where('featured', '==', state) const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
.where('status', '==', state)); "centers",
orderRef.valueChanges().subscribe((value) => { ref => ref.where("featured", "==", state).where("status", "==", state)
);
orderRef.valueChanges().subscribe(value => {
this.centers = []; this.centers = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach(item => {
console.log(item); // console.log(item);
if (item.centerName === undefined) { if (item.centerName === undefined) {
return; return;
} }
...@@ -42,7 +46,7 @@ export class CenterService { ...@@ -42,7 +46,7 @@ export class CenterService {
}; };
this.centers.push(center); this.centers.push(center);
}); });
console.log(this.centers); // console.log(this.centers);
} else { } else {
// alert('No Orders Found'); // alert('No Orders Found');
} }
...@@ -56,22 +60,31 @@ export class CenterService { ...@@ -56,22 +60,31 @@ export class CenterService {
const lat = 0.0144927536231884; const lat = 0.0144927536231884;
const lon = 0.0181818181818182; const lon = 0.0181818181818182;
const lowerLat = latitude - (lat * distance); const lowerLat = latitude - lat * distance;
const lowerLon = longitude - (lon * distance); const lowerLon = longitude - lon * distance;
const greaterLat = latitude + (lat * distance); const greaterLat = latitude + lat * distance;
const greaterLon = longitude + (lon * distance); const greaterLon = longitude + lon * distance;
const lesserGeopoint = new firebase.firestore.GeoPoint(lowerLat, lowerLon); const lesserGeopoint = new firebase.firestore.GeoPoint(lowerLat, lowerLon);
const greaterGeopoint = new firebase.firestore.GeoPoint(greaterLat, greaterLon); const greaterGeopoint = new firebase.firestore.GeoPoint(
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('centers', ref => ref.where('latLng', '>', lesserGeopoint) greaterLat,
.where('latLng', '<', greaterGeopoint).where('status', '==', state)); greaterLon
orderRef.valueChanges().subscribe((value) => { );
const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
"centers",
ref =>
ref
.where("latLng", ">", lesserGeopoint)
.where("latLng", "<", greaterGeopoint)
.where("status", "==", state)
);
orderRef.valueChanges().subscribe(value => {
this.nearcenters = []; this.nearcenters = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach(item => {
console.log(item); // console.log(item);
if (item.centerName === undefined) { if (item.centerName === undefined) {
return; return;
} }
...@@ -87,11 +100,10 @@ export class CenterService { ...@@ -87,11 +100,10 @@ export class CenterService {
}; };
this.nearcenters.push(center); this.nearcenters.push(center);
}); });
console.log(this.nearcenters); // console.log(this.nearcenters);
} else { } else {
// alert('No Orders Found'); // alert('No Orders Found');
} }
}); });
} }
} }
import { Injectable } from '@angular/core'; import { Injectable } from "@angular/core";
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore'; import {
import { Myorder } from './services/myorder'; AngularFirestore,
import { ServiceService } from './../config/service.service'; AngularFirestoreDocument,
import * as firebase from 'firebase'; AngularFirestoreCollection
import { take } from 'rxjs/operators'; } from "@angular/fire/firestore";
import { Observable, of } from 'rxjs'; import { Myorder } from "./services/myorder";
import { ServiceService } from "./../config/service.service";
import * as firebase from "firebase";
import { take } from "rxjs/operators";
import { Observable, of } from "rxjs";
@Injectable({ @Injectable({
providedIn: 'root' providedIn: "root"
}) })
export class MyordersService { export class MyordersService {
product: Myorder[] = []; product: Myorder[] = [];
...@@ -15,11 +19,8 @@ export class MyordersService { ...@@ -15,11 +19,8 @@ export class MyordersService {
orders: Myorder[]; orders: Myorder[];
selItem: Myorder; selItem: Myorder;
constructor( constructor(public afs: AngularFirestore, public service: ServiceService) {
public afs: AngularFirestore, const users = this.service.get("user").then(data => {
public service: ServiceService
) {
const users = this.service.get('user').then((data) => {
if (data) { if (data) {
data = JSON.parse(data); data = JSON.parse(data);
this.custId = data.uid; this.custId = data.uid;
...@@ -28,28 +29,28 @@ export class MyordersService { ...@@ -28,28 +29,28 @@ export class MyordersService {
// this.orderState(); // this.orderState();
} }
} else { } else {
this.custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2'; this.custId = "WwHnLICVY2dvZGUHuKqasiTB91a2";
} }
}); });
} }
/*public async orgorderList(custId) { /*public async orgorderList(custId) {
console.log('called'); // console.log('called');
console.log(custId); // console.log(custId);
const This = this; const This = this;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('orders', ref => ref.where('custId', '==', custId) const orderRef: AngularFirestoreCollection<any> = this.afs.collection('orders', ref => ref.where('custId', '==', custId)
.orderBy('bookDate', 'desc')); .orderBy('bookDate', 'desc'));
orderRef.stateChanges().subscribe((value) => { orderRef.stateChanges().subscribe((value) => {
console.log(value[0].payload.doc.data()); // console.log(value[0].payload.doc.data());
}); });
orderRef.valueChanges().pipe(take(1)).subscribe((value) => { orderRef.valueChanges().pipe(take(1)).subscribe((value) => {
console.log(value); // console.log(value);
this.orders = []; this.orders = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach((item) => {
console.log(item); // console.log(item);
const order: Myorder = { const order: Myorder = {
prodName: item.prodName, prodName: item.prodName,
color: item.color, color: item.color,
...@@ -70,7 +71,7 @@ export class MyordersService { ...@@ -70,7 +71,7 @@ export class MyordersService {
}; };
this.orders.push(order); this.orders.push(order);
}); });
console.log(this.orders); // console.log(this.orders);
} else { } else {
alert('No Orders Found'); alert('No Orders Found');
} }
...@@ -78,22 +79,23 @@ export class MyordersService { ...@@ -78,22 +79,23 @@ export class MyordersService {
}); });
}*/ }*/
public async orderList(custId) { public async orderList(custId) {
console.log('called'); // console.log('called');
console.log(custId); // console.log(custId);
const This = this; const This = this;
this.orders = []; this.orders = [];
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('orders', ref => ref.where('custId', '==', custId) const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
.orderBy('bookDate', 'desc')); "orders",
orderRef.stateChanges().subscribe((value) => { ref => ref.where("custId", "==", custId).orderBy("bookDate", "desc")
console.log(value); );
orderRef.stateChanges().subscribe(value => {
// console.log(value);
const res = value; const res = value;
console.log(res); // console.log(res);
if (res.length > 0) { if (res.length > 0) {
res.forEach((items) => { res.forEach(items => {
const item = items.payload.doc.data(); const item = items.payload.doc.data();
console.log(item); // console.log(item);
const orderId = item.orderId; const orderId = item.orderId;
const order: Myorder = { const order: Myorder = {
amount: item.amount, amount: item.amount,
...@@ -103,40 +105,39 @@ export class MyordersService { ...@@ -103,40 +105,39 @@ export class MyordersService {
deliveryLocation: item.deliveryLocation, deliveryLocation: item.deliveryLocation,
pickupLocation: item.pickupLocation, pickupLocation: item.pickupLocation,
deliveryAddress: item.deliveryAddress, deliveryAddress: item.deliveryAddress,
riderName: 'John', riderName: "John",
orderId: item.orderId, orderId: item.orderId,
orderCode: item.orderCode, orderCode: item.orderCode,
product: this.service.key2Array(item.product), product: this.service.key2Array(item.product),
time: '60' time: "60"
}; };
console.log(order); // console.log(order);
if (items.type === 'added') { if (items.type === "added") {
this.orders.push(order); this.orders.push(order);
} else { } else {
console.log(orderId); // console.log(orderId);
const index = this.orders.findIndex(obj => obj.orderId === orderId); const index = this.orders.findIndex(obj => obj.orderId === orderId);
if (index >= 0) { if (index >= 0) {
this.orders[index] = order; this.orders[index] = order;
} }
} }
}); });
console.log(this.orders); // console.log(this.orders);
} }
}); });
} }
/* public orderState(): Observable<Myorder[]> {
/* public orderState(): Observable<Myorder[]> { // console.log('called');
console.log('called');
const custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2'; const custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2';
this.orders = []; this.orders = [];
firebase.firestore().collection('orders').where('custId', '==', custId) firebase.firestore().collection('orders').where('custId', '==', custId)
.onSnapshot((snapData) => { .onSnapshot((snapData) => {
snapData.docChanges().forEach((change) => { snapData.docChanges().forEach((change) => {
console.log(change.type); // console.log(change.type);
if (change.type === 'modified') { if (change.type === 'modified') {
const item = change.doc.data(); const item = change.doc.data();
console.log(item); // console.log(item);
const orderId = item.orderId; const orderId = item.orderId;
const order: Myorder = { const order: Myorder = {
prodName: item.prodName, prodName: item.prodName,
...@@ -157,9 +158,9 @@ export class MyordersService { ...@@ -157,9 +158,9 @@ export class MyordersService {
const count = this.orders.length; const count = this.orders.length;
for (let index = 0; index < count; index++) { for (let index = 0; index < count; index++) {
if (this.orders[index].orderId === orderId) { if (this.orders[index].orderId === orderId) {
console.log(index); // console.log(index);
this.orders[index] = order; this.orders[index] = order;
console.log(this.orders); // console.log(this.orders);
break; break;
} }
} }
...@@ -195,13 +196,13 @@ export class MyordersService { ...@@ -195,13 +196,13 @@ export class MyordersService {
.onSnapshot(function(snapshot) { .onSnapshot(function(snapshot) {
snapshot.docChanges().forEach(function(change) { snapshot.docChanges().forEach(function(change) {
if (change.type === "added") { if (change.type === "added") {
console.log("New city: ", change.doc.data()); // console.log("New city: ", change.doc.data());
} }
if (change.type === "modified") { if (change.type === "modified") {
console.log("Modified city: ", change.doc.data()); // console.log("Modified city: ", change.doc.data());
} }
if (change.type === "removed") { if (change.type === "removed") {
console.log("Removed city: ", change.doc.data()); // console.log("Removed city: ", change.doc.data());
} }
}); });
}); });
...@@ -211,5 +212,4 @@ export class MyordersService { ...@@ -211,5 +212,4 @@ export class MyordersService {
public async trackOrder(order) { public async trackOrder(order) {
this.selItem = order; this.selItem = order;
} }
} }
import { Injectable } from '@angular/core'; import { Injectable } from "@angular/core";
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore'; import {
import { Router, ActivatedRoute } from '@angular/router'; AngularFirestore,
import { Order, CartProd } from './services/order'; AngularFirestoreDocument,
import { Products } from './services/product'; AngularFirestoreCollection
import { ServiceService } from './service.service'; } from "@angular/fire/firestore";
import * as firebase from 'firebase'; import { Router, ActivatedRoute } from "@angular/router";
import { CartItem } from './services/cart'; import { Order, CartProd } from "./services/order";
import { BehaviorSubject } from 'rxjs'; import { Products } from "./services/product";
import { ServiceService } from "./service.service";
import * as firebase from "firebase";
import { CartItem } from "./services/cart";
import { BehaviorSubject } from "rxjs";
@Injectable({ @Injectable({
providedIn: 'root' providedIn: "root"
}) })
export class OrdersService { export class OrdersService {
order: Order; order: Order;
...@@ -26,24 +29,24 @@ export class OrdersService { ...@@ -26,24 +29,24 @@ export class OrdersService {
public router: Router, public router: Router,
public service: ServiceService public service: ServiceService
) { ) {
this.size = 'small'; this.size = "small";
this.color = 'Blue'; this.color = "Blue";
this.custId = ''; this.custId = "";
this.service.get('user').then((data) => { this.service.get("user").then(data => {
if (data) { if (data) {
data = JSON.parse(data); data = JSON.parse(data);
this.users = data; this.users = data;
this.custId = data.uid; this.custId = data.uid;
console.log(this.custId); // console.log(this.custId);
} else { } else {
this.custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2'; this.custId = "WwHnLICVY2dvZGUHuKqasiTB91a2";
} }
}); });
} }
/*public async orgcheckOut(cart: CartItem[]) { /*public async orgcheckOut(cart: CartItem[]) {
console.log(cart); // console.log(cart);
console.log(this.users); // console.log(this.users);
return; return;
let currProcess = 0; let currProcess = 0;
const cartCount = cart.length; const cartCount = cart.length;
...@@ -86,10 +89,10 @@ export class OrdersService { ...@@ -86,10 +89,10 @@ export class OrdersService {
}; };
this.afs.collection('orders').doc(neworderId).set(orderItem).then(() => { this.afs.collection('orders').doc(neworderId).set(orderItem).then(() => {
currProcess += 1; currProcess += 1;
console.log('Booking Successfully'); // console.log('Booking Successfully');
this.afs.doc(`carts/${product.cartId}`).delete(); this.afs.doc(`carts/${product.cartId}`).delete();
// this.router.navigateByUrl('cart'); // this.router.navigateByUrl('cart');
console.log(currProcess, cartCount); // console.log(currProcess, cartCount);
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
if (currProcess === cartCount) { if (currProcess === cartCount) {
// this.router.navigateByUrl('cart'); // this.router.navigateByUrl('cart');
...@@ -103,10 +106,9 @@ export class OrdersService { ...@@ -103,10 +106,9 @@ export class OrdersService {
}*/ }*/
public async checkOut(cart: CartItem[], otherCharge) { public async checkOut(cart: CartItem[], otherCharge) {
console.log(cart); // console.log(cart);
console.log(this.users); // console.log(this.users);
const cartGroup = []; const cartGroup = [];
// const distinctShops = [...new Set(cart.map(obj => obj.shopperId))]; // const distinctShops = [...new Set(cart.map(obj => obj.shopperId))];
const distinctShops = []; const distinctShops = [];
...@@ -117,29 +119,33 @@ export class OrdersService { ...@@ -117,29 +119,33 @@ export class OrdersService {
distinctShops.push(item.shopperId); distinctShops.push(item.shopperId);
} }
} }
cart.forEach((items) => { cart.forEach(items => {
cartGroup[items.shopperId] = cartGroup[items.shopperId] === undefined ? [] : cartGroup[items.shopperId]; cartGroup[items.shopperId] =
cartGroup[items.shopperId] === undefined
? []
: cartGroup[items.shopperId];
cartGroup[items.shopperId].push(items); cartGroup[items.shopperId].push(items);
}); });
const cartCount = distinctShops.length; const cartCount = distinctShops.length;
// console.log(cartGroup);
// console.log(cartCount);
console.log(cartGroup);
console.log(cartCount);
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({ this.afs
.collection("orders")
.add({
bookDate: firebase.firestore.FieldValue.serverTimestamp() bookDate: firebase.firestore.FieldValue.serverTimestamp()
}).then((docRef) => { })
.then(docRef => {
const neworderId = docRef.id; const neworderId = docRef.id;
const delivery = new firebase.firestore.GeoPoint(10.0237, 76.3116); const delivery = new firebase.firestore.GeoPoint(10.0237, 76.3116);
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];
let prodPrice = 0; let prodPrice = 0;
cartItem.forEach((prodItem) => { cartItem.forEach(prodItem => {
prodPrice += prodItem.price; prodPrice += prodItem.price;
products[prodItem.prodId] = { products[prodItem.prodId] = {
prodId: prodItem.prodId, prodId: prodItem.prodId,
...@@ -149,61 +155,70 @@ export class OrdersService { ...@@ -149,61 +155,70 @@ export class OrdersService {
color: prodItem.color, color: prodItem.color,
size: prodItem.size, size: prodItem.size,
qty: prodItem.qty, qty: prodItem.qty,
discount: '' discount: ""
}; };
this.afs.doc(`carts/${prodItem.cartId}`).delete(); this.afs.doc(`carts/${prodItem.cartId}`).delete();
}); });
console.log(cartItem); // console.log(cartItem);
console.log(products); // console.log(products);
const product = cartItem[0]; const product = cartItem[0];
const orderItem: Order = { const orderItem: Order = {
amount: 'A$ ' + otherCharge.totalAmt, amount: "A$ " + otherCharge.totalAmt,
customer: firebase.firestore().doc('/customer/' + this.custId), customer: firebase.firestore().doc("/customer/" + this.custId),
shopper: product.shopper, shopper: product.shopper,
deliveryAddress: otherCharge.custAddress, deliveryAddress: otherCharge.custAddress,
deliveryCharge: 'A$ ' + otherCharge.deliveryCharge, deliveryCharge: "A$ " + otherCharge.deliveryCharge,
deliveryLocation: delivery, deliveryLocation: delivery,
bookDate: firebase.firestore.FieldValue.serverTimestamp(), bookDate: firebase.firestore.FieldValue.serverTimestamp(),
orderCode: this.orderCode(), orderCode: this.orderCode(),
orderId: neworderId, orderId: neworderId,
orderStatus: 1, orderStatus: 1,
pickupAddress: 'GetMi, Canberra, AUS', pickupAddress: "GetMi, Canberra, AUS",
pickupLocation: pickup, pickupLocation: pickup,
promoId: null, promoId: null,
rider: firebase.firestore().doc('/riders/qbTKza18mWVzYG9NLIbmjMbrYjG2'), rider: firebase
.firestore()
.doc("/riders/qbTKza18mWVzYG9NLIbmjMbrYjG2"),
status: 1, status: 1,
custId: this.custId, custId: this.custId,
riderId: 'qbTKza18mWVzYG9NLIbmjMbrYjG2', riderId: "qbTKza18mWVzYG9NLIbmjMbrYjG2",
shopperId: product.shopperId, shopperId: product.shopperId,
custName: 'Jone Doe', custName: "Jone Doe",
riderName: 'John', riderName: "John",
shopperState: 0, shopperState: 0,
shopperName: 'Witchery', shopperName: "Witchery",
product: products, product: products,
discount: 'A$ ' + otherCharge.discount, discount: "A$ " + otherCharge.discount,
promoApplied: otherCharge.discountApplied, promoApplied: otherCharge.discountApplied,
tax: 'A$ ' + otherCharge.taxAmount tax: "A$ " + otherCharge.taxAmount
}; };
console.log(orderItem); // console.log(orderItem);
this.afs.collection('orders').doc(neworderId).set(orderItem).then(() => { this.afs
console.log('Booking Successfully'); .collection("orders")
.doc(neworderId)
.set(orderItem)
.then(() => {
// console.log('Booking Successfully');
// this.router.navigateByUrl('cart'); // this.router.navigateByUrl('cart');
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) => { })
console.error('Error adding document: ', error); .catch(error => {
console.error("Error adding document: ", error);
}); });
}); });
}); });
promise.then(value => console.log(value)); // promise.then(value => console.log(value));
} }
public async changeOrder(orderId, status) { public async changeOrder(orderId, status) {
console.log(orderId, status); // console.log(orderId, status);
this.afs.collection('orders').doc(orderId).update({orderStatus: status}); this.afs
.collection("orders")
.doc(orderId)
.update({ orderStatus: status });
} }
public async buyNow(product: Products) { public async buyNow(product: Products) {
...@@ -212,18 +227,17 @@ export class OrdersService { ...@@ -212,18 +227,17 @@ export class OrdersService {
orderCode() { orderCode() {
const newpin = Math.round(Math.random() * 1000000); const newpin = Math.round(Math.random() * 1000000);
const orderCode = 'GM' + this.pad(newpin, 6, null); const orderCode = "GM" + this.pad(newpin, 6, null);
return orderCode; return orderCode;
} }
pad(n, width, z) { pad(n, width, z) {
z = z || '0'; z = z || "0";
n = n + ''; n = n + "";
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
} }
choose_size(size: string) { choose_size(size: string) {
this.size = size; this.size = size;
} }
} }
import { Injectable } from '@angular/core'; import { Injectable } from "@angular/core";
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore'; import {
import { Products } from './services/product'; AngularFirestore,
import { ServiceService } from './../config/service.service'; AngularFirestoreDocument,
import { take } from 'rxjs/operators'; AngularFirestoreCollection
} from "@angular/fire/firestore";
import { Products } from "./services/product";
import { Slides } from "./services/slides";
import { ServiceService } from "./../config/service.service";
import { take } from "rxjs/operators";
@Injectable({ @Injectable({
providedIn: 'root' providedIn: "root"
}) })
export class ProductsService { export class ProductsService {
prodSlideImg: Slides[] = [];
product: Products[] = []; product: Products[] = [];
fav: any[]; fav: any[];
selItem: Products; selItem: Products;
similar: Products[] = []; similar: Products[] = [];
user: any; user: any;
constructor( constructor(public afs: AngularFirestore, public service: ServiceService) {
public afs: AngularFirestore,
public service: ServiceService
) {
this.product = []; this.product = [];
this.fav = []; this.fav = [];
this.service.get('user').then(data => { this.prodSlideImg = [];
this.service.get("user").then(data => {
this.user = JSON.parse(data); this.user = JSON.parse(data);
this.getFavlist(this.user.uid); this.getFavlist(this.user.uid);
}); });
} }
// Fetches images for slide
public async getProdSlide(skuID: string) {
const This = this;
const state = true;
// firebase query
const prodRef: AngularFirestoreCollection<any> = this.afs.collection(
`product_gallery`,
ref => ref.where("skuId", "==", skuID)
);
prodRef.valueChanges().subscribe(value => {
this.prodSlideImg = [];
const res = value;
if (res.length > 0) {
res.forEach(item => {
const slideImg: Slides = {
downloadURL: item.downloadURL,
imageId: item.imageId,
path: item.path,
skuId: item.skuId
};
this.prodSlideImg.push(slideImg);
});
console.log("[prodSlideImgArray]", this.prodSlideImg);
return this.prodSlideImg;
} else {
// alert("No Products Found");
}
});
}
public async prodList(shopperId: string) { public async prodList(shopperId: string) {
const This = this; const This = this;
const state = true; const state = true;
console.log(shopperId); // console.log(shopperId);
const prodRef: AngularFirestoreCollection<any> = this.afs.collection(`products`, ref => ref.where('shopperId', '==', shopperId) const prodRef: AngularFirestoreCollection<any> = this.afs.collection(
.where('status', '==', state)); `products`,
prodRef.valueChanges().subscribe((value) => { ref =>
ref.where("shopperId", "==", shopperId).where("status", "==", state)
);
prodRef.valueChanges().subscribe(value => {
this.product = []; this.product = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach(item => {
console.log(item.size); // console.log(item.size);
const prod: Products = { const prod: Products = {
prodId: item.prodId, prodId: item.prodId,
prodName: item.prodName, prodName: item.prodName,
...@@ -61,7 +102,7 @@ export class ProductsService { ...@@ -61,7 +102,7 @@ export class ProductsService {
}; };
this.product.push(prod); this.product.push(prod);
}); });
console.log(this.product); // console.log(this.product);
} else { } else {
// alert('No Products Found'); // alert('No Products Found');
} }
...@@ -71,34 +112,35 @@ export class ProductsService { ...@@ -71,34 +112,35 @@ export class ProductsService {
public async filterSearch(sortValue: string) { public async filterSearch(sortValue: string) {
const This = this; const This = this;
const state = true; const state = true;
console.log(sortValue); // console.log(sortValue);
let field, order; let field, order;
if (sortValue === 'low') { if (sortValue === "low") {
field = 'price'; field = "price";
order = 'asc'; order = "asc";
} }
if (sortValue === 'high') { if (sortValue === "high") {
field = 'price'; field = "price";
order = 'desc'; order = "desc";
} }
if (sortValue === 'rate') { if (sortValue === "rate") {
// field = 'price'; // field = 'price';
// order = 'desc'; // order = 'desc';
} }
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
const prodRef: AngularFirestoreCollection<any> = this.afs.collection(`products`, ref => ref.where('status', '==', state).orderBy(field, order)); const prodRef: AngularFirestoreCollection<any> = this.afs.collection(
prodRef.valueChanges().subscribe((value) => { `products`,
ref => ref.where("status", "==", state).orderBy(field, order)
);
prodRef.valueChanges().subscribe(value => {
this.product = []; this.product = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach(item => {
console.log(item.size); // console.log(item.size);
const prod: Products = { const prod: Products = {
prodId: item.prodId, prodId: item.prodId,
prodName: item.prodName, prodName: item.prodName,
...@@ -123,29 +165,34 @@ export class ProductsService { ...@@ -123,29 +165,34 @@ export class ProductsService {
}; };
this.product.push(prod); this.product.push(prod);
}); });
console.log(this.product); // console.log(this.product);
} else { } else {
// alert('No Products Found'); // alert('No Products Found');
} }
}); });
} }
similarProd(shopperId, category, subCate, prodId) { similarProd(shopperId, category, subCate, prodId) {
const This = this; const This = this;
const state = true; const state = true;
console.log(shopperId); // console.log(shopperId);
const prodRef: AngularFirestoreCollection<any> = this.afs.collection(`products`, ref => ref.where('shopperId', '==', shopperId) const prodRef: AngularFirestoreCollection<any> = this.afs.collection(
.where('status', '==', state).where('category', '==', category).where('subCate', '==', subCate).where('prodId', '>', prodId) `products`,
.where('prodId', '<', prodId)); ref =>
prodRef.valueChanges().subscribe((value) => { ref
.where("shopperId", "==", shopperId)
.where("status", "==", state)
.where("category", "==", category)
.where("subCate", "==", subCate)
.where("prodId", ">", prodId)
.where("prodId", "<", prodId)
);
prodRef.valueChanges().subscribe(value => {
this.similar = []; this.similar = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach(item => {
console.log(item.size); // console.log(item.size);
const prod: Products = { const prod: Products = {
prodId: item.prodId, prodId: item.prodId,
prodName: item.prodName, prodName: item.prodName,
...@@ -170,65 +217,89 @@ export class ProductsService { ...@@ -170,65 +217,89 @@ export class ProductsService {
}; };
this.similar.push(prod); this.similar.push(prod);
}); });
console.log(this.similar); // console.log(this.similar);
} else { } else {
// alert('No Products Found'); // alert('No Products Found');
} }
}); });
} }
public async setProd(item: Products) { public async setProd(item: Products) {
this.selItem = item; this.selItem = item;
} }
public async getFavlist(userId: string) { public async getFavlist(userId: string) {
const favRef: AngularFirestoreDocument<any> = this.afs.collection(`favourite`).doc(userId); const favRef: AngularFirestoreDocument<any> = this.afs
favRef.valueChanges().pipe( .collection(`favourite`)
.doc(userId);
favRef
.valueChanges()
.pipe(
take(1) // Here you can limit to only emit once, using the take operator take(1) // Here you can limit to only emit once, using the take operator
).subscribe((value) => { )
.subscribe(value => {
if (value !== undefined) { if (value !== undefined) {
if (Object.keys(value).length > 0) { if (Object.keys(value).length > 0) {
this.fav = this.service.splitSep(value); this.fav = this.service.splitSep(value);
console.log(this.fav); // console.log(this.fav);
} }
console.log(value); // console.log(value);
} }
}); });
} }
public async changeFav(index, type) { public async changeFav(index, type) {
console.log(index, type, this.user.uid); // console.log(index, type, this.user.uid);
if (type === 'no') { if (type === "no") {
this.afs.collection('favourite').doc(this.user.uid).valueChanges().pipe( this.afs
.collection("favourite")
.doc(this.user.uid)
.valueChanges()
.pipe(
take(1) // Here you can limit to only emit once, using the take operator take(1) // Here you can limit to only emit once, using the take operator
).subscribe((value) => { )
.subscribe(value => {
if (value === undefined) { if (value === undefined) {
this.afs.collection('favourite').doc(this.user.uid).set({ this.afs
.collection("favourite")
.doc(this.user.uid)
.set({
[index]: true [index]: true
}); });
} else { } else {
console.log(value); // console.log(value);
value[index] = true; value[index] = true;
console.log(value); // console.log(value);
this.afs.collection('favourite').doc(this.user.uid).set(value); this.afs
.collection("favourite")
.doc(this.user.uid)
.set(value);
} }
}); });
} else { } else {
this.afs.collection('favourite').doc(this.user.uid).valueChanges().pipe( this.afs
.collection("favourite")
.doc(this.user.uid)
.valueChanges()
.pipe(
take(1) // Here you can limit to only emit once, using the take operator take(1) // Here you can limit to only emit once, using the take operator
).subscribe((value) => { )
console.log(value); .subscribe(value => {
// console.log(value);
if (value !== undefined) { if (value !== undefined) {
value[index] = undefined; value[index] = undefined;
Object.keys(value).forEach(key => value[key] === undefined ? delete value[key] : ''); Object.keys(value).forEach(key =>
console.log(value); value[key] === undefined ? delete value[key] : ""
this.afs.collection('favourite').doc(this.user.uid).set(value); );
// console.log(value);
this.afs
.collection("favourite")
.doc(this.user.uid)
.set(value);
} else { } else {
console.log(value); // console.log(value);
} }
}); });
} }
} }
} }
import { Injectable } from '@angular/core'; import { Injectable } from "@angular/core";
import { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore'; import {
import { Search } from './services/search'; AngularFirestore,
import { database } from 'firebase'; AngularFirestoreCollection
import { take } from 'rxjs/operators'; } from "@angular/fire/firestore";
import { Search } from "./services/search";
import { database } from "firebase";
import { take } from "rxjs/operators";
@Injectable({ @Injectable({
providedIn: 'root' providedIn: "root"
}) })
export class SearchService { export class SearchService {
searchList: Search[] = []; searchList: Search[] = [];
constructor( constructor(public afs: AngularFirestore) {}
public afs: AngularFirestore
) {
}
public async search(inputText: string) { public async search(inputText: string) {
if (inputText === '') { if (inputText === "") {
this.searchList = []; this.searchList = [];
return; return;
} }
...@@ -23,16 +23,25 @@ export class SearchService { ...@@ -23,16 +23,25 @@ export class SearchService {
const state = true; const state = true;
this.searchList = []; this.searchList = [];
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('shoppers', ref => ref.where('status', '==', state).orderBy('name').startAt(inputText.toUpperCase()).endAt(inputText.toLowerCase() + '\uf8ff').limit(5)); const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
orderRef.valueChanges().subscribe((value) => { "shoppers",
ref =>
ref
.where("status", "==", state)
.orderBy("name")
.startAt(inputText.toUpperCase())
.endAt(inputText.toLowerCase() + "\uf8ff")
.limit(5)
);
orderRef.valueChanges().subscribe(value => {
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach(item => {
console.log(item); // console.log(item);
const shopper: Search = { const shopper: Search = {
text: item.name, text: item.name,
data: item, data: item,
type: 'shopper' type: "shopper"
}; };
this.searchList.push(shopper); this.searchList.push(shopper);
}); });
...@@ -40,16 +49,25 @@ export class SearchService { ...@@ -40,16 +49,25 @@ export class SearchService {
}); });
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
const prodRef: AngularFirestoreCollection<any> = this.afs.collection('products', ref => ref.where('status', '==', state).orderBy('prodName').startAt(inputText.toUpperCase()).endAt(inputText.toLowerCase() + '\uf8ff').limit(5)); const prodRef: AngularFirestoreCollection<any> = this.afs.collection(
prodRef.valueChanges().subscribe((values) => { "products",
ref =>
ref
.where("status", "==", state)
.orderBy("prodName")
.startAt(inputText.toUpperCase())
.endAt(inputText.toLowerCase() + "\uf8ff")
.limit(5)
);
prodRef.valueChanges().subscribe(values => {
const result = values; const result = values;
if (result.length > 0) { if (result.length > 0) {
result.forEach((item) => { result.forEach(item => {
console.log(item); console.log(item);
const prod: Search = { const prod: Search = {
text: item.prodName, text: item.prodName,
data: item, data: item,
type: 'product' type: "product"
}; };
this.searchList.push(prod); this.searchList.push(prod);
}); });
...@@ -58,26 +76,30 @@ export class SearchService { ...@@ -58,26 +76,30 @@ export class SearchService {
}); });
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
const feaRef: AngularFirestoreCollection<any> = this.afs.collection('category', ref => ref.where('status', '==', state).orderBy('catName').startAt(inputText.toUpperCase()).endAt(inputText.toLowerCase() + '\uf8ff').limit(5)); const feaRef: AngularFirestoreCollection<any> = this.afs.collection(
feaRef.valueChanges().subscribe((values) => { "category",
ref =>
ref
.where("status", "==", state)
.orderBy("catName")
.startAt(inputText.toUpperCase())
.endAt(inputText.toLowerCase() + "\uf8ff")
.limit(5)
);
feaRef.valueChanges().subscribe(values => {
const result = values; const result = values;
if (result.length > 0) { if (result.length > 0) {
result.forEach((item) => { result.forEach(item => {
console.log(item); console.log(item);
const prod: Search = { const prod: Search = {
text: item.catName, text: item.catName,
data: item, data: item,
type: 'category' type: "category"
}; };
this.searchList.push(prod); this.searchList.push(prod);
}); });
console.log(this.searchList); console.log(this.searchList);
} }
}); });
} }
} }
import { Injectable } from '@angular/core'; import { Injectable } from "@angular/core";
import { Storage } from '@ionic/storage'; import { Storage } from "@ionic/storage";
@Injectable({ @Injectable({
providedIn: 'root' providedIn: "root"
}) })
export class ServiceService { export class ServiceService {
state: boolean; state: boolean;
constructor(public storage: Storage) { constructor(public storage: Storage) {
...@@ -13,20 +12,20 @@ export class ServiceService { ...@@ -13,20 +12,20 @@ export class ServiceService {
} }
public set(settingName: string, value: any) { public set(settingName: string, value: any) {
return this.storage.set(`setting:${ settingName }`, value); return this.storage.set(`setting:${settingName}`, value);
} }
public async get(settingName: string) { public async get(settingName: string) {
return await this.storage.get(`setting:${ settingName }`); return await this.storage.get(`setting:${settingName}`);
} }
public async remove(settingName: string) { public async remove(settingName: string) {
return await this.storage.remove(`setting:${ settingName }`); return await this.storage.remove(`setting:${settingName}`);
} }
public clear() { public clear() {
this.storage.clear().then(() => { this.storage.clear().then(() => {
console.log('all keys cleared'); console.log("all keys cleared");
}); });
} }
...@@ -49,7 +48,4 @@ export class ServiceService { ...@@ -49,7 +48,4 @@ export class ServiceService {
} }
return response; return response;
} }
} }
export interface Slides {
downloadURL: string;
imageId: string;
path: string;
skuId: string;
}
...@@ -12,7 +12,7 @@ export interface User { ...@@ -12,7 +12,7 @@ export interface User {
currency: { currency: {
currId: string; currId: string;
currName: string; currName: string;
symbol: string symbol: string;
}; };
} }
...@@ -25,6 +25,15 @@ export interface Signup { ...@@ -25,6 +25,15 @@ export interface Signup {
terms: boolean; terms: boolean;
} }
// Model for Change Details page
export interface UpdateUserDetails {
name: string;
emailId: string;
phone: string;
}
// Model to Update Password
export interface UpdateUserDetails {}
export interface Otp { export interface Otp {
uid: string; uid: string;
otp: number; otp: number;
......
import { Injectable } from '@angular/core'; import { Injectable } from "@angular/core";
import { AngularFireAuth } from '@angular/fire/auth'; import { AngularFireAuth } from "@angular/fire/auth";
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore'; import {
import { Shopper } from './services/shopper'; AngularFirestore,
import * as firebase from 'firebase'; AngularFirestoreDocument,
AngularFirestoreCollection
} from "@angular/fire/firestore";
import { Shopper } from "./services/shopper";
import * as firebase from "firebase";
@Injectable({ @Injectable({
providedIn: 'root' providedIn: "root"
}) })
export class ShoppersService { export class ShoppersService {
shoppers: Shopper[] = []; shoppers: Shopper[] = [];
activeshoppers: Shopper[] = []; activeshoppers: Shopper[] = [];
nearshoppers: Shopper[] = []; nearshoppers: Shopper[] = [];
constructor( constructor(public afs: AngularFirestore, public afAuth: AngularFireAuth) {
public afs: AngularFirestore,
public afAuth: AngularFireAuth,
) {
this.featuredshopperList(); this.featuredshopperList();
this.getNearBy(10.0159, 76.3419, 10); this.getNearBy(10.0159, 76.3419, 10);
} }
...@@ -22,14 +23,16 @@ export class ShoppersService { ...@@ -22,14 +23,16 @@ export class ShoppersService {
public async shopperList(centerId: string, type: string) { public async shopperList(centerId: string, type: string) {
const This = this; const This = this;
const state = true; const state = true;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('shoppers', ref => ref.where(type, '==', centerId) const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
.where('status', '==', state)); "shoppers",
orderRef.valueChanges().subscribe((value) => { ref => ref.where(type, "==", centerId).where("status", "==", state)
);
orderRef.valueChanges().subscribe(value => {
this.shoppers = []; this.shoppers = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach(item => {
console.log(item); // console.log(item);
const shopper: Shopper = { const shopper: Shopper = {
name: item.name, name: item.name,
emailId: item.emailId, emailId: item.emailId,
...@@ -49,7 +52,7 @@ export class ShoppersService { ...@@ -49,7 +52,7 @@ export class ShoppersService {
}; };
this.shoppers.push(shopper); this.shoppers.push(shopper);
}); });
console.log(this.shoppers); // console.log(this.shoppers);
} else { } else {
// alert('No Orders Found'); // alert('No Orders Found');
} }
...@@ -59,14 +62,16 @@ export class ShoppersService { ...@@ -59,14 +62,16 @@ export class ShoppersService {
public async featuredshopperList() { public async featuredshopperList() {
const This = this; const This = this;
const state = true; const state = true;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('shoppers', ref => ref.where('featured', '==', state) const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
.where('status', '==', state)); "shoppers",
orderRef.valueChanges().subscribe((value) => { ref => ref.where("featured", "==", state).where("status", "==", state)
);
orderRef.valueChanges().subscribe(value => {
this.activeshoppers = []; this.activeshoppers = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach(item => {
console.log(item); // console.log(item);
const shopper: Shopper = { const shopper: Shopper = {
name: item.name, name: item.name,
emailId: item.emailId, emailId: item.emailId,
...@@ -86,7 +91,7 @@ export class ShoppersService { ...@@ -86,7 +91,7 @@ export class ShoppersService {
}; };
this.activeshoppers.push(shopper); this.activeshoppers.push(shopper);
}); });
console.log(this.activeshoppers); // console.log(this.activeshoppers);
} else { } else {
// alert('No Orders Found'); // alert('No Orders Found');
} }
...@@ -100,22 +105,31 @@ export class ShoppersService { ...@@ -100,22 +105,31 @@ export class ShoppersService {
const lat = 0.0144927536231884; const lat = 0.0144927536231884;
const lon = 0.0181818181818182; const lon = 0.0181818181818182;
const lowerLat = latitude - (lat * distance); const lowerLat = latitude - lat * distance;
const lowerLon = longitude - (lon * distance); const lowerLon = longitude - lon * distance;
const greaterLat = latitude + (lat * distance); const greaterLat = latitude + lat * distance;
const greaterLon = longitude + (lon * distance); const greaterLon = longitude + lon * distance;
const lesserGeopoint = new firebase.firestore.GeoPoint(lowerLat, lowerLon); const lesserGeopoint = new firebase.firestore.GeoPoint(lowerLat, lowerLon);
const greaterGeopoint = new firebase.firestore.GeoPoint(greaterLat, greaterLon); const greaterGeopoint = new firebase.firestore.GeoPoint(
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('shoppers', ref => ref.where('centre.latLng', '>', lesserGeopoint) greaterLat,
.where('centre.latLng', '<', greaterGeopoint).where('status', '==', state)); greaterLon
orderRef.valueChanges().subscribe((value) => { );
const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
"shoppers",
ref =>
ref
.where("centre.latLng", ">", lesserGeopoint)
.where("centre.latLng", "<", greaterGeopoint)
.where("status", "==", state)
);
orderRef.valueChanges().subscribe(value => {
this.nearshoppers = []; this.nearshoppers = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach(item => {
console.log(item); // console.log(item);
const shopper: Shopper = { const shopper: Shopper = {
name: item.name, name: item.name,
emailId: item.emailId, emailId: item.emailId,
...@@ -135,12 +149,10 @@ export class ShoppersService { ...@@ -135,12 +149,10 @@ export class ShoppersService {
}; };
this.nearshoppers.push(shopper); this.nearshoppers.push(shopper);
}); });
console.log(this.nearshoppers); // console.log(this.nearshoppers);
} else { } else {
// alert('No Orders Found'); // alert('No Orders Found');
} }
}); });
} }
} }
import { Injectable } from "@angular/core";
import { User, UpdateUserDetails, Address } from "./services/user";
import { auth } from "firebase/app";
import { Router, ActivatedRoute } from "@angular/router";
import { AngularFireAuth } from "@angular/fire/auth";
import {
AngularFirestore,
AngularFirestoreDocument,
AngularFirestoreCollection
} from "@angular/fire/firestore";
import { ServiceService } from "./../config/service.service";
import { GooglePlus } from "@ionic-native/google-plus/ngx";
import { take } from "rxjs/operators";
import { from } from "rxjs";
@Injectable({
providedIn: "root"
})
export class UpdateService {
userData: any;
type: number;
userPostData: any;
updateStatus: number;
constructor(
public afs: AngularFirestore,
public afAuth: AngularFireAuth,
private router: Router,
private service: ServiceService
) {
// this.type = 1;
// this.afAuth.authState.subscribe(user => {
// if (user) {
// this.userData = user;
// console.log(this.userData);
// this.service.set("user", JSON.stringify(this.userData));
// if (this.type === 1) {
// this.router.navigateByUrl("home");
// } else {
// this.router.navigateByUrl("verification");
// }
// } else {
// this.service.set("user", null);
// JSON.parse(localStorage.getItem("user"));
// this.router.navigateByUrl("login");
// }
// });
}
updateData(userData: UpdateUserDetails, uid: string) {
this.type = 2;
const postData: UpdateUserDetails = {
phone: userData.phone,
name: userData.name,
emailId: userData.emailId
};
this.userPostData = postData;
this.afs
.collection("customers")
.doc(uid)
.update(postData)
.then(() => {
console.log("success");
this.router.navigateByUrl("profile");
})
.catch(error => {
console.log(error);
});
}
}
import { Injectable } from "@angular/core";
import { AngularFireAuth } from "@angular/fire/auth";
import {
AngularFirestore,
AngularFirestoreDocument,
AngularFirestoreCollection
} from "@angular/fire/firestore";
import * as firebase from "firebase";
import { User } from "./services/user";
@Injectable({
providedIn: "root"
})
// Gets User Details
export class UserService {
users: User;
constructor(public afs: AngularFirestore, public afAuth: AngularFireAuth) {}
public async getUserData(userId: string) {
const This = this;
const state = true;
// Get User Query
const userRef: AngularFirestoreCollection<any> = this.afs.collection(
"customers",
ref => ref.where("uid", "==", userId).where("status", "==", state)
);
userRef.valueChanges().subscribe(value => {
const res = value;
if (res.length > 0) {
const item = res[0];
this.users = {
name: item.name,
emailId: item.emailId,
phone: item.phone,
uid: item.uid,
profilePhoto: item.profilePic,
status: item.status,
phoneVerified: item.phoneVerified,
emailVerified: item.emailVerified,
loginType: 0,
otp: "",
currency: {
currId: "",
currName: "",
symbol: ""
}
};
}
// return this.users;
});
}
}
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