Commit 6825ef55 by muhsin

Merge branch 'master' into muhsin

parents fdd628fd 8d6511ef
......@@ -397,8 +397,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
......@@ -419,14 +418,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
......@@ -441,20 +438,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
......@@ -584,7 +578,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
......@@ -599,7 +592,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
......@@ -607,14 +599,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
......@@ -633,7 +623,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
......@@ -714,8 +703,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
......@@ -727,7 +715,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
......@@ -813,8 +800,7 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
......@@ -850,7 +836,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
......@@ -870,7 +855,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
......@@ -914,14 +898,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
}
}
},
......@@ -6832,8 +6814,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
......@@ -6876,8 +6857,7 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
......@@ -6888,8 +6868,7 @@
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
......@@ -7006,8 +6985,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
......@@ -7019,7 +6997,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
......@@ -7049,7 +7026,6 @@
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
......@@ -7068,7 +7044,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
......@@ -7162,7 +7137,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
......@@ -7248,8 +7222,7 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
......@@ -7285,7 +7258,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
......@@ -7305,7 +7277,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
......@@ -7349,14 +7320,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
}
}
},
......@@ -11916,7 +11885,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
......@@ -12510,8 +12478,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
......@@ -12554,8 +12521,7 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
......@@ -12566,8 +12532,7 @@
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
......@@ -12684,8 +12649,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
......@@ -12697,7 +12661,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
......@@ -12727,7 +12690,6 @@
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
......@@ -12746,7 +12708,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
......@@ -12827,8 +12788,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
......@@ -12840,7 +12800,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
......@@ -12926,8 +12885,7 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
......@@ -12963,7 +12921,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
......@@ -12983,7 +12940,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
......@@ -13027,14 +12983,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
}
}
},
......
......@@ -99,7 +99,8 @@ const routes: Routes = [
{ path: 'feedback', loadChildren: './feedback/feedback.module#FeedbackPageModule' },
{ path: 'address', loadChildren: './address/address.module#AddressPageModule' },
{ path: 'success', loadChildren: './success/success.module#SuccessPageModule' },
{ path: 'failed', loadChildren: './failed/failed.module#FailedPageModule' }
{ path: 'failed', loadChildren: './failed/failed.module#FailedPageModule' },
{ path: 'preference', loadChildren: './preference/preference.module#PreferencePageModule' }
];
@NgModule({
......
......@@ -111,7 +111,9 @@ export class AppComponent {
'address',
'forgot',
'feedback',
'wishlist'
'wishlist',
'preference',
'changedetails'
];
const currentUrl = this.router.url.split('/');
const index = restrictedUrl.findIndex(x => x === currentUrl[1]);
......
......@@ -37,6 +37,7 @@ export class CartPage implements OnInit {
loader = false;
custId: any;
custAddress: AddressList;
deliveryTime: any;
cartwizard = {
initialSlide: 0,
speed: 1000,
......@@ -184,7 +185,7 @@ export class CartPage implements OnInit {
console.log('ready for slide');
const timeStamp = Math.floor(Date.now() / 1000);
this.timeinterval = setInterval(() => {
this.getDeliveryTime(timeStamp);
This.getDeliveryTime(timeStamp);
}, 1000);
this.slides.slideNext();
});
......
......@@ -26,7 +26,7 @@
/>
<div
class="md-errors-spacer"
[hidden]="name.valid || submitted == false"
[hidden]="name.valid"
class="ion-padding-start"
>
Name is required
......@@ -56,10 +56,7 @@
placeholder="Change your Phone Number"
#phone="ngModel"
/>
<div
class="md-errors-spacer"
[hidden]="phone.valid || submitted == false"
>
<div class="md-errors-spacer" [hidden]="phone.valid">
<div *ngIf="phone.errors && phone.errors.required">
Phone number is required
</div>
......@@ -113,14 +110,20 @@
[required]="currentPassword ? true: false"
placeholder="Confirm Password"
/>
<div *ngIf="confirmPassword.errors">
{{confPasswordErr}}
<div
*ngIf="confirmPassword.value !=='' && confirmPassword.value !== password.value"
>
Password should match
</div>
</div>
</div>
<div class="row">
<button class="login_btn" (click)="onFormSubmit(updateForm)">
<button
class="login_btn"
(click)="onFormSubmit(updateForm)"
[disabled]="!phone.valid || !name.valid"
>
UPDATE
</button>
</div>
......
......@@ -61,30 +61,20 @@ export class ChangedetailsPage implements OnInit {
onFormSubmit(form: NgForm) {
this.submitted = true;
console.log(form.value);
if (form.valid) {
// if (form.valid) {
// Change Password
if (form.value.currentPassword && form.value.password) {
if (
form.value.password &&
form.value.password === form.value.confirmPassword
form.value.currentPassword &&
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(
form.value.currentPassword,
form.value.password
);
console.log('Password Changed and profile updated'), form.value;
} else {
console.log('Password should match');
this.confPasswordErr = 'Password should match';
}
} else {
// this.register.updateData(form.value, this.userData);
this.register.updateData(form.value, this.userData);
console.log('profile updated', form.value);
}
// console.log('valid form values', form.value);
} else {
console.log(form);
}
}
}
......@@ -109,6 +109,11 @@
<div class="clear"></div>
</li> -->
</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>
</ion-content>
<div class="loader" *ngIf="loader">
......
......@@ -98,7 +98,7 @@
}
.track_btn {
background: #29285b;
color: #FFF;
color: #fff;
float: right;
padding: 12px;
font-size: 18px;
......@@ -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 {
this.loader = false;
this.successState = false;
if (this.type === 1) {
this.service.set('type', 0);
this.router.navigateByUrl('home', { queryParams: null });
this.router.navigateByUrl('preference', { queryParams: null });
} else {
this.goBack();
}
......
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { PreferencePage } from './preference.page';
const routes: Routes = [
{
path: '',
component: PreferencePage
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes)
],
declarations: [PreferencePage]
})
export class PreferencePageModule {}
<div class="nav_header">
<button class="nav_btn nav_back floatLeft" (click)="goBack()" *ngIf="type==0">
<img src="../assets/Group17_2.png" />
</button>
<div class="nav_title floatLeft">
<h4>Preferences</h4>
</div>
<div class="clear"></div>
</div>
<ion-content>
<div class="preference-wrapper">
<div class="pref-wrap-two">
<ion-grid>
<ion-row
*ngIf="categoriesService.activecategories && categoriesService.activecategories.length > 0"
>
<ion-col
size="6"
*ngFor="let categories of categoriesService.categories"
>
<div class="preference-box">
<input
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>
</div>
</ion-col>
</ion-row>
</ion-grid>
</div>
<div class="bottom-button">
<button class="show-btn" (click)="onSubmit()">
Continue
</button>
<!-- <span>SKIP</span> -->
</div>
</div>
</ion-content>
<div class="loader" *ngIf="loader">
<div class="lds-ripple">
<div></div>
<div></div>
</div>
</div>
.preference-wrapper {
padding: 20px 20px 110px 20px;
.bottom-button {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background-color: #fff;
padding: 20px;
text-align: center;
z-index: 2;
button {
width: 100%;
background-color: #29285b;
color: #fff;
border-radius: 8px;
height: 45px;
font-size: 16px;
text-transform: uppercase;
}
span {
text-transform: uppercase;
font-size: 16px;
text-align: center;
margin-top: 10px;
display: inline-block;
font-weight: 600;
}
}
.pref-wrap-two {
.preference-box {
width: 100%;
position: relative;
img {
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
object-fit: cover;
}
h1 {
color: #fff;
position: absolute;
bottom: 0px;
left: 14px;
font-size: 14px;
text-transform: uppercase;
z-index: 2;
}
.preference {
-webkit-appearance: none;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
width: 100%;
height: 90px;
padding: 17px;
outline: none;
-webkit-transition: all 0.6s ease-in-out;
transition: all 0.6s ease-in-out;
position: relative;
display: block;
z-index: 9;
}
&:before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
background-color: rgba(0, 0, 0, 0.46);
z-index: 1;
}
}
.preference:checked {
&:before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
background-color: rgba(41, 40, 91, 0.52);
z-index: 9;
}
}
}
}
\ No newline at end of file
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PreferencePage } from './preference.page';
describe('PreferencePage', () => {
let component: PreferencePage;
let fixture: ComponentFixture<PreferencePage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PreferencePage ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PreferencePage);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { CategoriesService } from './../../config/category.service';
import { ServiceService } from './../../config/service.service';
import { Router, ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-preference',
templateUrl: './preference.page.html',
styleUrls: ['./preference.page.scss']
})
export class PreferencePage implements OnInit {
type: any;
successState: boolean;
uid: any;
userPrefence: any[];
loader: boolean;
constructor(
private categoriesService: CategoriesService,
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() {}
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 {
ngOnInit() {}
ionViewWillEnter() {
console.log('logged');
const users = this.service.get('user').then(data => {
if (data) {
data = JSON.parse(data);
......
......@@ -18,7 +18,7 @@
<div class="profile_circle">
<img
[src]="loggedUser.profilePhoto"
onerror="this.src='./../../assets/profile_banner.png'"
onerror="this.src='./../assets/asset_avatar.png'"
/>
<div class="edit"></div>
<input type="file" accept="image/*" (change)="fileChange($event)" />
......@@ -118,6 +118,17 @@
</ion-col>
</ion-row>
<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-col class="textLeft p0">
<p>Currency</p>
......@@ -150,3 +161,9 @@
</div>
</div>
</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';
import { UserService } from '../../config/user.service';
import { ServiceService } from '../../config/service.service';
import { AuthService } from '../../config/auth.service';
import { SubjectService } from './../../config/subject.service';
import { Router, ActivatedRoute } from '@angular/router';
import { finalize, tap } from 'rxjs/operators';
import { Location } from '@angular/common';
......@@ -40,6 +41,7 @@ export class ProfilePage implements OnInit {
loggedUser: any;
ref: AngularFireStorageReference;
downloadURL;
loader: boolean;
constructor(
private route: ActivatedRoute,
......@@ -50,8 +52,10 @@ export class ProfilePage implements OnInit {
private authService: AuthService,
private addressService: AddressService,
private wishService: WishService,
private location: Location
private location: Location,
private subject: SubjectService
) {
this.loader = false;
this.service.get('user').then(data => {
if (data) {
this.userData = JSON.parse(data);
......@@ -95,6 +99,7 @@ export class ProfilePage implements OnInit {
}
async fileChange(event) {
this.loader = true;
const fileList: FileList = event.target.files;
if (fileList.length > 0) {
const reader = new FileReader();
......@@ -119,7 +124,14 @@ export class ProfilePage implements OnInit {
.pipe(
finalize(() => {
ref.getDownloadURL().subscribe(url => {
this.loader = false;
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';
export class CategoriesService {
categories: Category[] = [];
activecategories: Category[] = [];
preferenceList: any[];
constructor(public afs: AngularFirestore, public service: ServiceService) {
this.preferenceList = [];
this.categoryList();
this.activeCategory();
}
......@@ -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 {
}
public async getFavlist(userId: string) {
console.log(userId);
const favRef: AngularFirestoreDocument<any> = this.afs
.collection(`favourite`)
.doc(userId);
......@@ -247,9 +248,11 @@ export class ProductsService {
if (value !== undefined) {
if (Object.keys(value).length > 0) {
this.fav = this.service.splitSep(value);
// console.log(this.fav);
console.log(this.fav);
}
// console.log(value);
} else {
this.fav = [];
}
});
}
......
......@@ -9,6 +9,7 @@ import {
AngularFirestoreCollection
} from '@angular/fire/firestore';
import { ServiceService } from './../config/service.service';
import { SubjectService } from './../config/subject.service';
import { GooglePlus } from '@ionic-native/google-plus/ngx';
import { take } from 'rxjs/operators';
import { from } from 'rxjs';
......@@ -27,7 +28,8 @@ export class UpdateService {
public afs: AngularFirestore,
public afAuth: AngularFireAuth,
private router: Router,
private service: ServiceService
private service: ServiceService,
private subject: SubjectService
) {
// this.type = 1;
// this.afAuth.authState.subscribe(user => {
......@@ -72,10 +74,11 @@ export class UpdateService {
this.service
.set('userData', JSON.stringify(updateOldData))
.then(res => {
this.subject.sendUserData(JSON.stringify(updateOldData));
console.log('success', updateOldData, res);
this.service
.showToast('Profile updated!', 'top', 'my-toast', 1000)
.then(res => {
.then(() => {
this.router.navigateByUrl('profile');
this.loader = false;
});
......@@ -91,7 +94,7 @@ export class UpdateService {
updatePassword(currentPassword: string, newPasswd: string) {
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
const credential = auth.EmailAuthProvider.credential(
currentUser.email,
......@@ -108,7 +111,7 @@ export class UpdateService {
console.log('password changed');
this.loader = false;
this.service
.showToast('Password Changed!', 'top', 'my-toast', 1000) //success toast
.showToast('Password Changed!', 'top', 'my-toast', 1000) // success toast
.then(res => {
this.router.navigateByUrl('profile');
this.loader = false;
......@@ -117,7 +120,7 @@ export class UpdateService {
.catch(error => {
console.log('something fishy');
this.service
.showToast('Something went wrong', 'top', 'my-toast', 1000) //failure toast
.showToast('Something went wrong', 'top', 'my-toast', 1000) // failure toast
.then(res => {
this.loader = false;
});
......@@ -126,7 +129,7 @@ export class UpdateService {
.catch(error => {
console.log(error);
this.service
.showToast(error.message, 'top', 'my-error', 3000) //failure toast
.showToast(error.message, 'top', 'my-error', 3000) // failure toast
.then(res => {
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