Merge branch 'adarsh' into 'master'
file
See merge request !44
Showing
... | ... | @@ -3,12 +3,12 @@ |
<ion-menu> | ||
<ion-content> | ||
<div class="side_menu_wrapper"> | ||
<ion-menu-toggle> | ||
<ion-menu-toggle *ngIf="userData"> | ||
<div class="top_banner"> | ||
<div class="top_image"></div> | ||
<div class="top_detail"> | ||
<h4>John Doe</h4> | ||
<p>[email protected]</p> | ||
<h4>{{userData.name}}</h4> | ||
<p>{{userData.emailId}}</p> | ||
</div> | ||
<div class="clear"></div> | ||
</div> | ||
... | ... | @@ -95,7 +95,7 @@ |
class="icon_sec m6_icon" | ||
[class.m6_icon_act]="sec_active6" | ||
(click)="setActive6()" | ||
></div> | ||
menuClose></div> | ||
</li> | ||
</ul> | ||
</div> |
<ion-content> | ||
<div class="cart_wrapper" *ngIf="data"> | ||
<div class="cart_head"> | ||
<div class="nav_header"> | ||
<button class="nav_btn nav_back_white floatLeft" (click)="goBack()"> | ||
<img src="../assets/arrow_white.png"> | ||
<div class="cart_wrapper" *ngIf="data"> | ||
<div class="cart_head"> | ||
<div class="nav_header"> | ||
<button class="nav_btn nav_back_white floatLeft" (click)="goBack()"> | ||
<img src="../assets/arrow_white.png" /> | ||
</button> | ||
<div class="nav_title floatLeft"> | ||
<h4></h4> | ||
</div> | ||
<button class="nav_btn floatRight"> | ||
</button> | ||
<div class="clear"></div> | ||
</div> | ||
<img src="../assets/white_tick.png"> | ||
<h4>ORDER IS PLACED</h4> | ||
<p>{{ data.bookDate.seconds * 1000 | date:'MMMM dd, y' }}</p> | ||
<div class="nav_title floatLeft"> | ||
<h4></h4> | ||
</div> | ||
<div class="order_status"> | ||
<div class="clear"></div> | ||
<div class="status_div go_green"> | ||
<h4>Order Placed</h4> | ||
<h6>{{ data.bookDate.seconds * 1000 | date:'MMMM dd, y' }}</h6> | ||
</div> | ||
<!-- <div class="status_gap go_green"> | ||
<button class="nav_btn floatRight"></button> | ||
<div class="clear"></div> | ||
</div> | ||
<img src="../assets/white_tick.png" /> | ||
<h4>ORDER IS PLACED</h4> | ||
<p>{{ data.bookDate.seconds * 1000 | date:'MMMM dd, y' }}</p> | ||
</div> | ||
<div class="order_status"> | ||
<div class="clear"></div> | ||
<div class="status_div go_green"> | ||
<h4>Order Placed</h4> | ||
<h6>{{ data.bookDate.seconds * 1000 | date:'MMMM dd, y' }}</h6> | ||
</div> | ||
<!-- <div class="status_gap go_green"> | ||
</div> | ||
<div class="status_div go_green"> | ||
<h4>Retailer Accepted</h4> | ||
... | ... | @@ -56,41 +54,56 @@ |
<div class="status_div"> | ||
<h4>Your product is delivered</h4> | ||
</div> --> | ||
</div> | ||
<div class="nearby_shop_list"> | ||
<ul> | ||
<li (click)="goToPage('productlist')"> | ||
<div class="nearby_image"> | ||
<img src="../assets/[email protected]"> | ||
</div> | ||
<div class="nearby_detail"> | ||
<h5> | ||
<span class="floatLeft">{{data.shopperName}}</span> | ||
<span class="floatRight">0 | ||
<img src="../assets/Path61_2.png"> | ||
</span> | ||
<div class="clear"></div> | ||
</h5> | ||
<p>Men's & Women's Fashion</p> | ||
</div> | ||
<div class="clear"></div> | ||
</li> | ||
</ul> | ||
</div> | ||
<div class="product_detail" *ngFor="let product of data.product"> | ||
<h6>{{product.color}}, {{product.size}}</h6> | ||
<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> | ||
</div> | ||
<div class="nearby_shop_list"> | ||
<ul> | ||
<li (click)="goToPage('productlist')"> | ||
<div class="nearby_image"> | ||
<img | ||
[src]="data.product[0].image" | ||
onerror="this.src='../assets/[email protected]'" | ||
/> | ||
</div> | ||
<div class="nearby_detail"> | ||
<h5> | ||
{{deliveryAddress}} | ||
<span class="floatLeft">{{data.shopperName}}</span> | ||
<span class="floatRight" | ||
>{{data.product[0].qty}} | ||
<img src="../assets/Path61_2.png" /> | ||
</span> | ||
<div class="clear"></div> | ||
</h5> | ||
<button class="cancel_btn" (click)="goToPage('ordercancelled')">CANCEL THIS ORDER</button> | ||
<hr> | ||
</div> | ||
<p class="prodName">{{data.product[0].prodName}}</p> | ||
</div> | ||
<div class="clear"></div> | ||
</li> | ||
</ul> | ||
</div> | ||
<div class="product_detail" *ngFor="let product of data.product"> | ||
<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> | ||
Amount : <strong>A$ {{product.price}}</strong | ||
><span class="afterpay">COD</span> | ||
</h5> | ||
<h5>Delivery time : <span>{{deliveryTime}}</span></h5> | ||
<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 class="related_product_slider"> | ||
<!-- <div class="related_product_slider"> | ||
<h5> | ||
<span class="floatLeft">Related Products</span><span class="floatRight">MORE</span> | ||
<div class="clear"></div> | ||
... | ... | @@ -145,5 +158,5 @@ |
</ion-slides> | ||
</ul> | ||
</div> --> | ||
</div> | ||
</ion-content> | ||
\ No newline at end of file | ||
</div> | ||
</ion-content> |
.cart_wrapper { | ||
width: 100%; | ||
.cart_head { | ||
width: 100%; | ||
.cart_head { | ||
width: 100%; | ||
height: 240px; | ||
text-align: center; | ||
background-image: url("../../assets/[email protected]"); | ||
background-position: center bottom; | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
.nav_header { | ||
position: static; | ||
background-color: transparent; | ||
.nav_title { | ||
h4 { | ||
color: #FFF; | ||
} | ||
} | ||
} | ||
img { | ||
width: 70px; | ||
} | ||
height: 240px; | ||
text-align: center; | ||
background-image: url('../../assets/[email protected]'); | ||
background-position: center bottom; | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
.nav_header { | ||
position: static; | ||
background-color: transparent; | ||
.nav_title { | ||
h4 { | ||
color: #fff; | ||
font-weight: bolder; | ||
margin-bottom: 5px; | ||
text-align: center; | ||
} | ||
p { | ||
color: rgba(215, 213, 228, 1); | ||
margin: 0px; | ||
padding: 0px; | ||
font-size: 14px; | ||
text-align: center; | ||
color: #fff; | ||
} | ||
} | ||
} | ||
.order_status { | ||
width: 100%; | ||
padding: 20px; | ||
.track_btn { | ||
border-radius: 5px; | ||
height: 40px; | ||
background-color: #29285b; | ||
color: #FFF; | ||
font-size: 18px; | ||
font-weight: lighter; | ||
padding-left: 20px; | ||
padding-right: 20px; | ||
} | ||
.status_div { | ||
margin-bottom: 10px; | ||
margin-top: 10px; | ||
h4 { | ||
margin: 0px; | ||
padding: 0px; | ||
color: rgba(215, 213, 228, 1); | ||
} | ||
h6 { | ||
margin: 0px; | ||
padding: 0px; | ||
color: rgba(215, 213, 228, 1); | ||
} | ||
} | ||
.go_green { | ||
h4 { | ||
color: rgba(53, 203, 171, 1); | ||
} | ||
} | ||
.go_green.status_gap { | ||
border-left: 2px dashed rgba(53, 203, 171, 1); | ||
} | ||
.status_gap { | ||
border-left: 2px dashed rgba(215, 213, 228, 1); | ||
height: 30px; | ||
} | ||
img { | ||
width: 70px; | ||
} | ||
.nearby_shop_list { | ||
ul { | ||
margin: 0px; | ||
padding-left: 10px; | ||
padding-right: 10px; | ||
li { | ||
list-style: none; | ||
padding-bottom: 10px; | ||
.nearby_image { | ||
width: 120px; | ||
height: 120px; | ||
float: left; | ||
background-color: #a8a8a8; | ||
border-radius: 8px; | ||
img { | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
object-position: center; | ||
} | ||
} | ||
.nearby_detail { | ||
width: calc(100% - 120px); | ||
float: left; | ||
padding-left: 20px; | ||
padding-top: 40px; | ||
h5 { | ||
margin: 0px; | ||
padding: 0px; | ||
color: rgba(59, 57, 77, 1); | ||
font-weight: 900; | ||
padding-bottom: 2px; | ||
img { | ||
width: 16px; | ||
} | ||
} | ||
p { | ||
margin: 0px; | ||
padding: 0px; | ||
color: rgba(176, 174, 199); | ||
} | ||
} | ||
} | ||
} | ||
h4 { | ||
color: #fff; | ||
font-weight: bolder; | ||
margin-bottom: 5px; | ||
text-align: center; | ||
} | ||
.product_detail { | ||
padding: 10px; | ||
hr { | ||
border-bottom: 1px solid rgba(176, 174, 199); | ||
height: 0px; | ||
border-top: none; | ||
} | ||
h6 { | ||
margin: 0px; | ||
padding: 0px; | ||
color: #29285b; | ||
font-size: 18px; | ||
padding-bottom: 15px; | ||
p { | ||
color: rgba(215, 213, 228, 1); | ||
margin: 0px; | ||
padding: 0px; | ||
font-size: 14px; | ||
text-align: center; | ||
} | ||
} | ||
.order_status { | ||
width: 100%; | ||
padding: 20px; | ||
.track_btn { | ||
border-radius: 5px; | ||
height: 40px; | ||
background-color: #29285b; | ||
color: #fff; | ||
font-size: 18px; | ||
font-weight: lighter; | ||
padding-left: 20px; | ||
padding-right: 20px; | ||
} | ||
.status_div { | ||
margin-bottom: 10px; | ||
margin-top: 10px; | ||
h4 { | ||
margin: 0px; | ||
padding: 0px; | ||
color: rgba(215, 213, 228, 1); | ||
} | ||
h6 { | ||
margin: 0px; | ||
padding: 0px; | ||
color: rgba(215, 213, 228, 1); | ||
} | ||
} | ||
.go_green { | ||
h4 { | ||
color: rgba(53, 203, 171, 1); | ||
} | ||
} | ||
.go_green.status_gap { | ||
border-left: 2px dashed rgba(53, 203, 171, 1); | ||
} | ||
.status_gap { | ||
border-left: 2px dashed rgba(215, 213, 228, 1); | ||
height: 30px; | ||
} | ||
} | ||
.nearby_shop_list { | ||
ul { | ||
margin: 0px; | ||
padding-left: 10px; | ||
padding-right: 10px; | ||
li { | ||
list-style: none; | ||
padding-bottom: 10px; | ||
.nearby_image { | ||
width: 120px; | ||
height: 120px; | ||
float: left; | ||
background-color: #a8a8a8; | ||
border-radius: 8px; | ||
img { | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
object-position: center; | ||
} | ||
} | ||
h5 { | ||
.nearby_detail { | ||
width: calc(100% - 120px); | ||
float: left; | ||
padding-left: 20px; | ||
padding-top: 40px; | ||
h5 { | ||
margin: 0px; | ||
padding: 0px; | ||
color: rgba(176, 174, 199, 1); | ||
font-size: 18px; | ||
line-height: 25px; | ||
padding-bottom: 15px; | ||
strong { | ||
color: rgba(41, 40, 91, 1); | ||
} | ||
span { | ||
color: rgba(41, 40, 91, 1); | ||
} | ||
.afterpay { | ||
color: rgba(206, 153, 76, 1); | ||
padding-left: 10px; | ||
color: rgba(59, 57, 77, 1); | ||
font-weight: 900; | ||
padding-bottom: 2px; | ||
img { | ||
width: 16px; | ||
} | ||
} | ||
h4 { | ||
color: rgba(41, 40, 91, 1); | ||
} | ||
p { | ||
margin: 0px; | ||
font-weight: 900; | ||
font-size: 18px; | ||
padding-top: 20px; | ||
padding-bottom: 10px; | ||
padding: 0px; | ||
color: rgba(176, 174, 199); | ||
} | ||
} | ||
.cancel_btn { | ||
border-radius: 8px; | ||
height: 45px; | ||
} | ||
} | ||
} | ||
.product_detail { | ||
padding: 10px; | ||
hr { | ||
border-bottom: 1px solid rgba(176, 174, 199); | ||
height: 0px; | ||
border-top: none; | ||
} | ||
h6 { | ||
margin: 0px; | ||
padding: 0px; | ||
color: #29285b; | ||
font-size: 18px; | ||
padding-bottom: 15px; | ||
} | ||
h5 { | ||
margin: 0px; | ||
padding: 0px; | ||
color: rgba(176, 174, 199, 1); | ||
font-size: 18px; | ||
line-height: 25px; | ||
padding-bottom: 15px; | ||
strong { | ||
color: rgba(41, 40, 91, 1); | ||
} | ||
span { | ||
color: rgba(41, 40, 91, 1); | ||
} | ||
.afterpay { | ||
color: rgba(206, 153, 76, 1); | ||
padding-left: 10px; | ||
} | ||
} | ||
h4 { | ||
color: rgba(41, 40, 91, 1); | ||
margin: 0px; | ||
font-weight: 900; | ||
font-size: 18px; | ||
padding-top: 20px; | ||
padding-bottom: 10px; | ||
} | ||
.cancel_btn { | ||
border-radius: 8px; | ||
height: 45px; | ||
width: 100%; | ||
background-color: #29285b; | ||
color: #fff; | ||
font-size: 18px; | ||
font-weight: lighter; | ||
padding-left: 20px; | ||
padding-right: 20px; | ||
margin-bottom: 20px; | ||
margin-top: 20px; | ||
} | ||
} | ||
.related_product_slider { | ||
h5 { | ||
color: rgba(41, 40, 91, 1); | ||
margin: 0px; | ||
padding: 10px; | ||
font-weight: 900; | ||
font-size: 18px; | ||
} | ||
p { | ||
color: rgba(59, 57, 77, 1); | ||
padding: 10px; | ||
text-align: justify; | ||
margin: 0px; | ||
font-size: 18px; | ||
} | ||
ul { | ||
padding: 10px; | ||
padding-bottom: 0px; | ||
padding-top: 0px; | ||
margin: 0px; | ||
li { | ||
width: 100%; | ||
display: inline-block; | ||
border-top: none; | ||
border-bottom: none; | ||
margin-bottom: 10px; | ||
.product_image { | ||
height: 235px; | ||
position: relative; | ||
.featured_badge { | ||
position: absolute; | ||
top: 20px; | ||
left: 0px; | ||
color: #fff; | ||
background-color: rgba(41, 40, 91, 1); | ||
padding: 2px; | ||
padding-left: 10px; | ||
padding-right: 10px; | ||
font-size: 13px; | ||
} | ||
.fav_icon { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
font-size: 27px; | ||
width: 30px; | ||
height: 30px; | ||
background-image: url('../../assets/Group32_2.png'); | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
background-size: 24px; | ||
} | ||
img { | ||
width: 100%; | ||
background-color: #29285b; | ||
color: #FFF; | ||
font-size: 18px; | ||
font-weight: lighter; | ||
padding-left: 20px; | ||
padding-right: 20px; | ||
margin-bottom: 20px; | ||
margin-top: 20px; | ||
height: 100%; | ||
object-fit: cover; | ||
object-position: center; | ||
} | ||
} | ||
} | ||
.related_product_slider { | ||
h5 { | ||
color: rgba(41, 40, 91, 1); | ||
margin: 0px; | ||
padding: 10px; | ||
font-weight: 900; | ||
font-size: 18px; | ||
margin: 0px; | ||
padding: 0px; | ||
color: rgba(59, 57, 77, 1); | ||
padding-top: 5px; | ||
padding-bottom: 5px; | ||
font-weight: 500; | ||
text-align: left; | ||
font-size: 16px; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
p { | ||
color: rgba(59, 57, 77, 1); | ||
padding: 10px; | ||
text-align: justify; | ||
margin: 0px; | ||
font-size: 18px; | ||
} | ||
ul { | ||
padding: 10px; | ||
padding-bottom: 0px; | ||
padding-top: 0px; | ||
margin: 0px; | ||
li { | ||
width: 100%; | ||
display: inline-block; | ||
border-top: none; | ||
border-bottom: none; | ||
margin-bottom: 10px; | ||
.product_image { | ||
height: 235px; | ||
position: relative; | ||
.featured_badge { | ||
position: absolute; | ||
top: 20px; | ||
left: 0px; | ||
color: #fff; | ||
background-color: rgba(41, 40, 91, 1); | ||
padding: 2px; | ||
padding-left: 10px; | ||
padding-right: 10px; | ||
font-size: 13px; | ||
} | ||
.fav_icon { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
font-size: 27px; | ||
width: 30px; | ||
height: 30px; | ||
background-image: url("../../assets/Group32_2.png"); | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
background-size: 24px; | ||
} | ||
img { | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
object-position: center; | ||
} | ||
} | ||
h5 { | ||
margin: 0px; | ||
padding: 0px; | ||
color: rgba(59, 57, 77, 1); | ||
padding-top: 5px; | ||
padding-bottom: 5px; | ||
font-weight: 500; | ||
text-align: left; | ||
font-size: 16px; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
p { | ||
margin: 0px; | ||
padding: 0px; | ||
color: rgba(176, 174, 199, 1); | ||
font-size: 12px; | ||
text-align: left; | ||
span { | ||
text-decoration: line-through; | ||
margin-left: 10px; | ||
color: rgba(215, 213, 228, 1) | ||
} | ||
.offer { | ||
color: #fff; | ||
background-color: rgba(41, 40, 91, 1); | ||
border-radius: 4px; | ||
text-decoration: none; | ||
padding: 3px; | ||
font-size: 13px; | ||
} | ||
} | ||
} | ||
margin: 0px; | ||
padding: 0px; | ||
color: rgba(176, 174, 199, 1); | ||
font-size: 12px; | ||
text-align: left; | ||
span { | ||
text-decoration: line-through; | ||
margin-left: 10px; | ||
color: rgba(215, 213, 228, 1); | ||
} | ||
.offer { | ||
color: #fff; | ||
background-color: rgba(41, 40, 91, 1); | ||
border-radius: 4px; | ||
text-decoration: none; | ||
padding: 3px; | ||
font-size: 13px; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
\ No newline at end of file | ||
} | ||
} | ||
.prodName { | ||
white-space: nowrap; | ||
width: 200px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} |
... | ... | @@ -3,7 +3,11 @@ import { User, Signup, Address } from './services/user'; |
import { auth } from 'firebase/app'; | ||
import { Router, ActivatedRoute } from '@angular/router'; | ||
import { AngularFireAuth } from '@angular/fire/auth'; | ||
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore'; | ||
import { | ||
AngularFirestore, | ||
AngularFirestoreDocument, | ||
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'; | ||
... | ... | @@ -14,10 +18,6 @@ import { from } from 'rxjs'; |
providedIn: 'root' | ||
}) | ||
export class AuthService { | ||
userData: any; | ||
type: number; | ||
userPostData: any; | ||
constructor( | ||
public afs: AngularFirestore, | ||
public afAuth: AngularFireAuth, | ||
... | ... | @@ -26,84 +26,115 @@ export class AuthService { |
private subjectService: SubjectService, | ||
private googlePlus: GooglePlus | ||
) { | ||
this.type = 1; | ||
this.afAuth.authState.subscribe(user => { | ||
if (user) { | ||
this.subjectService.sendLoginData(false); | ||
this.userData = user; | ||
console.log(this.userData); | ||
this.service.set('user', JSON.stringify(this.userData)); | ||
if (this.type === 1) { | ||
this.router.navigateByUrl('home'); | ||
} else { | ||
this.router.navigateByUrl('verification'); | ||
} | ||
this.type = 1; | ||
this.afAuth.authState.subscribe(user => { | ||
if (user) { | ||
this.subjectService.sendLoginData(false); | ||
this.userData = user; | ||
console.log(this.userData); | ||
this.service.set('user', JSON.stringify(this.userData)); | ||
this.SetUserData(user); | ||
if (this.type === 1) { | ||
this.router.navigateByUrl('home'); | ||
} else { | ||
this.subjectService.sendLoginData(true); | ||
this.service.set('user', null); | ||
JSON.parse(localStorage.getItem('user')); | ||
this.router.navigateByUrl('login'); | ||
this.router.navigateByUrl('verification'); | ||
} | ||
}); | ||
} else { | ||
this.subjectService.sendLoginData(true); | ||
this.service.set('user', null); | ||
JSON.parse(localStorage.getItem('user')); | ||
this.router.navigateByUrl('login'); | ||
} | ||
}); | ||
} | ||
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) { | ||
return this.afAuth.auth.signInWithEmailAndPassword(email, password).then((result) => { | ||
console.log('success'); | ||
document.body.scrollTop = document.documentElement.scrollTop = 0; | ||
this.SetUserData(result.user); | ||
}).catch((error) => { | ||
window.alert(error.message); | ||
}); | ||
return this.afAuth.auth | ||
.signInWithEmailAndPassword(email, password) | ||
.then(result => { | ||
console.log('success'); | ||
document.body.scrollTop = document.documentElement.scrollTop = 0; | ||
this.SetUserData(result.user); | ||
}) | ||
.catch(error => { | ||
window.alert(error.message); | ||
}); | ||
} | ||
public async verify(otp: string) { | ||
console.log(this.userData.uid, otp); | ||
// tslint:disable-next-line:radix | ||
// const otpnew = parseInt(otp); | ||
const custRef: AngularFirestoreCollection<any> = this.afs.collection('customers', ref => ref.where('otp', '==', otp) | ||
.where('uid', '==', this.userData.uid) | ||
const custRef: AngularFirestoreCollection<any> = this.afs.collection( | ||
'customers', | ||
ref => ref.where('otp', '==', otp).where('uid', '==', this.userData.uid) | ||
); | ||
custRef.valueChanges().pipe(take(1)).subscribe((value: User[]) => { | ||
if (value.length > 0) { | ||
this.afs.collection('customers').doc(this.userData.uid).update({otp: ''}); | ||
this.service.set('type', 1); | ||
this.router.navigateByUrl('nearby'); | ||
} else { | ||
window.alert('Please input valid OTP'); | ||
} | ||
}); | ||
custRef | ||
.valueChanges() | ||
.pipe(take(1)) | ||
.subscribe((value: User[]) => { | ||
if (value.length > 0) { | ||
this.afs | ||
.collection('customers') | ||
.doc(this.userData.uid) | ||
.update({ otp: '', phoneVerified: true }); | ||
this.service.set('type', 1); | ||
this.router.navigateByUrl('nearby'); | ||
} else { | ||
window.alert('Please input valid OTP'); | ||
} | ||
}); | ||
} | ||
profilePic(pic) { | ||
this.afs | ||
.collection('customers') | ||
.doc(this.userData.uid) | ||
.update({ profilePhoto: pic }); | ||
} | ||
public async google(type: number) { | ||
this.type = type; | ||
// this.googlePlus.login({}).then(res => console.log(res)).catch(err => console.error(err)); | ||
this.afAuth.auth.signInWithPopup(new auth.GoogleAuthProvider()).then((result) => { | ||
console.log('success'); | ||
console.log(result); | ||
this.socialSignUp(result); | ||
}); | ||
this.afAuth.auth | ||
.signInWithPopup(new auth.GoogleAuthProvider()) | ||
.then(result => { | ||
console.log('success'); | ||
console.log(result.additionalUserInfo.isNewUser); | ||
if ( | ||
result.additionalUserInfo && | ||
result.additionalUserInfo.isNewUser === true | ||
) { | ||
this.socialSignUp(result); | ||
} | ||
}); | ||
} | ||
public async facebook(type: number) { | ||
this.type = type; | ||
this.afAuth.auth.signInWithPopup(new auth.FacebookAuthProvider()).then((result) => { | ||
console.log('success'); | ||
console.log(result); | ||
}); | ||
} | ||
get isLoggedIn(): boolean { | ||
const user = JSON.parse(localStorage.getItem('user')); | ||
return(user !== null && user.emailVerified !== false) ? true : false; | ||
this.afAuth.auth | ||
.signInWithPopup(new auth.FacebookAuthProvider()) | ||
.then(result => { | ||
console.log('success'); | ||
console.log(result); | ||
}); | ||
} | ||
SetUserData(user: any) { | ||
const userRef: AngularFirestoreDocument<any> = this.afs.doc(`customers/${user.uid}`); | ||
userRef.valueChanges().subscribe((value) => { | ||
const userRef: AngularFirestoreDocument<any> = this.afs.doc( | ||
`customers/${user.uid}` | ||
); | ||
userRef.valueChanges().subscribe(value => { | ||
const userData: User = { | ||
uid: value.uid, | ||
emailId: value.emailId, | ||
... | ... | @@ -116,8 +147,10 @@ export class AuthService { |
currency: value.currency, | ||
otp: value.otp, | ||
loginType: value.loginType | ||
}; | ||
console.log(userData); | ||
}; | ||
this.loggedUser = userData; | ||
this.service.set('userData', JSON.stringify(this.loggedUser)); | ||
console.log(this.loggedUser); | ||
}); | ||
} | ||
... | ... | @@ -139,7 +172,7 @@ export class AuthService { |
}; | ||
const otp = Math.floor(1000 + Math.random() * 9000); | ||
userData = userData.user; | ||
const postData: User = { | ||
const postData: User = { | ||
uid: userData.uid, | ||
status: true, | ||
profilePhoto: userData.photoURL, | ||
... | ... | @@ -154,91 +187,104 @@ export class AuthService { |
}; | ||
this.userPostData = postData; | ||
console.log(postData); | ||
this.afs.collection('customers').doc(userData.uid).set(postData).then(() => { | ||
console.log('successs'); | ||
}); | ||
this.afs | ||
.collection('customers') | ||
.doc(userData.uid) | ||
.set(postData) | ||
.then(() => { | ||
console.log('successs'); | ||
}); | ||
} | ||
signup(userData: Signup) { | ||
this.type = 2; | ||
console.log(userData); | ||
const otp = Math.floor(1000 + Math.random() * 9000); | ||
this.afAuth.auth.createUserWithEmailAndPassword(userData.emailId, userData.password).then((result) => { | ||
console.log(result.user); | ||
this.afAuth.auth.currentUser.sendEmailVerification(); | ||
const currencyData = { | ||
currId: '123', | ||
currName: 'Australian dollar', | ||
symbol: 'A$' | ||
}; | ||
const custData = result.user; | ||
const postData: User = { | ||
uid: custData.uid, | ||
status: true, | ||
profilePhoto: '', | ||
phoneVerified: false, | ||
phone: userData.phone, | ||
name: userData.name, | ||
emailVerified: false, | ||
emailId: userData.emailId, | ||
currency: currencyData, | ||
otp: otp.toString(), | ||
loginType: 0 | ||
}; | ||
this.userPostData = postData; | ||
console.log(postData); | ||
this.afs.collection('customers').doc(custData.uid).set(postData).then(() => { | ||
console.log('successs'); | ||
this.afAuth.auth | ||
.createUserWithEmailAndPassword(userData.emailId, userData.password) | ||
.then(result => { | ||
console.log(result.user); | ||
this.afAuth.auth.currentUser.sendEmailVerification(); | ||
const currencyData = { | ||
currId: '123', | ||
currName: 'Australian dollar', | ||
symbol: 'A$' | ||
}; | ||
const custData = result.user; | ||
const postData: User = { | ||
uid: custData.uid, | ||
status: true, | ||
profilePhoto: '', | ||
phoneVerified: false, | ||
phone: userData.phone, | ||
name: userData.name, | ||
emailVerified: false, | ||
emailId: userData.emailId, | ||
currency: currencyData, | ||
otp: otp.toString(), | ||
loginType: 0 | ||
}; | ||
this.userPostData = postData; | ||
console.log(postData); | ||
this.afs | ||
.collection('customers') | ||
.doc(custData.uid) | ||
.set(postData) | ||
.then(() => { | ||
console.log('successs'); | ||
}); | ||
}) | ||
.catch(error => { | ||
window.alert(error.message); | ||
}); | ||
}).catch((error) => { | ||
window.alert(error.message); | ||
}); | ||
} | ||
createAddress(addressData: Address) { | ||
console.log(addressData); | ||
console.log(this.userData.uid); | ||
this.afs.collection('address').add({ | ||
uid: this.userData.uid | ||
}).then((docRef) => { | ||
console.log(docRef); | ||
const addrData = { | ||
uid: this.userData.uid, | ||
addressType: addressData.addressType, | ||
area: addressData.area, | ||
city: addressData.city, | ||
country: addressData.country, | ||
district: addressData.district, | ||
firstAddress: addressData.firstAddress, | ||
landmark: addressData.landmark, | ||
zip: addressData.zip, | ||
secondAddress: addressData.secondAddress, | ||
state: addressData.state, | ||
addrId: docRef.id, | ||
default: 1 | ||
}; | ||
const neworderId = docRef.id; | ||
console.log(addrData); | ||
this.afs.collection('address').doc(neworderId).set(addrData).then(() => { | ||
console.log('Address add Successfully'); | ||
this.service.set('user', JSON.stringify(this.userData)); | ||
this.router.navigateByUrl('home'); | ||
document.body.scrollTop = document.documentElement.scrollTop = 0; | ||
this.afs | ||
.collection('address') | ||
.add({ | ||
uid: this.userData.uid | ||
}) | ||
.then(docRef => { | ||
console.log(docRef); | ||
const addrData = { | ||
uid: this.userData.uid, | ||
addressType: addressData.addressType, | ||
area: addressData.area, | ||
city: addressData.city, | ||
country: addressData.country, | ||
district: addressData.district, | ||
firstAddress: addressData.firstAddress, | ||
landmark: addressData.landmark, | ||
zip: addressData.zip, | ||
secondAddress: addressData.secondAddress, | ||
state: addressData.state, | ||
addrId: docRef.id, | ||
default: 1 | ||
}; | ||
const neworderId = docRef.id; | ||
console.log(addrData); | ||
this.afs | ||
.collection('address') | ||
.doc(neworderId) | ||
.set(addrData) | ||
.then(() => { | ||
console.log('Address add Successfully'); | ||
this.service.set('user', JSON.stringify(this.userData)); | ||
this.router.navigateByUrl('home'); | ||
document.body.scrollTop = document.documentElement.scrollTop = 0; | ||
}); | ||
}); | ||
}); | ||
return false; | ||
} | ||
} | ||
/*displayName: "Adarsh Techware" | ||
email: "[email protected]" | ||
emailVerified: true | ||
: "https://lh4.googleusercontent.com/-h0rs2pE-Azw/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rcjNtapRhKoG09NKifQsv_lQPC_2A/photo.jpg" | ||
: "vT498Fz6X0Z6l5l5iNn5hxfwz692" | ||
providerData: [Gl]*/ | ||
Please
register
or
sign in
to comment