Commit 50d00c38 by Adarsh K

file

parent c8241e3e
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
<ion-menu> <ion-menu>
<ion-content> <ion-content>
<div class="side_menu_wrapper"> <div class="side_menu_wrapper">
<ion-menu-toggle> <ion-menu-toggle *ngIf="userData">
<div class="top_banner"> <div class="top_banner">
<div class="top_image"></div> <div class="top_image"></div>
<div class="top_detail"> <div class="top_detail">
<h4>John Doe</h4> <h4>{{userData.name}}</h4>
<p>[email protected]</p> <p>{{userData.emailId}}</p>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
class="icon_sec m6_icon" class="icon_sec m6_icon"
[class.m6_icon_act]="sec_active6" [class.m6_icon_act]="sec_active6"
(click)="setActive6()" (click)="setActive6()"
></div> menuClose></div>
</li> </li>
</ul> </ul>
</div> </div>
...@@ -3,7 +3,11 @@ import { Router, ActivatedRoute } from '@angular/router'; ...@@ -3,7 +3,11 @@ import { Router, ActivatedRoute } from '@angular/router';
import { Platform, Events } from '@ionic/angular'; import { Platform, Events } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx'; import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore'; import {
AngularFirestore,
AngularFirestoreDocument,
AngularFirestoreCollection
} from '@angular/fire/firestore';
import * as firebase from 'firebase'; import * as firebase from 'firebase';
import { ModalController } from '@ionic/angular'; import { ModalController } from '@ionic/angular';
import { DeliverypopPage } from './deliverypop/deliverypop.page'; import { DeliverypopPage } from './deliverypop/deliverypop.page';
...@@ -13,8 +17,6 @@ import { SubjectService } from './../config/subject.service'; ...@@ -13,8 +17,6 @@ import { SubjectService } from './../config/subject.service';
import { CategoriesService } from './../config/category.service'; import { CategoriesService } from './../config/category.service';
import { SearchmodalPage } from './searchmodal/searchmodal.page'; import { SearchmodalPage } from './searchmodal/searchmodal.page';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
templateUrl: 'app.component.html', templateUrl: 'app.component.html',
...@@ -30,6 +32,7 @@ export class AppComponent { ...@@ -30,6 +32,7 @@ export class AppComponent {
state: boolean; state: boolean;
menuw: number; menuw: number;
userData: any;
constructor( constructor(
private platform: Platform, private platform: Platform,
...@@ -46,10 +49,19 @@ export class AppComponent { ...@@ -46,10 +49,19 @@ export class AppComponent {
) { ) {
this.state = true; this.state = true;
this.initializeApp(); this.initializeApp();
this.orderState();
this.subjectService.getLoginData().subscribe(loginData => { this.subjectService.getLoginData().subscribe(loginData => {
this.state = loginData; this.state = loginData;
}); });
this.service.get('userData').then(userData => {
if (userData) {
this.userData = JSON.parse(userData);
console.log(userData);
this.orderState();
} else {
console.log(userData);
}
});
} }
initializeApp() { initializeApp() {
...@@ -70,7 +82,13 @@ export class AppComponent { ...@@ -70,7 +82,13 @@ export class AppComponent {
} }
fetchCase() { fetchCase() {
const restrictedUrl = ['productdetail', 'cart', 'nearby', 'verification']; const restrictedUrl = [
'productdetail',
'cart',
'nearby',
'verification',
'orderplaced'
];
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]);
// console.log(currentUrl[1], index, this.state); // console.log(currentUrl[1], index, this.state);
...@@ -137,8 +155,7 @@ export class AppComponent { ...@@ -137,8 +155,7 @@ export class AppComponent {
} }
orderState() { orderState() {
console.log('called'); const custId = this.userData.uid;
const custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2';
firebase firebase
.firestore() .firestore()
.collection('orders') .collection('orders')
......
...@@ -16,6 +16,7 @@ import { AngularFireModule } from '@angular/fire'; ...@@ -16,6 +16,7 @@ import { AngularFireModule } from '@angular/fire';
import { AngularFirestore } from '@angular/fire/firestore'; import { AngularFirestore } from '@angular/fire/firestore';
import { AngularFirestoreModule } from '@angular/fire/firestore'; import { AngularFirestoreModule } from '@angular/fire/firestore';
import { AngularFireAuthModule } from '@angular/fire/auth'; import { AngularFireAuthModule } from '@angular/fire/auth';
import { AngularFireStorageModule } from '@angular/fire/storage';
import { Geolocation } from '@ionic-native/geolocation/ngx'; import { Geolocation } from '@ionic-native/geolocation/ngx';
import { NativeGeocoder } from '@ionic-native/native-geocoder/ngx'; import { NativeGeocoder } from '@ionic-native/native-geocoder/ngx';
...@@ -41,6 +42,7 @@ import { SearchmodalPageModule } from './searchmodal/searchmodal.module'; ...@@ -41,6 +42,7 @@ import { SearchmodalPageModule } from './searchmodal/searchmodal.module';
DeliverypopPageModule, DeliverypopPageModule,
AngularFireAuthModule, AngularFireAuthModule,
AngularFirestoreModule, AngularFirestoreModule,
AngularFireStorageModule,
SearchmodalPageModule, SearchmodalPageModule,
FormsModule FormsModule
], ],
......
<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()"></button>
</button>
<div class="nav_title floatLeft"> <div class="nav_title floatLeft">
<h4>MY ORDERS</h4> <h4>MY ORDERS</h4>
</div> </div>
...@@ -12,32 +11,50 @@ ...@@ -12,32 +11,50 @@
<li *ngFor="let order of myorder.orders; let i = index"> <li *ngFor="let order of myorder.orders; let i = index">
<div class="order_info"> <div class="order_info">
<h5 class="floatLeft">{{order.orderCode}}</h5> <h5 class="floatLeft">{{order.orderCode}}</h5>
<button class="order_track floatRight" *ngIf="order.orderStatus >= 3 && order.orderStatus < 7" (click)="orderDetails(i)">Track Order</button> <button
class="order_track floatRight"
*ngIf="order.orderStatus >= 3 && order.orderStatus < 7"
(click)="orderDetails(i)"
>
Track Order
</button>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<div *ngFor="let product of order.product" (click)="viewOrder(order)"> <div *ngFor="let product of order.product" (click)="viewOrder(order)">
<div class="order_image"><img [src]="product.image" onerror="" /></div> <div class="order_image">
<img [src]="product.image" onerror="" />
</div>
<div class="order_detail"> <div class="order_detail">
<h5 class="floatLeft">{{product.prodName}}</h5> <h5 class="floatLeft">{{product.prodName}}</h5>
<div class="clear"></div> <div class="clear"></div>
<h5>{{product.color}}, {{product.size}} <span>{{product.qty}}</span></h5> <h5>
<span *ngIf="product.color !== 'No-Color'"
>{{product.color}},
</span>
<span *ngIf="product.size !== 'Any-Size'">{{product.size}}</span
>&nbsp;<span>{{product.qty}}</span>
</h5>
<p>A$ {{product.price}}</p> <p>A$ {{product.price}}</p>
</div> </div>
<div class="order_other"> <div class="order_other">
<h6 class="floatRight">{{ order.bookDate.seconds * 1000 | date:'MMMM dd, y' }}</h6> <h6 class="floatRight">
<span class="floatRight" *ngIf="order.orderStatus < 3 || order.orderStatus >= 7" (click)="acceptOrder(order)">{{getStatus(order.orderStatus)}}</span> {{ order.bookDate.seconds * 1000 | date:'MMMM dd, y' }}
</h6>
<span
class="floatRight"
*ngIf="order.orderStatus < 3 || order.orderStatus >= 7"
(click)="acceptOrder(order)"
>{{getStatus(order.orderStatus)}}</span
>
<div class="clear"></div> <div class="clear"></div>
<!-- <button class="track_btn" *ngIf="order.orderStatus >= 3 && order.orderStatus < 7" (click)="orderDetails(i)">TRACK</button> --> <!-- <button class="track_btn" *ngIf="order.orderStatus >= 3 && order.orderStatus < 7" (click)="orderDetails(i)">TRACK</button> -->
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
<hr> <hr />
</div> </div>
<div class="order_info"> <div class="order_info">
<h5 class="floatRight">TOTAL PRICE : {{order.amount}}</h5> <h5 class="floatRight">TOTAL PRICE : {{order.amount}}</h5>
......
...@@ -3,21 +3,19 @@ ...@@ -3,21 +3,19 @@
<div class="cart_head"> <div class="cart_head">
<div class="nav_header"> <div class="nav_header">
<button class="nav_btn nav_back_white floatLeft" (click)="goBack()"> <button class="nav_btn nav_back_white floatLeft" (click)="goBack()">
<img src="../assets/arrow_white.png"> <img src="../assets/arrow_white.png" />
</button> </button>
<div class="nav_title floatLeft"> <div class="nav_title floatLeft">
<h4></h4> <h4></h4>
</div> </div>
<button class="nav_btn floatRight"> <button class="nav_btn floatRight"></button>
</button>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<img src="../assets/white_tick.png"> <img src="../assets/white_tick.png" />
<h4>ORDER IS PLACED</h4> <h4>ORDER IS PLACED</h4>
<p>{{ data.bookDate.seconds * 1000 | date:'MMMM dd, y' }}</p> <p>{{ data.bookDate.seconds * 1000 | date:'MMMM dd, y' }}</p>
</div> </div>
<div class="order_status"> <div class="order_status">
<div class="clear"></div> <div class="clear"></div>
<div class="status_div go_green"> <div class="status_div go_green">
<h4>Order Placed</h4> <h4>Order Placed</h4>
...@@ -61,33 +59,48 @@ ...@@ -61,33 +59,48 @@
<ul> <ul>
<li (click)="goToPage('productlist')"> <li (click)="goToPage('productlist')">
<div class="nearby_image"> <div class="nearby_image">
<img src="../assets/[email protected]"> <img
[src]="data.product[0].image"
onerror="this.src='../assets/[email protected]'"
/>
</div> </div>
<div class="nearby_detail"> <div class="nearby_detail">
<h5> <h5>
<span class="floatLeft">{{data.shopperName}}</span> <span class="floatLeft">{{data.shopperName}}</span>
<span class="floatRight">0 <span class="floatRight"
<img src="../assets/Path61_2.png"> >{{data.product[0].qty}}
<img src="../assets/Path61_2.png" />
</span> </span>
<div class="clear"></div> <div class="clear"></div>
</h5> </h5>
<p>Men's & Women's Fashion</p> <p class="prodName">{{data.product[0].prodName}}</p>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</li> </li>
</ul> </ul>
</div> </div>
<div class="product_detail" *ngFor="let product of data.product"> <div class="product_detail" *ngFor="let product of data.product">
<h6>{{product.color}}, {{product.size}}</h6> <h6>
<span *ngIf="product.color !== 'No-Color'">{{product.color}}, </span>
<span *ngIf="product.size !== 'Any-Size'">{{product.size}}</span>
</h6>
<h5>Quantity : <span>{{product.qty}}</span></h5> <h5>Quantity : <span>{{product.qty}}</span></h5>
<h5>Amount : <strong>A$ {{product.price}}</strong><span class="afterpay">COD</span></h5>
<h5>Delivery time : <span>Delivery in 1 hour</span></h5>
<h4>DELIVERY</h4>
<h5> <h5>
{{deliveryAddress}} Amount : <strong>A$ {{product.price}}</strong
><span class="afterpay">COD</span>
</h5> </h5>
<button class="cancel_btn" (click)="goToPage('ordercancelled')">CANCEL THIS ORDER</button> <h5>Delivery time : <span>{{deliveryTime}}</span></h5>
<hr> <h4>DELIVERY</h4>
<h5 *ngIf="data.deliveryAddress">
{{data.deliveryAddress.addressType}},<br />{{data.deliveryAddress.address}},
<br />
{{data.deliveryAddress.building}}, <br />
{{data.deliveryAddress.landmark}}
</h5>
<button class="cancel_btn" (click)="goToPage('ordercancelled')">
CANCEL THIS ORDER
</button>
<hr />
</div> </div>
<!-- <div class="related_product_slider"> <!-- <div class="related_product_slider">
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
width: 100%; width: 100%;
height: 240px; height: 240px;
text-align: center; text-align: center;
background-image: url("../../assets/[email protected]"); background-image: url('../../assets/[email protected]');
background-position: center bottom; background-position: center bottom;
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: cover; background-size: cover;
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
background-color: transparent; background-color: transparent;
.nav_title { .nav_title {
h4 { h4 {
color: #FFF; color: #fff;
} }
} }
} }
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
border-radius: 5px; border-radius: 5px;
height: 40px; height: 40px;
background-color: #29285b; background-color: #29285b;
color: #FFF; color: #fff;
font-size: 18px; font-size: 18px;
font-weight: lighter; font-weight: lighter;
padding-left: 20px; padding-left: 20px;
...@@ -164,7 +164,7 @@ ...@@ -164,7 +164,7 @@
height: 45px; height: 45px;
width: 100%; width: 100%;
background-color: #29285b; background-color: #29285b;
color: #FFF; color: #fff;
font-size: 18px; font-size: 18px;
font-weight: lighter; font-weight: lighter;
padding-left: 20px; padding-left: 20px;
...@@ -220,7 +220,7 @@ ...@@ -220,7 +220,7 @@
font-size: 27px; font-size: 27px;
width: 30px; width: 30px;
height: 30px; height: 30px;
background-image: url("../../assets/Group32_2.png"); background-image: url('../../assets/Group32_2.png');
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 24px; background-size: 24px;
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
span { span {
text-decoration: line-through; text-decoration: line-through;
margin-left: 10px; margin-left: 10px;
color: rgba(215, 213, 228, 1) color: rgba(215, 213, 228, 1);
} }
.offer { .offer {
color: #fff; color: #fff;
...@@ -269,3 +269,10 @@ ...@@ -269,3 +269,10 @@
} }
} }
} }
.prodName {
white-space: nowrap;
width: 200px;
overflow: hidden;
text-overflow: ellipsis;
}
...@@ -6,29 +6,58 @@ import { ServiceService } from './../../config/service.service'; ...@@ -6,29 +6,58 @@ import { ServiceService } from './../../config/service.service';
@Component({ @Component({
selector: 'app-orderplaced', selector: 'app-orderplaced',
templateUrl: './orderplaced.page.html', templateUrl: './orderplaced.page.html',
styleUrls: ['./orderplaced.page.scss'], styleUrls: ['./orderplaced.page.scss']
}) })
export class OrderplacedPage implements OnInit { export class OrderplacedPage implements OnInit {
data: any; deliveryTime: any;
timeinterval: any;
constructor( constructor(
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private location: Location, private location: Location,
private service: ServiceService private service: ServiceService
) { ) {
this.deliveryTime = '';
this.service.get('order').then(val => { this.service.get('order').then(val => {
this.data = val; this.data = val;
this.timeinterval = setInterval(() => {
this.getDeliveryTime(this.data.bookDate.seconds);
}, 1000);
}); });
}
ngOnInit() {
} }
data: any;
relatedProd = { relatedProd = {
slidesPerView: 2 slidesPerView: 2
};
getDeliveryTime(timeStamp) {
console.log(timeStamp);
const endDate = new Date(timeStamp * 1000);
console.log(endDate);
endDate.setHours(endDate.getHours() + 1);
const t = this.getTimeRemaining(endDate, new Date());
const minutes = t.minutes < 10 ? '0' + t.minutes : t.minutes;
const seconds = t.seconds < 10 ? '0' + t.seconds : t.seconds;
this.deliveryTime = minutes + ' : ' + seconds;
if (t.t <= 0) {
clearInterval(this.timeinterval);
}
}
getTimeRemaining(endtime, currDate) {
const t = Date.parse(endtime) - Date.parse(currDate);
const seconds = Math.floor((t / 1000) % 60);
const minutes = Math.floor((t / 1000 / 60) % 60);
return {
t,
minutes,
seconds
};
} }
ngOnInit() {}
goToPage(path, data = null) { goToPage(path, data = null) {
this.router.navigateByUrl(path, { queryParams: data }); this.router.navigateByUrl(path, { queryParams: data });
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
...@@ -37,5 +66,4 @@ export class OrderplacedPage implements OnInit { ...@@ -37,5 +66,4 @@ export class OrderplacedPage implements OnInit {
goBack() { goBack() {
this.location.back(); this.location.back();
} }
} }
...@@ -8,13 +8,23 @@ ...@@ -8,13 +8,23 @@
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<ion-content> <ion-content>
<div class="profile_wrapper"> <div class="profile_wrapper" *ngIf="loggedUser">
<div class="profile_banner"> <div class="profile_banner">
<!-- <div class="profile_circle">
<div class="edit"></div>
</div> -->
<div class="profile_circle"> <div class="profile_circle">
<img
[src]="loggedUser.profilePhoto"
onerror="this.src='./../../assets/profile_banner.png'"
/>
<div class="edit"></div> <div class="edit"></div>
<input type="file" accept="image/*" (change)="fileChange($event)" />
</div> </div>
<h5>{{user && user.name}}</h5>
<p>LOGOUT</p> <h5>{{loggedUser.name}}</h5>
<p (click)="authService.SignOut()">LOGOUT</p>
</div> </div>
<div class="account_wrapper"> <div class="account_wrapper">
<div class="account_header"> <div class="account_header">
...@@ -30,13 +40,15 @@ ...@@ -30,13 +40,15 @@
<ion-row> <ion-row>
<ion-col class="textLeft p0"> <ion-col class="textLeft p0">
<p> <p>
Name<span Phone
>{{user && phoneVerified? "Verified": "Not Verified yet"}}</span <span *ngIf="loggedUser.phoneVerified == true">Verified</span>
<span *ngIf="loggedUser.phoneVerified == false"
>Not Verified yet</span
> >
</p> </p>
</ion-col> </ion-col>
<ion-col class="textRight p0"> <ion-col class="textRight p0">
<h6>{{user && user.name}}</h6> <h6>{{loggedUser.phone}}</h6>
</ion-col> </ion-col>
</ion-row> </ion-row>
</div> </div>
...@@ -44,13 +56,16 @@ ...@@ -44,13 +56,16 @@
<ion-row> <ion-row>
<ion-col class="textLeft p0"> <ion-col class="textLeft p0">
<p> <p>
Email<span Email<span *ngIf="userData && userData.emailVerified == true"
>{{user && emailVerified? "Verified": "Not Verified yet"}}</span >Verified</span
>
<span *ngIf="loggedUser.emailVerified == false"
>Not Verified yet</span
> >
</p> </p>
</ion-col> </ion-col>
<ion-col class="textRight p0"> <ion-col class="textRight p0">
<h6>{{user && user.emailId}}</h6> <h6>{{loggedUser.emailId}}</h6>
</ion-col> </ion-col>
</ion-row> </ion-row>
</div> </div>
...@@ -88,7 +103,7 @@ ...@@ -88,7 +103,7 @@
<ion-col class="textLeft p0"> <ion-col class="textLeft p0">
<p>My Order</p> <p>My Order</p>
</ion-col> </ion-col>
<ion-col class="textRight p0"> <ion-col class="textRight p0" (click)="goToPage('myorder')">
<h6> <h6>
<ion-icon name="arrow-forward"></ion-icon> <ion-icon name="arrow-forward"></ion-icon>
</h6> </h6>
......
.profile_wrapper { .profile_wrapper {
.profile_banner { .profile_banner {
width: 100%; width: 100%;
background-image: url("../../assets/profile_banner.png"); background-image: url('../../assets/profile_banner.png');
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: cover; background-size: cover;
...@@ -21,6 +21,17 @@ ...@@ -21,6 +21,17 @@
object-position: center; object-position: center;
border-radius: 50%; border-radius: 50%;
} }
input {
width: 80px;
height: 100%;
opacity: 0;
cursor: pointer;
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
}
.edit { .edit {
width: 30px; width: 30px;
height: 30px; height: 30px;
...@@ -28,7 +39,7 @@ ...@@ -28,7 +39,7 @@
object-fit: cover; object-fit: cover;
object-position: center; object-position: center;
background-color: #000; background-color: #000;
background-image: url("../../assets/edit_icon.png"); background-image: url('../../assets/edit_icon.png');
background-size: cover; background-size: cover;
cursor: pointer; cursor: pointer;
position: absolute; position: absolute;
...@@ -95,7 +106,7 @@ ...@@ -95,7 +106,7 @@
padding-bottom: 20px; padding-bottom: 20px;
} }
hr { hr {
border-bottom: 1px solid rgba(176, 174, 199, .5); border-bottom: 1px solid rgba(176, 174, 199, 0.5);
height: 0px; height: 0px;
border-top: none; border-top: none;
margin-top: 15px; margin-top: 15px;
......
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 { Router, ActivatedRoute } from "@angular/router"; import { AuthService } from '../../config/auth.service';
import { Router, ActivatedRoute } from '@angular/router';
import { finalize, tap } from 'rxjs/operators';
import {
AngularFireStorage,
AngularFireStorageReference,
AngularFireUploadTask
} from '@angular/fire/storage';
import {
AngularFirestore,
AngularFirestoreDocument,
AngularFirestoreCollection
} from '@angular/fire/firestore';
@Component({ @Component({
selector: "app-profile", selector: 'app-profile',
templateUrl: "./profile.page.html", templateUrl: './profile.page.html',
styleUrls: ["./profile.page.scss"] styleUrls: ['./profile.page.scss']
}) })
export class ProfilePage implements OnInit { export class ProfilePage implements OnInit {
user: User; user: User;
userdata: any; userdata: any;
custId: String; custId: string;
userData: any;
loggedUser: any;
ref: AngularFireStorageReference;
downloadURL;
constructor( constructor(
private router: Router, private router: Router,
private storage: AngularFireStorage,
private useService: UserService, private useService: UserService,
private service: ServiceService private service: ServiceService,
private authService: AuthService
) { ) {
const params = this.useService.users; this.service.get('user').then(data => {
const userdata = this.service.get("user").then(data => {
if (data) { if (data) {
data = JSON.parse(data); this.userData = JSON.parse(data);
this.service.set("params", data); console.log(this.userData);
this.custId = data.uid;
} }
}); });
this.useService.getUserData("9cYSZwGvVpgkUHVcz8Dm6oqGX152"); this.service.get('userData').then(data => {
if (data) {
// .then(res => { this.loggedUser = JSON.parse(data);
// console.log("asdasda", res); }
// this.userdata = res; });
// });
} }
goToPage(path, data = null) { goToPage(path, data = null) {
...@@ -43,11 +57,48 @@ export class ProfilePage implements OnInit { ...@@ -43,11 +57,48 @@ export class ProfilePage implements OnInit {
} }
ngOnInit() { ngOnInit() {
let This = this; const This = this;
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);
} }
async fileChange(event) {
const fileList: FileList = event.target.files;
if (fileList.length > 0) {
const reader = new FileReader();
let profilePic;
reader.onload = (events: any) => {
profilePic = events.target.result;
this.loggedUser.profilePhoto = events.target.result;
};
profilePic = event.target.result;
reader.readAsDataURL(event.target.files[0]);
const file = fileList[0];
const ext = file.name.split('.').pop();
if (ext === 'jpg' || ext === 'jpeg' || ext === 'png') {
const path = file.name; // + Date.now();
const ref = this.storage.ref(path);
const task = this.storage
.upload(path, file)
.snapshotChanges()
.pipe(
finalize(() => {
ref.getDownloadURL().subscribe(url => {
this.authService.profilePic(url);
});
})
)
.subscribe();
// this.downloadURL = await ref.getDownloadURL().toPromise();
// console.log(this.downloadURL);
}
}
}
} }
...@@ -3,7 +3,11 @@ import { User, Signup, Address } from './services/user'; ...@@ -3,7 +3,11 @@ 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 { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore'; import {
AngularFirestore,
AngularFirestoreDocument,
AngularFirestoreCollection
} 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';
...@@ -14,10 +18,6 @@ import { from } from 'rxjs'; ...@@ -14,10 +18,6 @@ import { from } from 'rxjs';
providedIn: 'root' providedIn: 'root'
}) })
export class AuthService { export class AuthService {
userData: any;
type: number;
userPostData: any;
constructor( constructor(
public afs: AngularFirestore, public afs: AngularFirestore,
public afAuth: AngularFireAuth, public afAuth: AngularFireAuth,
...@@ -33,6 +33,7 @@ export class AuthService { ...@@ -33,6 +33,7 @@ export class AuthService {
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);
if (this.type === 1) { if (this.type === 1) {
this.router.navigateByUrl('home'); this.router.navigateByUrl('home');
} else { } else {
...@@ -47,12 +48,25 @@ export class AuthService { ...@@ -47,12 +48,25 @@ export class AuthService {
}); });
} }
get isLoggedIn(): boolean {
const user = JSON.parse(localStorage.getItem('user'));
return user !== null && user.emailVerified !== false ? true : false;
}
userData: any;
type: number;
userPostData: any;
loggedUser: any;
public asyc;
public async SignIn(email: string, password: string) { public async SignIn(email: string, password: string) {
return this.afAuth.auth.signInWithEmailAndPassword(email, password).then((result) => { return this.afAuth.auth
.signInWithEmailAndPassword(email, password)
.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);
}).catch((error) => { })
.catch(error => {
window.alert(error.message); window.alert(error.message);
}); });
} }
...@@ -61,49 +75,66 @@ export class AuthService { ...@@ -61,49 +75,66 @@ export class AuthService {
console.log(this.userData.uid, otp); console.log(this.userData.uid, otp);
// 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('customers', ref => ref.where('otp', '==', otp) const custRef: AngularFirestoreCollection<any> = this.afs.collection(
.where('uid', '==', this.userData.uid) 'customers',
ref => ref.where('otp', '==', otp).where('uid', '==', this.userData.uid)
); );
custRef.valueChanges().pipe(take(1)).subscribe((value: User[]) => { custRef
.valueChanges()
.pipe(take(1))
.subscribe((value: User[]) => {
if (value.length > 0) { if (value.length > 0) {
this.afs.collection('customers').doc(this.userData.uid).update({otp: ''}); this.afs
.collection('customers')
.doc(this.userData.uid)
.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) {
this.afs
.collection('customers')
.doc(this.userData.uid)
.update({ profilePhoto: pic });
}
public async google(type: number) { public async google(type: number) {
this.type = type; this.type = type;
// this.googlePlus.login({}).then(res => console.log(res)).catch(err => console.error(err)); // this.googlePlus.login({}).then(res => console.log(res)).catch(err => console.error(err));
this.afAuth.auth.signInWithPopup(new auth.GoogleAuthProvider()).then((result) => { this.afAuth.auth
.signInWithPopup(new auth.GoogleAuthProvider())
.then(result => {
console.log('success'); console.log('success');
console.log(result); console.log(result.additionalUserInfo.isNewUser);
if (
result.additionalUserInfo &&
result.additionalUserInfo.isNewUser === true
) {
this.socialSignUp(result); this.socialSignUp(result);
}
}); });
} }
public async facebook(type: number) { public async facebook(type: number) {
this.type = type; this.type = type;
this.afAuth.auth.signInWithPopup(new auth.FacebookAuthProvider()).then((result) => { this.afAuth.auth
.signInWithPopup(new auth.FacebookAuthProvider())
.then(result => {
console.log('success'); console.log('success');
console.log(result); console.log(result);
}); });
} }
get isLoggedIn(): boolean {
const user = JSON.parse(localStorage.getItem('user'));
return(user !== null && user.emailVerified !== false) ? true : false;
}
SetUserData(user: any) { SetUserData(user: any) {
const userRef: AngularFirestoreDocument<any> = this.afs.doc(
const userRef: AngularFirestoreDocument<any> = this.afs.doc(`customers/${user.uid}`); `customers/${user.uid}`
userRef.valueChanges().subscribe((value) => { );
userRef.valueChanges().subscribe(value => {
const userData: User = { const userData: User = {
uid: value.uid, uid: value.uid,
emailId: value.emailId, emailId: value.emailId,
...@@ -117,7 +148,9 @@ export class AuthService { ...@@ -117,7 +148,9 @@ export class AuthService {
otp: value.otp, otp: value.otp,
loginType: value.loginType loginType: value.loginType
}; };
console.log(userData); this.loggedUser = userData;
this.service.set('userData', JSON.stringify(this.loggedUser));
console.log(this.loggedUser);
}); });
} }
...@@ -154,7 +187,11 @@ export class AuthService { ...@@ -154,7 +187,11 @@ export class AuthService {
}; };
this.userPostData = postData; this.userPostData = postData;
console.log(postData); console.log(postData);
this.afs.collection('customers').doc(userData.uid).set(postData).then(() => { this.afs
.collection('customers')
.doc(userData.uid)
.set(postData)
.then(() => {
console.log('successs'); console.log('successs');
}); });
} }
...@@ -163,7 +200,9 @@ export class AuthService { ...@@ -163,7 +200,9 @@ export class AuthService {
this.type = 2; this.type = 2;
console.log(userData); console.log(userData);
const otp = Math.floor(1000 + Math.random() * 9000); const otp = Math.floor(1000 + Math.random() * 9000);
this.afAuth.auth.createUserWithEmailAndPassword(userData.emailId, userData.password).then((result) => { this.afAuth.auth
.createUserWithEmailAndPassword(userData.emailId, userData.password)
.then(result => {
console.log(result.user); console.log(result.user);
this.afAuth.auth.currentUser.sendEmailVerification(); this.afAuth.auth.currentUser.sendEmailVerification();
const currencyData = { const currencyData = {
...@@ -187,10 +226,15 @@ export class AuthService { ...@@ -187,10 +226,15 @@ export class AuthService {
}; };
this.userPostData = postData; this.userPostData = postData;
console.log(postData); console.log(postData);
this.afs.collection('customers').doc(custData.uid).set(postData).then(() => { this.afs
.collection('customers')
.doc(custData.uid)
.set(postData)
.then(() => {
console.log('successs'); console.log('successs');
}); });
}).catch((error) => { })
.catch(error => {
window.alert(error.message); window.alert(error.message);
}); });
} }
...@@ -199,9 +243,12 @@ export class AuthService { ...@@ -199,9 +243,12 @@ export class AuthService {
console.log(addressData); console.log(addressData);
console.log(this.userData.uid); console.log(this.userData.uid);
this.afs.collection('address').add({ this.afs
.collection('address')
.add({
uid: this.userData.uid uid: this.userData.uid
}).then((docRef) => { })
.then(docRef => {
console.log(docRef); console.log(docRef);
const addrData = { const addrData = {
uid: this.userData.uid, uid: this.userData.uid,
...@@ -220,7 +267,11 @@ export class AuthService { ...@@ -220,7 +267,11 @@ export class AuthService {
}; };
const neworderId = docRef.id; const neworderId = docRef.id;
console.log(addrData); console.log(addrData);
this.afs.collection('address').doc(neworderId).set(addrData).then(() => { this.afs
.collection('address')
.doc(neworderId)
.set(addrData)
.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');
...@@ -231,14 +282,9 @@ export class AuthService { ...@@ -231,14 +282,9 @@ export class AuthService {
} }
} }
/*displayName: "Adarsh Techware" /*displayName: "Adarsh Techware"
email: "[email protected]" email: "[email protected]"
emailVerified: true emailVerified: true
: "https://lh4.googleusercontent.com/-h0rs2pE-Azw/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rcjNtapRhKoG09NKifQsv_lQPC_2A/photo.jpg" : "https://lh4.googleusercontent.com/-h0rs2pE-Azw/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rcjNtapRhKoG09NKifQsv_lQPC_2A/photo.jpg"
: "vT498Fz6X0Z6l5l5iNn5hxfwz692" : "vT498Fz6X0Z6l5l5iNn5hxfwz692"
providerData: [Gl]*/ providerData: [Gl]*/
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