Commit c026171d by Adarsh K

app dev

parent 8f51f913
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="com.getmi.rider" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>GetMiRider</name>
<description>An Ionic/Cordova app.</description>
<author email="www.techware.co.in" href="http://ionicframework.com/">Techware Software Solutions Pvt Ltd</author>
......
......@@ -25,7 +25,9 @@
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^4.7.1",
"@ionic/storage": "^2.2.0",
"agm-direction": "^0.7.8",
"angularfire2": "^5.2.1",
"cordova-android": "7.1.4",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.1.3",
......@@ -33,7 +35,9 @@
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-sqlite-storage": "^3.3.0",
"core-js": "^2.5.4",
"firebase": "^6.4.2",
"rxjs": "~6.5.1",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
......@@ -74,7 +78,8 @@
"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
"cordova-plugin-ionic-keyboard": {}
"cordova-plugin-ionic-keyboard": {},
"cordova-sqlite-storage": {}
},
"platforms": [
"android"
......
......@@ -6,6 +6,16 @@ import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { IonicStorageModule } from '@ionic/storage';
import { AngularFireModule } from '@angular/fire';
import { AngularFirestore } from '@angular/fire/firestore';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { environment } from '../environments/environment';
import { ServiceService } from './../config/service.service';
import { AuthService } from './../config/auth.service';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
......@@ -14,11 +24,21 @@ import { AppRoutingModule } from './app-routing.module';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
imports: [
BrowserModule,
IonicModule.forRoot(),
IonicStorageModule.forRoot(),
AppRoutingModule,
AngularFireModule.initializeApp(environment.firebase),
AngularFireAuthModule,
AngularFirestoreModule
],
providers: [
StatusBar,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
ServiceService,
AuthService
],
bootstrap: [AppComponent]
})
......
......@@ -11,17 +11,17 @@
<p>Delivered in 32 Mnts.</p>
<button class="rate_button">RATE CUSTOMER</button>
</div>
<div class="order_acceptance">
<div class="order_acceptance" *ngIf="order">
<div class="order_acceptance_inner">
<div class="point_header">
<div class="point_image"></div>
<div class="point_detail">You</div>
<strong class="floatRight">ORID008800</strong>
<strong class="floatRight"> {{order.orderCode}}</strong>
<div class="clear"></div>
</div>
<div class="point_box">
<div class="point_head floatLeft">
06, Tasmania, horse building<br>
{{order.pickupAddress}}<br>
<strong>2 Km</strong>
</div>
<div class="clear"></div>
......@@ -33,11 +33,11 @@
</div>
<div class="point_box">
<div class="point_head floatLeft">
06, Tasmania, horse building<br>
{{order.deliveryAddress}}<br>
<strong>1 Km</strong>
</div>
<strong class="floatRight">Men's Shirt<br>
<span>Au$ 88</span></strong>
<!-- <strong class="floatRight">Men's Shirt<br>
<span>Au$ 88</span></strong> -->
<div class="clear"></div>
</div>
<div class="point_header">
......@@ -45,13 +45,13 @@
<div class="point_detail">John Doe</div>
<div class="clear"></div>
</div>
<div class="point_box borderNone">
<!-- <div class="point_box borderNone">
<div class="point_head floatLeft">
06, Tasmania, horse building<br>
<strong>1 Km</strong>
</div>
<div class="clear"></div>
</div>
</div> -->
</div>
<hr>
<ion-row>
......@@ -77,5 +77,5 @@
</ion-content>
<ion-footer>
<button class="nxt_btn">GO TO NEXT TRIP</button>
<button class="nxt_btn" (click)="goToPage('home')">GO TO NEXT TRIP</button>
</ion-footer>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { MyordersService } from './../../config/myorder.service';
import { Myorder } from './../../config/services/myorder';
import { Router, ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-complete',
......@@ -6,10 +9,21 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./complete.page.scss'],
})
export class CompletePage implements OnInit {
order: Myorder;
constructor() { }
constructor(
public myorder: MyordersService,
public router: Router
) {
this.order = this.myorder.selItem;
}
ngOnInit() {
}
goToPage(path, data = null) {
this.router.navigateByUrl(path, { queryParams: data });
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
}
......@@ -13,14 +13,14 @@
<agm-direction [origin]="origin" [destination]="destination" [renderOptions]="renderOptions" [markerOptions]="markerOptions">
</agm-direction>
</agm-map>
<div class="bottom_bay">
<div class="bottom_bay" *ngIf="myorder.orders">
<!-- <button class="upload_btn" (click)="goToPage('upload')">UPLOAD DOCUMENTS</button>
<p>Please upload your documents to join ride</p> -->
<ion-slides pager="false" [options]="slideOpts">
<ion-slide>
<ion-slides pager="false" [options]="slideOpts" *ngIf="myorder.orders.length > 0">
<ion-slide *ngFor="let order of myorder.orders; let i = index">
<div class="order_acceptance">
<div class="order_acceptance_inner">
<div class="toggle_btn floatRight" (click)="goToPage('ridedetails')"></div>
<div class="toggle_btn floatRight" (click)="details(i)"></div>
<div class="point_header">
<div class="point_image"></div>
<div class="point_detail">You</div>
......@@ -28,7 +28,7 @@
</div>
<div class="point_box">
<div class="point_head floatLeft">
<strong>2 Km</strong>06, Tasmania, horse building
<strong>2 Km</strong>{{order.pickupAddress}}
</div>
<div class="clear"></div>
</div>
......@@ -39,106 +39,22 @@
</div>
<div class="point_box">
<div class="point_head floatLeft">
<strong>1 Km</strong>06, Tasmania, horse building
<strong>1 Km</strong>{{order.deliveryAddress}}
</div>
<div class="clear"></div>
</div>
<div class="point_header">
<div class="point_image"></div>
<div class="point_detail" style="width: calc(100% - 120px);">John Doe</div>
<strong class="floatRight">AUD$ 20</strong>
<strong class="floatRight">{{order.amount}}</strong>
<div class="clear"></div>
</div>
</div>
<div class="bottom_btn_bay">
<button class="accept_btn floatRight" (click)="goToPage('riderlounge')">
<button class="accept_btn floatRight" (click)="accept(i)">
Accept
</button>
<button class="reject_btn floatLeft">Reject</button>
<div class="clear"></div>
</div>
</div>
</ion-slide>
<ion-slide>
<div class="order_acceptance">
<div class="order_acceptance_inner">
<div class="toggle_btn floatRight" (click)="goToPage('ridedetails')"></div>
<div class="point_header">
<div class="point_image"></div>
<div class="point_detail">You</div>
<div class="clear"></div>
</div>
<div class="point_box">
<div class="point_head floatLeft">
<strong>2 Km</strong>06, Tasmania, horse building
</div>
<div class="clear"></div>
</div>
<div class="point_header">
<div class="point_image"></div>
<div class="point_detail">Lulu fashion store</div>
<div class="clear"></div>
</div>
<div class="point_box">
<div class="point_head floatLeft">
<strong>1 Km</strong>06, Tasmania, horse building
</div>
<div class="clear"></div>
</div>
<div class="point_header">
<div class="point_image"></div>
<div class="point_detail" style="width: calc(100% - 120px);">John Doe</div>
<strong class="floatRight">AUD$ 20</strong>
<div class="clear"></div>
</div>
</div>
<div class="bottom_btn_bay">
<button class="accept_btn floatRight" (click)="goToPage('riderlounge')">
Accept
</button>
<button class="reject_btn floatLeft">Reject</button>
<div class="clear"></div>
</div>
</div>
</ion-slide>
<ion-slide>
<div class="order_acceptance">
<div class="order_acceptance_inner">
<div class="toggle_btn floatRight" (click)="goToPage('ridedetails')"></div>
<div class="point_header">
<div class="point_image"></div>
<div class="point_detail">You</div>
<div class="clear"></div>
</div>
<div class="point_box">
<div class="point_head floatLeft">
<strong>2 Km</strong>06, Tasmania, horse building
</div>
<div class="clear"></div>
</div>
<div class="point_header">
<div class="point_image"></div>
<div class="point_detail">Lulu fashion store</div>
<div class="clear"></div>
</div>
<div class="point_box">
<div class="point_head floatLeft">
<strong>1 Km</strong>06, Tasmania, horse building
</div>
<div class="clear"></div>
</div>
<div class="point_header">
<div class="point_image"></div>
<div class="point_detail" style="width: calc(100% - 120px);">John Doe</div>
<strong class="floatRight">AUD$ 20</strong>
<div class="clear"></div>
</div>
</div>
<div class="bottom_btn_bay">
<button class="accept_btn floatRight" (click)="goToPage('riderlounge')">
Accept
</button>
<button class="reject_btn floatLeft">Reject</button>
<button class="reject_btn floatLeft" (click)="reject(i)">Reject</button>
<div class="clear"></div>
</div>
</div>
......
import { Component } from '@angular/core';
import { Location } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { MyordersService } from './../../config/myorder.service';
@Component({
......@@ -11,7 +12,7 @@ import { Router, ActivatedRoute } from '@angular/router';
export class HomePage {
status:any;
status: any;
public lat: number = 51.678418;
public lng: number = 7.809007;
public origin: any;
......@@ -22,15 +23,17 @@ export class HomePage {
constructor(
private router: Router,
private route: ActivatedRoute,
private location: Location
private location: Location,
public myorder: MyordersService
) {
this.status = 0;
this.status = 1;
}
ngOnInit() {
this.myorder.orderList('LVIMCEdUOGMzYxISL5OkMUPD35Q2');
this.getDirection();
}
......@@ -67,8 +70,24 @@ export class HomePage {
icon: './assets/destination.png',
}
};
}
accept(index: number) {
this.myorder.rideChange(this.myorder.orders[index].orderId, 1);
this.myorder.trackOrder(this.myorder.orders[index]);
this.myorder.rideStatus(3).then(() => {
this.router.navigateByUrl('riderlounge');
});
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
reject(index: number) {
this.myorder.rideReject(this.myorder.orders[index].orderId);
}
details(index: number) {
this.myorder.trackOrder(this.myorder.orders[index]);
this.router.navigateByUrl('ridedetails');
}
......
......@@ -13,13 +13,13 @@
</div>
<div class="login_inner">
<div class="row">
<ion-input placeholder="Rider ID/Phone Number"></ion-input>
<ion-input placeholder="Rider Email ID" #userName required></ion-input>
</div>
<div class="row">
<ion-input placeholder="Password" type="password "></ion-input>
<ion-input placeholder="Password" type="password" #userPassword required></ion-input>
</div>
<div class="row">
<button class="login_btn" (click)="goToPage('home')">
<button class="login_btn" (click)="authService.SignIn(userName.value, userPassword.value)">
LOGIN
</button>
</div>
......
import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { AuthService } from './../../config/auth.service';
@Component({
selector: 'app-login',
......@@ -12,7 +13,8 @@ export class LoginPage implements OnInit {
constructor(
private router: Router,
private route: ActivatedRoute,
private location: Location
private location: Location,
public authService: AuthService
) { }
ngOnInit() {
......
......@@ -9,18 +9,18 @@
</button>
<div class="clear"></div>
</div>
<div class="ridedetail_wrapper">
<div class="ridedetail_wrapper" *ngIf="order">
<div class="order_acceptance">
<div class="order_acceptance_inner">
<div class="point_header">
<div class="point_image"></div>
<div class="point_detail">You</div>
<strong class="floatRight">ORID008800</strong>
<strong class="floatRight">{{order.orderCode}}</strong>
<div class="clear"></div>
</div>
<div class="point_box">
<div class="point_head floatLeft">
06, Tasmania, horse building<br>
{{order.pickupAddress}}<br>
<strong>2 Km</strong>
</div>
<div class="clear"></div>
......@@ -32,11 +32,11 @@
</div>
<div class="point_box">
<div class="point_head floatLeft">
06, Tasmania, horse building<br>
{{order.deliveryAddress}}<br>
<strong>1 Km</strong>
</div>
<strong class="floatRight">Men's Shirt<br>
<span>Au$ 88</span></strong>
<!-- <strong class="floatRight">Men's Shirt<br>
<span>Au$ 88</span></strong> -->
<div class="clear"></div>
</div>
<div class="point_header">
......@@ -44,13 +44,13 @@
<div class="point_detail">John Doe</div>
<div class="clear"></div>
</div>
<div class="point_box borderNone">
<!-- <div class="point_box borderNone">
<div class="point_head floatLeft">
06, Tasmania, horse building<br>
<strong>1 Km</strong>
</div>
<div class="clear"></div>
</div>
</div> -->
</div>
<hr>
<br>
......@@ -71,11 +71,11 @@
</div>
</ion-content>
<ion-footer>
<div class="bottom_btn_bay">
<button class="accept_btn floatRight" (click)="goToPage('riderlounge')">
<div class="bottom_btn_bay" *ngIf="order.orderStatus == 2">
<button class="accept_btn floatRight" (click)="accept()">
Accept
</button>
<button class="reject_btn floatLeft">Reject</button>
<button class="reject_btn floatLeft" (click)="reject()">Reject</button>
<div class="clear"></div>
</div>
</ion-footer>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { MyordersService } from './../../config/myorder.service';
import { Myorder } from './../../config/services/myorder';
@Component({
selector: 'app-ridedetails',
......@@ -8,12 +10,16 @@ import { Router, ActivatedRoute } from '@angular/router';
styleUrls: ['./ridedetails.page.scss'],
})
export class RidedetailsPage implements OnInit {
order: Myorder;
constructor(
private router: Router,
private route: ActivatedRoute,
private location: Location
) { }
private location: Location,
public myorder: MyordersService
) {
this.order = this.myorder.selItem;
}
ngOnInit() {
}
......@@ -27,4 +33,18 @@ export class RidedetailsPage implements OnInit {
this.location.back();
}
accept() {
this.myorder.rideChange(this.order.orderId, 1);
this.myorder.selItem.orderStatus = 3;
this.myorder.rideStatus(3).then(() => {
this.router.navigateByUrl('riderlounge');
});
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
reject() {
this.myorder.rideReject(this.order.orderId);
this.router.navigateByUrl('home');
}
}
......@@ -12,7 +12,7 @@
</button>
<div class="clear"></div>
</div>
<div class="rider_lounge_wrapper">
<div class="rider_lounge_wrapper" *ngIf="order">
<agm-map [zoom]="20" [latitude]="lat" [longitude]="lng">
<agm-direction [origin]="origin" [destination]="destination" [renderOptions]="renderOptions" [markerOptions]="markerOptions">
</agm-direction>
......@@ -29,14 +29,14 @@
<div class="order_place_image"></div>
<div class="order_place_detail">
<h5>LuLu Fashion Store</h5>
<p>06, Tasmania, horse building..</p>
<p>{{order.pickupAddress}}</p>
</div>
<div class="clear"></div>
</div>
<div class="time">
<strong>10</strong>Mnt
</div>
<div class="reach_btn" (click)="next()">REACHED AT SHOP</div>
<div class="reach_btn" (click)="next(4)">REACHED AT SHOP</div>
<div class="clear"></div>
</div>
</div>
......@@ -48,13 +48,13 @@
<div class="order_place_image"></div>
<div class="order_place_detail" style="width: calc(100% - 90px);">
<h5>LuLu Fashion Store</h5>
<p>06, Tasmania, horse building..</p>
<p>{{order.pickupAddress}}</p>
</div>
<div class="toggle_btn floatRight" (click)="goToPage('ridedetails')"></div>
<div class="clear"></div>
</div>
<hr>
<div class="items_div">
<!-- <div class="items_div">
<ion-row>
<ion-col class="textLeft">
<input class="styled-checkbox" id="styled-checkbox-1" type="checkbox" value="value1">
......@@ -73,11 +73,11 @@
<p>AU$ 72</p>
</ion-col>
</ion-row>
</div>
</div> -->
<div class="time">
<strong>05</strong>Mnt
</div>
<div class="reach_btn" (click)="next()">PRODUCT COLLECTED</div>
<div class="reach_btn" (click)="next(5)">PRODUCT COLLECTED</div>
<div class="clear"></div>
</div>
</div>
......@@ -91,8 +91,8 @@
<div class="order_place">
<div class="order_place_image"></div>
<div class="order_place_detail" style="width: calc(100% - 140px);">
<h5>LuLu Fashion Store</h5>
<p>06, Tasmania, horse building..</p>
<h5>John Doe</h5>
<p>{{order.deliveryAddress}}</p>
</div>
<button class="call">Call</button>
<div class="clear"></div>
......@@ -100,7 +100,7 @@
<div class="time">
<strong>30</strong>Mnt
</div>
<div class="reach_btn" (click)="next()">REACHED AT CUSTOMER</div>
<div class="reach_btn" (click)="next(6)">REACHED AT CUSTOMER</div>
<div class="clear"></div>
</div>
</div>
......@@ -111,14 +111,14 @@
<div class="order_place pt0">
<div class="order_place_image"></div>
<div class="order_place_detail" style="width: calc(100% - 90px);">
<h5>LuLu Fashion Store</h5>
<p>06, Tasmania, horse building..</p>
<h5>John Doe</h5>
<p>{{order.deliveryAddress}}</p>
</div>
<div class="toggle_btn floatRight" (click)="goToPage('ridedetails')"></div>
<div class="clear"></div>
</div>
<hr>
<div class="items_div">
<!-- <div class="items_div">
<ion-row>
<ion-col class="textLeft">
<h4>Products</h4>
......@@ -134,11 +134,11 @@
<label for="styled-checkbox-2">Men's Jeans</label>
</ion-col>
</ion-row>
</div>
</div> -->
<div class="time">
<strong>05</strong>Mnt
</div>
<div class="reach_btn" (click)="goToPage('complete')">PRODUCT DELIVERED</div>
<div class="reach_btn" (click)="next(7)">PRODUCT DELIVERED</div>
<div class="clear"></div>
</div>
</div>
......
......@@ -2,6 +2,8 @@ import { Component, OnInit, ViewChild, } from '@angular/core';
import { IonSlides } from '@ionic/angular';
import { Location } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { MyordersService } from './../../config/myorder.service';
import { Myorder } from './../../config/services/myorder';
@Component({
......@@ -13,21 +15,23 @@ export class RiderloungePage implements OnInit {
@ViewChild(IonSlides, { static: false }) slides: IonSlides;
currentIndex: any;
order: Myorder;
status: any;
public lat: number = 51.678418;
public lng: number = 7.809007;
public lat = 51.678418;
public lng = 7.809007;
public origin: any;
public destination: any;
public renderOptions: any;
public markerOptions: any;
deliveryStatus:any;
deliveryStatus: any;
constructor(
private router: Router,
private route: ActivatedRoute,
private location: Location
private location: Location,
public myorder: MyordersService
) { }
......@@ -36,7 +40,7 @@ export class RiderloungePage implements OnInit {
slidesPerView: 1,
spaceBetween: 20,
allowTouchMove: false
}
};
ngOnInit() {
......@@ -61,8 +65,9 @@ export class RiderloungePage implements OnInit {
getDirection() {
this.origin = { lat: 51.678418, lng: 7.80 };
this.destination = { lat: 51.678418, lng: 7.82 };
this.order = this.myorder.selItem;
this.origin = { lat: this.order.pickupLocation._lat, lng: this.order.pickupLocation._long };
this.destination = { lat: this.order.deliveryLocation._lat, lng: this.order.deliveryLocation._long };
this.renderOptions = { polylineOptions: { strokeColor: 'rgba(69, 67, 152,1)' }, suppressMarkers: true };
this.markerOptions = {
origin: {
......@@ -77,9 +82,17 @@ export class RiderloungePage implements OnInit {
}
next() {
next(status: number) {
this.myorder.rideStatus(status).then((data) => {
if (status === 7) {
this.myorder.rideChange(this.myorder.selItem.orderId, 0);
this.goToPage('complete');
} else {
this.slides.slideNext();
}
this.myorder.selItem.orderStatus = status;
});
}
prev() {
this.slides.slidePrev();
......
import { Injectable } from '@angular/core';
import { User } 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 { ServiceService } from './../config/service.service';
import { MyordersService } from './../config/myorder.service';
import { from } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AuthService {
userData: any;
constructor(
public afs: AngularFirestore,
public afAuth: AngularFireAuth,
private router: Router,
private service: ServiceService,
public myorder: MyordersService
) {
this.afAuth.authState.subscribe(user => {
if (user) {
this.userData = user;
this.service.set('user', JSON.stringify(this.userData));
} else {
this.service.set('user', null);
JSON.parse(localStorage.getItem('user'));
}
});
}
public async SignIn(email: string, password: string) {
return this.afAuth.auth.signInWithEmailAndPassword(email, password).then((result) => {
console.log('success');
this.router.navigateByUrl('home');
this.SetUserData(result.user);
}).catch((error) => {
window.alert(error.message);
});
}
get isLoggedIn(): boolean {
const user = JSON.parse(localStorage.getItem('user'));
return (user !== null && user.emailVerified !== false) ? true : false;
}
SetUserData(user: any) {
console.log(user);
const userRef: AngularFirestoreDocument<any> = this.afs.doc(`riders/${user.uid}`);
userRef.valueChanges().subscribe((value) => {
console.log(value);
const userData: User = {
riderId: value.riderId,
emailId: value.emailId,
name: value.name,
profilePhoto: value.profilePic,
phone: value.phone,
onlineStatus: value.onlineStatus,
regNo: value.regNo,
fraudStatus: value.fraudStatus,
location: value.location,
vehicle: value.vehicle,
verified: value.verified,
currOrder: value.currOrder,
rideState: value.rideState
};
console.log(userData);
/* if (value.rideState === true) {
this.router.navigateByUrl('riderlounge');
} else {
this.router.navigateByUrl('home');
}
document.body.scrollTop = document.documentElement.scrollTop = 0;*/
});
}
public async SignOut() {
return this.afAuth.auth.signOut().then(() => {
this.service.remove('user');
console.log('logout');
});
}
}
import { Injectable } from '@angular/core';
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore';
import { Myorder } from './services/myorder';
import { ServiceService } from './../config/service.service';
import * as firebase from 'firebase';
@Injectable({
providedIn: 'root'
})
export class MyordersService {
product: Myorder[] = [];
riderId: string;
orders: Myorder[];
selItem: Myorder;
constructor(
public afs: AngularFirestore,
public service: ServiceService
) {
const users = this.service.get('user').then((data) => {
if (data) {
data = JSON.parse(data);
this.riderId = data.uid;
if (this.riderId !== undefined) {
this.orderList(this.riderId);
}
} else {
this.riderId = 'LVIMCEdUOGMzYxISL5OkMUPD35Q2';
}
});
}
public async orderList(riderId) {
console.log('called');
console.log(riderId);
const This = this;
riderId = 'qbTKza18mWVzYG9NLIbmjMbrYjG2';
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('orders', ref => ref.where('riderId', '==', riderId)
.where('orderStatus', '==', 2)
.orderBy('bookDate', 'desc'));
orderRef.valueChanges().subscribe((value) => {
this.orders = [];
const res = value;
if (res.length > 0) {
res.forEach((item) => {
console.log(item);
const order: Myorder = {
prodName: item.prodName,
color: item.color,
image: item.image,
amount: item.amount,
qty: item.qty,
status: item.status,
orderStatus: item.orderStatus,
bookDate: item.bookDate,
deliveryLocation: item.deliveryLocation,
deliveryAddress: item.deliveryAddress,
pickupAddress: item.pickupAddress,
pickupLocation: item.pickupLocation,
riderName: 'John',
orderId: item.orderId,
orderCode: item.orderCode,
size: item.size,
time: '60'
};
this.orders.push(order);
});
console.log(this.orders);
} else {
// alert('No Orders Found');
}
});
}
public async trackOrder(order) {
this.selItem = order;
}
public async rideStatus(status: number) {
this.afs.collection('orders').doc(this.selItem.orderId).update({orderStatus: status}).then(() => {
console.log('Booking Successfully');
});
}
public async rideChange(riderId: string, state: number) {
this.riderId = 'qbTKza18mWVzYG9NLIbmjMbrYjG2';
if (state === 1) {
const change = {currOrder: riderId, rideState: 1};
this.afs.collection('riders').doc(this.riderId).update(change).then(() => {
console.log('Rider Set Booking');
});
} else {
const change = {currOrder: '', rideState: 0};
this.afs.collection('riders').doc(this.riderId).update(change).then(() => {
console.log('Rider Set Booking');
});
}
}
public async rideReject(riderId: string) {
this.afs.collection('orders').doc(riderId).update({riderId: ''}).then(() => {
console.log('Booking Rejected');
});
}
}
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
@Injectable({
providedIn: 'root'
})
export class ServiceService {
constructor(public storage: Storage) { }
public set(settingName: string, value: any) {
return this.storage.set(`setting:${ settingName }`, value);
}
public async get(settingName: string) {
return await this.storage.get(`setting:${ settingName }`);
}
public async remove(settingName: string) {
return await this.storage.remove(`setting:${ settingName }`);
}
public clear() {
this.storage.clear().then(() => {
console.log('all keys cleared');
});
}
public key2Array(item: object) {
const response = [];
for (const key in item) {
if (item.hasOwnProperty(key)) {
response.push(item[key]);
}
}
return response;
}
}
export interface Myorder {
amount: string;
prodName: any;
image: string;
size: string;
color: string;
qty: number;
bookDate: any;
pickupAddress: string;
pickupLocation: any;
deliveryAddress: string;
deliveryLocation: any;
status: number;
orderId: string;
orderCode: string;
orderStatus: number;
riderName: string;
time: string;
}
export interface User {
riderId: string;
emailId: string;
name: string;
phone: string;
onlineStatus: boolean;
profilePhoto: string;
fraudStatus: boolean;
location: any;
regNo: string;
vehicle: string;
verified: boolean;
currOrder: string;
rideState: boolean;
}
......@@ -3,7 +3,16 @@
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
production: false,
firebase: {
apiKey: 'AIzaSyDzc8lCO4NAfc3PbXPQjvmSWDbsw-yTqXw',
authDomain: 'getmi-4fd26.firebaseapp.com',
databaseURL: 'https://getmi-4fd26.firebaseio.com',
projectId: 'getmi-4fd26',
storageBucket: 'getmi-4fd26.appspot.com',
messagingSenderId: '949385251610',
appId: '1:949385251610:web:cec06e05a0b1aa58'
}
};
/*
......
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