Commit 5c5b57d4 by muhsin

conflict

parents 8fa93f08 1abb04f9
import { NgModule } from "@angular/core"; import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from "@angular/router"; import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
const routes: Routes = [ const routes: Routes = [
{ {
path: "", path: '',
loadChildren: "./landing/landing.module#LandingPageModule" loadChildren: './landing/landing.module#LandingPageModule'
}, },
{ path: "tabs", loadChildren: "./tabs/tabs.module#TabsPageModule" }, { path: 'tabs', loadChildren: './tabs/tabs.module#TabsPageModule' },
{ path: "login", loadChildren: "./login/login.module#LoginPageModule" }, { path: 'login', loadChildren: './login/login.module#LoginPageModule' },
{ path: "signup", loadChildren: "./signup/signup.module#SignupPageModule" }, { path: 'signup', loadChildren: './signup/signup.module#SignupPageModule' },
{ {
path: "verification", path: 'verification',
loadChildren: "./verification/verification.module#VerificationPageModule" loadChildren: './verification/verification.module#VerificationPageModule'
}, },
{ path: "forgot", loadChildren: "./forgot/forgot.module#ForgotPageModule" }, { path: 'forgot', loadChildren: './forgot/forgot.module#ForgotPageModule' },
{ {
path: "changepass", path: 'changepass',
loadChildren: "./changepass/changepass.module#ChangepassPageModule" loadChildren: './changepass/changepass.module#ChangepassPageModule'
}, },
{ {
path: "orderdelivered", path: 'orderdelivered',
loadChildren: loadChildren:
"./orderdelivered/orderdelivered.module#OrderdeliveredPageModule" './orderdelivered/orderdelivered.module#OrderdeliveredPageModule'
}, },
{ {
path: "orderplaced", path: 'orderplaced',
loadChildren: "./orderplaced/orderplaced.module#OrderplacedPageModule" loadChildren: './orderplaced/orderplaced.module#OrderplacedPageModule'
}, },
{ {
path: "ordercancelled", path: 'ordercancelled',
loadChildren: loadChildren:
"./ordercancelled/ordercancelled.module#OrdercancelledPageModule" './ordercancelled/ordercancelled.module#OrdercancelledPageModule'
}, },
{ {
path: "myorder", path: 'myorder',
loadChildren: "./myorder/myorder.module#MyorderPageModule" loadChildren: './myorder/myorder.module#MyorderPageModule'
}, },
{ path: "cart", loadChildren: "./cart/cart.module#CartPageModule" }, { path: 'cart', loadChildren: './cart/cart.module#CartPageModule' },
{ {
path: "changedetails", path: 'changedetails',
loadChildren: "./changedetails/changedetails.module#ChangedetailsPageModule" loadChildren: './changedetails/changedetails.module#ChangedetailsPageModule'
}, },
{ {
path: "wishlist", path: 'wishlist',
loadChildren: "./wishlist/wishlist.module#WishlistPageModule" loadChildren: './wishlist/wishlist.module#WishlistPageModule'
}, },
{ {
path: "addaddresss", path: 'addaddresss',
loadChildren: "./addaddresss/addaddresss.module#AddaddresssPageModule" loadChildren: './addaddresss/addaddresss.module#AddaddresssPageModule'
}, },
{ {
path: "profile", path: 'profile',
loadChildren: "./profile/profile.module#ProfilePageModule" loadChildren: './profile/profile.module#ProfilePageModule'
}, },
{ path: "home", loadChildren: "./home/home.module#HomePageModule" }, { path: 'home', loadChildren: './home/home.module#HomePageModule' },
{ {
path: "productlist", path: 'productlist',
loadChildren: "./productlist/productlist.module#ProductlistPageModule" loadChildren: './productlist/productlist.module#ProductlistPageModule'
}, },
{ {
path: "productdetail", path: 'productdetail',
loadChildren: "./productdetail/productdetail.module#ProductdetailPageModule" loadChildren: './productdetail/productdetail.module#ProductdetailPageModule'
}, },
{ {
path: "reviewlist", path: 'reviewlist',
loadChildren: "./reviewlist/reviewlist.module#ReviewlistPageModule" loadChildren: './reviewlist/reviewlist.module#ReviewlistPageModule'
}, },
{ {
path: "catagory", path: 'catagory',
loadChildren: "./catagory/catagory.module#CatagoryPageModule" loadChildren: './catagory/catagory.module#CatagoryPageModule'
}, },
{ {
path: "trackorder", path: 'trackorder',
loadChildren: "./trackorder/trackorder.module#TrackorderPageModule" loadChildren: './trackorder/trackorder.module#TrackorderPageModule'
}, },
{ {
path: "storelist", path: 'storelist',
loadChildren: "./storelist/storelist.module#StorelistPageModule" loadChildren: './storelist/storelist.module#StorelistPageModule'
}, },
{ {
path: "catstorelist", path: 'catstorelist',
loadChildren: "./catstorelist/catstorelist.module#CatStorelistPageModule" loadChildren: './catstorelist/catstorelist.module#CatStorelistPageModule'
}, },
{ path: "nearby", loadChildren: "./nearby/nearby.module#NearbyPageModule" }, { path: 'nearby', loadChildren: './nearby/nearby.module#NearbyPageModule' },
{ path: "review", loadChildren: "./review/review.module#ReviewPageModule" }, { path: 'review', loadChildren: './review/review.module#ReviewPageModule' },
{ {
path: "delivery", path: 'delivery',
loadChildren: "./delivery/delivery.module#DeliveryPageModule" loadChildren: './delivery/delivery.module#DeliveryPageModule'
}, },
{ {
path: "addcard", path: 'addcard',
loadChildren: "./addcard/addcard.module#AddcardPageModule" loadChildren: './addcard/addcard.module#AddcardPageModule'
}, },
{ {
path: "searchmodal", path: 'searchmodal',
loadChildren: "./searchmodal/searchmodal.module#SearchmodalPageModule" loadChildren: './searchmodal/searchmodal.module#SearchmodalPageModule'
} }
]; ];
@NgModule({ @NgModule({
......
...@@ -56,7 +56,8 @@ ...@@ -56,7 +56,8 @@
<ion-router-outlet main></ion-router-outlet> <ion-router-outlet main></ion-router-outlet>
</ion-split-pane> </ion-split-pane>
</ion-app> </ion-app>
<div class="common_tab" [hidden]="getState()">
<div class="common_tab" [hidden]="fetchCase() === true">
<ul> <ul>
<li (click)="goToPage('home')"> <li (click)="goToPage('home')">
<div <div
...@@ -72,7 +73,7 @@ ...@@ -72,7 +73,7 @@
(click)="setActive2()" (click)="setActive2()"
></div> ></div>
</li> </li>
<li (click)="goToPage('catagory')"> <li (click)="searchModal()">
<div <div
class="icon_sec m3_icon" class="icon_sec m3_icon"
[class.m3_icon_act]="sec_active3" [class.m3_icon_act]="sec_active3"
......
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { Router, ActivatedRoute } from "@angular/router"; import { Router, ActivatedRoute } from '@angular/router';
import { Platform } 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 { import {
AngularFirestore, AngularFirestore,
AngularFirestoreDocument, AngularFirestoreDocument,
AngularFirestoreCollection AngularFirestoreCollection
} from "@angular/fire/firestore"; } 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';
import { AuthService } from "./../config/auth.service"; import { AuthService } from './../config/auth.service';
import { ServiceService } from "./../config/service.service"; import { ServiceService } from './../config/service.service';
import { CategoriesService } from "./../config/category.service"; import { SubjectService } from './../config/subject.service';
import { User } from "../config/services/user"; import { CategoriesService } from './../config/category.service';
import { UserService } from "../config/user.service"; import { SearchmodalPage } from './searchmodal/searchmodal.page';
@Component({ @Component({
selector: "app-root", selector: 'app-root',
templateUrl: "app.component.html", templateUrl: 'app.component.html',
styleUrls: ["app.component.scss"] styleUrls: ['app.component.scss']
}) })
export class AppComponent { export class AppComponent {
sec_active1 = true; sec_active1 = true;
...@@ -28,9 +29,10 @@ export class AppComponent { ...@@ -28,9 +29,10 @@ export class AppComponent {
sec_active4 = false; sec_active4 = false;
sec_active5 = false; sec_active5 = false;
sec_active6 = false; sec_active6 = false;
state: boolean;
// Customer Info // Customer Info
user: User; // user: User;
menuw: number; menuw: number;
...@@ -44,20 +46,15 @@ export class AppComponent { ...@@ -44,20 +46,15 @@ export class AppComponent {
public authService: AuthService, public authService: AuthService,
public service: ServiceService, public service: ServiceService,
public categoryService: CategoriesService, public categoryService: CategoriesService,
private route: ActivatedRoute, public subjectService: SubjectService,
private useService: UserService private route: ActivatedRoute
) { ) {
this.state = true;
this.initializeApp(); this.initializeApp();
this.orderState(); this.orderState();
this.subjectService.getLoginData().subscribe(loginData => {
const userdata = this.service.get("user").then(data => { this.state = loginData;
if (data) {
data = JSON.parse(data);
console.log(data);
}
}); });
this.useService.getUserData("9cYSZwGvVpgkUHVcz8Dm6oqGX152");
} }
initializeApp() { initializeApp() {
...@@ -65,7 +62,7 @@ export class AppComponent { ...@@ -65,7 +62,7 @@ export class AppComponent {
this.statusBar.styleDefault(); this.statusBar.styleDefault();
this.statusBar.overlaysWebView(false); this.statusBar.overlaysWebView(false);
this.statusBar.show(); this.statusBar.show();
this.statusBar.backgroundColorByHexString("#29285b"); this.statusBar.backgroundColorByHexString('#29285b');
}); });
} }
...@@ -77,15 +74,20 @@ export class AppComponent { ...@@ -77,15 +74,20 @@ export class AppComponent {
return await modal.present(); return await modal.present();
} }
ngOnInit() { fetchCase() {
let This = this; const restrictedUrl = ['productdetail', 'cart', 'nearby', 'verification'];
setTimeout(() => { const currentUrl = this.router.url.split('/');
this.user = this.useService.users; const index = restrictedUrl.findIndex(x => x === currentUrl[1]);
console.log("[usersaaa]", this.user); // console.log(currentUrl[1], index, this.state);
}, 500); if (index > -1 || this.state === true) {
return true;
} else {
return false;
}
} }
goToPage(path, data = null) { goToPage(path, data = null) {
this.service.set("params", data); this.service.set('params', data);
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;
} }
...@@ -139,20 +141,16 @@ export class AppComponent { ...@@ -139,20 +141,16 @@ export class AppComponent {
this.sec_active5 = false; this.sec_active5 = false;
} }
getState() {
return this.service.state;
}
orderState() { orderState() {
console.log("called"); console.log('called');
const custId = "WwHnLICVY2dvZGUHuKqasiTB91a2"; const custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2';
firebase firebase
.firestore() .firestore()
.collection("orders") .collection('orders')
.where("custId", "==", custId) .where('custId', '==', custId)
.onSnapshot(snapData => { .onSnapshot(snapData => {
snapData.docChanges().forEach(change => { snapData.docChanges().forEach(change => {
if (change.type === "modified") { if (change.type === 'modified') {
const data = change.doc.data(); const data = change.doc.data();
if (data.orderStatus === 7) { if (data.orderStatus === 7) {
this.finishpop(data); this.finishpop(data);
...@@ -184,4 +182,12 @@ export class AppComponent { ...@@ -184,4 +182,12 @@ export class AppComponent {
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;
} }
async searchModal() {
const modal = await this.modalController.create({
component: SearchmodalPage
});
modal.onDidDismiss().then(dataReturned => {});
return await modal.present();
}
} }
import { NgModule } from "@angular/core"; import { NgModule } from '@angular/core';
import { BrowserModule } from "@angular/platform-browser"; import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from "@angular/router"; import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from "@ionic/angular"; import { IonicModule, IonicRouteStrategy } 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 { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { IonicStorageModule } from "@ionic/storage"; import { IonicStorageModule } from '@ionic/storage';
import { GooglePlus } from "@ionic-native/google-plus/ngx"; import { GooglePlus } from '@ionic-native/google-plus/ngx';
import { AppRoutingModule } from "./app-routing.module"; import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from "./app.component"; import { AppComponent } from './app.component';
import { AngularFireModule } from "@angular/fire"; 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 { 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';
import { environment } from "../environments/environment"; import { environment } from '../environments/environment';
import { ServiceService } from "./../config/service.service"; import { ServiceService } from './../config/service.service';
import { AuthService } from "./../config/auth.service"; import { AuthService } from './../config/auth.service';
import { from } from "rxjs"; import { from } from 'rxjs';
import { DeliverypopPageModule } from "./deliverypop/deliverypop.module"; import { DeliverypopPageModule } from './deliverypop/deliverypop.module';
import { FormsModule } from "@angular/forms"; import { FormsModule } from '@angular/forms';
import { SearchmodalPageModule } from "./searchmodal/searchmodal.module"; import { SearchmodalPageModule } from './searchmodal/searchmodal.module';
@NgModule({ @NgModule({
declarations: [AppComponent], declarations: [AppComponent],
......
...@@ -82,10 +82,10 @@ ...@@ -82,10 +82,10 @@
<hr> <hr>
<h5> <h5>
<span class="floatLeft">DELIVERY</span> <span class="floatLeft">DELIVERY</span>
<span class="floatRight">EDIT</span> <span class="floatRight" (click)="istoggle()">EDIT</span>
<div class="clear"></div> <div class="clear"></div>
</h5> </h5>
<ion-grid class="p0"> <ion-grid class="p0" *ngIf="custAddress">
<ion-row> <ion-row>
<ion-col class="p0"> <ion-col class="p0">
<h6> <h6>
...@@ -192,7 +192,7 @@ ...@@ -192,7 +192,7 @@
<div class="order_placed_div"> <div class="order_placed_div">
<img src="../assets/[email protected]"> <img src="../assets/[email protected]">
<h4>Order Placed</h4> <h4>Order Placed</h4>
<p>June 26th 2019, 03:00 PM</p> <p>{{bookDate}}</p>
<h3>The product will be delivered in</h3> <h3>The product will be delivered in</h3>
<h1>60:00 Mins</h1> <h1>60:00 Mins</h1>
<button class="view_order" (click)="goToPage('myorder')">VIEW ORDERS</button><br> <button class="view_order" (click)="goToPage('myorder')">VIEW ORDERS</button><br>
...@@ -223,3 +223,44 @@ ...@@ -223,3 +223,44 @@
</div> </div>
</div> </div>
<div *ngIf="isShow" [@slideInOut]>
<div class="nav_header">
<button class="nav_btn nav_back floatLeft" (click)="istoggle(); setAddress()">
<img src="../assets/Group17_2.png">
</button>
<div class="nav_title floatLeft">
<h4>CHANGE LOCATION</h4>
</div>
<div class="clear"></div>
</div>
<ion-content class="sort_wrappper">
<agm-map [zoom]="20" [latitude]="lat" [longitude]="lng" [disableDefaultUI]="false" [zoomControl]="false" [backgroundColor]="'rgba(29, 27, 130,0.2)'">
<agm-marker [latitude]="lat" [longitude]="lng"></agm-marker>
</agm-map>
<div class="add_address_wrapper">
<h5>
<span class="floatLeft">NEW ADDRESS</span>
<span class="floatRight" (click)="istoggle(); goToPage('nearby')">ADD NEW</span>
<div class="clear"></div>
</h5>
<ul *ngIf="addressService.addressList && addressService.addressList.length > 0">
<li *ngFor="let address of addressService.addressList; let i = index">
<div class="floatLeft">{{address.default}}
<input class="styled-checkbox" name="addressId" id="styled-checkbox-{{i}}" type="radio" (click)="setDefault(address.addressId, i)" [value]="address.addressId" #addressType [checked]="address.defaultVal == 1">
<label for="styled-checkbox-{{i}}"> {{address.addressType}}
</label>
</div>
<div class="floatLeft">
<p>
{{address.building}}, {{address.landmark}}, {{address.address}}
</p>
</div>
<div class="clear"></div>
</li>
</ul>
</div>
</ion-content>
</div>
...@@ -453,4 +453,101 @@ ...@@ -453,4 +453,101 @@
font-weight: 300; font-weight: 300;
float: right; float: right;
} }
}
.sort_wrappper {
height: 100vh;
width: 100%;
background: #fff;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
z-index: 99;
agm-map {
width: 100%;
height: 100vh;
}
.add_address_wrapper {
position: fixed;
bottom: 0px;
left: 0px;
right: 0px;
padding: 20px;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
background: #fff;
-webkit-box-shadow: 0px -2px 5px 0px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px -2px 5px 0px rgba(0, 0, 0, 0.2);
box-shadow: 0px -2px 5px 0px rgba(0, 0, 0, 0.2);
h5 {
color: rgba(41, 40, 91, 1);
margin: 0px;
padding: 0px;
font-weight: 800;
}
ul {
margin: 0px;
padding: 0px;
padding-top: 30px;
li {
list-style: none;
margin-bottom: 15px;
p {
margin: 0px;
padding: 0px;
color: rgba(176, 174, 199, 1);
padding-top: 5px;
padding-bottom: 5px;
}
.styled-checkbox {
position: absolute; // take it out of document flow
opacity: 0; // hide it
&+label {
position: relative;
cursor: pointer;
padding: 0;
width: 100%;
}
// Box.
&+label:before {
content: '';
margin-right: 10px;
display: inline-block;
vertical-align: text-top;
width: 20px;
height: 20px;
border-radius: 50%;
background: white;
border: 1px solid rgba(215, 213, 228, 1);
}
&:checked+label:before {
background: #29285b;
}
// Disabled state label.
&:disabled+label {
color: #b8b8b8;
cursor: auto;
}
// Disabled box.
&:disabled+label:before {
box-shadow: none;
background: #ddd;
}
// Checkmark. Could be replaced with an image
&:checked+label:after {
content: '';
position: absolute;
left: 6px;
top: 10px;
background: white;
width: 2px;
height: 2px;
box-shadow: 2px 0 0 white, 4px 0 0 white, 4px -2px 0 white, 4px -4px 0 white, 4px -6px 0 white, 4px -8px 0 white;
transform: rotate(45deg);
}
}
}
}
}
} }
\ No newline at end of file
...@@ -8,7 +8,8 @@ import { ModalController } from '@ionic/angular'; ...@@ -8,7 +8,8 @@ import { ModalController } from '@ionic/angular';
import { DeliverypopPage } from '../deliverypop/deliverypop.page'; import { DeliverypopPage } from '../deliverypop/deliverypop.page';
import { ServiceService } from './../../config/service.service'; import { ServiceService } from './../../config/service.service';
import { AddressService } from './../../config/address.service'; import { AddressService } from './../../config/address.service';
import { AddressList } from './../../config/services/address' import { AddressList } from './../../config/services/address';
import { trigger, transition, animate, style } from '@angular/animations';
import { zip } from 'rxjs'; import { zip } from 'rxjs';
...@@ -16,11 +17,23 @@ import { zip } from 'rxjs'; ...@@ -16,11 +17,23 @@ import { zip } from 'rxjs';
selector: 'app-cart', selector: 'app-cart',
templateUrl: './cart.page.html', templateUrl: './cart.page.html',
styleUrls: ['./cart.page.scss'], styleUrls: ['./cart.page.scss'],
animations: [
trigger('slideInOut', [
transition(':enter', [
style({ transform: 'translateY(100%)' }),
animate('200ms ease-in', style({ transform: 'translateY(0%)' }))
]),
transition(':leave', [
animate('200ms ease-out', style({ transform: 'translateY(100%)' }))
])
])
]
}) })
export class CartPage implements OnInit { export class CartPage implements OnInit {
@ViewChild(IonSlides, { static: false }) slides: IonSlides; @ViewChild(IonSlides, { static: false }) slides: IonSlides;
currentIndex: any; currentIndex: any;
isShow = false;
count: any; count: any;
gateway: any; gateway: any;
loader = false; loader = false;
...@@ -36,6 +49,7 @@ export class CartPage implements OnInit { ...@@ -36,6 +49,7 @@ export class CartPage implements OnInit {
discountApplied: boolean; discountApplied: boolean;
discount: number; discount: number;
totalAmt: number; totalAmt: number;
bookDate: any;
constructor( constructor(
private router: Router, private router: Router,
...@@ -47,7 +61,7 @@ export class CartPage implements OnInit { ...@@ -47,7 +61,7 @@ export class CartPage implements OnInit {
public service: ServiceService, public service: ServiceService,
public addressService: AddressService public addressService: AddressService
) { ) {
this.bookDate = this.formatDate();
this.currentIndex = 0; this.currentIndex = 0;
this.count = 1; this.count = 1;
this.gateway = 1; this.gateway = 1;
...@@ -67,12 +81,19 @@ export class CartPage implements OnInit { ...@@ -67,12 +81,19 @@ export class CartPage implements OnInit {
} }
ngOnInit() { ngOnInit() {
let address = this.addressService.addressList.find(x => x.defaultVal === 1); console.log(this.addressService.addressList);
if (!address) { this.setAddress();
address = this.addressService.addressList[0]; }
setAddress() {
if (this.addressService.addressList.length > 0) {
let address = this.addressService.addressList.find(x => x.defaultVal === 1);
if (!address) {
address = this.addressService.addressList[0];
}
this.custAddress = address;
} }
this.custAddress = address;
console.log(address);
} }
getwaypaypal() { getwaypaypal() {
...@@ -118,6 +139,13 @@ export class CartPage implements OnInit { ...@@ -118,6 +139,13 @@ export class CartPage implements OnInit {
this.location.back(); this.location.back();
} }
setDefault(addressId: any, index: number) {
console.log(index);
this.addressService.setDefaultAddress(addressId, this.custId);
console.log(this.addressService.addressList[index]);
this.custAddress = this.addressService.addressList[index];
}
next(index: number = null) { next(index: number = null) {
...@@ -128,18 +156,22 @@ export class CartPage implements OnInit { ...@@ -128,18 +156,22 @@ export class CartPage implements OnInit {
}, 500); }, 500);
console.log(index); console.log(index);
if (index === 2) { if (index === 2) {
const otherCharges = { if (this.custAddress !== undefined) {
deliveryCharge : this.deliveryCharge, const otherCharges = {
taxAmount: this.taxAmount, deliveryCharge : this.deliveryCharge,
discount: this.discount, taxAmount: this.taxAmount,
discountApplied: this.discountApplied, discount: this.discount,
totalAmt: this.totalAmt, discountApplied: this.discountApplied,
custAddress: this.custAddress totalAmt: this.totalAmt,
}; custAddress: this.custAddress
const state = this.orderService.checkOut(this.cartService.carts, otherCharges).then((data) => { };
console.log('ready for slide'); const state = this.orderService.checkOut(this.cartService.carts, otherCharges).then((data) => {
this.slides.slideNext(); console.log('ready for slide');
}); this.slides.slideNext();
});
} else {
alert('Please choose delivery location');
}
} else { } else {
this.slides.slideNext(); this.slides.slideNext();
} }
...@@ -201,4 +233,21 @@ export class CartPage implements OnInit { ...@@ -201,4 +233,21 @@ export class CartPage implements OnInit {
}); });
} }
istoggle() {
this.isShow = !this.isShow;
}
formatDate() {
const date = new Date();
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
let hours = date.getHours();
const minutes = date.getMinutes();
const ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
const newminutes = minutes < 10 ? '0' + minutes : minutes;
const strTime = hours + ':' + newminutes + ' ' + ampm;
return months[date.getMonth()] + ' ' + date.getDate() + ',' + date.getFullYear() + ' ' + strTime;
}
} }
...@@ -2,6 +2,7 @@ import { Component, OnInit, ViewChild, } from '@angular/core'; ...@@ -2,6 +2,7 @@ import { Component, OnInit, ViewChild, } from '@angular/core';
import { IonSlides } from '@ionic/angular'; import { IonSlides } from '@ionic/angular';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { ServiceService } from './../../config/service.service'; import { ServiceService } from './../../config/service.service';
import { SubjectService } from './../../config/subject.service';
@Component({ @Component({
selector: 'app-landing', selector: 'app-landing',
...@@ -9,33 +10,42 @@ import { ServiceService } from './../../config/service.service'; ...@@ -9,33 +10,42 @@ import { ServiceService } from './../../config/service.service';
styleUrls: ['./landing.page.scss'], styleUrls: ['./landing.page.scss'],
}) })
export class LandingPage implements OnInit { export class LandingPage implements OnInit {
slideOpts = {
initialSlide: 0,
speed: 1000,
allowTouchMove: false
};
@ViewChild(IonSlides, { static: false })slides: IonSlides;
currentIndex: any;
constructor( constructor(
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private service: ServiceService private service: ServiceService,
public subjectService: SubjectService
) { ) {
this.service.get('landing').then((data) => { this.service.get('landing').then((data) => {
if (data === true) { if (data === true) {
const user = JSON.parse(localStorage.getItem('user')); const user = JSON.parse(localStorage.getItem('user'));
console.log(user); console.log(user);
if (user) { if (user) {
this.subjectService.sendLoginData(false);
this.goToPage('home'); this.goToPage('home');
} else { } else {
this.subjectService.sendLoginData(true);
this.goToPage('login'); this.goToPage('login');
} }
} }
}); });
} }
slideOpts = {
initialSlide: 0,
speed: 1000,
allowTouchMove: false
};
@ViewChild(IonSlides, { static: false })slides: IonSlides;
currentIndex: any;
landingOptions = {
initialSlide: 1,
speed: 1000,
allowTouchMove: false
};
ngOnInit() { ngOnInit() {
} }
...@@ -45,12 +55,6 @@ export class LandingPage implements OnInit { ...@@ -45,12 +55,6 @@ export class LandingPage implements OnInit {
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
} }
landingOptions = {
initialSlide: 1,
speed: 1000,
allowTouchMove: false
};
next() { next() {
this.slides.slideNext(); this.slides.slideNext();
......
...@@ -127,6 +127,8 @@ export class NearbyPage implements OnInit { ...@@ -127,6 +127,8 @@ export class NearbyPage implements OnInit {
if (this.type === 1) { if (this.type === 1) {
this.service.set('type', 0); this.service.set('type', 0);
this.router.navigateByUrl('home', { queryParams: null }); this.router.navigateByUrl('home', { queryParams: null });
} else {
this.goBack();
} }
}, 3000); }, 3000);
} }
......
...@@ -18,14 +18,14 @@ ...@@ -18,14 +18,14 @@
(click)="changeFav(product.prodId)" (click)="changeFav(product.prodId)"
></div> ></div>
<div class="featured_badge" *ngIf="product.featured">Featured</div> <div class="featured_badge" *ngIf="product.featured">Featured</div>
<ion-slides pager="true" [options]="bannerOptions"> <ion-slides pager="true" [options]="bannerOptions" *ngIf="slideData">
<ion-slide> <ion-slide *ngFor="let prodImg of slideData">
<img <img
[src]="product.image" [src]="prodImg"
onerror="this.src='../assets/[email protected]'" onerror="this.src='../assets/[email protected]'"
/> />
</ion-slide> </ion-slide>
<ion-slide> <!-- <ion-slide>
<img <img
[src]="product.image" [src]="product.image"
onerror="this.src='../assets/[email protected]'" onerror="this.src='../assets/[email protected]'"
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
[src]="product.image" [src]="product.image"
onerror="this.src='../assets/[email protected]'" onerror="this.src='../assets/[email protected]'"
/> />
</ion-slide> </ion-slide> -->
</ion-slides> </ion-slides>
</div> </div>
<div class="product_header"> <div class="product_header">
...@@ -63,12 +63,12 @@ ...@@ -63,12 +63,12 @@
</div> </div>
<div class="product_div_content"> <div class="product_div_content">
<h5>Color</h5> <h5 *ngIf="product.color && product.color[0] !=='No-Color'">Color</h5>
<div class="size_div"> <div class="size_div">
<ul *ngIf="product.size"> <ul *ngIf="product.size">
<ion-slides pager="false" [options]="slideOpts"> <ion-slides pager="false" [options]="slideOpts">
<ion-slide *ngFor="let color of product.color; let i = index"> <ion-slide *ngFor="let color of product.color; let i = index">
<li> <li *ngIf="color !=='No-Color'">
<button id="custom_check_button"> <button id="custom_check_button">
<label> <label>
<input <input
...@@ -87,12 +87,12 @@ ...@@ -87,12 +87,12 @@
</ion-slides> </ion-slides>
</ul> </ul>
</div> </div>
<h5>Size</h5> <h5 *ngIf="product.size && product.size[0] !=='Any-Size'">Size</h5>
<div class="size_div"> <div class="size_div">
<ul *ngIf="product.size"> <ul *ngIf="product.size">
<ion-slides pager="false" [options]="slideOpts"> <ion-slides pager="false" [options]="slideOpts">
<ion-slide *ngFor="let size of product.size; let i = index"> <ion-slide *ngFor="let size of product.size; let i = index">
<li> <li *ngIf="size !=='Any-Size'">
<button id="custom_check_button"> <button id="custom_check_button">
<label> <label>
<input <input
......
import { Component, OnInit } from "@angular/core"; import { Component, OnInit } from '@angular/core';
import { Location } from "@angular/common"; import { Location } from '@angular/common';
import { Router, ActivatedRoute } from "@angular/router"; import { Router, ActivatedRoute } from '@angular/router';
import { Products } from "./../../config/services/product"; import { Products } from './../../config/services/product';
import { Slides } from "./../../config/services/slides"; import { Slides } from './../../config/services/slides';
import { Order } from "./../../config/services/order"; import { Order } from './../../config/services/order';
import { CartsService } from "./../../config/cart.service"; import { CartsService } from './../../config/cart.service';
import { ProductsService } from "./../../config/products.service"; import { ProductsService } from './../../config/products.service';
import { ServiceService } from "./../../config/service.service"; import { ServiceService } from './../../config/service.service';
import { map } from "rxjs/operators"; import { map } from 'rxjs/operators';
@Component({ @Component({
selector: "app-productdetail", selector: 'app-productdetail',
templateUrl: "./productdetail.page.html", templateUrl: './productdetail.page.html',
styleUrls: ["./productdetail.page.scss"] styleUrls: ['./productdetail.page.scss']
}) })
export class ProductdetailPage implements OnInit { export class ProductdetailPage implements OnInit {
slide: Slides; slide: Slides;
product: Products; product: Products;
order: Order; order: Order;
data: any; data: any;
slideData: any; slideData: any[];
bannerOptions = { bannerOptions = {
slidesPerView: 1, slidesPerView: 1,
...@@ -51,18 +51,9 @@ export class ProductdetailPage implements OnInit { ...@@ -51,18 +51,9 @@ export class ProductdetailPage implements OnInit {
params.subCate, params.subCate,
params.prodId params.prodId
); );
this.service.get("params").then(val => { this.service.get('params').then(val => {
this.data = val; this.data = val;
}); });
//
this.prodService
.getProdSlide(this.prodService.selItem.skuCode)
.then(res => {
this.slideData = res;
// console.log("resData", res);
});
this.cartService.cartList(); this.cartService.cartList();
// console.log(this.prodService.fav); // console.log(this.prodService.fav);
} }
...@@ -76,6 +67,9 @@ export class ProductdetailPage implements OnInit { ...@@ -76,6 +67,9 @@ export class ProductdetailPage implements OnInit {
getProd(params) { getProd(params) {
if (params) { if (params) {
let slideItem = [];
slideItem.push(params.image);
this.slideData = slideItem;
const prod: Products = { const prod: Products = {
prodId: params.prodId, prodId: params.prodId,
subCate: params.subCate, subCate: params.subCate,
...@@ -99,6 +93,10 @@ export class ProductdetailPage implements OnInit { ...@@ -99,6 +93,10 @@ export class ProductdetailPage implements OnInit {
size: params.size size: params.size
}; };
this.product = prod; this.product = prod;
this.prodService.fetchGallery(params.skuCode).then((galleryData: any) => {
slideItem = galleryData;
this.slideData = slideItem;
});
} else { } else {
this.product = undefined; this.product = undefined;
} }
...@@ -126,7 +124,7 @@ export class ProductdetailPage implements OnInit { ...@@ -126,7 +124,7 @@ export class ProductdetailPage implements OnInit {
buyNow(product: any, type: number) { buyNow(product: any, type: number) {
this.cartService.buyNow(product).then(() => { this.cartService.buyNow(product).then(() => {
if (type === 1) { if (type === 1) {
this.router.navigateByUrl("cart"); this.router.navigateByUrl('cart');
} else { } else {
// alert('Product added to cart'); // alert('Product added to cart');
} }
...@@ -140,7 +138,7 @@ export class ProductdetailPage implements OnInit { ...@@ -140,7 +138,7 @@ export class ProductdetailPage implements OnInit {
checkFavStatus(index) { checkFavStatus(index) {
const state = this.prodService.fav.findIndex(x => x === index); const state = this.prodService.fav.findIndex(x => x === index);
return state > -1 ? "fav_fill" : "fav_icon"; return state > -1 ? 'fav_fill' : 'fav_icon';
} }
changeFav(index) { changeFav(index) {
...@@ -149,10 +147,10 @@ export class ProductdetailPage implements OnInit { ...@@ -149,10 +147,10 @@ export class ProductdetailPage implements OnInit {
// console.log(this.prodService.fav); // console.log(this.prodService.fav);
if (state > -1) { if (state > -1) {
this.prodService.fav.splice(state, 1); this.prodService.fav.splice(state, 1);
this.prodService.changeFav(index, "yes"); this.prodService.changeFav(index, 'yes');
} else { } else {
this.prodService.fav.push(index); this.prodService.fav.push(index);
this.prodService.changeFav(index, "no"); this.prodService.changeFav(index, 'no');
} }
return; return;
// console.log(this.prodService.fav); // console.log(this.prodService.fav);
......
...@@ -44,10 +44,11 @@ export class SignupPage implements OnInit { ...@@ -44,10 +44,11 @@ export class SignupPage implements OnInit {
private location: Location, private location: Location,
public register: AuthService public register: AuthService
) { ) {
console.log(this.currDate.getFullYear() - 10);
this.currDate.setFullYear(this.currDate.getFullYear() - 10); this.currDate.setFullYear(this.currDate.getFullYear() - 10);
console.log(this.currDate); console.log(this.currDate);
const month = '' + (this.currDate.getMonth() + 1), const month = this.currDate.getMonth() + 1 < 10 ? '0' + (this.currDate.getMonth() + 1) : '' + (this.currDate.getMonth() + 1),
day = '' + this.currDate.getDate(), day = this.currDate.getDate() < 10 ? '0' + this.currDate.getDate() : this.currDate.getDate(),
year = this.currDate.getFullYear(); year = this.currDate.getFullYear();
this.minDate = [year, month, day].join('-'); this.minDate = [year, month, day].join('-');
} }
......
import { Injectable } from "@angular/core"; import { Injectable } from '@angular/core';
import { import { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore';
AngularFirestore, import { take } from 'rxjs/operators';
AngularFirestoreCollection import { Address, AddressList } from './services/address';
} from "@angular/fire/firestore";
import { AddressList, Address } from "./services/address";
import { database } from "firebase";
import { take } from "rxjs/operators";
@Injectable({ @Injectable({
providedIn: "root" providedIn: 'root'
}) })
export class AddressService { export class AddressService {
addressList: AddressList[] = []; addressList: AddressList[] = [];
...@@ -18,15 +14,10 @@ export class AddressService { ...@@ -18,15 +14,10 @@ export class AddressService {
const This = this; const This = this;
const state = true; const state = true;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection( const orderRef: AngularFirestoreCollection<any> = this.afs.collection(
"address", 'address',
ref => ref.where("status", "==", state).where("uid", "==", userId) ref => ref.where('status', '==', state).where('uid', '==', userId)
); );
orderRef orderRef.valueChanges().subscribe(value => {
.valueChanges()
.pipe(
take(1) // Here you can limit to only emit once, using the take operator
)
.subscribe(value => {
this.addressList = []; this.addressList = [];
const res = value; const res = value;
if (res.length > 0) { if (res.length > 0) {
...@@ -43,7 +34,7 @@ export class AddressService { ...@@ -43,7 +34,7 @@ export class AddressService {
}; };
this.addressList.push(address); this.addressList.push(address);
}); });
// console.log(this.addressList); console.log(this.addressList);
} else { } else {
// alert('No Orders Found'); // alert('No Orders Found');
} }
...@@ -51,16 +42,18 @@ export class AddressService { ...@@ -51,16 +42,18 @@ export class AddressService {
} }
addressCreate(data: Address) { addressCreate(data: Address) {
console.log(data);
this.afs this.afs
.collection("address") .collection('address')
.add({}) .add({})
.then(docRef => { .then(docRef => {
data.addressId = docRef.id; data.addressId = docRef.id;
this.afs this.afs
.collection("address") .collection('address')
.doc(data.addressId) .doc(data.addressId)
.set(data) .set(data)
.then(() => { .then(() => {
this.setDefaultAddress(data.addressId, data.uid);
// console.log('Address created Successfully'); // console.log('Address created Successfully');
}); });
}); });
...@@ -68,19 +61,23 @@ export class AddressService { ...@@ -68,19 +61,23 @@ export class AddressService {
setDefaultAddress(addId: string, userId: string) { setDefaultAddress(addId: string, userId: string) {
this.afs this.afs
.collection("address", ref => ref.where("uid", "==", userId)) .collection('address', ref => ref.where('uid', '==', userId))
.get() .get()
.forEach(item => { .forEach(item => {
return item.docs.map(m => { return item.docs.map(m => {
return this.afs.doc(`address/${m.id}`).update({ defaultVal: 0 }); return this.afs.doc(`address/${m.id}`).update({ defaultVal: 0 });
}); });
}); });
this.afs setTimeout(() => {
.collection("address") console.log(addId);
this.afs
.collection('address')
.doc(addId) .doc(addId)
.update({ defaultVal: 1 }) .update({ defaultVal: 1 })
.then(() => { .then(() => {
// console.log('Address updated Successfully'); console.log('Address updated Successfully');
}); });
}, 1000);
} }
} }
...@@ -5,6 +5,7 @@ import { Router, ActivatedRoute } from '@angular/router'; ...@@ -5,6 +5,7 @@ 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 { GooglePlus } from '@ionic-native/google-plus/ngx'; import { GooglePlus } from '@ionic-native/google-plus/ngx';
import { take } from 'rxjs/operators'; import { take } from 'rxjs/operators';
import { from } from 'rxjs'; import { from } from 'rxjs';
...@@ -22,11 +23,13 @@ export class AuthService { ...@@ -22,11 +23,13 @@ export class AuthService {
public afAuth: AngularFireAuth, public afAuth: AngularFireAuth,
private router: Router, private router: Router,
private service: ServiceService, private service: ServiceService,
private subjectService: SubjectService,
private googlePlus: GooglePlus private googlePlus: GooglePlus
) { ) {
this.type = 1; this.type = 1;
this.afAuth.authState.subscribe(user => { this.afAuth.authState.subscribe(user => {
if (user) { if (user) {
this.subjectService.sendLoginData(false);
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));
...@@ -36,6 +39,7 @@ export class AuthService { ...@@ -36,6 +39,7 @@ export class AuthService {
this.router.navigateByUrl('verification'); this.router.navigateByUrl('verification');
} }
} else { } else {
this.subjectService.sendLoginData(true);
this.service.set('user', null); this.service.set('user', null);
JSON.parse(localStorage.getItem('user')); JSON.parse(localStorage.getItem('user'));
this.router.navigateByUrl('login'); this.router.navigateByUrl('login');
...@@ -119,6 +123,7 @@ export class AuthService { ...@@ -119,6 +123,7 @@ export class AuthService {
public async SignOut() { public async SignOut() {
return this.afAuth.auth.signOut().then(() => { return this.afAuth.auth.signOut().then(() => {
this.subjectService.sendLoginData(true);
this.service.remove('user'); this.service.remove('user');
console.log('logout'); console.log('logout');
}); });
......
import { Injectable } from "@angular/core"; import { Injectable } from '@angular/core';
import { import {
AngularFirestore, AngularFirestore,
AngularFirestoreDocument, AngularFirestoreDocument,
AngularFirestoreCollection AngularFirestoreCollection
} from "@angular/fire/firestore"; } from '@angular/fire/firestore';
import { Router, ActivatedRoute } from "@angular/router"; import { Router, ActivatedRoute } from '@angular/router';
import { Order, CartProd } from "./services/order"; import { Order, CartProd } from './services/order';
import { Products } from "./services/product"; import { Products } from './services/product';
import { ServiceService } from "./service.service"; import { ServiceService } from './service.service';
import * as firebase from "firebase"; import * as firebase from 'firebase';
import { CartItem } from "./services/cart"; import { CartItem } from './services/cart';
import { BehaviorSubject } from "rxjs"; import { BehaviorSubject } from 'rxjs';
@Injectable({ @Injectable({
providedIn: "root" providedIn: 'root'
}) })
export class OrdersService { export class OrdersService {
order: Order; order: Order;
...@@ -29,17 +29,17 @@ export class OrdersService { ...@@ -29,17 +29,17 @@ export class OrdersService {
public router: Router, public router: Router,
public service: ServiceService public service: ServiceService
) { ) {
this.size = "small"; this.size = 'small';
this.color = "Blue"; this.color = 'Blue';
this.custId = ""; this.custId = '';
this.service.get("user").then(data => { this.service.get('user').then(data => {
if (data) { if (data) {
data = JSON.parse(data); data = JSON.parse(data);
this.users = data; this.users = data;
this.custId = data.uid; this.custId = data.uid;
// console.log(this.custId); // console.log(this.custId);
} else { } else {
this.custId = "WwHnLICVY2dvZGUHuKqasiTB91a2"; this.custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2';
} }
}); });
} }
...@@ -134,7 +134,7 @@ export class OrdersService { ...@@ -134,7 +134,7 @@ export class OrdersService {
distinctShops.forEach(item => { distinctShops.forEach(item => {
// console.log(item); // console.log(item);
this.afs this.afs
.collection("orders") .collection('orders')
.add({ .add({
bookDate: firebase.firestore.FieldValue.serverTimestamp() bookDate: firebase.firestore.FieldValue.serverTimestamp()
}) })
...@@ -155,7 +155,7 @@ export class OrdersService { ...@@ -155,7 +155,7 @@ export class OrdersService {
color: prodItem.color, color: prodItem.color,
size: prodItem.size, size: prodItem.size,
qty: prodItem.qty, qty: prodItem.qty,
discount: "" discount: ''
}; };
this.afs.doc(`carts/${prodItem.cartId}`).delete(); this.afs.doc(`carts/${prodItem.cartId}`).delete();
}); });
...@@ -163,50 +163,50 @@ export class OrdersService { ...@@ -163,50 +163,50 @@ export class OrdersService {
// console.log(products); // console.log(products);
const product = cartItem[0]; const product = cartItem[0];
const orderItem: Order = { const orderItem: Order = {
amount: "A$ " + otherCharge.totalAmt, amount: 'A$ ' + otherCharge.totalAmt,
customer: firebase.firestore().doc("/customer/" + this.custId), customer: firebase.firestore().doc('/customer/' + this.custId),
shopper: product.shopper, shopper: product.shopper,
deliveryAddress: otherCharge.custAddress, deliveryAddress: otherCharge.custAddress,
deliveryCharge: "A$ " + otherCharge.deliveryCharge, deliveryCharge: 'A$ ' + otherCharge.deliveryCharge,
deliveryLocation: delivery, deliveryLocation: delivery,
bookDate: firebase.firestore.FieldValue.serverTimestamp(), bookDate: firebase.firestore.FieldValue.serverTimestamp(),
orderCode: this.orderCode(), orderCode: this.orderCode(),
orderId: neworderId, orderId: neworderId,
orderStatus: 1, orderStatus: 1,
pickupAddress: "GetMi, Canberra, AUS", pickupAddress: 'GetMi, Canberra, AUS',
pickupLocation: pickup, pickupLocation: pickup,
promoId: null, promoId: null,
rider: firebase rider: firebase
.firestore() .firestore()
.doc("/riders/qbTKza18mWVzYG9NLIbmjMbrYjG2"), .doc('/riders/qbTKza18mWVzYG9NLIbmjMbrYjG2'),
status: 1, status: 1,
custId: this.custId, custId: this.custId,
riderId: "qbTKza18mWVzYG9NLIbmjMbrYjG2", riderId: 'qbTKza18mWVzYG9NLIbmjMbrYjG2',
shopperId: product.shopperId, shopperId: product.shopperId,
custName: "Jone Doe", custName: 'Jone Doe',
riderName: "John", riderName: 'John',
shopperState: 0, shopperState: 0,
shopperName: "Witchery", shopperName: 'Witchery',
product: products, product: products,
discount: "A$ " + otherCharge.discount, discount: 'A$ ' + otherCharge.discount,
promoApplied: otherCharge.discountApplied, promoApplied: otherCharge.discountApplied,
tax: "A$ " + otherCharge.taxAmount tax: 'A$ ' + otherCharge.taxAmount
}; };
// console.log(orderItem); // console.log(orderItem);
this.afs this.afs
.collection("orders") .collection('orders')
.doc(neworderId) .doc(neworderId)
.set(orderItem) .set(orderItem)
.then(() => { .then(() => {
// console.log('Booking Successfully'); // console.log('Booking Successfully');
// this.router.navigateByUrl('cart'); // this.router.navigateByUrl('cart');
resolve("Cart to Order Successfully"); resolve('Cart to Order Successfully');
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
}); });
}) })
.catch(error => { .catch(error => {
console.error("Error adding document: ", error); console.error('Error adding document: ', error);
}); });
}); });
}); });
...@@ -216,7 +216,7 @@ export class OrdersService { ...@@ -216,7 +216,7 @@ export class OrdersService {
public async changeOrder(orderId, status) { public async changeOrder(orderId, status) {
// console.log(orderId, status); // console.log(orderId, status);
this.afs this.afs
.collection("orders") .collection('orders')
.doc(orderId) .doc(orderId)
.update({ orderStatus: status }); .update({ orderStatus: status });
} }
...@@ -227,13 +227,13 @@ export class OrdersService { ...@@ -227,13 +227,13 @@ export class OrdersService {
orderCode() { orderCode() {
const newpin = Math.round(Math.random() * 1000000); const newpin = Math.round(Math.random() * 1000000);
const orderCode = "GM" + this.pad(newpin, 6, null); const orderCode = 'GM' + this.pad(newpin, 6, null);
return orderCode; return orderCode;
} }
pad(n, width, z) { pad(n, width, z) {
z = z || "0"; z = z || '0';
n = n + ""; n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
} }
......
import { Injectable } from "@angular/core"; import { Injectable } from '@angular/core';
import { import { AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument } from '@angular/fire/firestore';
AngularFirestore, import { take } from 'rxjs/operators';
AngularFirestoreDocument, import { ServiceService } from './../config/service.service';
AngularFirestoreCollection import { Products } from './services/product';
} from "@angular/fire/firestore";
import { Products } from "./services/product";
import { Slides } from "./services/slides";
import { ServiceService } from "./../config/service.service";
import { take } from "rxjs/operators";
@Injectable({ @Injectable({
providedIn: "root" providedIn: 'root'
}) })
export class ProductsService { export class ProductsService {
prodSlideImg: Slides[] = []; prodSlideImg: any;
product: Products[] = []; product: Products[] = [];
fav: any[]; fav: any[];
selItem: Products; selItem: Products;
...@@ -24,42 +18,35 @@ export class ProductsService { ...@@ -24,42 +18,35 @@ export class ProductsService {
this.product = []; this.product = [];
this.fav = []; this.fav = [];
this.prodSlideImg = []; this.prodSlideImg = [];
this.service.get("user").then(data => { this.service.get('user').then(data => {
this.user = JSON.parse(data); this.user = JSON.parse(data);
this.getFavlist(this.user.uid); this.getFavlist(this.user.uid);
}); });
} }
// Fetches images for slide // Fetches images for slide
public async getProdSlide(skuID: string) { public async fetchGallery(skuID: string) {
const This = this; const This = this;
const state = true; const state = true;
// firebase query // firebase query
const prodRef: AngularFirestoreCollection<any> = this.afs.collection( return new Promise (resolve => {
`product_gallery`, const prodRef: AngularFirestoreCollection<any> = this.afs.collection(
ref => ref.where("skuId", "==", skuID) `product_gallery`,
); ref => ref.where('skuId', '==', skuID)
prodRef.valueChanges().subscribe(value => { );
this.prodSlideImg = []; prodRef.valueChanges().subscribe(value => {
const res = value; this.prodSlideImg = [];
const res = value;
if (res.length > 0) { if (res.length > 0) {
res.forEach(item => { res.forEach((item) => {
const slideImg: Slides = { this.prodSlideImg.push(item.downloadURL);
downloadURL: item.downloadURL, });
imageId: item.imageId, resolve(this.prodSlideImg);
path: item.path, } else {
skuId: item.skuId resolve(this.prodSlideImg);
}; }
this.prodSlideImg.push(slideImg); });
});
console.log("[prodSlideImgArray]", this.prodSlideImg);
return this.prodSlideImg;
} else {
// alert("No Products Found");
}
}); });
} }
...@@ -70,7 +57,7 @@ export class ProductsService { ...@@ -70,7 +57,7 @@ export class ProductsService {
const prodRef: AngularFirestoreCollection<any> = this.afs.collection( const prodRef: AngularFirestoreCollection<any> = this.afs.collection(
`products`, `products`,
ref => ref =>
ref.where("shopperId", "==", shopperId).where("status", "==", state) ref.where('shopperId', '==', shopperId).where('status', '==', state)
); );
prodRef.valueChanges().subscribe(value => { prodRef.valueChanges().subscribe(value => {
this.product = []; this.product = [];
...@@ -115,17 +102,17 @@ export class ProductsService { ...@@ -115,17 +102,17 @@ export class ProductsService {
// console.log(sortValue); // console.log(sortValue);
let field, order; let field, order;
if (sortValue === "low") { if (sortValue === 'low') {
field = "price"; field = 'price';
order = "asc"; order = 'asc';
} }
if (sortValue === "high") { if (sortValue === 'high') {
field = "price"; field = 'price';
order = "desc"; order = 'desc';
} }
if (sortValue === "rate") { if (sortValue === 'rate') {
// field = 'price'; // field = 'price';
// order = 'desc'; // order = 'desc';
} }
...@@ -133,7 +120,7 @@ export class ProductsService { ...@@ -133,7 +120,7 @@ export class ProductsService {
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
const prodRef: AngularFirestoreCollection<any> = this.afs.collection( const prodRef: AngularFirestoreCollection<any> = this.afs.collection(
`products`, `products`,
ref => ref.where("status", "==", state).orderBy(field, order) ref => ref.where('status', '==', state).orderBy(field, order)
); );
prodRef.valueChanges().subscribe(value => { prodRef.valueChanges().subscribe(value => {
this.product = []; this.product = [];
...@@ -180,12 +167,12 @@ export class ProductsService { ...@@ -180,12 +167,12 @@ export class ProductsService {
`products`, `products`,
ref => ref =>
ref ref
.where("shopperId", "==", shopperId) .where('shopperId', '==', shopperId)
.where("status", "==", state) .where('status', '==', state)
.where("category", "==", category) .where('category', '==', category)
.where("subCate", "==", subCate) .where('subCate', '==', subCate)
.where("prodId", ">", prodId) .where('prodId', '>', prodId)
.where("prodId", "<", prodId) .where('prodId', '<', prodId)
); );
prodRef.valueChanges().subscribe(value => { prodRef.valueChanges().subscribe(value => {
this.similar = []; this.similar = [];
...@@ -250,9 +237,9 @@ export class ProductsService { ...@@ -250,9 +237,9 @@ export class ProductsService {
public async changeFav(index, type) { public async changeFav(index, type) {
// console.log(index, type, this.user.uid); // console.log(index, type, this.user.uid);
if (type === "no") { if (type === 'no') {
this.afs this.afs
.collection("favourite") .collection('favourite')
.doc(this.user.uid) .doc(this.user.uid)
.valueChanges() .valueChanges()
.pipe( .pipe(
...@@ -261,7 +248,7 @@ export class ProductsService { ...@@ -261,7 +248,7 @@ export class ProductsService {
.subscribe(value => { .subscribe(value => {
if (value === undefined) { if (value === undefined) {
this.afs this.afs
.collection("favourite") .collection('favourite')
.doc(this.user.uid) .doc(this.user.uid)
.set({ .set({
[index]: true [index]: true
...@@ -271,14 +258,14 @@ export class ProductsService { ...@@ -271,14 +258,14 @@ export class ProductsService {
value[index] = true; value[index] = true;
// console.log(value); // console.log(value);
this.afs this.afs
.collection("favourite") .collection('favourite')
.doc(this.user.uid) .doc(this.user.uid)
.set(value); .set(value);
} }
}); });
} else { } else {
this.afs this.afs
.collection("favourite") .collection('favourite')
.doc(this.user.uid) .doc(this.user.uid)
.valueChanges() .valueChanges()
.pipe( .pipe(
...@@ -289,11 +276,11 @@ export class ProductsService { ...@@ -289,11 +276,11 @@ export class ProductsService {
if (value !== undefined) { if (value !== undefined) {
value[index] = undefined; value[index] = undefined;
Object.keys(value).forEach(key => Object.keys(value).forEach(key =>
value[key] === undefined ? delete value[key] : "" value[key] === undefined ? delete value[key] : ''
); );
// console.log(value); // console.log(value);
this.afs this.afs
.collection("favourite") .collection('favourite')
.doc(this.user.uid) .doc(this.user.uid)
.set(value); .set(value);
} else { } else {
......
import { Injectable } from '@angular/core';
import { observable, Observable } from 'rxjs';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable({
providedIn: 'root'
})
export class SubjectService {
private loginState = new BehaviorSubject<any>(null);
sendLoginData(state: any) {
this.loginState.next(state);
}
getLoginData(): Observable<any> {
return this.loginState.asObservable();
}
}
import { Injectable } from "@angular/core"; import { Injectable } from '@angular/core';
import { import {
User, User,
UpdateUserDetails, UpdateUserDetails,
Address, Address,
updatePassword UpdatePassword
} from "./services/user"; } 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 { import {
AngularFirestore, AngularFirestore,
AngularFirestoreDocument, AngularFirestoreDocument,
AngularFirestoreCollection AngularFirestoreCollection
} from "@angular/fire/firestore"; } from '@angular/fire/firestore';
import { ServiceService } from "./../config/service.service"; import { ServiceService } from './../config/service.service';
import { GooglePlus } from "@ionic-native/google-plus/ngx"; import { GooglePlus } from '@ionic-native/google-plus/ngx';
import { take } from "rxjs/operators"; import { take } from 'rxjs/operators';
import { from } from "rxjs"; import { from } from 'rxjs';
@Injectable({ @Injectable({
providedIn: "root" providedIn: 'root'
}) })
export class UpdateService { export class UpdateService {
userData: any; userData: any;
...@@ -63,12 +63,12 @@ export class UpdateService { ...@@ -63,12 +63,12 @@ export class UpdateService {
this.userPostData = postData; this.userPostData = postData;
this.afs this.afs
.collection("customers") .collection('customers')
.doc(uid) .doc(uid)
.update(postData) .update(postData)
.then(() => { .then(() => {
console.log("success"); console.log('success');
this.router.navigateByUrl("profile"); this.router.navigateByUrl('profile');
}) })
.catch(error => { .catch(error => {
console.log(error); console.log(error);
...@@ -76,7 +76,7 @@ export class UpdateService { ...@@ -76,7 +76,7 @@ export class UpdateService {
} }
// Change Password // Change Password
updatePassword(userData: updatePassword) { updatePassword(userData: UpdatePassword) {
// Gets current user // Gets current user
let user = this.afAuth.auth.currentUser; let user = this.afAuth.auth.currentUser;
let newPassword = userData.password; let newPassword = userData.password;
...@@ -85,7 +85,7 @@ export class UpdateService { ...@@ -85,7 +85,7 @@ export class UpdateService {
user user
.updatePassword(newPassword) .updatePassword(newPassword)
.then(() => { .then(() => {
console.log("Password Changed"); console.log('Password Changed');
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
......
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