Skip to content
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

fix model computed date properties for OrderModel #18

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading