-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add carrier orders list #1218
Open
evereq
wants to merge
4
commits into
develop
Choose a base branch
from
feat/#57-carrier-orders-list
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/carrier-mobile-ionic/src/components/orders-list/orders-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<ion-header> | ||
<ion-toolbar color="primary"> | ||
<ion-title>Select Order for Delivery ...</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content fullscreen color="light"> | ||
<ion-card button *ngFor="let order of filteredList"> | ||
<ion-card-content (click)="selectNewOrder(order.id)"> | ||
<ion-item> | ||
<ion-avatar slot="start"> | ||
<img [src]="order.warehouse.logo" /> | ||
</ion-avatar> | ||
<ion-label> | ||
<p>name: {{ order.warehouse.name }}</p> | ||
<p>Phone: {{ order.warehouse.contactPhone }}</p> | ||
<p>Email: {{ order.warehouse.cantactEmail }}</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @valiopld did you tested this? Is it not a typo |
||
</ion-label> | ||
</ion-item> | ||
|
||
<ion-item> | ||
<ion-avatar slot="start"> | ||
<img [src]="order.user.image" /> | ||
</ion-avatar> | ||
<ion-label> | ||
<p> | ||
name: {{ order.user.firstName }} | ||
{{ order.user.lastName }} | ||
</p> | ||
<p>Phone: {{ order.user.phone }}</p> | ||
<p>Email:</p> | ||
<p>Adress: {{ order.user.fullAddress }}</p> | ||
</ion-label> | ||
</ion-item> | ||
Tital Price: {{ order.totalPrice }} | ||
</ion-card-content> | ||
</ion-card> | ||
</ion-content> | ||
|
||
<ion-tab-bar slot="bottom" color="primary"> | ||
<ion-tab-button (click)="closeOrderListModal()" tab="schedule"> | ||
<ion-label>BACK</ion-label> | ||
</ion-tab-button> | ||
</ion-tab-bar> |
15 changes: 15 additions & 0 deletions
15
packages/carrier-mobile-ionic/src/components/orders-list/orders-list.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ion-header { | ||
background: red; | ||
} | ||
ion-toolbar { | ||
background-color: green; | ||
} | ||
ion-buttons { | ||
color: blue; | ||
} | ||
ion-content { | ||
background: blue; | ||
} | ||
h1 { | ||
color: blue; | ||
} |
106 changes: 106 additions & 0 deletions
106
packages/carrier-mobile-ionic/src/components/orders-list/orders-list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { Component, OnInit, NgZone } from '@angular/core'; | ||
import { ModalController } from '@ionic/angular'; | ||
import { GeoLocationOrdersService } from '../../services/geo-location-order.service'; | ||
import { CarrierRouter } from '@modules/client.common.angular2/routers/carrier-router.service'; | ||
import { Store } from 'services/store.service'; | ||
import { GeoLocationService } from '../../services/geo-location.service'; | ||
import { Geolocation } from '@ionic-native/geolocation/ngx'; | ||
import IGeoLocation from '@modules/server.common/interfaces/IGeoLocation'; | ||
import { OrderRouter } from '@modules/client.common.angular2/routers/order-router.service'; | ||
import IOrder from '@modules/server.common/interfaces/IOrder'; | ||
import { CarrierOrdersRouter } from '@modules/client.common.angular2/routers/carrier-orders-router.service'; | ||
import { Router } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'orders-list-modal', | ||
templateUrl: './orders-list.component.html', | ||
styleUrls: ['./orders-list.component.scss'], | ||
}) | ||
export class OrdersListComponent implements OnInit { | ||
filteredList = []; | ||
private carrier; | ||
private carrier$; | ||
private orders$; | ||
|
||
constructor( | ||
private modalCtrl: ModalController, | ||
private geoLocationOrdersService: GeoLocationOrdersService, | ||
private carrierRouter: CarrierRouter, | ||
private store: Store, | ||
private geolocation: Geolocation, | ||
private geoLocationService: GeoLocationService, | ||
private orderRouter: OrderRouter, | ||
private carrierOrdersRouter: CarrierOrdersRouter, | ||
|
||
private ngZone: NgZone, | ||
private router: Router | ||
) {} | ||
|
||
ngOnInit() { | ||
this.loadOrderslist(); | ||
} | ||
|
||
filterOrdersList(orders) { | ||
this.filteredList = [].concat(orders); | ||
} | ||
|
||
async loadOrderslist() { | ||
this.carrier$ = this.carrierRouter | ||
.get(this.store.carrierId) | ||
.subscribe(async (carrier) => { | ||
this.carrier = carrier; | ||
const position = this.geoLocationService.defaultLocation() | ||
? this.geoLocationService.defaultLocation() | ||
: await this.geolocation.getCurrentPosition(); | ||
|
||
let dbGeoInput = { | ||
loc: { | ||
type: 'Point', | ||
coordinates: [ | ||
position.coords.longitude, | ||
position.coords.latitude, | ||
], | ||
}, | ||
} as IGeoLocation; | ||
|
||
this.orders$ = this.geoLocationOrdersService | ||
.getOrdersForWork( | ||
dbGeoInput, | ||
carrier.skippedOrderIds, | ||
{ | ||
limit: 10, | ||
}, | ||
{ | ||
isCancelled: false, | ||
} | ||
) | ||
.subscribe((list) => { | ||
this.filterOrdersList(list); | ||
}); | ||
}); | ||
} | ||
|
||
selectNewOrder(id) { | ||
//checking if selected order is started | ||
//its not possible to take 2 orders a the same time for now | ||
|
||
const status = this.store.selectedOrder.carrierStatus; | ||
if (status !== 0) { | ||
//todo add message popup error | ||
alert('You are already in delivery ...'); | ||
} else { | ||
this.store.orderId = id; | ||
} | ||
this.closeOrderListModal(); | ||
} | ||
|
||
async closeOrderListModal() { | ||
this.destroyAll(); | ||
await this.modalCtrl.dismiss(); | ||
} | ||
|
||
destroyAll() { | ||
this.carrier$ ? this.carrier$.unsubscribe() : null; | ||
this.orders$ ? this.orders$.unsubscribe() : null; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/carrier-mobile-ionic/src/components/orders-list/orders-list.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { IonicModule } from '@ionic/angular'; | ||
import { OrdersListComponent } from './orders-list.component'; | ||
import { GeoLocationOrdersService } from '../../services/geo-location-order.service'; | ||
import { Geolocation } from '@ionic-native/geolocation/ngx'; | ||
import { GeoLocationService } from '../../services/geo-location.service'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, IonicModule], | ||
declarations: [OrdersListComponent], | ||
entryComponents: [OrdersListComponent], | ||
exports: [OrdersListComponent], | ||
providers: [GeoLocationOrdersService, Geolocation, GeoLocationService], | ||
}) | ||
export class OrdersListModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@valiopld why "name", but "Phone", where is consistency (even if it's ugly, things should be consistently ugly)