Commit 8594a2d4 by muhsin

added profile page

parent 49001fd8
...@@ -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",
...@@ -102,4 +102,4 @@ ...@@ -102,4 +102,4 @@
"android" "android"
] ]
} }
} }
\ No newline at end of file
<ion-app> <ion-app>
<ion-split-pane> <ion-split-pane>
<ion-menu> <ion-menu>
<ion-content> <ion-content>
<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">
<h4>John Doe</h4>
<p>[email protected]</p>
</div>
<div class="clear"></div>
</div>
</ion-menu-toggle>
<div class="sidemenu_list">
<ul>
<ion-menu-toggle>
<li (click)="vieworder('home')">Shop</li>
</ion-menu-toggle>
<li>About us</li>
<ion-menu-toggle>
<li (click)="vieworder('myorder')">View Order</li>
</ion-menu-toggle>
</div> <div class="sub_menu">
<div class="top_detail" > <ul *ngIf="categoryService.activecategories">
<h4>John Doe</h4> <ion-menu-toggle>
<p>[email protected]</p> <li
</div> *ngFor="let category of categoryService.activecategories"
<div class="clear"></div> (click)="goToPage('catstorelist', category)"
</div> >
</ion-menu-toggle> {{ category.catName }}
<div class="sidemenu_list"> </li>
<ul> </ion-menu-toggle>
<ion-menu-toggle> <!-- <li>Women's Fashion</li>
<li (click)="vieworder('home')">Shop</li>
</ion-menu-toggle>
<li>About us</li>
<ion-menu-toggle>
<li (click)="vieworder('myorder')">View Order</li>
</ion-menu-toggle>
<div class="sub_menu">
<ul *ngIf="categoryService.activecategories">
<ion-menu-toggle>
<li *ngFor="let category of categoryService.activecategories" (click)="goToPage('catstorelist', category)">{{category.catName}}</li>
</ion-menu-toggle>
<!-- <li>Women's Fashion</li>
<li>Features</li> <li>Features</li>
<li>Bags</li> <li>Bags</li>
<li>Shoes</li> <li>Shoes</li>
<li>Electronics</li> --> <li>Electronics</li> -->
</ul> </ul>
</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()"
<span class="floatRight version">Version 0.1.0.2</span> >Logout</span
<div class="clear"></div> >
</li> <span class="floatRight version">Version 0.1.0.2</span>
</ul> <div class="clear"></div>
</div> </li>
</div> </ul>
</ion-content> </div>
</ion-menu> </div>
<ion-router-outlet main></ion-router-outlet> </ion-content>
</ion-split-pane> </ion-menu>
<ion-router-outlet main></ion-router-outlet>
</ion-split-pane>
</ion-app> </ion-app>
<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
</li> class="icon_sec m1_icon"
<li (click)="goToPage('catagory')"> [class.m1_icon_act]="sec_active1"
<div class="icon_sec m2_icon" [class.m2_icon_act]="sec_active2" (click)="setActive2()"></div> (click)="setActive1()"
</li> ></div>
<li (click)="goToPage('catagory')"> </li>
<div class="icon_sec m3_icon" [class.m3_icon_act]="sec_active3" (click)="setActive3()"></div> <li (click)="goToPage('catagory')">
</li> <div
<!-- <li (click)="goToPage('cart')"> class="icon_sec m2_icon"
[class.m2_icon_act]="sec_active2"
(click)="setActive2()"
></div>
</li>
<li (click)="goToPage('catagory')">
<div
class="icon_sec m3_icon"
[class.m3_icon_act]="sec_active3"
(click)="setActive3()"
></div>
</li>
<!-- <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
</li> class="icon_sec m5_icon"
<li (click)="goToPage('profile')"> [class.m5_icon_act]="sec_active5"
<div class="icon_sec m6_icon" [class.m6_icon_act]="sec_active6" (click)="setActive6()"></div> (click)="setActive5()"
</li> ></div>
</ul> </li>
</div> <li (click)="goToPage('profile')">
\ No newline at end of file <div
class="icon_sec m6_icon"
[class.m6_icon_act]="sec_active6"
(click)="setActive6()"
></div>
</li>
</ul>
</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>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</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
</div> name="name"
<div class="row"> required
<input class="" type="mail" placeholder="[email protected]"> class=""
</div> type="text"
<div class="row"> [(ngModel)]="updateData.name"
<input class="" type="number" placeholder="+00 9851 5871 6985"> placeholder="John Doe"
</div> #name="ngModel"
<div class="row"> />
<h6>Change Password</h6> <div
</div> class="md-errors-spacer"
<div class="row"> [hidden]="name.valid || submitted == false"
<input class="" type="password" placeholder="Current Password"> class="ion-padding-start"
</div> >
<div class="row"> Name is required
<input class="" type="password" placeholder="New Password">
</div>
<div class="row">
<input class="" type="password" placeholder="Confirm Password">
</div>
<div class="row">
<button class="login_btn">UPDATE</button>
</div>
</div> </div>
</div> </div>
</ion-content> <div class="row">
\ No newline at end of file <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 class="row">
<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 class="row">
<h6>Change Password</h6>
</div>
<div class="row">
<input class="" type="password" placeholder="Current Password" />
</div>
<div class="row">
<input class="" type="password" placeholder="New Password" />
</div>
<div class="row">
<input class="" type="password" placeholder="Confirm Password" />
</div>
<div class="row">
<button class="login_btn" (click)="onFormSubmit(updateForm)">
UPDATE
</button>
</div>
</form>
</div>
</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);
}
}
} }
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>
<ion-content> <ion-content>
<div class="profile_wrapper"> <div class="profile_wrapper">
<div class="profile_banner"> <div class="profile_banner">
<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
<div class="clear"></div> class="floatRight"
</div> (click)="goToPage('changedetails', user && user)"
<div class="row"> ><img src="../../assets/edit.png"
<ion-row> /></span>
<ion-col class="textLeft p0"> <div class="clear"></div>
<p>Name<span>Verfied</span></p> </div>
</ion-col> <div class="row">
<ion-col class="textRight p0"> <ion-row>
<h6>John Doe</h6> <ion-col class="textLeft p0">
</ion-col> <p>
</ion-row> Name<span
</div> >{{user && phoneVerified? "Verified": "Not Verified yet"}}</span
<div class="row"> >
<ion-row> </p>
<ion-col class="textLeft p0"> </ion-col>
<p>Email<span>Not Verfied yet</span></p> <ion-col class="textRight p0">
</ion-col> <h6>{{user && user.name}}</h6>
<ion-col class="textRight p0"> </ion-col>
<h6>[email protected]</h6> </ion-row>
</ion-col> </div>
</ion-row> <div class="row">
</div> <ion-row>
<hr> <ion-col class="textLeft p0">
<ion-row> <p>
<ion-col class="textLeft p0"> Email<span
<p>Wishlist</p> >{{user && emailVerified? "Verified": "Not Verified yet"}}</span
</ion-col> >
<ion-col class="textRight p0"> </p>
<h6>(3)</h6> </ion-col>
</ion-col> <ion-col class="textRight p0">
</ion-row> <h6>{{user && user.emailId}}</h6>
<hr> </ion-col>
<ion-row> </ion-row>
<ion-col class="textLeft p0"> </div>
<p>Address</p> <hr />
</ion-col> <ion-row>
<ion-col class="textRight p0"> <ion-col class="textLeft p0">
<h6>(1)</h6> <p>Wishlist</p>
</ion-col> </ion-col>
</ion-row> <ion-col class="textRight p0">
<hr> <h6>(3)</h6>
<ion-row> </ion-col>
<ion-col class="textLeft p0"> </ion-row>
<p>My Cards</p> <hr />
</ion-col> <ion-row>
<ion-col class="textRight p0"> <ion-col class="textLeft p0">
<h6> <p>Address</p>
<ion-icon name="arrow-forward"></ion-icon> </ion-col>
</h6> <ion-col class="textRight p0">
</ion-col> <h6>(1)</h6>
</ion-row> </ion-col>
<hr> </ion-row>
<ion-row> <hr />
<ion-col class="textLeft p0"> <ion-row>
<p>My Order</p> <ion-col class="textLeft p0">
</ion-col> <p>My Cards</p>
<ion-col class="textRight p0"> </ion-col>
<h6> <ion-col class="textRight p0">
<ion-icon name="arrow-forward"></ion-icon> <h6>
</h6> <ion-icon name="arrow-forward"></ion-icon>
</ion-col> </h6>
</ion-row> </ion-col>
<hr> </ion-row>
<ion-row> <hr />
<ion-col class="textLeft p0"> <ion-row>
<p>Currency</p> <ion-col class="textLeft p0">
</ion-col> <p>My Order</p>
<ion-col class="textRight p0"> </ion-col>
<h6> <ion-col class="textRight p0">
<span>AUD</span> <h6>
</h6> <ion-icon name="arrow-forward"></ion-icon>
</ion-col> </h6>
</ion-row> </ion-col>
</ion-row>
<hr />
<ion-row>
</div> <ion-col class="textLeft p0">
<p>Currency</p>
</ion-col>
<ion-col class="textRight p0">
<h6>
<span>AUD</span>
</h6>
</ion-col>
</ion-row>
</div> </div>
</ion-content> </div>
\ No newline at end of file </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);
}
} }
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) => { )
this.addressList = []; .subscribe(value => {
const res = value; this.addressList = [];
if (res.length > 0) { const res = value;
res.forEach((item) => { if (res.length > 0) {
console.log(item); res.forEach(item => {
const address: AddressList = { // console.log(item);
address: item.address, const address: AddressList = {
addressType: item.addressType, address: item.address,
latLng: item.latLng, addressType: item.addressType,
defaultVal: item.defaultVal, latLng: item.latLng,
building: item. building, defaultVal: item.defaultVal,
landmark: item.landmark, building: item.building,
addressId: item.addressId landmark: item.landmark,
}; addressId: item.addressId
this.addressList.push(address); };
}); this.addressList.push(address);
console.log(this.addressList); });
} else { // console.log(this.addressList);
// alert('No Orders Found'); } else {
} // alert('No Orders Found');
}); }
});
} }
addressCreate(data: Address) { addressCreate(data: Address) {
this.afs.collection('address').add({}).then((docRef) => { this.afs
data.addressId = docRef.id; .collection("address")
this.afs.collection('address').doc(data.addressId).set(data).then(() => { .add({})
console.log('Address created Successfully'); .then(docRef => {
data.addressId = docRef.id;
this.afs
.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());
} }
}); });
}); });
...@@ -209,7 +210,6 @@ export class MyordersService { ...@@ -209,7 +210,6 @@ 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, 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;
} }
const This = this; const This = this;
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).endAt(inputText + '\uf8ff').limit(5)); const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
orderRef.valueChanges().subscribe((value) => { "shoppers",
ref =>
ref
.where("status", "==", state)
.orderBy("name")
.startAt(inputText)
.endAt(inputText + "\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,44 +49,57 @@ export class SearchService { ...@@ -40,44 +49,57 @@ 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).endAt(inputText + '\uf8ff').limit(5)); const prodRef: AngularFirestoreCollection<any> = this.afs.collection(
prodRef.valueChanges().subscribe((values) => { "products",
const result = values; ref =>
if (result.length > 0) { ref
result.forEach((item) => { .where("status", "==", state)
console.log(item); .orderBy("prodName")
const prod: Search = { .startAt(inputText)
text: item.prodName, .endAt(inputText + "\uf8ff")
data: item, .limit(5)
type: 'product' );
}; prodRef.valueChanges().subscribe(values => {
this.searchList.push(prod); const result = values;
}); if (result.length > 0) {
console.log(this.searchList); result.forEach(item => {
} // console.log(item);
const prod: Search = {
text: item.prodName,
data: item,
type: "product"
};
this.searchList.push(prod);
});
// console.log(this.searchList);
}
}); });
// 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).endAt(inputText + '\uf8ff').limit(5)); const feaRef: AngularFirestoreCollection<any> = this.afs.collection(
feaRef.valueChanges().subscribe((values) => { "category",
const result = values; ref =>
if (result.length > 0) { ref
result.forEach((item) => { .where("status", "==", state)
console.log(item); .orderBy("catName")
const prod: Search = { .startAt(inputText)
text: item.catName, .endAt(inputText + "\uf8ff")
data: item, .limit(5)
type: 'category' );
}; feaRef.valueChanges().subscribe(values => {
this.searchList.push(prod); const result = values;
}); if (result.length > 0) {
console.log(this.searchList); result.forEach(item => {
} // console.log(item);
const prod: Search = {
text: item.catName,
data: item,
type: "category"
};
this.searchList.push(prod);
});
// 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");
}); });
} }
...@@ -34,7 +33,7 @@ export class ServiceService { ...@@ -34,7 +33,7 @@ export class ServiceService {
const response = []; const response = [];
for (const key in item) { for (const key in item) {
if (item.hasOwnProperty(key)) { if (item.hasOwnProperty(key)) {
response.push(item[key]); response.push(item[key]);
} }
} }
return response; return response;
...@@ -44,12 +43,9 @@ export class ServiceService { ...@@ -44,12 +43,9 @@ export class ServiceService {
const response = []; const response = [];
for (const key in item) { for (const key in item) {
if (item.hasOwnProperty(key)) { if (item.hasOwnProperty(key)) {
response.push(key); response.push(key);
} }
} }
return response; return response;
} }
} }
export interface Slides {
downloadURL: string;
imageId: string;
path: string;
skuId: string;
}
export interface User { export interface User {
uid: string; uid: string;
emailId: string; emailId: string;
name: string; name: string;
phone: string; phone: string;
phoneVerified: boolean; phoneVerified: boolean;
profilePhoto: string; profilePhoto: string;
emailVerified: boolean; emailVerified: boolean;
status: boolean; status: boolean;
loginType: number; loginType: number;
otp: string; otp: string;
currency: { currency: {
currId: string; currId: string;
currName: string; currName: string;
symbol: string symbol: string;
}; };
} }
export interface Signup { export interface Signup {
name: string; name: string;
emailId: string; emailId: string;
phone: string; phone: string;
password: string; password: string;
dob: any; dob: any;
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;
} }
export interface Address { export interface Address {
addressType: string; addressType: string;
firstAddress: string; firstAddress: string;
secondAddress: string; secondAddress: string;
city: string; city: string;
state: string; state: string;
district: string; district: string;
landmark: string; landmark: string;
area: string; area: string;
zip: string; zip: string;
country: string; country: string;
default: number; default: 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,
...@@ -39,7 +42,7 @@ export class ShoppersService { ...@@ -39,7 +42,7 @@ export class ShoppersService {
status: item.status, status: item.status,
address: item.address, address: item.address,
featured: item.featured, featured: item.featured,
featuredImage: item.featuredImage, featuredImage: item.featuredImage,
shopName: item.shopName, shopName: item.shopName,
shopStatus: item.shopStatus, shopStatus: item.shopStatus,
workingHours: item.workingHours, workingHours: item.workingHours,
...@@ -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,
...@@ -76,7 +81,7 @@ export class ShoppersService { ...@@ -76,7 +81,7 @@ export class ShoppersService {
status: item.status, status: item.status,
address: item.address, address: item.address,
featured: item.featured, featured: item.featured,
featuredImage: item.featuredImage, featuredImage: item.featuredImage,
shopName: item.shopName, shopName: item.shopName,
shopStatus: item.shopStatus, shopStatus: item.shopStatus,
workingHours: item.workingHours, workingHours: item.workingHours,
...@@ -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,
...@@ -125,7 +139,7 @@ export class ShoppersService { ...@@ -125,7 +139,7 @@ export class ShoppersService {
status: item.status, status: item.status,
address: item.address, address: item.address,
featured: item.featured, featured: item.featured,
featuredImage: item.featuredImage, featuredImage: item.featuredImage,
shopName: item.shopName, shopName: item.shopName,
shopStatus: item.shopStatus, shopStatus: item.shopStatus,
workingHours: item.workingHours, workingHours: item.workingHours,
...@@ -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