Merge branch 'adarsh' into 'master'
Adarsh
See merge request !25
Showing
.git.zip
0 → 100644
File added
... | ... | @@ -24,9 +24,9 @@ |
"@angular/platform-browser-dynamic": "~8.1.2", | ||
"@angular/router": "~8.1.2", | ||
"@ionic-native/core": "^5.0.0", | ||
"@ionic-native/geolocation": "^5.0.0", | ||
"@ionic-native/geolocation": "^5.15.1", | ||
"@ionic-native/google-plus": "^5.0.0-beta.0", | ||
"@ionic-native/native-geocoder": "^5.0.0", | ||
"@ionic-native/native-geocoder": "^5.15.1", | ||
"@ionic-native/splash-screen": "^5.0.0", | ||
"@ionic-native/status-bar": "^5.12.0", | ||
"@ionic/angular": "^4.7.1", | ||
... | ... | @@ -46,6 +46,7 @@ |
"core-js": "^2.5.4", | ||
"firebase": "^6.4.0", | ||
"rxjs": "~6.5.1", | ||
"rxjs-compat": "^6.5.3", | ||
"tslib": "^1.9.0", | ||
"zone.js": "~0.9.1" | ||
}, | ||
... | ... | @@ -99,4 +100,4 @@ |
"android" | ||
] | ||
} | ||
} | ||
} | ||
\ No newline at end of file |
... | ... | @@ -13,30 +13,12 @@ |
<div class="home_sub_header"> | ||
Featured Catagories | ||
</div> | ||
<div class="featured_catagory_list"> | ||
<ul> | ||
<li (click)="goToPage('productlist')"> | ||
<img src="../assets/handsome-man-outdoors-drinking-coffee-with-sunglasses-guy-with-beard-instagram-effect_1212-818@3x.png"> | ||
<div class="featured_catagory_list" > | ||
<ul *ngIf="categoriesService.activecategories && categoriesService.activecategories.length > 0"> | ||
<li *ngFor="let categories of categoriesService.activecategories" (click)="goToPage('catstorelist', categories)"> | ||
<img [src]="categories.catImage" onerror="this.src='../assets/handsome-man-outdoors-drinking-coffee-with-sunglasses-guy-with-beard-instagram-effect_1212-818@3x.png'"> | ||
<div class="featured_overlay"> | ||
<h4>Men's Fashion</h4> | ||
</div> | ||
</li> | ||
<li (click)="goToPage('productlist')"> | ||
<img src="../assets/beautiful-woman-with-cocktail-suitcase-bed-hootel-room_118454-1593@3x.png"> | ||
<div class="featured_overlay"> | ||
<h4>Women's Fashion</h4> | ||
</div> | ||
</li> | ||
<li (click)="goToPage('productlist')"> | ||
<img src="./assets/[email protected]"> | ||
<div class="featured_overlay"> | ||
<h4>Bags</h4> | ||
</div> | ||
</li> | ||
<li (click)="goToPage('productlist')"> | ||
<img src="../assets/blue-striped-female-sneakers-colorful-background-top-view-flat-lay-minimal-background_77190-500@3x.png"> | ||
<div class="featured_overlay"> | ||
<h4>Shoes</h4> | ||
<h4>{{categories.catName}}</h4> | ||
</div> | ||
</li> | ||
</ul> | ||
... | ... |
src/app/catstorelist/catstorelist.module.ts
0 → 100644
src/app/catstorelist/catstorelist.page.html
0 → 100644
src/app/catstorelist/catstorelist.page.scss
0 → 100644
This diff is collapsed.
Click to expand it.
src/app/catstorelist/catstorelist.page.ts
0 → 100644
... | ... | @@ -23,27 +23,13 @@ |
</ion-col> | ||
</ion-row> | ||
</div> | ||
<ion-slides pager="true"> | ||
<ion-slide> | ||
<div class="banner_slide" (click)="goToPage('storelist')"> | ||
<h5>Chadstone</h5> | ||
<p>The fashion capital</p> | ||
<ion-slides pager="true" *ngIf="centerService.centers && centerService.centers.length > 0"> | ||
<ion-slide *ngFor="let center of centerService.centers"> | ||
<div class="banner_slide" (click)="goToPage('storelist', center)"> | ||
<h5>{{center.centerName}}</h5> | ||
<p>{{center.description}}</p> | ||
</div> | ||
<img src="./../../assets/getmi_malls/mall_banner/mall_4.png"> | ||
</ion-slide> | ||
<ion-slide> | ||
<div class="banner_slide" (click)="goToPage('storelist')"> | ||
<h5>Westfield Knox</h5> | ||
<p>Your one-stop hub for Shopping & Fun</p> | ||
</div> | ||
<img src="./../../assets/getmi_malls/mall_banner/mall_1.png"> | ||
</ion-slide> | ||
<ion-slide> | ||
<div class="banner_slide" (click)="goToPage('storelist')"> | ||
<h5>Emporium Melbourne</h5> | ||
<p>The luxury shopping centre</p> | ||
</div> | ||
<img src="./../../assets/getmi_malls/mall_banner/mall_5.png"> | ||
<img [src]="center.centerImg" onerror="this.src='./../../assets/getmi_malls/mall_banner/mall_4.png'"> | ||
</ion-slide> | ||
</ion-slides> | ||
</div> | ||
... | ... | @@ -51,22 +37,13 @@ |
Featured Stores | ||
</div> | ||
<div class="featured_slider"> | ||
<ion-slides pager="false" [options]="slideOpts"> | ||
<ion-slide> | ||
<div class="feature_product" (click)="goToPage('productlist')"> | ||
<img src="./../../assets/getmi_malls/featured/featured1.png"> | ||
<div class="feature_overlay"> | ||
<h5>Witchery</h5> | ||
<p>Shop Women's Fashion</p> | ||
</div> | ||
</div> | ||
</ion-slide> | ||
<ion-slide> | ||
<div class="feature_product" (click)="goToPage('productlist')"> | ||
<img src="./../../assets/getmi_malls/featured/featured2.png"> | ||
<ion-slides pager="false" [options]="slideOpts" *ngIf="shopperService.activeshoppers && shopperService.activeshoppers.length > 0"> | ||
<ion-slide *ngFor="let shopper of shopperService.activeshoppers"> | ||
<div class="feature_product" (click)="goToPage('productlist', shopper)"> | ||
<img [src]="shopper.featuredImage" onerror="this.src='./../../assets/getmi_malls/featured/featured1.png'"> | ||
<div class="feature_overlay"> | ||
<h5>VonZipper</h5> | ||
<p>Lifestyle & Personality</p> | ||
<h5>{{shopper.name}}</h5> | ||
<p>{{shopper.caption}}</p> | ||
</div> | ||
</div> | ||
</ion-slide> | ||
... | ... | @@ -90,69 +67,21 @@ |
<div class="clear"></div> | ||
</div> | ||
<div class="nearby_shop_list"> | ||
<ul> | ||
<li (click)="goToPage('storelist')"> | ||
<div class="nearby_image"> | ||
<img src="./../../assets/getmi_malls/mall_298/mall1.png"> | ||
<ul *ngIf="centerService.nearcenters && centerService.nearcenters.length > 0"> | ||
<li *ngFor="let center of centerService.nearcenters" (click)="goToPage('storelist', center)"> | ||
<div class="nearby_image"> | ||
<img [src]="center.centerImg" onerror="this.src='./../../assets/getmi_malls/mall_298/mall2.png'"> | ||
</div> | ||
<div class="nearby_detail"> | ||
<h5> | ||
<span class="floatLeft">Queen Victoria Building</span> | ||
<span class="floatRight">5 | ||
<span class="floatLeft">{{center.centerName}}</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> | ||
<li (click)="goToPage('storelist')"> | ||
<div class="nearby_image"> | ||
<img src="./../../assets/getmi_malls/mall_298/mall2.png"> | ||
</div> | ||
<div class="nearby_detail"> | ||
<h5> | ||
<span class="floatLeft">Westfield Knox</span> | ||
<span class="floatRight">4 | ||
<img src="../assets/Path61_2.png"> | ||
</span> | ||
<div class="clear"></div> | ||
</h5> | ||
<p>Your one-stop hub for Shopping & Fun</p> | ||
</div> | ||
<div class="clear"></div> | ||
</li> | ||
<li (click)="goToPage('storelist')"> | ||
<div class="nearby_image"> | ||
<img src="./../../assets/getmi_malls/mall_298/mall4.png"> | ||
</div> | ||
<div class="nearby_detail"> | ||
<h5> | ||
<span class="floatLeft">Chadstone</span> | ||
<span class="floatRight">5 | ||
<img src="../assets/Path61_2.png"> | ||
</span> | ||
<div class="clear"></div> | ||
</h5> | ||
<p>The fashion capital</p> | ||
</div> | ||
<div class="clear"></div> | ||
</li> | ||
<li (click)="goToPage('storelist')"> | ||
<div class="nearby_image"> | ||
<img src="./../../assets/getmi_malls/mall_298/mall5.png"> | ||
</div> | ||
<div class="nearby_detail"> | ||
<h5> | ||
<span class="floatLeft">Emporium Melbourne</span> | ||
<span class="floatRight">4 | ||
<img src="../assets/Path61_2.png"> | ||
</span> | ||
<div class="clear"></div> | ||
</h5> | ||
<p>The luxury shopping centre</p> | ||
<p>{{center.description}}</p> | ||
</div> | ||
<div class="clear"></div> | ||
</li> | ||
... | ... | @@ -162,29 +91,11 @@ |
Featured Catagories | ||
</div> | ||
<div class="featured_catagory_list"> | ||
<ul> | ||
<li (click)="goToPage('productlist')"> | ||
<img src="../assets/handsome-man-outdoors-drinking-coffee-with-sunglasses-guy-with-beard-instagram-effect_1212-818@3x.png"> | ||
<div class="featured_overlay"> | ||
<h4>Men's Fashion</h4> | ||
</div> | ||
</li> | ||
<li (click)="goToPage('productlist')"> | ||
<img src="../assets/beautiful-woman-with-cocktail-suitcase-bed-hootel-room_118454-1593@3x.png"> | ||
<div class="featured_overlay"> | ||
<h4>Women's Fashion</h4> | ||
</div> | ||
</li> | ||
<li (click)="goToPage('productlist')"> | ||
<img src="./assets/[email protected]"> | ||
<div class="featured_overlay"> | ||
<h4>Bags</h4> | ||
</div> | ||
</li> | ||
<li (click)="goToPage('productlist')"> | ||
<img src="../assets/blue-striped-female-sneakers-colorful-background-top-view-flat-lay-minimal-background_77190-500@3x.png"> | ||
<ul *ngIf="categoriesService.activecategories && categoriesService.activecategories.length > 0"> | ||
<li *ngFor="let categories of categoriesService.activecategories" (click)="goToPage('catstorelist', categories)"> | ||
<img [src]="categories.catImage" onerror="this.src='../assets/handsome-man-outdoors-drinking-coffee-with-sunglasses-guy-with-beard-instagram-effect_1212-818@3x.png'"> | ||
<div class="featured_overlay"> | ||
<h4>Shoes</h4> | ||
<h4>{{categories.catName}}</h4> | ||
</div> | ||
</li> | ||
</ul> | ||
... | ... |
... | ... | @@ -19,7 +19,9 @@ |
<ion-row> | ||
<ion-col size="8"> | ||
<h3>{{product.prodName}}</h3> | ||
<p><strong><span><img src="../assets/Path61_2.png"></span>4</strong>Lulu Fashion, {{product.category}} | ||
<p><strong><span><img src="../assets/Path61_2.png"></span>0</strong> {{product.category}}, {{product.subCate}} | ||
<br/> | ||
<span *ngFor="let tag of product.tag">#{{tag}}</span> | ||
</p> | ||
</ion-col> | ||
<ion-col size="4"> | ||
... | ... | @@ -37,8 +39,8 @@ |
<li> | ||
<button id="custom_check_button"> | ||
<label> | ||
<input id="{{size.sizeId}}" type="radio" name="services" value="{{size.sizeId}}" (click)="cartService.choose_size(size.sizeName)" [checked]="i==0"> | ||
<p>{{size.sizeName}}</p> | ||
<input id="{{size}}" type="radio" name="services" value="{{size}}" (click)="cartService.choose_size(size)" [checked]="i==0"> | ||
<p>{{size}}</p> | ||
</label> | ||
</button> | ||
</li> | ||
... | ... | @@ -49,11 +51,11 @@ |
<h5>Description</h5> | ||
<p>{{product.prodDesc}} | ||
</p> | ||
<h5> | ||
<!--<h5> | ||
<span class="floatLeft">Reviews</span><span class="floatRight" (click)="goToPage('reviewlist')">MORE</span> | ||
<div class="clear"></div> | ||
</h5> | ||
<div class="review_list"> | ||
<div class="review_list"> | ||
<ul> | ||
<li> | ||
<div class="review_image"> | ||
... | ... | @@ -112,57 +114,23 @@ |
<div class="clear"></div> | ||
</li> | ||
</ul> | ||
</div> | ||
<h5> | ||
<span class="floatLeft">Related Products</span><span class="floatRight">MORE</span> | ||
</div> --> | ||
<h5 *ngIf="product.similar && product.similar.length > 0"> | ||
<span class="floatLeft">Related Products</span><span class="floatRight" (click)="goToPage('productlist', data)">MORE</span> | ||
<div class="clear"></div> | ||
</h5> | ||
<div class="related_product_slider"> | ||
<ul> | ||
<ul *ngIf="product.similar && product.similar.length > 0"> | ||
<ion-slides pager="false" [options]="relatedProd"> | ||
<ion-slide> | ||
<li (click)="goToPage('productdetail')"> | ||
<div class="product_image"> | ||
<img src="../assets/[email protected]"> | ||
<div class="fav_icon"> | ||
</div> | ||
</div> | ||
<h5>European Style V Neck</h5> | ||
<p>AU$99.00</p> | ||
</li> | ||
</ion-slide> | ||
<ion-slide> | ||
<li (click)="goToPage('productdetail')"> | ||
<div class="product_image"> | ||
<img src="../assets/Recommended-Ball-Gown-Floor-Length-V-Neck-Lace-Organza-Prom-Dress-OD850662@3x.png"> | ||
<div class="fav_icon"> | ||
</div> | ||
</div> | ||
<h5>European Style V Neck</h5> | ||
<p>AU$99.00</p> | ||
</li> | ||
</ion-slide> | ||
<ion-slide> | ||
<li (click)="goToPage('productdetail')"> | ||
<div class="product_image"> | ||
<img src="../assets/[email protected]"> | ||
<div class="fav_icon"> | ||
</div> | ||
</div> | ||
<h5>European Style V Neck</h5> | ||
<p>AU$99.00 <span class="offer">-8%</span></p> | ||
</li> | ||
</ion-slide> | ||
<ion-slide> | ||
<li (click)="goToPage('productdetail')"> | ||
<ion-slide *ngFor="let similar of product.similar"> | ||
<li (click)="viewProd(similar)"> | ||
<div class="product_image"> | ||
<img src="../assets/[email protected]"> | ||
<img [src]="similar.image" onerror="this.src='../assets/[email protected]'"> | ||
<div class="fav_icon"> | ||
</div> | ||
<div class="featured_badge">Featured</div> | ||
</div> | ||
<h5>European Style V Neck</h5> | ||
<p>AU$99.00<span>AU$110.00</span></p> | ||
<h5>{{similar.prodName}}</h5> | ||
<p>{{similar.price}}</p> | ||
</li> | ||
</ion-slide> | ||
</ion-slides> | ||
... | ... |
... | ... | @@ -23,19 +23,19 @@ |
</div> | ||
<div class="clear"></div> | ||
</div> | ||
<div class="product_title"> | ||
Women's Fashion | ||
<div class="product_title" *ngIf="data"> | ||
{{data.shopName}} | ||
</div> | ||
<ul [class.grid_view]="onGrid" *ngIf="prodService.product && prodService.product.length > 0"> | ||
<li *ngFor="let product of prodService.product; let i = index" (click)="prodDetails(i)"> | ||
<li *ngFor="let product of prodService.product; let i = index"> | ||
<div class="product_image"> | ||
<img [src]="product.image" onerror="this.src='../assets/[email protected]'"> | ||
<div class="fav_icon"> | ||
<img [src]="product.image" onerror="this.src='../assets/[email protected]'" (click)="prodDetails(i)"> | ||
<div class="fav_icon" (click)="changeFav(product.prodId)" *ngIf="checkFavStatus(product.prodId)"> | ||
</div> | ||
<div class="featured_badge" *ngIf="product.featured">Featured</div> | ||
</div> | ||
<h5>{{product.prodName}}</h5> | ||
<p>A$ {{product.price}}<span class="offer" *ngIf="product.discount > 0">-{{product.discount}}%</span></p> | ||
<h5 class="ellipse" (click)="prodDetails(i)">{{product.prodName}}</h5> | ||
<p (click)="prodDetails(i)">A$ {{product.price}}<span class="offer" *ngIf="product.discount > 0">-{{product.discount}}%</span></p> | ||
</li> | ||
</ul> | ||
</div> | ||
... | ... |
import { Injectable } from '@angular/core'; | ||
import { User } from './services/user'; | ||
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 } from '@angular/fire/firestore'; | ||
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore'; | ||
import { ServiceService } from './../config/service.service'; | ||
import { GooglePlus } from '@ionic-native/google-plus/ngx'; | ||
import { take } from 'rxjs/operators'; | ||
import { from } from 'rxjs'; | ||
@Injectable({ | ||
... | ... | @@ -13,6 +14,8 @@ import { from } from 'rxjs'; |
}) | ||
export class AuthService { | ||
userData: any; | ||
type: number; | ||
userPostData: any; | ||
constructor( | ||
public afs: AngularFirestore, | ||
... | ... | @@ -21,11 +24,17 @@ export class AuthService { |
private service: ServiceService, | ||
private googlePlus: GooglePlus | ||
) { | ||
this.type = 1; | ||
this.afAuth.authState.subscribe(user => { | ||
if (user) { | ||
this.userData = user; | ||
console.log(this.userData); | ||
this.service.set('user', JSON.stringify(this.userData)); | ||
this.router.navigateByUrl('home'); | ||
if (this.type === 1) { | ||
this.router.navigateByUrl('home'); | ||
} else { | ||
this.router.navigateByUrl('verification'); | ||
} | ||
} else { | ||
this.service.set('user', null); | ||
JSON.parse(localStorage.getItem('user')); | ||
... | ... | @@ -44,16 +53,37 @@ export class AuthService { |
}); | ||
} | ||
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) | ||
); | ||
custRef.valueChanges().pipe(take(1)).subscribe((value: User[]) => { | ||
if (value.length > 0) { | ||
this.afs.collection('customers').doc(this.userData.uid).update({otp: ''}); | ||
this.router.navigateByUrl('addaddresss'); | ||
} else { | ||
window.alert('Please input valid OTP'); | ||
} | ||
}); | ||
} | ||
public async google() { | ||
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); | ||
}); | ||
} | ||
public async facebook() { | ||
public async facebook(type: number) { | ||
this.type = type; | ||
this.afAuth.auth.signInWithPopup(new auth.FacebookAuthProvider()).then((result) => { | ||
console.log('success'); | ||
console.log(result); | ||
... | ... | @@ -62,7 +92,7 @@ export class AuthService { |
get isLoggedIn(): boolean { | ||
const user = JSON.parse(localStorage.getItem('user')); | ||
return (user !== null && user.emailVerified !== false) ? true : false; | ||
return(user !== null && user.emailVerified !== false) ? true : false; | ||
} | ||
SetUserData(user: any) { | ||
... | ... | @@ -78,7 +108,9 @@ export class AuthService { |
phone: value.phone, | ||
phoneVerified: value.phoneVerified, | ||
status: value.status, | ||
currency: value.currency | ||
currency: value.currency, | ||
otp: value.otp, | ||
loginType: value.loginType | ||
}; | ||
console.log(userData); | ||
}); | ||
... | ... | @@ -91,5 +123,116 @@ export class AuthService { |
}); | ||
} | ||
socialSignUp(userData: any) { | ||
this.type = 2; | ||
console.log(userData.user); | ||
const currencyData = { | ||
currId: '123', | ||
currName: 'Australian dollar', | ||
symbol: 'A$' | ||
}; | ||
const otp = Math.floor(1000 + Math.random() * 9000); | ||
userData = userData.user; | ||
const postData: User = { | ||
uid: userData.uid, | ||
status: true, | ||
profilePhoto: userData.photoURL, | ||
phoneVerified: false, | ||
phone: userData.phoneNumber, | ||
name: userData.displayName, | ||
emailVerified: userData.emailVerified, | ||
emailId: userData.email, | ||
currency: currencyData, | ||
otp: otp.toString(), | ||
loginType: 1 | ||
}; | ||
this.userPostData = postData; | ||
console.log(postData); | ||
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'); | ||
}); | ||
}).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; | ||
}); | ||
}); | ||
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]*/ | ||
... | ... | @@ -41,20 +41,21 @@ export class CartsService { |
} | ||
public async buyNow(product: Products) { | ||
this.color = 'Blue'; | ||
this.prodId = product.prodId; | ||
const prodRef = firebase.firestore().collection('products').doc(this.prodId); | ||
const cartRef: AngularFirestoreCollection<any> = this.afs.collection('carts', ref => ref.where('size', '==', this.size) | ||
.where('color', '==', this.color) | ||
.where('color', '==', Object.keys(product.color)[0]) | ||
.where('custId', '==', this.custId) | ||
.where('product', '==', prodRef) | ||
); | ||
cartRef.valueChanges().pipe(take(1)).subscribe((value: Cart[]) => { | ||
; | ||
cartRef.valueChanges().pipe(take(1)).subscribe((value) => { | ||
console.log(value); | ||
if (value.length === 0) { | ||
product.image = product.image === undefined ? '../assets/[email protected]' : product.image; | ||
const cart: Cart = { | ||
color: this.color, | ||
color: Object.keys(product.color)[0], | ||
custId: this.custId, | ||
shopperId: product.shopperId, | ||
product: firebase.firestore().doc(`products/${this.prodId}`), | ||
... | ... | @@ -66,6 +67,7 @@ export class CartsService { |
qty: 1, | ||
size: this.size | ||
}; | ||
console.log(cart); | ||
this.afs.collection('carts').add(cart).then((docRef) => { | ||
const neworderId = docRef.id; | ||
this.afs.collection('carts').doc(neworderId).update({cartId: docRef.id}).then(() => { | ||
... | ... | @@ -76,7 +78,16 @@ export class CartsService { |
console.error('Error adding document: ', error); | ||
}); | ||
} else { | ||
alert('Item already added in the cart'); | ||
console.log(value); | ||
// alert('Item already added in the cart'); | ||
const cartId = value[0].cartId; | ||
// tslint:disable-next-line:radix | ||
const qty = parseInt(value[0].qty) + 1; | ||
this.afs.collection('carts').doc(cartId).update({qty: `${qty}`}).then(() => { | ||
console.log('Booking Successfully'); | ||
document.body.scrollTop = document.documentElement.scrollTop = 0; | ||
}); | ||
} | ||
}); | ||
} | ||
... | ... | @@ -101,7 +112,10 @@ export class CartsService { |
qty: item.qty, | ||
size: item.size, | ||
}; | ||
this.cartTotal += item.price; | ||
console.log(item.price, item.qty); | ||
if (item.price) { | ||
this.cartTotal += item.price * item.qty; | ||
} | ||
/*const prodItem = item.product.get().then((property) => { | ||
const response = property.data(); | ||
cartItem.prodName = response.prodName; | ||
... | ... | @@ -123,6 +137,32 @@ export class CartsService { |
this.size = size; | ||
} | ||
removeCount(index) { | ||
// tslint:disable-next-line:radix | ||
const qty = this.carts[index].qty > 1 ? this.carts[index].qty - 1 : this.carts[index].qty; | ||
this.carts[index].qty = qty; | ||
console.log(this.carts[index].qty); | ||
this.afs.collection('carts').doc(this.carts[index].cartId).update({ | ||
qty: this.carts[index].qty | ||
}); | ||
} | ||
addCount(index) { | ||
const qty = this.carts[index].qty + 1; | ||
this.cartTotal = 0; | ||
this.carts[index].qty = qty; | ||
this.afs.collection('carts').doc(this.carts[index].cartId).update({ | ||
qty: this.carts[index].qty | ||
}); | ||
} | ||
removeItem(index) { | ||
this.afs.collection('carts').doc(this.carts[index].cartId).delete(); | ||
} | ||
} |
src/config/category.service.ts
0 → 100644
src/config/center.service.ts
0 → 100644
src/config/services/category.ts
0 → 100644
src/config/services/center.ts
0 → 100644
src/config/services/shopper.ts
0 → 100644
src/config/shopper.service.ts
0 → 100644
Please
register
or
sign in
to comment