Skip to content

Commit

Permalink
Merge pull request #18 from fleetbase/data-patches
Browse files Browse the repository at this point in the history
fix model computed date properties for `OrderModel`
  • Loading branch information
roncodes authored Nov 10, 2023
2 parents 2c8d3d5 + d88f3cb commit 5955bc6
Showing 1 changed file with 38 additions and 30 deletions.
68 changes: 38 additions & 30 deletions addon/models/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,125 +146,133 @@ export default class OrderModel extends Model {
}

@computed('updated_at') get updatedAgo() {
if (!this.updated_at) {
if (!isValidDate(this.updated_at)) {
return null;
}

return formatDistanceToNow(this.updated_at);
}

@computed('updated_at') get updatedAt() {
if (!this.updated_at) {
if (!isValidDate(this.updated_at)) {
return null;
}

return formatDate(this.updated_at, 'PP HH:mm');
}

@computed('updated_at') get updatedAtShort() {
if (!this.updated_at) {
if (!isValidDate(this.updated_at)) {
return null;
}

return formatDate(this.updated_at, 'PP');
}

@computed('created_at') get createdAgo() {
if (!this.created_at) {
if (!isValidDate(this.created_at)) {
return null;
}

return formatDistanceToNow(this.created_at);
}

@computed('created_at') get createdAt() {
if (!this.created_at) {
if (!isValidDate(this.created_at)) {
return null;
}

return formatDate(this.created_at, 'PP HH:mm');
}

@computed('created_at') get createdAtShort() {
if (!this.created_at) {
if (!isValidDate(this.created_at)) {
return null;
}

return formatDate(this.created_at, 'PP');
}

@computed('created_at') get createdAtWithTime() {
if (!isValidDate(this.created_at)) {
return null;
}

return formatDate(this.created_at, 'PP HH:mm');
}

@computed('created_at') get createdAtDetailed() {
if (!isValidDate(this.created_at)) {
return null;
}

return formatDate(this.created_at, 'PP HH:mm');
}

@computed('dispatched_at') get dispatchedAgo() {
if (!this.dispatched_at) {
return 'N/A';
if (!isValidDate(this.dispatched_at)) {
return null;
}

return formatDistanceToNow(this.dispatched_at);
}

@computed('dispatched_at') get dispatchedAt() {
if (!this.dispatched_at) {
return 'N/A';
if (!isValidDate(this.dispatched_at)) {
return null;
}

return formatDate(this.dispatched_at, 'PP HH:mm');
}

@computed('dispatched_at') get dispatchedAtShort() {
if (!this.dispatched_at) {
return 'N/A';
if (!isValidDate(this.dispatched_at)) {
return null;
}

return formatDate(this.dispatched_at, 'PP');
}

@computed('started_at') get startedAgo() {
if (!this.started_at) {
return 'N/A';
if (!isValidDate(this.started_at)) {
return null;
}

return formatDistanceToNow(this.started_at);
}

@computed('started_at') get startedAt() {
if (!this.started_at) {
return 'N/A';
if (!isValidDate(this.started_at)) {
return null;
}

return formatDate(this.started_at, 'PP HH:mm');
}

@computed('started_at') get startedAtShort() {
if (!this.started_at) {
return 'N/A';
if (!isValidDate(this.started_at)) {
return null;
}

return formatDate(this.started_at, 'PP');
}

@computed('scheduled_at') get scheduledAt() {
if (!this.scheduled_at || !isValidDate(this.scheduled_at)) {
return 'N/A';
if (!isValidDate(this.scheduled_at)) {
return null;
}

return formatDate(this.scheduled_at, 'PP HH:mm');
}

@computed('scheduled_at') get scheduledAtTime() {
if (!this.scheduled_at || !isValidDate(this.scheduled_at)) {
return 'N/A';
if (!isValidDate(this.scheduled_at)) {
return null;
}

return formatDate(this.scheduled_at, 'HH:mm');
}

@computed('created_at') get createdAtWithTime() {
return formatDate(this.created_at, 'PP HH:mm');
}

@computed('created_at') get createdAtDetailed() {
return formatDate(this.created_at, 'PP HH:mm');
}

// eslint-disable-next-line ember/use-brace-expansion
@computed('payload.isMultiDrop', 'payload.waypoints.[]', 'payload.pickup_uuid', 'payload.dropoff_uuid')
get isMultipleDropoffOrder() {
Expand Down

0 comments on commit 5955bc6

Please sign in to comment.