Commit 61500c9e by Adarsh K

address

parent a9bd8295
<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>Address</h4> <h4>Address</h4>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<ion-content> <ion-content>
<div class="address-wrapper"> <div class="address-wrapper" *ngIf="addressService.addressList">
<ion-grid> <ion-grid *ngFor="let address of addressService.addressList; let i = index">
<ion-row> <ion-row>
<ion-col size="1"> <ion-col size="1">
<input type="radio" class="address-radio" name="address" checked> <input
</ion-col> type="radio"
<ion-col size="9"> id="address_{{i}}"
<h1>Shamjith KS</h1> class="address-radio"
<h1>+00 0000 888 888</h1> name="address"
<p>Carnival Infopark, Infopark Kochi 682030, Kerala, India</p> [checked]="address.defaultVal == 1"
</ion-col> />
<ion-col size="2"><button class="show-btn"><img src="../../assets/delete.png"></button></ion-col> </ion-col>
</ion-row> <ion-col size="9">
</ion-grid> <h1>{{address.addressType}}</h1>
<ion-grid> <h1>{{address.address}}</h1>
<ion-row> <p>{{address.building}}, {{address.landmark}}</p>
<ion-col size="1"> </ion-col>
<input type="radio" class="address-radio" name="address"> <ion-col size="2" [hidden]="address.defaultVal == 1"
</ion-col> ><button
<ion-col size="9"> class="show-btn"
<h1>Shamjith KS</h1> (click)="addressService.deleteAddress(address.addressId)"
<h1>+00 0000 888 888</h1> >
<p>Carnival Infopark, Infopark Kochi 682030, Kerala, India</p> <img src="../../assets/delete.png" /></button
</ion-col> ></ion-col>
<ion-col size="2"><button><img src="../../assets/delete.png"></button></ion-col> </ion-row>
</ion-row> </ion-grid>
</ion-grid> <div class="address-btn-wrapper">
<div class="address-btn-wrapper"><button class="show-btn">Add New Address</button></div> <button class="show-btn" (click)="goToPage('nearby')">
Add New Address
</button>
</div> </div>
</div>
</ion-content> </ion-content>
\ No newline at end of file
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { AddressService } from './../../config/address.service';
import { Router, ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
@Component({ @Component({
selector: 'app-address', selector: 'app-address',
templateUrl: './address.page.html', templateUrl: './address.page.html',
styleUrls: ['./address.page.scss'], styleUrls: ['./address.page.scss']
}) })
export class AddressPage implements OnInit { export class AddressPage implements OnInit {
constructor(
private location: Location,
public addressService: AddressService,
public router: Router
) {}
constructor() { } ngOnInit() {}
ngOnInit() { goBack() {
this.location.back();
} }
goToPage(path, data = null) {
this.router.navigateByUrl(path, { queryParams: data });
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
} }
<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">
<img src="../assets/asset_avatar.png"> <img src="../assets/asset_avatar.png" />
</div> </div>
<div class="top_detail"> <div class="top_detail">
<h4>John Doe</h4> <h4>John Doe</h4>
<p>[email protected]</p> <p>[email protected]</p>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</ion-menu-toggle> </ion-menu-toggle>
<div class="sidemenu_list"> <div class="sidemenu_list">
<ul> <ul>
<ion-menu-toggle> <ion-menu-toggle>
<li (click)="vieworder('home')">Shop</li> <li (click)="vieworder('home')">Shop</li>
</ion-menu-toggle> </ion-menu-toggle>
<li>About us</li> <!-- <li>About us</li> -->
<ion-menu-toggle> <ion-menu-toggle>
<li (click)="vieworder('myorder')">View Order</li> <li (click)="vieworder('myorder')">View Order</li>
</ion-menu-toggle> </ion-menu-toggle>
<div class="sub_menu"> <div class="sub_menu">
<ul *ngIf="categoryService.activecategories"> <ul *ngIf="categoryService.activecategories">
<ion-menu-toggle> <ion-menu-toggle>
<li *ngFor="let category of categoryService.activecategories" (click)="goToPage('catstorelist', category)"> <li
{{ category.catName }} *ngFor="let category of categoryService.activecategories"
</li> (click)="goToPage('catstorelist', category)"
</ion-menu-toggle> >
<!-- <li>Women's Fashion</li> {{ 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> <ion-menu-toggle>
<li> <li (click)="vieworder('feedback')">Complaints & Feedback</li>
<span class="floatLeft" (click)="authService.SignOut()">Logout</span> </ion-menu-toggle>
<span class="floatRight version">Version 0.1.0.2</span> <li>
<div class="clear"></div> <span class="floatLeft" (click)="authService.SignOut()"
</li> >Logout</span
</ul> >
</div> <span class="floatRight version">Version 0.1.0.2</span>
</div> <div class="clear"></div>
</ion-content> </li>
</ion-menu> </ul>
<ion-router-outlet main></ion-router-outlet> </div>
</ion-split-pane> </div>
</ion-content>
</ion-menu>
<ion-router-outlet main></ion-router-outlet>
</ion-split-pane>
</ion-app> </ion-app>
<div class="common_tab" [hidden]="fetchCase() === true"> <div class="common_tab" [hidden]="fetchCase() === true">
<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)="searchModal()"> </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)="searchModal()">
<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()" menuClose></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()"
menuClose
></div>
</li>
</ul>
</div>
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
@Component({ @Component({
selector: 'app-feedback', selector: 'app-feedback',
templateUrl: './feedback.page.html', templateUrl: './feedback.page.html',
styleUrls: ['./feedback.page.scss'], styleUrls: ['./feedback.page.scss']
}) })
export class FeedbackPage implements OnInit { export class FeedbackPage implements OnInit {
constructor(private location: Location) {}
constructor() { } ngOnInit() {}
ngOnInit() { goBack() {
this.location.back();
} }
} }
<div class="nav_header"> <div class="nav_header">
<ion-menu-toggle> <ion-menu-toggle>
<button class="nav_btn nav_menu floatLeft"></button> <button class="nav_btn nav_menu floatLeft"></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" *ngIf="loggedUser"> <div class="profile_wrapper" *ngIf="loggedUser">
<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> -->
<div class="profile_circle"> <div class="profile_circle">
<img [src]="loggedUser.profilePhoto" onerror="this.src='./../../assets/profile_banner.png'" /> <img
<div class="edit"></div> [src]="loggedUser.profilePhoto"
<input type="file" accept="image/*" (change)="fileChange($event)" /> onerror="this.src='./../../assets/profile_banner.png'"
</div> />
<div class="edit"></div>
<input type="file" accept="image/*" (change)="fileChange($event)" />
</div>
<h5>{{loggedUser.name}}</h5> <h5>{{loggedUser.name}}</h5>
<p (click)="istoggle()">LOGOUT</p> <p (click)="istoggle()">LOGOUT</p>
</div>
<div class="account_wrapper">
<div class="account_header">
<h5 class="floatLeft">ACCOUNT INFORMATION</h5>
<span class="floatRight" (click)="goToPage('changedetails', user && user)"><img
src="../../assets/edit.png" /></span>
<div class="clear"></div>
</div>
<div class="row">
<ion-row>
<ion-col class="textLeft p0">
<p>
Phone
<span *ngIf="loggedUser.phoneVerified == true">Verified</span>
<span *ngIf="loggedUser.phoneVerified == false">Not Verified yet</span>
</p>
</ion-col>
<ion-col class="textRight p0">
<h6>{{loggedUser.phone}}</h6>
</ion-col>
</ion-row>
</div>
<div class="row">
<ion-row>
<ion-col class="textLeft p0">
<p>
Email<span *ngIf="userData && userData.emailVerified == true">Verified</span>
<span *ngIf="loggedUser.emailVerified == false">Not Verified yet</span>
</p>
</ion-col>
<ion-col class="textRight p0">
<h6>{{loggedUser.emailId}}</h6>
</ion-col>
</ion-row>
</div>
<hr />
<ion-row>
<ion-col class="textLeft p0">
<p>Wishlist</p>
</ion-col>
<ion-col class="textRight p0">
<h6>(3)</h6>
</ion-col>
</ion-row>
<hr />
<ion-row>
<ion-col class="textLeft p0">
<p>Address</p>
</ion-col>
<ion-col class="textRight p0">
<h6>(1)</h6>
</ion-col>
</ion-row>
<hr />
<ion-row>
<ion-col class="textLeft p0">
<p>My Cards</p>
</ion-col>
<ion-col class="textRight p0">
<h6>
<ion-icon name="arrow-forward"></ion-icon>
</h6>
</ion-col>
</ion-row>
<hr />
<ion-row>
<ion-col class="textLeft p0">
<p>My Order</p>
</ion-col>
<ion-col class="textRight p0" (click)="goToPage('myorder')">
<h6>
<ion-icon name="arrow-forward"></ion-icon>
</h6>
</ion-col>
</ion-row>
<hr />
<ion-row>
<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> </div>
<div class="logout-pop-wrapper" *ngIf="isShow" [@slideInOut]> <div class="account_wrapper">
<div class="logout_inner"> <div class="account_header">
<h4>Logout</h4> <h5 class="floatLeft">ACCOUNT INFORMATION</h5>
<p>Are you sure to Logout ?</p> <span
<div class="logout_footer"> class="floatRight"
(click)="goToPage('changedetails', user && user)"
<button class="btn-cancel floatLeft" (click)="istoggle();">Cancel</button> ><img src="../../assets/edit.png"
<button class="btn-logout floatRight" (click)="authService.SignOut(); istoggle()">Logout</button> /></span>
<div class="clear"></div>
</div>
<div class="row">
<ion-row>
<ion-col class="textLeft p0">
<p>
Phone
<span *ngIf="loggedUser.phoneVerified == true">Verified</span>
<span *ngIf="loggedUser.phoneVerified == false"
>Not Verified yet</span
>
</p>
</ion-col>
<ion-col class="textRight p0">
<h6>{{loggedUser.phone}}</h6>
</ion-col>
</ion-row>
</div>
<div class="row">
<ion-row>
<ion-col class="textLeft p0">
<p>
Email<span *ngIf="userData && userData.emailVerified == true"
>Verified</span
>
<span *ngIf="loggedUser.emailVerified == false"
>Not Verified yet</span
>
</p>
</ion-col>
<ion-col class="textRight p0">
<h6>{{loggedUser.emailId}}</h6>
</ion-col>
</ion-row>
</div>
<hr />
<ion-row>
<ion-col class="textLeft p0">
<p>Wishlist</p>
</ion-col>
<ion-col class="textRight p0" (click)="goToPage('wishlist')">
<h6>(3)</h6>
</ion-col>
</ion-row>
<hr />
<ion-row>
<ion-col class="textLeft p0">
<p>Address</p>
</ion-col>
<ion-col class="textRight p0" (click)="goToPage('address')">
<h6 *ngIf="addressService.addList">
({{addressService.addressList.length}})
</h6>
</ion-col>
</ion-row>
<hr />
<!-- <ion-row>
<ion-col class="textLeft p0">
<p>My Cards</p>
</ion-col>
<ion-col class="textRight p0" (click)="goToPage('addcard')">
<h6>
<ion-icon name="arrow-forward"></ion-icon>
</h6>
</ion-col>
</ion-row>
<hr /> -->
<ion-row>
<ion-col class="textLeft p0">
<p>My Order</p>
</ion-col>
<ion-col class="textRight p0" (click)="goToPage('myorder')">
<h6>
<ion-icon name="arrow-forward"></ion-icon>
</h6>
</ion-col>
</ion-row>
<hr />
<ion-row>
<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>
<div class="logout-pop-wrapper" *ngIf="isShow" [@slideInOut]>
<div class="logout_inner">
<h4>Logout</h4>
<p>Are you sure to Logout ?</p>
<div class="logout_footer">
<button class="btn-cancel floatLeft" (click)="istoggle();">
Cancel
</button>
<button
class="btn-logout floatRight"
(click)="authService.SignOut(); istoggle()"
>
Logout
</button>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</div>
</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 { User } from '../../config/services/user';
import { UserService } from "../../config/user.service"; import { UserService } from '../../config/user.service';
import { ServiceService } from "../../config/service.service"; import { ServiceService } from '../../config/service.service';
import { AuthService } from "../../config/auth.service"; import { AuthService } from '../../config/auth.service';
import { Router, ActivatedRoute } from "@angular/router"; import { Router, ActivatedRoute } from '@angular/router';
import { finalize, tap } from "rxjs/operators"; import { finalize, tap } from 'rxjs/operators';
import { Location } from '@angular/common';
import { AddressService } from './../../config/address.service';
import { import {
AngularFireStorage, AngularFireStorage,
AngularFireStorageReference, AngularFireStorageReference,
AngularFireUploadTask AngularFireUploadTask
} from "@angular/fire/storage"; } from '@angular/fire/storage';
import { trigger, transition, animate, style } from "@angular/animations"; import { trigger, transition, animate, style } from '@angular/animations';
@Component({ @Component({
selector: "app-profile", selector: 'app-profile',
templateUrl: "./profile.page.html", templateUrl: './profile.page.html',
styleUrls: ["./profile.page.scss"], styleUrls: ['./profile.page.scss'],
animations: [ animations: [
trigger("slideInOut", [ trigger('slideInOut', [
transition(":enter", [ transition(':enter', [
style({ transform: "translateY(100%)" }), style({ transform: 'translateY(100%)' }),
animate("200ms ease-in", style({ transform: "translateY(0%)" })) animate('200ms ease-in', style({ transform: 'translateY(0%)' }))
]), ]),
transition(":leave", [ transition(':leave', [
animate("200ms ease-out", style({ transform: "translateY(100%)" })) animate('200ms ease-out', style({ transform: 'translateY(100%)' }))
]) ])
]) ])
] ]
...@@ -43,16 +45,18 @@ export class ProfilePage implements OnInit { ...@@ -43,16 +45,18 @@ export class ProfilePage implements OnInit {
private storage: AngularFireStorage, private storage: AngularFireStorage,
private useService: UserService, private useService: UserService,
private service: ServiceService, private service: ServiceService,
private authService: AuthService private authService: AuthService,
private addressService: AddressService,
private location: Location
) { ) {
this.service.get("user").then(data => { this.service.get('user').then(data => {
if (data) { if (data) {
this.userData = JSON.parse(data); this.userData = JSON.parse(data);
console.log(this.userData); console.log(this.userData);
} }
}); });
this.service.get("userData").then(data => { this.service.get('userData').then(data => {
if (data) { if (data) {
this.loggedUser = JSON.parse(data); this.loggedUser = JSON.parse(data);
} }
...@@ -69,7 +73,7 @@ export class ProfilePage implements OnInit { ...@@ -69,7 +73,7 @@ export class ProfilePage implements OnInit {
setTimeout(() => { setTimeout(() => {
this.user = this.useService.users; this.user = this.useService.users;
// console.log('[users]', this.user); // console.log('[users]', this.user);
this.service.set("params", this.user); this.service.set('params', this.user);
}, 500); }, 500);
} }
...@@ -77,6 +81,10 @@ export class ProfilePage implements OnInit { ...@@ -77,6 +81,10 @@ export class ProfilePage implements OnInit {
this.isShow = !this.isShow; this.isShow = !this.isShow;
} }
goBack() {
this.location.back();
}
async fileChange(event) { async fileChange(event) {
const fileList: FileList = event.target.files; const fileList: FileList = event.target.files;
if (fileList.length > 0) { if (fileList.length > 0) {
...@@ -92,8 +100,8 @@ export class ProfilePage implements OnInit { ...@@ -92,8 +100,8 @@ export class ProfilePage implements OnInit {
reader.readAsDataURL(event.target.files[0]); reader.readAsDataURL(event.target.files[0]);
const file = fileList[0]; const file = fileList[0];
const ext = file.name.split(".").pop(); const ext = file.name.split('.').pop();
if (ext === "jpg" || ext === "jpeg" || ext === "png") { if (ext === 'jpg' || ext === 'jpeg' || ext === 'png') {
const path = file.name; // + Date.now(); const path = file.name; // + Date.now();
const ref = this.storage.ref(path); const ref = this.storage.ref(path);
const task = this.storage const task = this.storage
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
@Component({ @Component({
selector: 'app-wishlist', selector: 'app-wishlist',
templateUrl: './wishlist.page.html', templateUrl: './wishlist.page.html',
styleUrls: ['./wishlist.page.scss'], styleUrls: ['./wishlist.page.scss']
}) })
export class WishlistPage implements OnInit { export class WishlistPage implements OnInit {
constructor(private location: Location) {}
constructor() { } ngOnInit() {}
ngOnInit() { goBack() {
this.location.back();
} }
} }
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore'; import {
AngularFirestore,
AngularFirestoreCollection
} from '@angular/fire/firestore';
import { take } from 'rxjs/operators'; import { take } from 'rxjs/operators';
import { Address, AddressList } from './services/address'; import { Address, AddressList } from './services/address';
...@@ -18,27 +21,27 @@ export class AddressService { ...@@ -18,27 +21,27 @@ export class AddressService {
ref => ref.where('status', '==', state).where('uid', '==', userId) ref => ref.where('status', '==', state).where('uid', '==', userId)
); );
orderRef.valueChanges().subscribe(value => { orderRef.valueChanges().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');
} }
}); });
} }
addressCreate(data: Address) { addressCreate(data: Address) {
...@@ -71,13 +74,19 @@ export class AddressService { ...@@ -71,13 +74,19 @@ export class AddressService {
setTimeout(() => { setTimeout(() => {
console.log(addId); console.log(addId);
this.afs this.afs
.collection('address')
.doc(addId)
.update({ defaultVal: 1 })
.then(() => {
console.log('Address updated Successfully');
});
}, 1000);
}
deleteAddress(addId: string) {
this.afs
.collection('address') .collection('address')
.doc(addId) .doc(addId)
.update({ defaultVal: 1 }) .delete();
.then(() => {
console.log('Address updated Successfully');
});
}, 1000);
} }
} }
import { Injectable } from "@angular/core"; import { Injectable } from '@angular/core';
import { User, Signup, Address } from "./services/user"; import { User, Signup, Address } from './services/user';
import { auth } from "firebase/app"; import { auth } from 'firebase/app';
import { Router, ActivatedRoute } from "@angular/router"; import { Router, ActivatedRoute } from '@angular/router';
import { AngularFireAuth } from "@angular/fire/auth"; import { AngularFireAuth } from '@angular/fire/auth';
import { import {
AngularFirestore, AngularFirestore,
AngularFirestoreDocument, AngularFirestoreDocument,
AngularFirestoreCollection AngularFirestoreCollection
} from "@angular/fire/firestore"; } from '@angular/fire/firestore';
import { ServiceService } from "./../config/service.service"; import { ServiceService } from './../config/service.service';
import { SubjectService } from "./../config/subject.service"; import { SubjectService } from './../config/subject.service';
import { GooglePlus } from "@ionic-native/google-plus/ngx"; import { GooglePlus } from '@ionic-native/google-plus/ngx';
import { take } from "rxjs/operators"; import { take } from 'rxjs/operators';
import { from } from "rxjs"; import { from } from 'rxjs';
@Injectable({ @Injectable({
providedIn: "root" providedIn: 'root'
}) })
export class AuthService { export class AuthService {
constructor( constructor(
...@@ -32,24 +32,24 @@ export class AuthService { ...@@ -32,24 +32,24 @@ export class AuthService {
this.subjectService.sendLoginData(false); this.subjectService.sendLoginData(false);
this.userData = user; this.userData = user;
console.log(this.userData); console.log(this.userData);
this.service.set("user", JSON.stringify(this.userData)); this.service.set('user', JSON.stringify(this.userData));
this.SetUserData(user); this.SetUserData(user);
if (this.type === 1) { if (this.type === 1) {
this.router.navigateByUrl("home"); this.router.navigateByUrl('home');
} else { } else {
this.router.navigateByUrl("verification"); this.router.navigateByUrl('verification');
} }
} else { } else {
this.subjectService.sendLoginData(true); this.subjectService.sendLoginData(true);
this.service.set("user", null); this.service.set('user', null);
JSON.parse(localStorage.getItem("user")); JSON.parse(localStorage.getItem('user'));
this.router.navigateByUrl("login"); this.router.navigateByUrl('login');
} }
}); });
} }
get isLoggedIn(): boolean { get isLoggedIn(): boolean {
const user = JSON.parse(localStorage.getItem("user")); const user = JSON.parse(localStorage.getItem('user'));
return user !== null && user.emailVerified !== false ? true : false; return user !== null && user.emailVerified !== false ? true : false;
} }
userData: any; userData: any;
...@@ -62,7 +62,7 @@ export class AuthService { ...@@ -62,7 +62,7 @@ export class AuthService {
return this.afAuth.auth return this.afAuth.auth
.signInWithEmailAndPassword(email, password) .signInWithEmailAndPassword(email, password)
.then(result => { .then(result => {
console.log("success"); console.log('success');
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
this.SetUserData(result.user); this.SetUserData(result.user);
}) })
...@@ -76,8 +76,8 @@ export class AuthService { ...@@ -76,8 +76,8 @@ export class AuthService {
// tslint:disable-next-line:radix // tslint:disable-next-line:radix
// const otpnew = parseInt(otp); // const otpnew = parseInt(otp);
const custRef: AngularFirestoreCollection<any> = this.afs.collection( const custRef: AngularFirestoreCollection<any> = this.afs.collection(
"customers", 'customers',
ref => ref.where("otp", "==", otp).where("uid", "==", this.userData.uid) ref => ref.where('otp', '==', otp).where('uid', '==', this.userData.uid)
); );
custRef custRef
.valueChanges() .valueChanges()
...@@ -85,20 +85,20 @@ export class AuthService { ...@@ -85,20 +85,20 @@ export class AuthService {
.subscribe((value: User[]) => { .subscribe((value: User[]) => {
if (value.length > 0) { if (value.length > 0) {
this.afs this.afs
.collection("customers") .collection('customers')
.doc(this.userData.uid) .doc(this.userData.uid)
.update({ otp: "", phoneVerified: true }); .update({ otp: '', phoneVerified: true });
this.service.set("type", 1); this.service.set('type', 1);
this.router.navigateByUrl("nearby"); this.router.navigateByUrl('nearby');
} else { } else {
window.alert("Please input valid OTP"); window.alert('Please input valid OTP');
} }
}); });
} }
profilePic(pic) { profilePic(pic) {
this.afs this.afs
.collection("customers") .collection('customers')
.doc(this.userData.uid) .doc(this.userData.uid)
.update({ profilePhoto: pic }); .update({ profilePhoto: pic });
} }
...@@ -109,7 +109,7 @@ export class AuthService { ...@@ -109,7 +109,7 @@ export class AuthService {
this.afAuth.auth this.afAuth.auth
.signInWithPopup(new auth.GoogleAuthProvider()) .signInWithPopup(new auth.GoogleAuthProvider())
.then(result => { .then(result => {
console.log("success"); console.log('success');
console.log(result.additionalUserInfo.isNewUser); console.log(result.additionalUserInfo.isNewUser);
if ( if (
result.additionalUserInfo && result.additionalUserInfo &&
...@@ -125,7 +125,7 @@ export class AuthService { ...@@ -125,7 +125,7 @@ export class AuthService {
this.afAuth.auth this.afAuth.auth
.signInWithPopup(new auth.FacebookAuthProvider()) .signInWithPopup(new auth.FacebookAuthProvider())
.then(result => { .then(result => {
console.log("success"); console.log('success');
console.log(result); console.log(result);
}); });
} }
...@@ -149,7 +149,7 @@ export class AuthService { ...@@ -149,7 +149,7 @@ export class AuthService {
loginType: value.loginType loginType: value.loginType
}; };
this.loggedUser = userData; this.loggedUser = userData;
this.service.set("userData", JSON.stringify(this.loggedUser)); this.service.set('userData', JSON.stringify(this.loggedUser));
console.log(this.loggedUser); console.log(this.loggedUser);
}); });
} }
...@@ -157,8 +157,8 @@ export class AuthService { ...@@ -157,8 +157,8 @@ export class AuthService {
public async SignOut() { public async SignOut() {
return this.afAuth.auth.signOut().then(() => { return this.afAuth.auth.signOut().then(() => {
this.subjectService.sendLoginData(true); this.subjectService.sendLoginData(true);
this.service.remove("user"); this.service.remove('user');
console.log("logout"); console.log('logout');
}); });
} }
...@@ -166,9 +166,9 @@ export class AuthService { ...@@ -166,9 +166,9 @@ export class AuthService {
this.type = 2; this.type = 2;
console.log(userData.user); console.log(userData.user);
const currencyData = { const currencyData = {
currId: "123", currId: '123',
currName: "Australian dollar", currName: 'Australian dollar',
symbol: "A$" symbol: 'A$'
}; };
const otp = Math.floor(1000 + Math.random() * 9000); const otp = Math.floor(1000 + Math.random() * 9000);
userData = userData.user; userData = userData.user;
...@@ -188,11 +188,11 @@ export class AuthService { ...@@ -188,11 +188,11 @@ export class AuthService {
this.userPostData = postData; this.userPostData = postData;
console.log(postData); console.log(postData);
this.afs this.afs
.collection("customers") .collection('customers')
.doc(userData.uid) .doc(userData.uid)
.set(postData) .set(postData)
.then(() => { .then(() => {
console.log("successs"); console.log('successs');
}); });
} }
...@@ -206,15 +206,15 @@ export class AuthService { ...@@ -206,15 +206,15 @@ export class AuthService {
console.log(result.user); console.log(result.user);
this.afAuth.auth.currentUser.sendEmailVerification(); this.afAuth.auth.currentUser.sendEmailVerification();
const currencyData = { const currencyData = {
currId: "123", currId: '123',
currName: "Australian dollar", currName: 'Australian dollar',
symbol: "A$" symbol: 'A$'
}; };
const custData = result.user; const custData = result.user;
const postData: User = { const postData: User = {
uid: custData.uid, uid: custData.uid,
status: true, status: true,
profilePhoto: "", profilePhoto: '',
phoneVerified: false, phoneVerified: false,
phone: userData.phone, phone: userData.phone,
name: userData.name, name: userData.name,
...@@ -227,11 +227,11 @@ export class AuthService { ...@@ -227,11 +227,11 @@ export class AuthService {
this.userPostData = postData; this.userPostData = postData;
console.log(postData); console.log(postData);
this.afs this.afs
.collection("customers") .collection('customers')
.doc(custData.uid) .doc(custData.uid)
.set(postData) .set(postData)
.then(() => { .then(() => {
console.log("successs"); console.log('successs');
}); });
}) })
.catch(error => { .catch(error => {
...@@ -244,7 +244,7 @@ export class AuthService { ...@@ -244,7 +244,7 @@ export class AuthService {
console.log(this.userData.uid); console.log(this.userData.uid);
this.afs this.afs
.collection("address") .collection('address')
.add({ .add({
uid: this.userData.uid uid: this.userData.uid
}) })
...@@ -268,13 +268,13 @@ export class AuthService { ...@@ -268,13 +268,13 @@ export class AuthService {
const neworderId = docRef.id; const neworderId = docRef.id;
console.log(addrData); console.log(addrData);
this.afs this.afs
.collection("address") .collection('address')
.doc(neworderId) .doc(neworderId)
.set(addrData) .set(addrData)
.then(() => { .then(() => {
console.log("Address add Successfully"); console.log('Address add Successfully');
this.service.set("user", JSON.stringify(this.userData)); this.service.set('user', JSON.stringify(this.userData));
this.router.navigateByUrl("home"); this.router.navigateByUrl('home');
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
}); });
}); });
......
import { Injectable } from "@angular/core"; import { Injectable } from '@angular/core';
import { import {
AngularFirestore, AngularFirestore,
AngularFirestoreDocument, AngularFirestoreDocument,
AngularFirestoreCollection AngularFirestoreCollection
} from "@angular/fire/firestore"; } from '@angular/fire/firestore';
import { Router, ActivatedRoute } from "@angular/router"; import { Router, ActivatedRoute } from '@angular/router';
import { Products } from "./services/product"; import { Products } from './services/product';
import { Cart, CartItem } from "./services/cart"; import { Cart, CartItem } from './services/cart';
import { ServiceService } from "./service.service"; import { ServiceService } from './service.service';
import * as firebase from "firebase"; import * as firebase from 'firebase';
import { take } from "rxjs/operators"; import { take } from 'rxjs/operators';
import { User } from "./services/user"; import { User } from './services/user';
import { from } from "rxjs"; import { from } from 'rxjs';
@Injectable({ @Injectable({
providedIn: "root" providedIn: 'root'
}) })
export class CartsService { export class CartsService {
size: string; size: string;
...@@ -31,9 +31,9 @@ export class CartsService { ...@@ -31,9 +31,9 @@ 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;
...@@ -46,20 +46,20 @@ export class CartsService { ...@@ -46,20 +46,20 @@ 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()
...@@ -69,7 +69,7 @@ export class CartsService { ...@@ -69,7 +69,7 @@ export class CartsService {
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,
...@@ -86,12 +86,12 @@ export class CartsService { ...@@ -86,12 +86,12 @@ export class CartsService {
}; };
// 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(() => {
...@@ -100,7 +100,7 @@ export class CartsService { ...@@ -100,7 +100,7 @@ export class CartsService {
}); });
}) })
.catch(error => { .catch(error => {
console.error("Error adding document: ", error); console.error('Error adding document: ', error);
}); });
} else { } else {
// console.log(value); // console.log(value);
...@@ -109,7 +109,7 @@ export class CartsService { ...@@ -109,7 +109,7 @@ export class CartsService {
// 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(() => {
...@@ -122,8 +122,8 @@ export class CartsService { ...@@ -122,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 = [];
...@@ -181,7 +181,7 @@ export class CartsService { ...@@ -181,7 +181,7 @@ export class CartsService {
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
...@@ -193,7 +193,7 @@ export class CartsService { ...@@ -193,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
...@@ -202,7 +202,7 @@ export class CartsService { ...@@ -202,7 +202,7 @@ 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();
} }
...@@ -211,9 +211,9 @@ export class CartsService { ...@@ -211,9 +211,9 @@ export class CartsService {
// console.log(promoCode); // console.log(promoCode);
const state = true; const state = true;
const promoRef: AngularFirestoreCollection<any> = this.afs.collection( const promoRef: AngularFirestoreCollection<any> = this.afs.collection(
"promocode", 'promocode',
ref => ref =>
ref.where("promoCode", "==", promoCode).where("status", "==", state) ref.where('promoCode', '==', promoCode).where('status', '==', state)
); );
return promoRef.valueChanges(); return promoRef.valueChanges();
} }
......
import { Injectable } from "@angular/core"; import { Injectable } from '@angular/core';
import { import {
AngularFirestore, AngularFirestore,
AngularFirestoreDocument, AngularFirestoreDocument,
AngularFirestoreCollection AngularFirestoreCollection
} from "@angular/fire/firestore"; } from '@angular/fire/firestore';
import { Category } from "./services/category"; import { Category } from './services/category';
import * as firebase from "firebase"; import * as firebase from 'firebase';
import { ServiceService } from "./service.service"; import { ServiceService } from './service.service';
@Injectable({ @Injectable({
providedIn: "root" providedIn: 'root'
}) })
export class CategoriesService { export class CategoriesService {
categories: Category[] = []; categories: Category[] = [];
...@@ -22,7 +22,7 @@ export class CategoriesService { ...@@ -22,7 +22,7 @@ export class CategoriesService {
public async categoryList() { public async categoryList() {
const This = this; const This = this;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection( const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
"shopcategory" 'shopcategory'
); );
orderRef.valueChanges().subscribe(value => { orderRef.valueChanges().subscribe(value => {
this.categories = []; this.categories = [];
...@@ -50,8 +50,8 @@ export class CategoriesService { ...@@ -50,8 +50,8 @@ export class CategoriesService {
const This = this; const This = this;
const state = true; const state = true;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection( const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
"shopcategory", 'shopcategory',
ref => ref.where("status", "==", state) ref => ref.where('status', '==', state)
); );
orderRef.valueChanges().subscribe(value => { orderRef.valueChanges().subscribe(value => {
this.activecategories = []; this.activecategories = [];
......
import { Injectable } from "@angular/core"; import { Injectable } from '@angular/core';
import { import {
AngularFirestore, AngularFirestore,
AngularFirestoreDocument, AngularFirestoreDocument,
AngularFirestoreCollection AngularFirestoreCollection
} from "@angular/fire/firestore"; } from '@angular/fire/firestore';
import { Myorder } from "./services/myorder"; import { Myorder } from './services/myorder';
import { ServiceService } from "./../config/service.service"; import { ServiceService } from './../config/service.service';
import * as firebase from "firebase"; import * as firebase from 'firebase';
import { take } from "rxjs/operators"; import { take } from 'rxjs/operators';
import { Observable, of } from "rxjs"; import { Observable, of } from 'rxjs';
@Injectable({ @Injectable({
providedIn: "root" providedIn: 'root'
}) })
export class MyordersService { export class MyordersService {
product: Myorder[] = []; product: Myorder[] = [];
...@@ -20,7 +20,7 @@ export class MyordersService { ...@@ -20,7 +20,7 @@ export class MyordersService {
selItem: Myorder; selItem: Myorder;
constructor(public afs: AngularFirestore, public service: ServiceService) { constructor(public afs: AngularFirestore, public service: ServiceService) {
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;
...@@ -29,7 +29,7 @@ export class MyordersService { ...@@ -29,7 +29,7 @@ export class MyordersService {
// this.orderState(); // this.orderState();
} }
} else { } else {
this.custId = "WwHnLICVY2dvZGUHuKqasiTB91a2"; this.custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2';
} }
}); });
} }
...@@ -85,8 +85,8 @@ export class MyordersService { ...@@ -85,8 +85,8 @@ export class MyordersService {
const This = this; const This = this;
this.orders = []; this.orders = [];
const orderRef: AngularFirestoreCollection<any> = this.afs.collection( const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
"orders", 'orders',
ref => ref.where("custId", "==", custId).orderBy("bookDate", "desc") ref => ref.where('custId', '==', custId).orderBy('bookDate', 'desc')
); );
orderRef.stateChanges().subscribe(value => { orderRef.stateChanges().subscribe(value => {
// console.log(value); // console.log(value);
...@@ -105,14 +105,14 @@ export class MyordersService { ...@@ -105,14 +105,14 @@ 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);
......
import { Injectable } from "@angular/core"; import { Injectable } from '@angular/core';
import { User, UpdateUserDetails, Address } from "./services/user"; import { User, UpdateUserDetails, Address } from './services/user';
import { auth } from "firebase/app"; import { auth } from 'firebase/app';
import { Router, ActivatedRoute } from "@angular/router"; import { Router, ActivatedRoute } from '@angular/router';
import { AngularFireAuth } from "@angular/fire/auth"; import { AngularFireAuth } from '@angular/fire/auth';
import { import {
AngularFirestore, AngularFirestore,
AngularFirestoreDocument, AngularFirestoreDocument,
AngularFirestoreCollection AngularFirestoreCollection
} from "@angular/fire/firestore"; } from '@angular/fire/firestore';
import { ServiceService } from "./../config/service.service"; import { ServiceService } from './../config/service.service';
import { GooglePlus } from "@ionic-native/google-plus/ngx"; import { GooglePlus } from '@ionic-native/google-plus/ngx';
import { take } from "rxjs/operators"; import { take } from 'rxjs/operators';
import { from } from "rxjs"; import { from } from 'rxjs';
@Injectable({ @Injectable({
providedIn: "root" providedIn: 'root'
}) })
export class UpdateService { export class UpdateService {
userData: any; userData: any;
...@@ -58,12 +58,12 @@ export class UpdateService { ...@@ -58,12 +58,12 @@ export class UpdateService {
this.userPostData = postData; this.userPostData = postData;
this.afs this.afs
.collection("customers") .collection('customers')
.doc(uid) .doc(uid)
.update(postData) .update(postData)
.then(() => { .then(() => {
console.log("success"); console.log('success');
this.router.navigateByUrl("profile"); this.router.navigateByUrl('profile');
}) })
.catch(error => { .catch(error => {
console.log(error); console.log(error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment