Commit 4bfc277f by Adarsh K

Merge branch 'adarsh' into 'master'

Adarsh See merge request !59
parents 97cdb621 1382e73e
...@@ -112,7 +112,8 @@ export class AppComponent { ...@@ -112,7 +112,8 @@ export class AppComponent {
'forgot', 'forgot',
'feedback', 'feedback',
'wishlist', 'wishlist',
'preference' 'preference',
'changedetails'
]; ];
const currentUrl = this.router.url.split('/'); const currentUrl = this.router.url.split('/');
const index = restrictedUrl.findIndex(x => x === currentUrl[1]); const index = restrictedUrl.findIndex(x => x === currentUrl[1]);
......
import { Component, OnInit, ViewChild } from "@angular/core"; import { Component, OnInit, ViewChild } from '@angular/core';
import { IonSlides } from "@ionic/angular"; import { IonSlides } from '@ionic/angular';
import { Location } from "@angular/common"; import { Location } from '@angular/common';
import { Router, ActivatedRoute } from "@angular/router"; import { Router, ActivatedRoute } from '@angular/router';
import { CartsService } from "./../../config/cart.service"; import { CartsService } from './../../config/cart.service';
import { OrdersService } from "./../../config/order.service"; import { OrdersService } from './../../config/order.service';
import { ModalController } from "@ionic/angular"; import { ModalController } from '@ionic/angular';
import { DeliverypopPage } from "../deliverypop/deliverypop.page"; import { DeliverypopPage } from '../deliverypop/deliverypop.page';
import { ServiceService } from "./../../config/service.service"; import { ServiceService } from './../../config/service.service';
import { AddressService } from "./../../config/address.service"; import { AddressService } from './../../config/address.service';
import { AddressList } from "./../../config/services/address"; import { AddressList } from './../../config/services/address';
import { trigger, transition, animate, style } from "@angular/animations"; import { trigger, transition, animate, style } from '@angular/animations';
import { zip } from "rxjs"; import { zip } from 'rxjs';
@Component({ @Component({
selector: "app-cart", selector: 'app-cart',
templateUrl: "./cart.page.html", templateUrl: './cart.page.html',
styleUrls: ["./cart.page.scss"], styleUrls: ['./cart.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%)' }))
]) ])
]) ])
] ]
...@@ -61,7 +61,7 @@ export class CartPage implements OnInit { ...@@ -61,7 +61,7 @@ export class CartPage implements OnInit {
public service: ServiceService, public service: ServiceService,
public addressService: AddressService public addressService: AddressService
) { ) {
console.log("cart loaded"); console.log('cart loaded');
this.bookDate = this.formatDate(); this.bookDate = this.formatDate();
this.currentIndex = 0; this.currentIndex = 0;
this.count = 1; this.count = 1;
...@@ -72,7 +72,7 @@ export class CartPage implements OnInit { ...@@ -72,7 +72,7 @@ export class CartPage implements OnInit {
this.discount = 0; this.discount = 0;
// this.cartService.cartList(); // this.cartService.cartList();
this.loader = true; this.loader = true;
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;
...@@ -90,7 +90,7 @@ export class CartPage implements OnInit { ...@@ -90,7 +90,7 @@ export class CartPage implements OnInit {
} }
ionViewWillEnter() { ionViewWillEnter() {
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.cartService.cartList(); this.cartService.cartList();
...@@ -182,15 +182,15 @@ export class CartPage implements OnInit { ...@@ -182,15 +182,15 @@ export class CartPage implements OnInit {
const state = this.orderService const state = this.orderService
.checkOut(this.cartService.carts, otherCharges) .checkOut(this.cartService.carts, otherCharges)
.then(data => { .then(data => {
console.log("ready for slide"); console.log('ready for slide');
const timeStamp = Math.floor(Date.now() / 1000); const timeStamp = Math.floor(Date.now() / 1000);
this.timeinterval = setInterval(() => { this.timeinterval = setInterval(() => {
this.getDeliveryTime(timeStamp); This.getDeliveryTime(timeStamp);
}, 1000); }, 1000);
this.slides.slideNext(); this.slides.slideNext();
}); });
} else { } else {
alert("Please choose delivery location"); alert('Please choose delivery location');
} }
} else { } else {
this.slides.slideNext(); this.slides.slideNext();
...@@ -203,9 +203,9 @@ export class CartPage implements OnInit { ...@@ -203,9 +203,9 @@ export class CartPage implements OnInit {
console.log(endDate); console.log(endDate);
endDate.setHours(endDate.getHours() + 1); endDate.setHours(endDate.getHours() + 1);
const t = this.getTimeRemaining(endDate, new Date()); const t = this.getTimeRemaining(endDate, new Date());
const minutes = t.minutes < 10 ? "0" + t.minutes : t.minutes; const minutes = t.minutes < 10 ? '0' + t.minutes : t.minutes;
const seconds = t.seconds < 10 ? "0" + t.seconds : t.seconds; const seconds = t.seconds < 10 ? '0' + t.seconds : t.seconds;
this.deliveryTime = minutes + " : " + seconds; this.deliveryTime = minutes + ' : ' + seconds;
if (t.t <= 0) { if (t.t <= 0) {
clearInterval(this.timeinterval); clearInterval(this.timeinterval);
} }
...@@ -285,33 +285,33 @@ export class CartPage implements OnInit { ...@@ -285,33 +285,33 @@ export class CartPage implements OnInit {
formatDate() { formatDate() {
const date = new Date(); const date = new Date();
const months = [ const months = [
"Jan", 'Jan',
"Feb", 'Feb',
"Mar", 'Mar',
"Apr", 'Apr',
"May", 'May',
"June", 'June',
"July", 'July',
"Aug", 'Aug',
"Sep", 'Sep',
"Oct", 'Oct',
"Nov", 'Nov',
"Dec" 'Dec'
]; ];
let hours = date.getHours(); let hours = date.getHours();
const minutes = date.getMinutes(); const minutes = date.getMinutes();
const ampm = hours >= 12 ? "PM" : "AM"; const ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12; hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12' hours = hours ? hours : 12; // the hour '0' should be '12'
const newminutes = minutes < 10 ? "0" + minutes : minutes; const newminutes = minutes < 10 ? '0' + minutes : minutes;
const strTime = hours + ":" + newminutes + " " + ampm; const strTime = hours + ':' + newminutes + ' ' + ampm;
return ( return (
months[date.getMonth()] + months[date.getMonth()] +
" " + ' ' +
date.getDate() + date.getDate() +
"," + ',' +
date.getFullYear() + date.getFullYear() +
" " + ' ' +
strTime strTime
); );
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/> />
<div <div
class="md-errors-spacer" class="md-errors-spacer"
[hidden]="name.valid || submitted == false" [hidden]="name.valid"
class="ion-padding-start" class="ion-padding-start"
> >
Name is required Name is required
...@@ -56,10 +56,7 @@ ...@@ -56,10 +56,7 @@
placeholder="Change your Phone Number" placeholder="Change your Phone Number"
#phone="ngModel" #phone="ngModel"
/> />
<div <div class="md-errors-spacer" [hidden]="phone.valid">
class="md-errors-spacer"
[hidden]="phone.valid || submitted == false"
>
<div *ngIf="phone.errors && phone.errors.required"> <div *ngIf="phone.errors && phone.errors.required">
Phone number is required Phone number is required
</div> </div>
...@@ -113,14 +110,20 @@ ...@@ -113,14 +110,20 @@
[required]="currentPassword ? true: false" [required]="currentPassword ? true: false"
placeholder="Confirm Password" placeholder="Confirm Password"
/> />
<div *ngIf="confirmPassword.errors"> <div
{{confPasswordErr}} *ngIf="confirmPassword.value !=='' && confirmPassword.value !== password.value"
>
Password should match
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<button class="login_btn" (click)="onFormSubmit(updateForm)"> <button
class="login_btn"
(click)="onFormSubmit(updateForm)"
[disabled]="!phone.valid || !name.valid"
>
UPDATE UPDATE
</button> </button>
</div> </div>
......
...@@ -61,30 +61,20 @@ export class ChangedetailsPage implements OnInit { ...@@ -61,30 +61,20 @@ export class ChangedetailsPage implements OnInit {
onFormSubmit(form: NgForm) { onFormSubmit(form: NgForm) {
this.submitted = true; this.submitted = true;
console.log(form.value); console.log(form.value);
if (form.valid) { // if (form.valid) {
// Change Password // Change Password
if (form.value.currentPassword && form.value.password) {
if ( if (
form.value.password && form.value.currentPassword &&
form.value.password === form.value.confirmPassword form.value.password && form.value.password === form.value.confirmPassword
) { ) {
// this.register.updateData(form.value, this.userData.uid); this.register.updateData(form.value, this.userData.uid);
this.register.updatePassword( this.register.updatePassword(
form.value.currentPassword, form.value.currentPassword,
form.value.password form.value.password
); );
console.log('Password Changed and profile updated'), form.value;
} else { } else {
console.log('Password should match'); this.register.updateData(form.value, this.userData);
this.confPasswordErr = 'Password should match';
}
} else {
// this.register.updateData(form.value, this.userData);
console.log('profile updated', form.value); console.log('profile updated', form.value);
} }
// console.log('valid form values', form.value);
} else {
console.log(form);
}
} }
} }
...@@ -109,6 +109,11 @@ ...@@ -109,6 +109,11 @@
<div class="clear"></div> <div class="clear"></div>
</li> --> </li> -->
</ul> </ul>
<div class="empty-wishlist-wrapper" *ngIf="myorder.orders.length == 0">
<img src="../../assets/wishlist.png" />
<h1>There is no order</h1>
<button (click)="goToPage('home')">shop now</button>
</div>
</div> </div>
</ion-content> </ion-content>
<div class="loader" *ngIf="loader"> <div class="loader" *ngIf="loader">
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
} }
.track_btn { .track_btn {
background: #29285b; background: #29285b;
color: #FFF; color: #fff;
float: right; float: right;
padding: 12px; padding: 12px;
font-size: 18px; font-size: 18px;
...@@ -109,4 +109,29 @@ ...@@ -109,4 +109,29 @@
} }
} }
} }
.empty-wishlist-wrapper {
text-align: center;
padding-top: 25%;
img {
width: 100px;
}
h1 {
font-size: 18px;
font-weight: bolder;
text-transform: uppercase;
color: #3b394d;
}
button {
background-color: #29285b;
border-radius: 8px;
height: 50px;
width: 48%;
color: #fff;
font-size: 18px;
font-weight: lighter;
text-transform: uppercase;
margin-top: 10px;
}
}
} }
...@@ -134,8 +134,7 @@ export class NearbyPage implements OnInit { ...@@ -134,8 +134,7 @@ export class NearbyPage implements OnInit {
this.loader = false; this.loader = false;
this.successState = false; this.successState = false;
if (this.type === 1) { if (this.type === 1) {
this.service.set('type', 0); this.router.navigateByUrl('preference', { queryParams: null });
this.router.navigateByUrl('home', { queryParams: null });
} else { } else {
this.goBack(); this.goBack();
} }
......
<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()" *ngIf="type==0">
<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>Preference</h4> <h4>Preferences</h4>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
...@@ -12,11 +12,24 @@ ...@@ -12,11 +12,24 @@
<div class="preference-wrapper"> <div class="preference-wrapper">
<div class="pref-wrap-two"> <div class="pref-wrap-two">
<ion-grid> <ion-grid>
<ion-row *ngIf="categoriesService.activecategories && categoriesService.activecategories.length > 0"> <ion-row
<ion-col size="6" *ngFor="let categories of categoriesService.activecategories"> *ngIf="categoriesService.activecategories && categoriesService.activecategories.length > 0"
>
<ion-col
size="6"
*ngFor="let categories of categoriesService.categories"
>
<div class="preference-box"> <div class="preference-box">
<input type="checkbox" class="preference" /> <input
<img [src]="categories.catImage" onerror="this.src='../assets/handsome-man-outdoors-drinking-coffee-with-sunglasses-guy-with-beard-instagram-effect_1212-818@3x.png'"> type="checkbox"
class="preference"
(click)="selectPrefernce(categories.catId)"
[checked]="selectedPref(categories.catId)"
/>
<img
[src]="categories.catImage"
onerror="this.src='../assets/handsome-man-outdoors-drinking-coffee-with-sunglasses-guy-with-beard-instagram-effect_1212-818@3x.png'"
/>
<h1>{{categories.catName}}</h1> <h1>{{categories.catName}}</h1>
</div> </div>
</ion-col> </ion-col>
...@@ -24,10 +37,16 @@ ...@@ -24,10 +37,16 @@
</ion-grid> </ion-grid>
</div> </div>
<div class="bottom-button"> <div class="bottom-button">
<button class="show-btn" (click)="goToPage('nearby')"> <button class="show-btn" (click)="onSubmit()">
Continue Continue
</button> </button>
<span>SKIP</span> <!-- <span>SKIP</span> -->
</div> </div>
</div> </div>
</ion-content> </ion-content>
<div class="loader" *ngIf="loader">
<div class="lds-ripple">
<div></div>
<div></div>
</div>
</div>
import { Component, OnInit } from "@angular/core"; import { Component, OnInit } from '@angular/core';
import { CategoriesService } from "./../../config/category.service"; import { CategoriesService } from './../../config/category.service';
import { ServiceService } from "./../../config/service.service"; import { ServiceService } from './../../config/service.service';
import { Router, ActivatedRoute } from '@angular/router';
@Component({ @Component({
selector: "app-preference", selector: 'app-preference',
templateUrl: "./preference.page.html", templateUrl: './preference.page.html',
styleUrls: ["./preference.page.scss"] styleUrls: ['./preference.page.scss']
}) })
export class PreferencePage implements OnInit { export class PreferencePage implements OnInit {
type: any;
successState: boolean;
uid: any;
userPrefence: any[];
loader: boolean;
constructor( constructor(
private categoriesService: CategoriesService, private categoriesService: CategoriesService,
private service: ServiceService private service: ServiceService,
) {} private router: Router
) {
this.successState = false;
this.userPrefence = [];
this.type = 0;
const users = this.service.get('user').then(data => {
if (data) {
data = JSON.parse(data);
this.uid = data.uid;
this.categoriesService
.preference(this.uid)
.then(datas => {
console.log(datas);
console.log(this.categoriesService.preferenceList);
this.userPrefence = this.categoriesService.preferenceList;
console.log(this.userPrefence);
})
.catch(err => {
this.userPrefence = [];
});
}
});
this.service.get('type').then(data => {
this.type = data;
});
}
ngOnInit() {} ngOnInit() {}
selectPrefernce(preferenceId) {
console.log(this.userPrefence);
console.log(preferenceId);
if (this.userPrefence) {
const index = this.userPrefence.findIndex(x => x === preferenceId);
if (index > -1) {
this.userPrefence.splice(index, 1);
} else {
this.userPrefence.push(preferenceId);
}
} else {
this.userPrefence = [];
this.userPrefence.push(preferenceId);
}
}
onSubmit() {
this.loader = true;
console.log(this.userPrefence);
this.categoriesService.preferenceCreate(this.userPrefence, this.uid);
this.successState = true;
setTimeout(() => {
this.loader = false;
this.successState = false;
if (this.type === 1) {
this.service.set('type', 0);
this.router.navigateByUrl('home', { queryParams: null });
} else {
this.goBack();
}
}, 3000);
}
selectedPref(preferenceId) {
const index = this.userPrefence.findIndex(x => x === preferenceId);
console.log(index);
if (index > -1) {
return true;
} else {
return false;
}
}
goBack() {
window.history.back();
}
} }
...@@ -66,6 +66,7 @@ export class ProductlistPage implements OnInit { ...@@ -66,6 +66,7 @@ export class ProductlistPage implements OnInit {
ngOnInit() {} ngOnInit() {}
ionViewWillEnter() { ionViewWillEnter() {
console.log('logged');
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);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<div class="profile_circle"> <div class="profile_circle">
<img <img
[src]="loggedUser.profilePhoto" [src]="loggedUser.profilePhoto"
onerror="this.src='./../../assets/profile_banner.png'" onerror="this.src='./../assets/asset_avatar.png'"
/> />
<div class="edit"></div> <div class="edit"></div>
<input type="file" accept="image/*" (change)="fileChange($event)" /> <input type="file" accept="image/*" (change)="fileChange($event)" />
...@@ -118,6 +118,17 @@ ...@@ -118,6 +118,17 @@
</ion-col> </ion-col>
</ion-row> </ion-row>
<hr /> <hr />
<ion-row (click)="goToPage('preference')">
<ion-col class="textLeft p0">
<p>Preferences</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-row>
<ion-col class="textLeft p0"> <ion-col class="textLeft p0">
<p>Currency</p> <p>Currency</p>
...@@ -150,3 +161,9 @@ ...@@ -150,3 +161,9 @@
</div> </div>
</div> </div>
</ion-content> </ion-content>
<div class="loader" *ngIf="loader">
<div class="lds-ripple">
<div></div>
<div></div>
</div>
</div>
...@@ -3,6 +3,7 @@ import { User } from '../../config/services/user'; ...@@ -3,6 +3,7 @@ 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 { SubjectService } from './../../config/subject.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 { Location } from '@angular/common';
...@@ -40,6 +41,7 @@ export class ProfilePage implements OnInit { ...@@ -40,6 +41,7 @@ export class ProfilePage implements OnInit {
loggedUser: any; loggedUser: any;
ref: AngularFireStorageReference; ref: AngularFireStorageReference;
downloadURL; downloadURL;
loader: boolean;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
...@@ -50,8 +52,10 @@ export class ProfilePage implements OnInit { ...@@ -50,8 +52,10 @@ export class ProfilePage implements OnInit {
private authService: AuthService, private authService: AuthService,
private addressService: AddressService, private addressService: AddressService,
private wishService: WishService, private wishService: WishService,
private location: Location private location: Location,
private subject: SubjectService
) { ) {
this.loader = false;
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);
...@@ -95,6 +99,7 @@ export class ProfilePage implements OnInit { ...@@ -95,6 +99,7 @@ export class ProfilePage implements OnInit {
} }
async fileChange(event) { async fileChange(event) {
this.loader = true;
const fileList: FileList = event.target.files; const fileList: FileList = event.target.files;
if (fileList.length > 0) { if (fileList.length > 0) {
const reader = new FileReader(); const reader = new FileReader();
...@@ -119,7 +124,14 @@ export class ProfilePage implements OnInit { ...@@ -119,7 +124,14 @@ export class ProfilePage implements OnInit {
.pipe( .pipe(
finalize(() => { finalize(() => {
ref.getDownloadURL().subscribe(url => { ref.getDownloadURL().subscribe(url => {
this.loader = false;
this.authService.profilePic(url); this.authService.profilePic(url);
this.service.get('userData').then(userData => {
const userDatas = JSON.parse(userData);
userDatas.profilePhoto = url;
this.service.set('userData', JSON.stringify(userDatas));
this.subject.sendUserData(JSON.stringify(userDatas));
});
}); });
}) })
) )
......
...@@ -14,7 +14,9 @@ import { ServiceService } from './service.service'; ...@@ -14,7 +14,9 @@ import { ServiceService } from './service.service';
export class CategoriesService { export class CategoriesService {
categories: Category[] = []; categories: Category[] = [];
activecategories: Category[] = []; activecategories: Category[] = [];
preferenceList: any[];
constructor(public afs: AngularFirestore, public service: ServiceService) { constructor(public afs: AngularFirestore, public service: ServiceService) {
this.preferenceList = [];
this.categoryList(); this.categoryList();
this.activeCategory(); this.activeCategory();
} }
...@@ -74,4 +76,52 @@ export class CategoriesService { ...@@ -74,4 +76,52 @@ export class CategoriesService {
} }
}); });
} }
public async preference(custId) {
const This = this;
const state = true;
const promise = new Promise(resolve => {
const orderRef: AngularFirestoreDocument<any> = this.afs
.collection('preference')
.doc(custId);
orderRef.valueChanges().subscribe(value => {
console.log(value);
this.preferenceList = [];
if (value) {
console.log(value);
// tslint:disable-next-line: forin
for (const index in value) {
console.log(index);
this.preferenceList.push(index);
resolve(this.preferenceList);
}
resolve();
// console.log(this.activecategories);
} else {
this.preferenceList = [];
resolve([]);
}
});
});
return promise;
}
preferenceCreate(preferData, custId) {
if (preferData.length > 0) {
const preferArray = [];
preferData.forEach(element => {
preferArray[element] = true;
});
const pref = Object.assign({}, preferArray);
this.afs
.collection('preference')
.doc(custId)
.set(pref);
} else {
this.afs
.collection('preference')
.doc(custId)
.delete();
}
}
} }
...@@ -235,6 +235,7 @@ export class ProductsService { ...@@ -235,6 +235,7 @@ export class ProductsService {
} }
public async getFavlist(userId: string) { public async getFavlist(userId: string) {
console.log(userId);
const favRef: AngularFirestoreDocument<any> = this.afs const favRef: AngularFirestoreDocument<any> = this.afs
.collection(`favourite`) .collection(`favourite`)
.doc(userId); .doc(userId);
...@@ -247,9 +248,11 @@ export class ProductsService { ...@@ -247,9 +248,11 @@ export class ProductsService {
if (value !== undefined) { if (value !== undefined) {
if (Object.keys(value).length > 0) { if (Object.keys(value).length > 0) {
this.fav = this.service.splitSep(value); this.fav = this.service.splitSep(value);
// console.log(this.fav); console.log(this.fav);
} }
// console.log(value); // console.log(value);
} else {
this.fav = [];
} }
}); });
} }
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
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 { 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';
...@@ -27,7 +28,8 @@ export class UpdateService { ...@@ -27,7 +28,8 @@ export class UpdateService {
public afs: AngularFirestore, public afs: AngularFirestore,
public afAuth: AngularFireAuth, public afAuth: AngularFireAuth,
private router: Router, private router: Router,
private service: ServiceService private service: ServiceService,
private subject: SubjectService
) { ) {
// this.type = 1; // this.type = 1;
// this.afAuth.authState.subscribe(user => { // this.afAuth.authState.subscribe(user => {
...@@ -72,10 +74,11 @@ export class UpdateService { ...@@ -72,10 +74,11 @@ export class UpdateService {
this.service this.service
.set('userData', JSON.stringify(updateOldData)) .set('userData', JSON.stringify(updateOldData))
.then(res => { .then(res => {
this.subject.sendUserData(JSON.stringify());
console.log('success', updateOldData, res); console.log('success', updateOldData, res);
this.service this.service
.showToast('Profile updated!', 'top', 'my-toast', 1000) .showToast('Profile updated!', 'top', 'my-toast', 1000)
.then(res => { .then(() => {
this.router.navigateByUrl('profile'); this.router.navigateByUrl('profile');
this.loader = false; this.loader = false;
}); });
...@@ -91,7 +94,7 @@ export class UpdateService { ...@@ -91,7 +94,7 @@ export class UpdateService {
updatePassword(currentPassword: string, newPasswd: string) { updatePassword(currentPassword: string, newPasswd: string) {
this.loader = true; this.loader = true;
let currentUser = this.afAuth.auth.currentUser; // Gets current user const currentUser = this.afAuth.auth.currentUser; // Gets current user
// Credential is required for re-authentication // Credential is required for re-authentication
const credential = auth.EmailAuthProvider.credential( const credential = auth.EmailAuthProvider.credential(
currentUser.email, currentUser.email,
...@@ -108,7 +111,7 @@ export class UpdateService { ...@@ -108,7 +111,7 @@ export class UpdateService {
console.log('password changed'); console.log('password changed');
this.loader = false; this.loader = false;
this.service this.service
.showToast('Password Changed!', 'top', 'my-toast', 1000) //success toast .showToast('Password Changed!', 'top', 'my-toast', 1000) // success toast
.then(res => { .then(res => {
this.router.navigateByUrl('profile'); this.router.navigateByUrl('profile');
this.loader = false; this.loader = false;
...@@ -117,7 +120,7 @@ export class UpdateService { ...@@ -117,7 +120,7 @@ export class UpdateService {
.catch(error => { .catch(error => {
console.log('something fishy'); console.log('something fishy');
this.service this.service
.showToast('Something went wrong', 'top', 'my-toast', 1000) //failure toast .showToast('Something went wrong', 'top', 'my-toast', 1000) // failure toast
.then(res => { .then(res => {
this.loader = false; this.loader = false;
}); });
...@@ -126,7 +129,7 @@ export class UpdateService { ...@@ -126,7 +129,7 @@ export class UpdateService {
.catch(error => { .catch(error => {
console.log(error); console.log(error);
this.service this.service
.showToast(error.message, 'top', 'my-error', 3000) //failure toast .showToast(error.message, 'top', 'my-error', 3000) // failure toast
.then(res => { .then(res => {
this.loader = false; this.loader = false;
}); });
......
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