@lipagas/storefront-engine
Version:
Headless Commerce & Marketplace Extension for Fleetbase
51 lines (41 loc) • 1.29 kB
JavaScript
import Model, { attr, belongsTo } from '@ember-data/model';
import { format, formatDistanceToNow } from 'date-fns';
import getWithDefault from '@lipagas/ember-core/utils/get-with-default';
export default class ProductAddonCategoryModel extends Model {
/** @ids */
product_uuid;
category_uuid;
/** @relationships */
category;
/** @attributes */
name;
excluded_addons;
/** @dates */
created_at;
updated_at;
/** @methods */
toJSON() {
return {
uuid: this.id,
category_uuid: this.category_uuid,
product_uuid: this.product_uuid,
name: this.name,
excluded_addons: getWithDefault(this, 'excluded_addons', []),
updated_at: this.updated_at,
created_at: this.created_at,
};
}
/** @computed */
get updatedAgo() {
return formatDistanceToNow(this.updated_at);
}
get updatedAt() {
return format(this.updated_at, 'PPP');
}
get createdAgo() {
return formatDistanceToNow(this.created_at);
}
get createdAt() {
return format(this.created_at, 'PPP p');
}
}