Commit 879c02cd by Adarsh K

new changes

parent f075ecc3
<?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.retailer" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Getmi retailer</name>
<description>An awesome Ionic/Cordova app.</description>
<author email="[email protected]" href="http://techware.co.in/">Techware software solutions Pvt Ltd</author>
......
......@@ -25,7 +25,9 @@
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.12.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,7 +24,16 @@ import { AppRoutingModule } from './app-routing.module';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
imports: [
BrowserModule,
IonicModule.forRoot(),
AppRoutingModule,
IonicStorageModule.forRoot(),
AppRoutingModule,
AngularFireModule.initializeApp(environment.firebase),
AngularFireAuthModule,
AngularFirestoreModule
],
providers: [
StatusBar,
SplashScreen,
......
......@@ -13,122 +13,62 @@
</div>
<div class="clear"></div>
</div>
<div class="notification new_order" [hidden]="currentIndex ==3">
<div *ngIf="myorder.orders" class="notification new_order" [hidden]="myorder.orders.length == 0">
YOU HAVE NEW ORDER
</div>
<div class="notification no_order" [hidden]="currentIndex !=3">
<div *ngIf="myorder.orders" class="notification no_order" [hidden]="myorder.orders.length > 0">
NO PENDING ORDERS
</div>
<div class="incoming_order">
<ion-slides pager="false" [options]="orderOptions" (ionSlideDidChange)="slideChanged()" [hidden]="currentIndex ==3">
<ion-slide>
<!-- [options]="orderOptions" (ionSlideDidChange)="slideChanged()" [hidden]="currentIndex ==3" #slides-->
<ion-slides pager="false">
<ion-slide *ngFor="let order of myorder.orders; let i = index">
<div class="incoming_order_wrapper">
<div class="incoming_detail">
<div class="image">
<img [src]="order.image" />
</div>
<div class="image_detail">
<h5>European Style V Neck</h5>
<h5>{{order.prodName}}</h5>
<p>Women's Fashion</p>
<ul>
<li>Green</li>
<li>Small</li>
<li>{{order.color}}</li>
<li>{{order.size}}</li>
</ul>
<h6>
<span class="floatLeft">Quantity:</span>
<span class="floatLeft">
<div class="quality">1</div>
</span><strong class="floatLeft"> AU$88.00</strong>
<div class="quality">{{order.qty}}</div>
</span><strong class="floatLeft"> {{order.amount}}</strong>
<span class="payment floatLeft">Paid</span>
<div class="clear"></div>
</h6>
</div>
</div>
<div class="btn_bay">
<button class="reject">REJECT</button>
<button class="accept" (click)="next()">ACCEPT</button>
</div>
</div>
</ion-slide>
<ion-slide>
<div class="incoming_order_wrapper">
<div class="incoming_detail">
<div class="image">
</div>
<div class="image_detail">
<h5>European Style V Neck</h5>
<p>Women's Fashion</p>
<ul>
<li>Green</li>
<li>Small</li>
</ul>
<h6>
<span class="floatLeft">Quantity:</span>
<span class="floatLeft">
<div class="quality">1</div>
</span><strong class="floatLeft"> AU$88.00</strong>
<span class="payment floatLeft">Paid</span>
<div class="clear"></div>
</h6>
</div>
<div class="btn_bay" *ngIf="order.orderStatus === 1">
<button class="reject" (click)="reject(order.orderId)">REJECT</button>
<button class="accept" (click)="accept(order.orderId)">ACCEPT</button>
</div>
<div *ngIf="order.shopperState != 0">
<div class="order_status_banner">
<hr>
<ul>
<li class="textLeft green"><span>Order Accepted</span></li>
<li class="textCenter"><span>Product Packed</span></li>
<li class="textRight"><span>Rider Picked</span></li>
<li class="textLeft" [ngClass]="{'green': order.shopperState >= 1}"><span>Order Accepted</span></li>
<li class="textCenter" [ngClass]="{'green': order.shopperState >= 2}" ><span>Product Packed</span></li>
<li class="textRight" [ngClass]="{'green': order.shopperState >= 3}"><span>Rider Picked</span></li>
</ul>
</div>
<div class="btn_bay">
<button class="track" (click)="goToPage('trackorder')">03<span>Mnt</span> <strong>TRACK
RIDER</strong></button>
<button class="marked" (click)="next()">MARKED AS PACKED</button>
</div>
</div>
</ion-slide>
<ion-slide>
<div class="incoming_order_wrapper">
<div class="incoming_detail">
<div class="image">
</div>
<div class="image_detail">
<h5>European Style V Neck</h5>
<p>Women's Fashion</p>
<ul>
<li>Green</li>
<li>Small</li>
</ul>
<h6>
<span class="floatLeft">Quantity:</span>
<span class="floatLeft">
<div class="quality">1</div>
</span><strong class="floatLeft"> AU$88.00</strong>
<span class="payment floatLeft">Paid</span>
<div class="clear"></div>
</h6>
<button class="marked" (click)="shopperTrack(order.orderId, 2)" *ngIf="order.shopperState == 1">MARKED AS PACKED</button>
<button class="marked" (click)="shopperTrack(order.orderId, 3)" *ngIf="order.shopperState == 2">RIDER PICKED</button>
<button class="marked" *ngIf="order.shopperState == 3">PROCESSING...</button>
</div>
</div>
<div class="order_status_banner">
<hr>
<ul>
<li class="textLeft green"><span>Order Accepted</span></li>
<li class="textCenter green"><span>Product Packed</span></li>
<li class="textRight"><span>Rider Picked</span></li>
</ul>
</div>
<div class="btn_bay">
<button class="track" (click)="goToPage('trackorder')">03<span>Mnt</span> <strong>TRACK
RIDER</strong></button>
<button class="marked" (click)="next()">RIDER PICKED</button>
</div>
</div>
</ion-slide>
<ion-slide></ion-slide>
</ion-slides>
</ion-slides><!-- -->
</div>
<div class="order_header">
<h5 class="floatLeft">PAST SALES</h5>
......@@ -137,33 +77,33 @@
</div>
<div class="past_orders">
<ul>
<li>
<ul *ngIf="myorder.pastOrders">
<li *ngFor="let pastorder of myorder.pastOrders">
<div class="incoming_detail">
<div class="image">
<img [src]="pastorder.image" />
</div>
<div class="image_detail">
<h5>European Style V Neck</h5>
<p>Green, small <strong>1</strong></p>
<h6><strong class="floatLeft"> AU$88.00</strong>
<h5>{{pastorder.prodName}}</h5>
<p>{{pastorder.color}}, {{pastorder.size}} <strong>1</strong></p>
<h6><strong class="floatLeft"> {{pastorder.amount}}</strong>
<span class="payment floatLeft">Paid</span>
<div class="clear"></div>
</h6>
<ion-row>
<ion-col class="p0">
<h4>ORID00678</h4>
<p>Today, 07:00 PM</p>
<ion-row *ngIf="pastorder.orderCode">
<ion-col class="p0" *ngIf="pastorder.orderCode">
<h4>{{pastorder.orderCode}}</h4>
<p>{{ pastorder.bookDate.seconds * 1000 | date:'MMM dd, y' }}</p>
</ion-col>
<ion-col class="p0 textRight">
<button class="finished">Finished</button>
<button [ngClass]="(pastorder.orderStatus == 8)? 'cancelled': 'finished'">{{orderState(pastorder.orderStatus)}}</button>
</ion-col>
</ion-row>
</div>
</div>
</li>
<li>
<!-- <li>
<div class="incoming_detail">
<div class="image">
......@@ -187,7 +127,7 @@
</div>
</div>
</li>
</li> -->
</ul>
</div>
</ion-content>
\ No newline at end of file
import { Component, OnInit, ViewChild, } from '@angular/core';
import { IonSlides } from '@ionic/angular';
import { Router, ActivatedRoute } from '@angular/router';
import { MyordersService } from './../../config/myorder.service';
@Component({
selector: 'app-home',
......@@ -12,12 +13,20 @@ export class HomePage implements OnInit {
@ViewChild(IonSlides, { static: false }) slides: IonSlides;
currentIndex: any;
orderOptions = {
initialSlide: 1,
speed: 500,
allowTouchMove: false
};
constructor(
private router: Router, private route: ActivatedRoute
private router: Router, private route: ActivatedRoute,
public myorder: MyordersService
) { }
ngOnInit() {
this.myorder.orderList('qbTKza18mWVzYG9NLIbmjMbrYjG2');
this.myorder.pastOrderList('qbTKza18mWVzYG9NLIbmjMbrYjG2');
}
......@@ -26,11 +35,7 @@ export class HomePage implements OnInit {
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
orderOptions = {
initialSlide: 1,
speed: 500,
allowTouchMove: false
};
next() {
......@@ -49,4 +54,38 @@ export class HomePage implements OnInit {
});
}
reject(orderId: string) {
this.myorder.rideChange(orderId, 8);
}
accept(orderId: string) {
this.myorder.rideChange(orderId, 2);
this.shopperTrack(orderId, 1);
}
shopperTrack(orderId: string, status: number) {
this.myorder.rideStatus(orderId, status);
}
orderState(status: number) {
switch (status) {
case 5:
return 'Picked';
break;
case 6:
return 'Reached';
break;
case 7:
return 'Delivered';
break;
case 8:
return 'Rejected';
break;
default:
return 'Finished';
}
}
}
......@@ -13,13 +13,13 @@
</div>
<div class="login_inner">
<div class="row">
<ion-input placeholder="Retailer ID/Phone Number"></ion-input>
<ion-input placeholder="Retailer 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() {
......
......@@ -14,50 +14,25 @@
<div class="clear"></div>
</div>
<ul>
<li>
<li *ngFor="let pastorder of myorder.pastOrders">
<div class="incoming_detail">
<div class="image">
</div>
<div class="image_detail">
<h5>European Style V Neck</h5>
<p>Green, small <strong>1</strong></p>
<h6><strong class="floatLeft"> AU$88.00</strong>
<span class="payment floatLeft">Paid</span>
<div class="clear"></div>
</h6>
<ion-row>
<ion-col class="p0">
<h4>ORID00678</h4>
<p>Today, 07:00 PM</p>
</ion-col>
<ion-col class="p0 textRight">
<button class="finished">Finished</button>
</ion-col>
</ion-row>
</div>
</div>
</li>
<li>
<div class="incoming_detail">
<div class="image">
<img [src]="pastorder.image" />
</div>
<div class="image_detail">
<h5>European Style V Neck</h5>
<p>Green, small <strong>1</strong></p>
<h6><strong class="floatLeft"> AU$88.00</strong>
<h5>{{pastorder.prodName}}</h5>
<p>{{pastorder.color}}, {{pastorder.size}} <strong>1</strong></p>
<h6><strong class="floatLeft"> {{pastorder.amount}}</strong>
<span class="payment floatLeft">Paid</span>
<div class="clear"></div>
</h6>
<ion-row>
<ion-col class="p0">
<h4>ORID00678</h4>
<p>Today, 07:00 PM</p>
<ion-row *ngIf="pastorder.orderCode">
<ion-col class="p0" *ngIf="pastorder.orderCode">
<h4>{{pastorder.orderCode}}</h4>
<p>{{ pastorder.bookDate.seconds * 1000 | date:'MMM dd, y' }}</p>
</ion-col>
<ion-col class="p0 textRight">
<button class="cancelled">Cancelled</button>
<button [ngClass]="(pastorder.orderStatus == 8)? 'cancelled': 'finished'">{{orderState(pastorder.orderStatus)}}</button>
</ion-col>
</ion-row>
......
import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { MyordersService } from './../../config/myorder.service';
@Component({
selector: 'app-pastsales',
......@@ -10,7 +11,10 @@ import { Router, ActivatedRoute } from '@angular/router';
export class PastsalesPage implements OnInit {
constructor(
private router: Router, private route: ActivatedRoute, private location: Location
private router: Router,
private route: ActivatedRoute,
private location: Location,
public myorder: MyordersService
) { }
ngOnInit() {
......@@ -26,4 +30,23 @@ export class PastsalesPage implements OnInit {
this.location.back();
}
orderState(status: number) {
switch (status) {
case 5:
return 'Picked';
break;
case 6:
return 'Reached';
break;
case 7:
return 'Delivered';
break;
case 8:
return 'Rejected';
break;
default:
return 'Finished';
}
}
}
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 { from } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AuthService {
userData: any;
constructor(
public afs: AngularFirestore,
public afAuth: AngularFireAuth,
private router: Router,
private service: ServiceService
) {
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(`shoppers/${user.uid}`);
userRef.valueChanges().subscribe((value) => {
console.log(value);
const userData: User = {
shopperId: value.uid,
emailId: value.emailId,
name: value.name,
shopName: value.shopName,
location: value.location,
shopStatus: value.shopStatus,
workingHours: value.workingHours,
profilePhoto: value.profilePic,
phone: value.phone
};
console.log(userData);
});
}
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[] = [];
shopperId: string;
orders: Myorder[];
selItem: Myorder;
pastOrders: Myorder[];
constructor(
public afs: AngularFirestore,
public service: ServiceService
) {
const users = this.service.get('user').then((data) => {
if (data) {
data = JSON.parse(data);
this.shopperId = data.uid;
if (this.shopperId !== undefined) {
this.orderList(this.shopperId);
this.pastOrderList(this.shopperId);
}
} else {
this.shopperId = 'qbTKza18mWVzYG9NLIbmjMbrYjG2';
}
});
}
public async orderList(shopperId) {
console.log('called');
console.log(shopperId);
const This = this;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('orders', ref => ref.where('shopperId', '==', shopperId)
.where('orderStatus', '<=', 4));
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,
shopperState: item.shopperState !== undefined ? item.shopperState : 0,
time: '60'
};
this.orders.push(order);
});
console.log(this.orders);
} else {
// alert('No Orders Found');
}
});
}
public async pastOrderList(shopperId) {
console.log('called');
console.log(shopperId);
const This = this;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('orders', ref => ref.where('shopperId', '==', shopperId)
.where('orderStatus', '>', 4));
orderRef.valueChanges().subscribe((value) => {
this.pastOrders = [];
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,
shopperState: item.shopperState !== undefined ? item.shopperState : 0,
time: '60'
};
this.pastOrders.push(order);
});
console.log(this.pastOrders);
} else {
// alert('No Orders Found');
}
});
}
public async rideStatus(riderId: string, status: number) {
this.afs.collection('orders').doc(riderId).update({shopperState: status}).then(() => {
console.log('shopper status');
});
}
public async rideChange(riderId: string, status: number) {
this.afs.collection('orders').doc(riderId).update({orderStatus: status}).then(() => {
console.log('status Successfully');
});
}
}
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;
shopperState: boolean;
}
export interface User {
shopperId: string;
emailId: string;
name: string;
phone: string;
shopName: string;
profilePhoto: string;
shopStatus: boolean;
workingHours: string;
location: any;
}
......@@ -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