Commit 13bbafef by Adarsh K

Merge branch 'adarsh' into 'master'

bug fixes See merge request !82
parents 3276cf66 afbadcae
......@@ -133,7 +133,7 @@ export class CartPage implements OnInit {
}
getTax(amount) {
return Math.round((this.taxAmount = (amount * 10) / 100)).toFixed(2);
return (this.taxAmount = (amount * 10) / 100).toFixed(2);
}
getwaypayk() {
......@@ -154,7 +154,7 @@ export class CartPage implements OnInit {
}
goToPage(path, data = null) {
this.router.navigateByUrl(path, { queryParams: data });
this.router.navigateByUrl(path, { queryParams: data, replaceUrl: true });
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
......
......@@ -66,6 +66,7 @@ export class HomePage implements OnInit {
private authService: AuthService
) {
this.loader = false;
this.address = 'Pick your Location';
}
ngOnInit() {
......@@ -89,7 +90,7 @@ export class HomePage implements OnInit {
navigator.geolocation.getCurrentPosition(position => {
this.lat = position.coords.latitude;
this.lng = position.coords.longitude;
this.centerService.getNearBy(this.lat, this.lng, 10);
this.centerService.getNearBy(this.lat, this.lng, this.service.distance);
this.getAddress(this.lat, this.lng);
});
}
......@@ -121,7 +122,7 @@ export class HomePage implements OnInit {
this.addressService.setDefaultAddress(address.addressId, this.custId).then(() => {
this.address = address.address;
console.log(address.latLng);
this.centerService.getNearBy(address.latLng._lat, address.latLng._long, 10);
this.centerService.getNearBy(address.latLng._lat, address.latLng._long, this.service.distance);
this.loader = false;
}).catch(err => {
this.loader = false;
......
......@@ -30,7 +30,7 @@
<span *ngIf="product.size !== 'Any-Size'">{{product.size}}</span>&nbsp;<span>{{product.qty}}</span>
</h5>
<p *ngIf="product.price">A$ {{service.formatNumber(product.price)}}</p>
<p *ngIf="product.price">A$ {{service.formatNumber(product.price.toFixed(2))}}</p>
</div>
<div class="order_other">
<h6 class="floatRight" *ngIf="order.bookDate">
......@@ -47,7 +47,7 @@
</div>
<div class="order_info">
<h5 class="floatRight">TOTAL PRICE : {{service.formatNumber(order.amount)}}</h5>
<h5 class="floatRight">TOTAL PRICE : {{getProductTotal(order.product)}}</h5>
<div class="clear"></div>
</div>
......
......@@ -120,4 +120,11 @@ export class MyorderPage implements OnInit {
return unescape(text.replace(/%uFFFD/g, ''));
}
getProductTotal(products) {
let amtPrice = 0;
products.forEach(element => {
amtPrice += element.price * element.qty;
});
return 'A$' + this.service.formatNumber(amtPrice);
}
}
......@@ -23,10 +23,10 @@ const routes: Routes = [
IonicModule,
AgmDirectionModule,
AgmCoreModule.forRoot({
apiKey: "AIzaSyBn6hOlr6YHcZAmbptlsmbhvH5iQllWflE"
apiKey: 'AIzaSyBn6hOlr6YHcZAmbptlsmbhvH5iQllWflE'
}),
RouterModule.forChild(routes)
],
declarations: [NearbyPage]
})
export class NearbyPageModule {}
export class NearbyPageModule { }
<div class="nav_header">
<button class="nav_btn nav_back floatLeft" (click)="goBack()">
<button class="nav_btn nav_back floatLeft" (click)="goBack()" *ngIf="authService.regState">
<img src="../assets/Group17_2.png" />
</button>
<div class="nav_title floatLeft">
......@@ -9,119 +9,54 @@
</div>
<ion-content>
<div class="nearby_map">
<agm-map
[latitude]="latitude"
[longitude]="longitude"
[zoom]="8"
[backgroundColor]="'rgba(29, 27, 130,0.2)'"
>
<agm-marker
[latitude]="latitude"
[longitude]="longitude"
[markerDraggable]="true"
(dragEnd)="markerDragEnd($event)"
></agm-marker>
<agm-map [latitude]="latitude" [longitude]="longitude" [zoom]="8" [backgroundColor]="'rgba(29, 27, 130,0.2)'">
<agm-marker [latitude]="latitude" [longitude]="longitude" [markerDraggable]="true"
(dragEnd)="markerDragEnd($event)"></agm-marker>
</agm-map>
<form
(ngSubmit)="onSubmit(addressForm.value); addressForm.reset()"
#addressForm="ngForm"
method="post"
class="form-horizontal"
>
<form (ngSubmit)="onSubmit(addressForm.value); addressForm.reset()" #addressForm="ngForm" method="post"
class="form-horizontal">
<div class="add_address_wrapper">
<h5>DELIVERY</h5>
<p>{{address}}</p>
<input
[(ngModel)]="addressForm.building"
name="building"
#building="ngModel"
name="building"
required
placeholder="House No./ Building No"
/>
<div
class="md-errors-spacer"
[hidden]="building.valid || landmark.pristine"
class="ion-padding-start"
>
<input [(ngModel)]="addressForm.building" name="building" #building="ngModel" name="building" required
placeholder="House No./ Building No" />
<div class="md-errors-spacer" [hidden]="building.valid || landmark.pristine" class="ion-padding-start">
Building Name is required
</div>
<input
[(ngModel)]="addressForm.landmark"
name="landmark"
#landmark="ngModel"
name="landmark"
required
placeholder="Landmark"
/>
<div
class="md-errors-spacer"
[hidden]="landmark.valid || landmark.pristine"
class="ion-padding-start"
>
<input [(ngModel)]="addressForm.landmark" name="landmark" #landmark="ngModel" name="landmark" required
placeholder="Landmark" />
<div class="md-errors-spacer" [hidden]="landmark.valid || landmark.pristine" class="ion-padding-start">
Landmark is required
</div>
<ion-grid>
<ion-row>
<ion-col>
<h6>
<input
class="styled-checkbox"
id="styled-check-1"
type="radio"
value="Home"
[(ngModel)]="addressForm.addressType"
name="addressType"
#addressType="ngModel"
required
/>
<input class="styled-checkbox" id="styled-check-1" type="radio" value="Home"
[(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel" required />
<label for="styled-check-1"><span>Home</span></label>
</h6>
</ion-col>
<ion-col>
<h6>
<input
class="styled-checkbox"
id="styled-check-2"
type="radio"
value="Work"
[(ngModel)]="addressForm.addressType"
name="addressType"
#addressType="ngModel"
required
/>
<input class="styled-checkbox" id="styled-check-2" type="radio" value="Work"
[(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel" required />
<label for="styled-check-2"><span>Office</span></label>
</h6>
</ion-col>
<ion-col>
<h6>
<input
class="styled-checkbox"
id="styled-check-3"
type="radio"
value="Other"
[(ngModel)]="addressForm.addressType"
name="addressType"
#addressType="ngModel"
required
/>
<input class="styled-checkbox" id="styled-check-3" type="radio" value="Other"
[(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel" required />
<label for="styled-check-3"><span>Others</span></label>
</h6>
</ion-col>
</ion-row>
<div
class="md-errors-spacer"
[hidden]="addressType.valid || addressType.pristine"
class="ion-padding-start"
>
<div class="md-errors-spacer" [hidden]="addressType.valid || addressType.pristine" class="ion-padding-start">
Address Type is required
</div>
</ion-grid>
<button
class="add_btn"
type="submit"
[disabled]="!addressForm.form.valid"
>
<button class="add_btn" type="submit" [disabled]="!addressForm.form.valid">
ADD
</button>
</div>
......@@ -133,4 +68,4 @@
<div></div>
</div>
</div>
</ion-content>
</ion-content>
\ No newline at end of file
......@@ -11,6 +11,7 @@ import { MapsAPILoader, MouseEvent } from '@agm/core';
import { Address } from './../../config/services/address';
import { AddressService } from './../../config/address.service';
import { ServiceService } from './../../config/service.service';
import { AuthService } from './../../config/auth.service';
import { NgForm } from '@angular/forms';
import * as firebase from 'firebase';
/* import { google } from '@agm/core/services/google-maps-types'; */
......@@ -41,7 +42,8 @@ export class NearbyPage implements OnInit {
private mapsAPILoader: MapsAPILoader,
private ngZone: NgZone,
public addressService: AddressService,
public service: ServiceService
public service: ServiceService,
public authService: AuthService
) {
this.successState = false;
this.type = 0;
......@@ -67,7 +69,13 @@ export class NearbyPage implements OnInit {
// google maps zoom level
private setCurrentLocation() {
console.log('map-called');
if ('geolocation' in navigator) {
console.log(navigator);
this.latitude = -33.87276;
this.longitude = 151.20534;
this.zoom = 8;
this.getAddress(this.latitude, this.longitude);
navigator.geolocation.getCurrentPosition(position => {
this.latitude = position.coords.latitude;
this.longitude = position.coords.longitude;
......@@ -85,6 +93,7 @@ export class NearbyPage implements OnInit {
}
getAddress(latitude, longitude) {
this.geoCoder = new google.maps.Geocoder();
this.geoCoder.geocode(
{ location: { lat: latitude, lng: longitude } },
(results, status) => {
......@@ -96,10 +105,10 @@ export class NearbyPage implements OnInit {
this.address = results[0].formatted_address;
console.log(this.address);
} else {
window.alert('No results found');
console.log('No results found');
}
} else {
window.alert('Geocoder failed due to: ' + status);
console.log('Geocoder failed due to: ' + status);
}
}
);
......@@ -133,7 +142,7 @@ export class NearbyPage implements OnInit {
setTimeout(() => {
this.loader = false;
this.successState = false;
if (this.type === 1) {
if (this.authService.regState === false) {
this.router.navigateByUrl('preference', { queryParams: null });
} else {
this.goBack();
......
<div class="nav_header">
<button class="nav_btn nav_back floatLeft" (click)="goBack()">
<button class="nav_btn nav_back floatLeft" (click)="goBack()" *ngIf="authService.regState">
<img src="../assets/Group17_2.png" />
</button>
<div class="nav_title floatLeft">
......
import { Component, OnInit } from '@angular/core';
import { CategoriesService } from './../../config/category.service';
import { ServiceService } from './../../config/service.service';
import { AuthService } from './../../config/auth.service';
import { Router, ActivatedRoute } from '@angular/router';
@Component({
......@@ -18,7 +19,8 @@ export class PreferencePage implements OnInit {
constructor(
private categoriesService: CategoriesService,
private service: ServiceService,
private router: Router
private router: Router,
private authService: AuthService
) {
this.successState = false;
this.userPrefence = [];
......@@ -73,9 +75,11 @@ export class PreferencePage implements OnInit {
this.loader = false;
this.successState = false;
this.service.set('type', 0);
if (this.type === 1) {
if (this.authService.regState === false) {
this.authService.regState = true;
this.router.navigateByUrl('home', { queryParams: null });
} else {
this.authService.regState = true;
this.goBack();
}
}, 3000);
......
......@@ -151,7 +151,7 @@ export class ProductdetailPage implements OnInit {
this.cartService.buyNow(product).then((data) => {
if (data === true) {
if (type === 1) {
this.router.navigateByUrl('cart');
this.router.navigateByUrl('cart', { replaceUrl: true });
} else {
this.service.showToast('Added into cart', 'top', 'my-toast', 2000);
}
......
<div class="nav_header">
<button class="nav_btn nav_back floatLeft" (click)="goBack()">
<button class="nav_btn nav_back floatLeft" (click)="goBack()" *ngIf="authService.regState">
<img src="../assets/Group17_2.png" />
</button>
<div class="nav_title floatLeft">
......@@ -15,14 +15,7 @@
<h6>+01 {{authService.userPostData.phone}}</h6>
</div>
<div class="row">
<input
class=""
type="number"
placeholder="Type OTP"
maxlength="4"
#otp
required
/>
<input class="" type="number" placeholder="Type OTP" maxlength="4" #otp required />
</div>
<div class="row">
<button class="login_btn" (click)="authService.verify(otp.value)">
......@@ -43,4 +36,4 @@
<div></div>
</div>
</div>
</ion-content>
</ion-content>
\ No newline at end of file
......@@ -135,7 +135,7 @@ export class AddressService {
.delete();
}
public async getNearBy(centerId, userId) {
public async getNearBy(centerId, userId, distance) {
// latitude, longitude, distance, userId
console.log(centerId);
if (centerId) {
......@@ -161,7 +161,6 @@ export class AddressService {
const lat = 0.0144927536231884;
const lon = 0.0181818181818182;
const distance = 10;
const lowerLat = latitude - lat * distance;
const lowerLon = longitude - lon * distance;
......
......@@ -51,7 +51,7 @@ export class AuthService {
this.router.navigateByUrl('home', { replaceUrl: true });
} else {
this.regState = false;
this.router.navigateByUrl('verification');
this.router.navigateByUrl('verification', { replaceUrl: true });
}
} else {
console.log('here too');
......@@ -109,7 +109,7 @@ export class AuthService {
.update({ otp: '', phoneVerified: true });
this.service.set('type', 1);
this.loader = false;
this.router.navigateByUrl('nearby');
this.router.navigateByUrl('nearby', { replaceUrl: true });
} else {
this.loader = false;
this.service.showToast(
......
......@@ -60,7 +60,7 @@ export class CartsService {
if (this.cartCenter === '') {
this.cartCenter = product.centerId;
this.addressService.defaultAddress(this.custId);
this.addressService.getNearBy(this.cartCenter, this.custId);
this.addressService.getNearBy(this.cartCenter, this.custId, this.service.distance);
}
const cartRef: AngularFirestoreCollection<any> = this.afs.collection(
'carts',
......@@ -156,7 +156,7 @@ export class CartsService {
if (this.cartCenter === '') {
this.cartCenter = res[0].centerId;
this.addressService.defaultAddress(this.custId);
this.addressService.getNearBy(this.cartCenter, this.custId);
this.addressService.getNearBy(this.cartCenter, this.custId, this.service.distance);
}
res.forEach(item => {
const cartItem: CartItem = {
......
......@@ -5,6 +5,7 @@ import {
AngularFirestoreCollection
} from '@angular/fire/firestore';
import { Centers, CenterData } from './services/center';
import { ServiceService } from './service.service';
import * as firebase from 'firebase';
@Injectable({
......@@ -13,9 +14,10 @@ import * as firebase from 'firebase';
export class CenterService {
centers: Centers[] = [];
nearcenters: Centers[] = [];
constructor(public afs: AngularFirestore) {
constructor(public afs: AngularFirestore, public service: ServiceService) {
console.log(this.service.distance);
this.centerList();
this.getNearBy(10.0159, 76.3419, 10);
this.getNearBy(10.0159, 76.3419, this.service.distance);
}
public async centerList() {
......@@ -54,6 +56,7 @@ export class CenterService {
}
public async getNearBy(latitude, longitude, distance) {
console.log(distance);
const This = this;
const state = true;
......
......@@ -233,7 +233,7 @@ export class MyordersService {
const lat = 0.0144927536231884;
const lon = 0.0181818181818182;
const distance = 10;
const distance = this.service.distance;
const lowerLat = latitude - lat * distance;
const lowerLon = longitude - lon * distance;
......
......@@ -163,11 +163,11 @@ export class OrdersService {
const product = cartItem[0];
this.custId = this.custId.trim();
const orderItem: Order = {
amount: 'A$ ' + otherCharge.totalAmt,
amount: 'A$ ' + otherCharge.totalAmt.toFixed(2),
customer: firebase.firestore().doc('/customer/' + this.custId),
shopper: product.shopper,
deliveryAddress: otherCharge.custAddress,
deliveryCharge: 'A$ ' + otherCharge.deliveryCharge,
deliveryCharge: 'A$ ' + otherCharge.deliveryCharge.toFixed(2),
deliveryLocation: otherCharge.custAddress.latLng,
bookDate: firebase.firestore.FieldValue.serverTimestamp(),
orderDate: Math.floor(Date.now() / 1000),
......@@ -195,9 +195,9 @@ export class OrdersService {
shopperName: '',
product: products,
timeRemain: timer,
discount: 'A$ ' + otherCharge.discount,
discount: 'A$ ' + otherCharge.discount.toFixed(2),
promoApplied: otherCharge.discountApplied,
tax: 'A$ ' + otherCharge.taxAmount
tax: 'A$ ' + otherCharge.taxAmount.toFixed(2)
};
// console.log(orderItem);
......
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
import { ToastController } from '@ionic/angular';
import * as firebase from 'firebase';
@Injectable({
providedIn: 'root'
})
export class ServiceService {
state: boolean;
distance: any;
constructor(
public storage: Storage,
public toastController: ToastController
) {
this.state = true;
this.distance = 10;
this.storage.ready().then(() => {
this.get('user');
});
this.setting().then((data) => {
if (data) {
this.distance = data;
}
}).catch(err => {
this.distance = 10;
});
}
public set(settingName: string, value: any) {
......@@ -80,4 +89,21 @@ export class ServiceService {
formatNumber(num: number) {
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')
}
setting() {
const promise = new Promise(resolve => {
const prodRef = firebase
.firestore()
.collection('setting')
.doc('basic').onSnapshot(doc => {
console.log(doc.data());
if (doc.exists) {
const data = doc.data();
this.distance = data.distance;
resolve(this.distance);
}
});
});
return promise;
}
}
......@@ -5,6 +5,7 @@ import {
AngularFirestoreDocument,
AngularFirestoreCollection
} from '@angular/fire/firestore';
import { ServiceService } from './service.service';
import { Shopper } from './services/shopper';
import * as firebase from 'firebase';
......@@ -15,9 +16,9 @@ export class ShoppersService {
shoppers: Shopper[] = [];
activeshoppers: Shopper[] = [];
nearshoppers: Shopper[] = [];
constructor(public afs: AngularFirestore, public afAuth: AngularFireAuth) {
constructor(public afs: AngularFirestore, public afAuth: AngularFireAuth, public service: ServiceService) {
this.featuredshopperList();
this.getNearBy(10.0159, 76.3419, 10);
this.getNearBy(-33.87276, 151.20534, this.service.distance);
}
public async shopperList(centerId: any, type: string) {
......
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