Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
resolve an issue when not all types are activated
Browse files Browse the repository at this point in the history
  • Loading branch information
peternijssen committed May 15, 2019
1 parent b6374f0 commit 2a76068
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
64 changes: 35 additions & 29 deletions postnl-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,46 +231,52 @@ class PostNL extends LitElement {
this.distribution_delivered = []

// Format letters
Object.entries(this.letterObject.attributes.letters).sort((a, b) => new Date(b[1].delivery_date) - new Date(a[1].delivery_date)).map(([key, letter]) => {
if (window.moment) {
if (moment(letter.delivery_date).isBefore(moment().subtract(this.past_days, 'days').startOf('day'))) {
return;
if (this.letterObject) {
Object.entries(this.letterObject.attributes.letters).sort((a, b) => new Date(b[1].delivery_date) - new Date(a[1].delivery_date)).map(([key, letter]) => {
if (window.moment) {
if (moment(letter.delivery_date).isBefore(moment().subtract(this.past_days, 'days').startOf('day'))) {
return;
}
}
}

this.letters.push(letter);
});
this.letters.push(letter);
});
}

// Format deliveries
Object.entries(this.deliveryObject.attributes.enroute).sort((a, b) => new Date(b[1].planned_date) - new Date(a[1].planned_date)).map(([key, shipment]) => {
this.delivery_enroute.push(shipment);
});

Object.entries(this.deliveryObject.attributes.delivered).sort((a, b) => new Date(b[1].delivery_date) - new Date(a[1].delivery_date)).map(([key, shipment]) => {
if (window.moment) {
if (shipment.delivery_date != null && moment(shipment.delivery_date).isBefore(moment().subtract(this.past_days, 'days').startOf('day'))) {
return;
if (this.deliveryObject) {
Object.entries(this.deliveryObject.attributes.enroute).sort((a, b) => new Date(b[1].planned_date) - new Date(a[1].planned_date)).map(([key, shipment]) => {
this.delivery_enroute.push(shipment);
});

Object.entries(this.deliveryObject.attributes.delivered).sort((a, b) => new Date(b[1].delivery_date) - new Date(a[1].delivery_date)).map(([key, shipment]) => {
if (window.moment) {
if (shipment.delivery_date != null && moment(shipment.delivery_date).isBefore(moment().subtract(this.past_days, 'days').startOf('day'))) {
return;
}
}
}


this.delivery_delivered.push(shipment);
});
this.delivery_delivered.push(shipment);
});
}

// Format distribution
Object.entries(this.distributionObject.attributes.enroute).sort((a, b) => new Date(b[1].planned_date) - new Date(a[1].planned_date)).map(([key, shipment]) => {
this.distribution_enroute.push(shipment);
});

Object.entries(this.distributionObject.attributes.delivered).sort((a, b) => new Date(b[1].delivery_date) - new Date(a[1].delivery_date)).map(([key, shipment]) => {
if (window.moment) {
if (shipment.delivery_date != null && moment(shipment.delivery_date).isBefore(moment().subtract(this.past_days, 'days').startOf('day'))) {
return;
if (this.distributionObject) {
Object.entries(this.distributionObject.attributes.enroute).sort((a, b) => new Date(b[1].planned_date) - new Date(a[1].planned_date)).map(([key, shipment]) => {
this.distribution_enroute.push(shipment);
});

Object.entries(this.distributionObject.attributes.delivered).sort((a, b) => new Date(b[1].delivery_date) - new Date(a[1].delivery_date)).map(([key, shipment]) => {
if (window.moment) {
if (shipment.delivery_date != null && moment(shipment.delivery_date).isBefore(moment().subtract(this.past_days, 'days').startOf('day'))) {
return;
}
}
}

this.distribution_delivered.push(shipment);
});
this.distribution_delivered.push(shipment);
});
}
}

render({ _hass, _hide, _values, config, delivery, distribution, letters } = this) {
Expand Down
4 changes: 2 additions & 2 deletions tracker.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"postnl-card": {
"version": "0.9.1",
"version": "0.9.2",
"updated_at": "2019-05-15",
"visit_repo": "https://github.com/peternijssen/lovelace-postnl",
"remote_location": "https://github.com/peternijssen/lovelace-postnl/releases/download/0.9.1/postnl-card.js",
"remote_location": "https://github.com/peternijssen/lovelace-postnl/releases/download/0.9.2/postnl-card.js",
"changelog": "https://github.com/peternijssen/lovelace-postnl/releases/latest"
}
}

0 comments on commit 2a76068

Please sign in to comment.