Skip to content

Commit 323bfc4

Browse files
committed
#111 task.Duration is trimmed
1 parent f357d77 commit 323bfc4

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

app/job/job-track/job-track.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ <h3 class="panel-title col-md-11">
6666
<div class="col-md-12">
6767
<strong>{{ orderStatusHeading }}</strong>
6868
<!--injected html here because I wanted to highlight the email address substring! in the orderInfoDesc-->
69-
<p [innerHtml]="orderInfoDesc"></p>
69+
<p [innerHtml]="orderStatusDesc"></p>
7070
</div>
7171
<div class="row">
7272
<div class="col-md-6">

app/job/job-track/job-track.component.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ export class JobTrackComponent implements OnInit {
6868
.subscribe((job) => {
6969
this.status = "SUCCESSFUL";
7070
this.job = job;
71-
this.fixingServerText(this.job);
7271
this.orderStatusHeading = this.orderInfoService.orderInfo(job).orderStatusHeading;
7372
this.orderStatusDesc = this.orderInfoService.orderInfo(job).orderStatusDesc;
7473
this.coordinateInfo = new CoordinateInfo(this.job);
75-
7674
this.job.Tasks.forEach(element => {
7775
if(element.Type !== "FetchDeliveryMan"){
7876
this.tasksTiming.push(element);
@@ -91,6 +89,7 @@ export class JobTrackComponent implements OnInit {
9189

9290
})
9391
}
92+
this.fixingServerText(); // this should be called at the end
9493
},
9594
(error) => {
9695
this.status = "FAILED";
@@ -108,16 +107,21 @@ export class JobTrackComponent implements OnInit {
108107
});
109108
}
110109

111-
fixingServerText(job: Job) {
110+
fixingServerText() {
112111
// this weird function is to streamline server responses
113112
// like, CashOnDelivery to Cash On Deliver ||
114113
// IN_PROGRESS to IN PROGRESS
115114
// Not sure whether it will stay here finally
116115
this.job.Order.PaymentMethod = "Cash On Delivery";
117116

118-
this.job.Tasks.forEach(task => {
117+
this.tasksTiming.forEach(task => {
119118
if(task.Type === "PackagePickUp") task.Type = "Pickup";
120119
if(task.Type === "SecureDelivery") task.Type = "Secured Delivery";
120+
121+
if(task.Duration){
122+
task.Duration = task.Duration.substr(0,8)
123+
}
124+
121125
})
122126
}
123127
}

app/job/shared/jobtasks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class JobTask {
1111
InitiationTime: Date;
1212
ModifiedTime: Date;
1313
CompletionTime: Date;
14-
Duration: any;
14+
Duration: string;
1515
IsReadytoMoveToNextTask: boolean;
1616
IsDependencySatisfied: boolean;
1717
IsStartingTask: boolean;

app/job/shared/orderInfo.service.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ export class OrderInfoService {
2424
_orderStatusDesc = "Your Pickup is completed, Delivery is in progress. Come back to this page for updates on your Order status.";
2525
break;
2626
case 4:
27-
_orderStatusHeading = "You Delivery has been completed!";
27+
_orderStatusHeading = "Your Delivery has been completed!";
28+
_orderStatusDesc = "Thank you for using our service";
29+
break;
30+
case 5:
31+
_orderStatusHeading = "Your Delivery has been completed, Secured Delivery is in progress!";
32+
_orderStatusDesc = "Your Delivery is completed, Secured Delivery is in progress. Come back to this page for updates on your Order status.";
33+
break;
34+
case 6:
35+
_orderStatusHeading = "Your Secured Delivery has been completed!";
2836
_orderStatusDesc = "Thank you for using our service";
2937
break;
3038
default:
@@ -37,7 +45,6 @@ export class OrderInfoService {
3745
}
3846
}
3947

40-
// INFO: This is shamefully ugly
4148
private findOrderStatus(job: Job): number {
4249
let status = 0;
4350
job.Tasks.forEach(task => {
@@ -55,6 +62,14 @@ export class OrderInfoService {
5562
status = 4;
5663
}
5764
}
65+
else if (task.Type === "SecureDelivery"){
66+
if (task.State === "IN_PROGRESS") {
67+
status = 5;
68+
}
69+
else if (task.State === "COMPLETED") {
70+
status = 6;
71+
}
72+
}
5873
});
5974
return status;
6075
}

0 commit comments

Comments
 (0)