@fleetbase/storefront-engine 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/README.md +32 -0
- package/addon/adapters/addon-category.js +1 -0
- package/addon/adapters/customer.js +1 -0
- package/addon/adapters/gateway.js +1 -0
- package/addon/adapters/network.js +1 -0
- package/addon/adapters/notification-channel.js +1 -0
- package/addon/adapters/product-addon-category.js +1 -0
- package/addon/adapters/product-addon.js +1 -0
- package/addon/adapters/product-hour.js +1 -0
- package/addon/adapters/product-store-location.js +1 -0
- package/addon/adapters/product-variant-option.js +1 -0
- package/addon/adapters/product-variant.js +1 -0
- package/addon/adapters/product.js +1 -0
- package/addon/adapters/store-hour.js +1 -0
- package/addon/adapters/store-location.js +1 -0
- package/addon/adapters/store.js +1 -0
- package/addon/adapters/storefront.js +5 -0
- package/addon/components/file-record.hbs +22 -0
- package/addon/components/file-record.js +43 -0
- package/addon/components/modals/add-store-hours.hbs +8 -0
- package/addon/components/modals/add-stores-to-network.hbs +5 -0
- package/addon/components/modals/assign-driver.hbs +25 -0
- package/addon/components/modals/create-first-store.hbs +21 -0
- package/addon/components/modals/create-gateway.hbs +35 -0
- package/addon/components/modals/create-network-category.hbs +50 -0
- package/addon/components/modals/create-network.hbs +20 -0
- package/addon/components/modals/create-new-variant.hbs +15 -0
- package/addon/components/modals/create-notification-channel.hbs +45 -0
- package/addon/components/modals/create-product-category.hbs +30 -0
- package/addon/components/modals/create-store.hbs +9 -0
- package/addon/components/modals/edit-network.hbs +1 -0
- package/addon/components/modals/import-products.hbs +97 -0
- package/addon/components/modals/incoming-order.hbs +242 -0
- package/addon/components/modals/manage-addons.hbs +50 -0
- package/addon/components/modals/manage-addons.js +86 -0
- package/addon/components/modals/order-ready-assign-driver.hbs +36 -0
- package/addon/components/modals/select-addon-category.hbs +5 -0
- package/addon/components/modals/share-network.hbs +35 -0
- package/addon/components/modals/store-location-form.hbs +30 -0
- package/addon/components/order-card.hbs +1 -0
- package/addon/components/order-card.js +3 -0
- package/addon/components/schedule-manager.hbs +22 -0
- package/addon/components/schedule-manager.js +73 -0
- package/addon/components/settings-container.hbs +7 -0
- package/addon/components/store-selector.hbs +21 -0
- package/addon/components/store-selector.js +20 -0
- package/addon/components/widget/customers.hbs +44 -0
- package/addon/components/widget/customers.js +53 -0
- package/addon/components/widget/orders.hbs +111 -0
- package/addon/components/widget/orders.js +248 -0
- package/addon/components/widget/storefront-metrics.hbs +54 -0
- package/addon/components/widget/storefront-metrics.js +61 -0
- package/addon/controllers/application.js +33 -0
- package/addon/controllers/customers/index.js +267 -0
- package/addon/controllers/home.js +3 -0
- package/addon/controllers/networks/index/network/customers.js +3 -0
- package/addon/controllers/networks/index/network/index.js +147 -0
- package/addon/controllers/networks/index/network/orders.js +3 -0
- package/addon/controllers/networks/index/network/stores.js +370 -0
- package/addon/controllers/networks/index/network.js +29 -0
- package/addon/controllers/networks/index.js +138 -0
- package/addon/controllers/orders/index.js +331 -0
- package/addon/controllers/products/index/category/edit.js +62 -0
- package/addon/controllers/products/index/category/new.js +287 -0
- package/addon/controllers/products/index/category.js +163 -0
- package/addon/controllers/products/index/index/edit.js +1 -0
- package/addon/controllers/products/index/index.js +136 -0
- package/addon/controllers/products/index.js +203 -0
- package/addon/controllers/settings/api.js +3 -0
- package/addon/controllers/settings/gateways.js +110 -0
- package/addon/controllers/settings/index.js +102 -0
- package/addon/controllers/settings/locations.js +186 -0
- package/addon/controllers/settings/notifications.js +102 -0
- package/addon/engine.js +19 -0
- package/addon/helpers/get-tip-amount.js +5 -0
- package/addon/models/addon-category.js +6 -0
- package/addon/models/gateway.js +46 -0
- package/addon/models/network.js +166 -0
- package/addon/models/notification-channel.js +47 -0
- package/addon/models/product-addon-category.js +41 -0
- package/addon/models/product-addon.js +41 -0
- package/addon/models/product-hour.js +72 -0
- package/addon/models/product-store-location.js +41 -0
- package/addon/models/product-variant-option.js +39 -0
- package/addon/models/product-variant.js +44 -0
- package/addon/models/product.js +208 -0
- package/addon/models/store-hour.js +72 -0
- package/addon/models/store-location.js +93 -0
- package/addon/models/store.js +100 -0
- package/addon/routes/application.js +47 -0
- package/addon/routes/customers/index/edit.js +3 -0
- package/addon/routes/customers/index.js +25 -0
- package/addon/routes/home.js +3 -0
- package/addon/routes/networks/index/network/customers.js +3 -0
- package/addon/routes/networks/index/network/index.js +15 -0
- package/addon/routes/networks/index/network/orders.js +3 -0
- package/addon/routes/networks/index/network/stores.js +28 -0
- package/addon/routes/networks/index/network.js +10 -0
- package/addon/routes/networks/index.js +19 -0
- package/addon/routes/orders/index/edit.js +3 -0
- package/addon/routes/orders/index/new.js +3 -0
- package/addon/routes/orders/index/view.js +3 -0
- package/addon/routes/orders/index.js +29 -0
- package/addon/routes/products/index/category/edit.js +15 -0
- package/addon/routes/products/index/category/new.js +7 -0
- package/addon/routes/products/index/category.js +54 -0
- package/addon/routes/products/index/index/edit.js +1 -0
- package/addon/routes/products/index/index.js +22 -0
- package/addon/routes/products/index.js +21 -0
- package/addon/routes/settings/api.js +10 -0
- package/addon/routes/settings/gateways.js +11 -0
- package/addon/routes/settings/index.js +16 -0
- package/addon/routes/settings/locations.js +14 -0
- package/addon/routes/settings/notifications.js +11 -0
- package/addon/routes.js +48 -0
- package/addon/serializers/addon-category.js +15 -0
- package/addon/serializers/network.js +19 -0
- package/addon/serializers/notification-channel.js +15 -0
- package/addon/serializers/product-addon-category.js +15 -0
- package/addon/serializers/product-variant.js +15 -0
- package/addon/serializers/product.js +20 -0
- package/addon/serializers/store-location.js +17 -0
- package/addon/serializers/store.js +19 -0
- package/addon/services/storefront.js +208 -0
- package/addon/templates/application.hbs +16 -0
- package/addon/templates/customers/index/edit.hbs +2 -0
- package/addon/templates/customers/index.hbs +22 -0
- package/addon/templates/home.hbs +7 -0
- package/addon/templates/networks/index/network/customers.hbs +2 -0
- package/addon/templates/networks/index/network/index.hbs +254 -0
- package/addon/templates/networks/index/network/orders.hbs +2 -0
- package/addon/templates/networks/index/network/stores.hbs +164 -0
- package/addon/templates/networks/index/network.hbs +38 -0
- package/addon/templates/networks/index.hbs +60 -0
- package/addon/templates/orders/index/edit.hbs +2 -0
- package/addon/templates/orders/index/new.hbs +2 -0
- package/addon/templates/orders/index/view.hbs +2 -0
- package/addon/templates/orders/index.hbs +22 -0
- package/addon/templates/products/index/category/edit.hbs +1 -0
- package/addon/templates/products/index/category/new.hbs +248 -0
- package/addon/templates/products/index/category.hbs +41 -0
- package/addon/templates/products/index/index/edit.hbs +1 -0
- package/addon/templates/products/index/index.hbs +40 -0
- package/addon/templates/products/index.hbs +22 -0
- package/addon/templates/settings/api.hbs +18 -0
- package/addon/templates/settings/gateways.hbs +48 -0
- package/addon/templates/settings/index.hbs +229 -0
- package/addon/templates/settings/locations.hbs +39 -0
- package/addon/templates/settings/notifications.hbs +35 -0
- package/addon/templates/settings.hbs +30 -0
- package/addon/utils/get-gateway-schemas.js +34 -0
- package/addon/utils/get-notification-schemas.js +18 -0
- package/app/adapters/addon-category.js +1 -0
- package/app/adapters/gateway.js +1 -0
- package/app/adapters/network.js +1 -0
- package/app/adapters/notification-channel.js +1 -0
- package/app/adapters/product-addon-category.js +1 -0
- package/app/adapters/product-addon.js +1 -0
- package/app/adapters/product-hour.js +1 -0
- package/app/adapters/product-store-location.js +1 -0
- package/app/adapters/product-variant-option.js +1 -0
- package/app/adapters/product-variant.js +1 -0
- package/app/adapters/product.js +1 -0
- package/app/adapters/store-hour.js +1 -0
- package/app/adapters/store-location.js +1 -0
- package/app/adapters/store.js +1 -0
- package/app/adapters/storefront.js +1 -0
- package/app/components/file-record.js +1 -0
- package/app/components/modals/add-store-hours.js +1 -0
- package/app/components/modals/add-stores-to-network.js +1 -0
- package/app/components/modals/assign-driver.js +1 -0
- package/app/components/modals/create-first-store.js +1 -0
- package/app/components/modals/create-gateway.js +1 -0
- package/app/components/modals/create-network-category.js +1 -0
- package/app/components/modals/create-network.js +1 -0
- package/app/components/modals/create-new-variant.js +1 -0
- package/app/components/modals/create-notification-channel.js +1 -0
- package/app/components/modals/create-product-category.js +1 -0
- package/app/components/modals/create-store.js +1 -0
- package/app/components/modals/edit-network.js +1 -0
- package/app/components/modals/import-products.js +1 -0
- package/app/components/modals/incoming-order.js +1 -0
- package/app/components/modals/manage-addons.js +1 -0
- package/app/components/modals/order-ready-assign-driver.js +1 -0
- package/app/components/modals/select-addon-category.js +1 -0
- package/app/components/modals/share-network.js +1 -0
- package/app/components/modals/store-location-form.js +1 -0
- package/app/components/order-card.js +1 -0
- package/app/components/schedule-manager.js +1 -0
- package/app/components/settings-container.js +1 -0
- package/app/components/store-selector.js +1 -0
- package/app/components/widget/customers.js +1 -0
- package/app/components/widget/orders.js +1 -0
- package/app/components/widget/storefront-metrics.js +1 -0
- package/app/controllers/application.js +1 -0
- package/app/controllers/customers/index.js +1 -0
- package/app/controllers/home.js +1 -0
- package/app/controllers/networks/index/network/customers.js +1 -0
- package/app/controllers/networks/index/network/index.js +1 -0
- package/app/controllers/networks/index/network/orders.js +1 -0
- package/app/controllers/networks/index/network/stores.js +1 -0
- package/app/controllers/networks/index/network.js +1 -0
- package/app/controllers/networks/index.js +1 -0
- package/app/controllers/orders/index.js +1 -0
- package/app/controllers/products/index/category/edit.js +1 -0
- package/app/controllers/products/index/category/new.js +1 -0
- package/app/controllers/products/index/category.js +1 -0
- package/app/controllers/products/index/index/edit.js +1 -0
- package/app/controllers/products/index/index.js +1 -0
- package/app/controllers/products/index.js +1 -0
- package/app/controllers/settings/api.js +1 -0
- package/app/controllers/settings/gateways.js +1 -0
- package/app/controllers/settings/index.js +1 -0
- package/app/controllers/settings/locations.js +1 -0
- package/app/controllers/settings/notifications.js +1 -0
- package/app/helpers/get-tip-amount.js +1 -0
- package/app/models/addon-category.js +1 -0
- package/app/models/gateway.js +1 -0
- package/app/models/network.js +1 -0
- package/app/models/notification-channel.js +1 -0
- package/app/models/product-addon-category.js +1 -0
- package/app/models/product-addon.js +1 -0
- package/app/models/product-hour.js +1 -0
- package/app/models/product-store-location.js +1 -0
- package/app/models/product-variant-option.js +1 -0
- package/app/models/product-variant.js +1 -0
- package/app/models/product.js +1 -0
- package/app/models/store-hour.js +1 -0
- package/app/models/store-location.js +1 -0
- package/app/models/store.js +1 -0
- package/app/routes/application.js +1 -0
- package/app/routes/customers/index/edit.js +1 -0
- package/app/routes/customers/index.js +1 -0
- package/app/routes/home.js +1 -0
- package/app/routes/networks/index/network/customers.js +1 -0
- package/app/routes/networks/index/network/index.js +1 -0
- package/app/routes/networks/index/network/orders.js +1 -0
- package/app/routes/networks/index/network/stores.js +1 -0
- package/app/routes/networks/index/network.js +1 -0
- package/app/routes/networks/index.js +1 -0
- package/app/routes/orders/index/edit.js +1 -0
- package/app/routes/orders/index/new.js +1 -0
- package/app/routes/orders/index/view.js +1 -0
- package/app/routes/orders/index.js +1 -0
- package/app/routes/products/index/category/edit.js +1 -0
- package/app/routes/products/index/category/new.js +1 -0
- package/app/routes/products/index/category.js +1 -0
- package/app/routes/products/index/index/edit.js +1 -0
- package/app/routes/products/index/index.js +1 -0
- package/app/routes/products/index.js +1 -0
- package/app/routes/settings/api.js +1 -0
- package/app/routes/settings/gateways.js +1 -0
- package/app/routes/settings/index.js +1 -0
- package/app/routes/settings/locations.js +1 -0
- package/app/routes/settings/notifications.js +1 -0
- package/app/serializers/addon-category.js +1 -0
- package/app/serializers/network.js +1 -0
- package/app/serializers/notification-channel.js +1 -0
- package/app/serializers/product-addon-category.js +1 -0
- package/app/serializers/product-variant.js +1 -0
- package/app/serializers/product.js +1 -0
- package/app/serializers/store-location.js +1 -0
- package/app/serializers/store.js +1 -0
- package/app/services/storefront.js +1 -0
- package/app/templates/customers/index/edit.js +1 -0
- package/app/templates/customers/index.js +1 -0
- package/app/templates/home.js +1 -0
- package/app/templates/networks/index/network/customers.js +1 -0
- package/app/templates/networks/index/network/index.js +1 -0
- package/app/templates/networks/index/network/orders.js +1 -0
- package/app/templates/networks/index/network/stores.js +1 -0
- package/app/templates/networks/index/network.js +1 -0
- package/app/templates/networks/index.js +1 -0
- package/app/templates/orders/index/edit.js +1 -0
- package/app/templates/orders/index/new.js +1 -0
- package/app/templates/orders/index/view.js +1 -0
- package/app/templates/orders/index.js +1 -0
- package/app/templates/products/index/category/edit.js +1 -0
- package/app/templates/products/index/category/new.js +1 -0
- package/app/templates/products/index/category.js +1 -0
- package/app/templates/products/index/index/edit.js +1 -0
- package/app/templates/products/index/index.js +1 -0
- package/app/templates/products/index.js +1 -0
- package/app/templates/settings/api.js +1 -0
- package/app/templates/settings/gateways.js +1 -0
- package/app/templates/settings/index.js +1 -0
- package/app/templates/settings/locations.js +1 -0
- package/app/templates/settings/notifications.js +1 -0
- package/app/templates/settings.js +1 -0
- package/app/utils/get-gateway-schemas.js +1 -0
- package/app/utils/get-notification-schemas.js +1 -0
- package/config/environment.js +21 -0
- package/index.js +22 -0
- package/package.json +123 -0
- package/pnpm-lock.yaml +12509 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Model, { attr, belongsTo } from '@ember-data/model';
|
|
2
|
+
import { format, formatDistanceToNow } from 'date-fns';
|
|
3
|
+
|
|
4
|
+
export default class ProductAddonCategoryModel extends Model {
|
|
5
|
+
/** @ids */
|
|
6
|
+
@attr('string') product_uuid;
|
|
7
|
+
@attr('string') category_uuid;
|
|
8
|
+
|
|
9
|
+
/** @relationships */
|
|
10
|
+
@belongsTo('addon-category') category;
|
|
11
|
+
|
|
12
|
+
/** @attributes */
|
|
13
|
+
@attr('string') name;
|
|
14
|
+
@attr('raw') excluded_addons;
|
|
15
|
+
|
|
16
|
+
/** @dates */
|
|
17
|
+
@attr('date') created_at;
|
|
18
|
+
@attr('date') updated_at;
|
|
19
|
+
|
|
20
|
+
/** @methods */
|
|
21
|
+
toJSON() {
|
|
22
|
+
return this.serialize();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @computed */
|
|
26
|
+
get updatedAgo() {
|
|
27
|
+
return formatDistanceToNow(this.updated_at);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get updatedAt() {
|
|
31
|
+
return format(this.updated_at, 'PPP');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get createdAgo() {
|
|
35
|
+
return formatDistanceToNow(this.created_at);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get createdAt() {
|
|
39
|
+
return format(this.created_at, 'PPP p');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Model, { attr } from '@ember-data/model';
|
|
2
|
+
import { format, formatDistanceToNow } from 'date-fns';
|
|
3
|
+
|
|
4
|
+
export default class ProductAddonModel extends Model {
|
|
5
|
+
/** @ids */
|
|
6
|
+
@attr('string') created_by_uuid;
|
|
7
|
+
@attr('string') category_uuid;
|
|
8
|
+
|
|
9
|
+
/** @attributes */
|
|
10
|
+
@attr('string', { defaultValue: '' }) name;
|
|
11
|
+
@attr('string', { defaultValue: '' }) description;
|
|
12
|
+
@attr('string') price;
|
|
13
|
+
@attr('string') sale_price;
|
|
14
|
+
@attr('boolean') is_on_sale;
|
|
15
|
+
|
|
16
|
+
/** @dates */
|
|
17
|
+
@attr('date') created_at;
|
|
18
|
+
@attr('date') updated_at;
|
|
19
|
+
|
|
20
|
+
/** @methods */
|
|
21
|
+
toJSON() {
|
|
22
|
+
return this.serialize();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @computed */
|
|
26
|
+
get updatedAgo() {
|
|
27
|
+
return formatDistanceToNow(this.updated_at);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get updatedAt() {
|
|
31
|
+
return format(this.updated_at, 'PPP');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get createdAgo() {
|
|
35
|
+
return formatDistanceToNow(this.created_at);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get createdAt() {
|
|
39
|
+
return format(this.created_at, 'PPP p');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import Model, { attr, belongsTo } from '@ember-data/model';
|
|
2
|
+
import { computed } from '@ember/object';
|
|
3
|
+
import { format, formatDistanceToNow, parse, isValid } from 'date-fns';
|
|
4
|
+
|
|
5
|
+
export default class ProductHourModel extends Model {
|
|
6
|
+
/** @ids */
|
|
7
|
+
@attr('string') product_uuid;
|
|
8
|
+
|
|
9
|
+
/** @relationships */
|
|
10
|
+
@belongsTo('product') product;
|
|
11
|
+
|
|
12
|
+
/** @attributes */
|
|
13
|
+
@attr('string') day_of_week;
|
|
14
|
+
@attr('string') start;
|
|
15
|
+
@attr('string') end;
|
|
16
|
+
|
|
17
|
+
/** @dates */
|
|
18
|
+
@attr('date') created_at;
|
|
19
|
+
@attr('date') updated_at;
|
|
20
|
+
|
|
21
|
+
/** @methods */
|
|
22
|
+
toJSON() {
|
|
23
|
+
return this.serialize();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** @computed */
|
|
27
|
+
@computed('start') get startDateInstance() {
|
|
28
|
+
if (!this.start) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const includesSeconds = this.start.split(':').length === 3;
|
|
33
|
+
const format = includesSeconds ? 'k:mm:ss' : 'k:mm';
|
|
34
|
+
|
|
35
|
+
return parse(this.start, format, new Date());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@computed('end') get endDateInstance() {
|
|
39
|
+
if (!this.end) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const includesSeconds = this.end.split(':').length === 3;
|
|
44
|
+
const format = includesSeconds ? 'k:mm:ss' : 'k:mm';
|
|
45
|
+
|
|
46
|
+
return parse(this.end, format, new Date());
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@computed('end', 'endDateInstance', 'start', 'startDateInstance') get humanReadableHours() {
|
|
50
|
+
if (!isValid(this.startDateInstance) || !isValid(this.endDateInstance)) {
|
|
51
|
+
return `${this.start} - ${this.end}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return `${format(this.startDateInstance, 'p')} - ${format(this.endDateInstance, 'p')}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get updatedAgo() {
|
|
58
|
+
return formatDistanceToNow(this.updated_at);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get updatedAt() {
|
|
62
|
+
return format(this.updated_at, 'PPP');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get createdAgo() {
|
|
66
|
+
return formatDistanceToNow(this.created_at);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get createdAt() {
|
|
70
|
+
return format(this.created_at, 'PPP p');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Model, { attr, hasMany } from '@ember-data/model';
|
|
2
|
+
|
|
3
|
+
export default class ProductStoreLocationModel extends Model {
|
|
4
|
+
/** @ids */
|
|
5
|
+
@attr('string') created_by_uuid;
|
|
6
|
+
@attr('string') company_uuid;
|
|
7
|
+
|
|
8
|
+
/** @relationships */
|
|
9
|
+
@hasMany('store') stores;
|
|
10
|
+
|
|
11
|
+
/** @attributes */
|
|
12
|
+
@attr('string', { defaultValue: '' }) name;
|
|
13
|
+
@attr('string', { defaultValue: '' }) description;
|
|
14
|
+
@attr('string') slug;
|
|
15
|
+
|
|
16
|
+
/** @dates */
|
|
17
|
+
@attr('date') created_at;
|
|
18
|
+
@attr('date') updated_at;
|
|
19
|
+
|
|
20
|
+
/** @methods */
|
|
21
|
+
toJSON() {
|
|
22
|
+
return this.serialize();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @computed */
|
|
26
|
+
get updatedAgo() {
|
|
27
|
+
return moment(this.updated_at).fromNow();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get updatedAt() {
|
|
31
|
+
return moment(this.updated_at).format('DD MMM YYYY');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get createdAgo() {
|
|
35
|
+
return moment(this.created_at).fromNow();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get createdAt() {
|
|
39
|
+
return moment(this.created_at).format('DD MMM YYYY');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import Model, { attr } from '@ember-data/model';
|
|
2
|
+
import { format, formatDistanceToNow } from 'date-fns';
|
|
3
|
+
|
|
4
|
+
export default class ProductVariantOptionModel extends Model {
|
|
5
|
+
/** @ids */
|
|
6
|
+
@attr('string') product_variant_uuid;
|
|
7
|
+
|
|
8
|
+
/** @attributes */
|
|
9
|
+
@attr('string', { defaultValue: '' }) name;
|
|
10
|
+
@attr('string', { defaultValue: '' }) description;
|
|
11
|
+
@attr('string') additional_cost;
|
|
12
|
+
@attr('raw') translations;
|
|
13
|
+
|
|
14
|
+
/** @dates */
|
|
15
|
+
@attr('date') created_at;
|
|
16
|
+
@attr('date') updated_at;
|
|
17
|
+
|
|
18
|
+
/** @methods */
|
|
19
|
+
toJSON() {
|
|
20
|
+
return this.serialize();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** @computed */
|
|
24
|
+
get updatedAgo() {
|
|
25
|
+
return formatDistanceToNow(this.updated_at);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get updatedAt() {
|
|
29
|
+
return format(this.updated_at, 'PPP');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get createdAgo() {
|
|
33
|
+
return formatDistanceToNow(this.created_at);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get createdAt() {
|
|
37
|
+
return format(this.created_at, 'PPP p');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import Model, { attr, hasMany } from '@ember-data/model';
|
|
2
|
+
|
|
3
|
+
export default class ProductVariantModel extends Model {
|
|
4
|
+
/** @ids */
|
|
5
|
+
@attr('string') product_uuid;
|
|
6
|
+
@attr('string') created_by_uuid;
|
|
7
|
+
@attr('string') company_uuid;
|
|
8
|
+
|
|
9
|
+
/** @relationships */
|
|
10
|
+
@hasMany('product-variant-option') options;
|
|
11
|
+
|
|
12
|
+
/** @attributes */
|
|
13
|
+
@attr('string', { defaultValue: '' }) name;
|
|
14
|
+
@attr('string', { defaultValue: '' }) description;
|
|
15
|
+
@attr('boolean') is_multiselect;
|
|
16
|
+
@attr('boolean') is_required;
|
|
17
|
+
@attr('raw') translations;
|
|
18
|
+
|
|
19
|
+
/** @dates */
|
|
20
|
+
@attr('date') created_at;
|
|
21
|
+
@attr('date') updated_at;
|
|
22
|
+
|
|
23
|
+
/** @methods */
|
|
24
|
+
toJSON() {
|
|
25
|
+
return this.serialize();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** @computed */
|
|
29
|
+
get updatedAgo() {
|
|
30
|
+
return moment(this.updated_at).fromNow();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get updatedAt() {
|
|
34
|
+
return moment(this.updated_at).format('DD MMM YYYY');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get createdAgo() {
|
|
38
|
+
return moment(this.created_at).fromNow();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get createdAt() {
|
|
42
|
+
return moment(this.created_at).format('DD MMM YYYY');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { getOwner } from '@ember/application';
|
|
4
|
+
import { set, setProperties } from '@ember/object';
|
|
5
|
+
import { isArray } from '@ember/array';
|
|
6
|
+
import { isEmpty } from '@ember/utils';
|
|
7
|
+
import { underscore } from '@ember/string';
|
|
8
|
+
import { format, formatDistanceToNow } from 'date-fns';
|
|
9
|
+
|
|
10
|
+
export default class ProductModel extends Model {
|
|
11
|
+
/** @ids */
|
|
12
|
+
@attr('string') created_by_uuid;
|
|
13
|
+
@attr('string') company_uuid;
|
|
14
|
+
@attr('string') store_uuid;
|
|
15
|
+
@attr('string') category_uuid;
|
|
16
|
+
@attr('string') primary_image_uuid;
|
|
17
|
+
@attr('string') public_id;
|
|
18
|
+
|
|
19
|
+
/** @relationships */
|
|
20
|
+
@belongsTo('category') category;
|
|
21
|
+
@belongsTo('file') primary_image;
|
|
22
|
+
@hasMany('file') files;
|
|
23
|
+
@hasMany('product-variant', { async: false }) variants;
|
|
24
|
+
@hasMany('product-addon-category') addon_categories;
|
|
25
|
+
@hasMany('product-hour') hours;
|
|
26
|
+
|
|
27
|
+
/** @attributes */
|
|
28
|
+
@attr('string', { defaultValue: '' }) name;
|
|
29
|
+
@attr('string', { defaultValue: '' }) description;
|
|
30
|
+
@attr('string') primary_image_url;
|
|
31
|
+
@attr('string') sku;
|
|
32
|
+
@attr('string') currency;
|
|
33
|
+
@attr('string') price;
|
|
34
|
+
@attr('string') sale_price;
|
|
35
|
+
@attr('raw') tags;
|
|
36
|
+
@attr('raw') youtube_urls;
|
|
37
|
+
@attr('raw') translations;
|
|
38
|
+
@attr('raw') meta;
|
|
39
|
+
@attr('raw') meta_array;
|
|
40
|
+
@attr('boolean') is_on_sale;
|
|
41
|
+
@attr('boolean') is_recommended;
|
|
42
|
+
@attr('boolean') is_service;
|
|
43
|
+
@attr('boolean') is_available;
|
|
44
|
+
@attr('boolean') is_bookable;
|
|
45
|
+
@attr('string') status;
|
|
46
|
+
@attr('string') slug;
|
|
47
|
+
|
|
48
|
+
/** @tracked */
|
|
49
|
+
@tracked isLoadingVariants = false;
|
|
50
|
+
@tracked isLoadingAddons = false;
|
|
51
|
+
@tracked isLoadingFiles = false;
|
|
52
|
+
@tracked isLoadingHours = false;
|
|
53
|
+
|
|
54
|
+
/** @dates */
|
|
55
|
+
@attr('date') created_at;
|
|
56
|
+
@attr('date') updated_at;
|
|
57
|
+
|
|
58
|
+
/** @methods */
|
|
59
|
+
toJSON() {
|
|
60
|
+
return this.serialize();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** @computed */
|
|
64
|
+
get updatedAgo() {
|
|
65
|
+
return formatDistanceToNow(this.updated_at);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get updatedAt() {
|
|
69
|
+
return format(this.updated_at, 'PPP');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get createdAgo() {
|
|
73
|
+
return formatDistanceToNow(this.created_at);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get createdAt() {
|
|
77
|
+
return format(this.created_at, 'PPP p');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** @methods */
|
|
81
|
+
serializeMeta() {
|
|
82
|
+
let { meta_array } = this;
|
|
83
|
+
|
|
84
|
+
if (isEmpty(meta_array)) {
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const serialized = {};
|
|
89
|
+
|
|
90
|
+
for (let i = 0; i < meta_array.length; i++) {
|
|
91
|
+
const metaField = meta_array.objectAt(i);
|
|
92
|
+
const { label, value } = metaField;
|
|
93
|
+
|
|
94
|
+
if (!label) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
serialized[underscore(label)] = value;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
setProperties(this, { meta: serialized });
|
|
102
|
+
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
loadAddonCategories() {
|
|
107
|
+
const owner = getOwner(this);
|
|
108
|
+
const store = owner.lookup(`service:store`);
|
|
109
|
+
|
|
110
|
+
this.isLoadingAddons = true;
|
|
111
|
+
|
|
112
|
+
return new Promise((resolve) => {
|
|
113
|
+
return store
|
|
114
|
+
.query('product-addon-category', { product_uuid: this.id, with: ['category'] })
|
|
115
|
+
.then((productAddonCategories) => {
|
|
116
|
+
this.addon_categories = productAddonCategories;
|
|
117
|
+
this.isLoadingAddons = false;
|
|
118
|
+
|
|
119
|
+
resolve(productAddonCategories);
|
|
120
|
+
})
|
|
121
|
+
.catch((error) => {
|
|
122
|
+
this.isLoadingAddons = false;
|
|
123
|
+
resolve([]);
|
|
124
|
+
throw error;
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
loadVariants() {
|
|
130
|
+
const owner = getOwner(this);
|
|
131
|
+
const store = owner.lookup(`service:store`);
|
|
132
|
+
|
|
133
|
+
this.isLoadingVariants = true;
|
|
134
|
+
|
|
135
|
+
return new Promise((resolve) => {
|
|
136
|
+
return store
|
|
137
|
+
.query('product-variant', { product_uuid: this.id, with: ['options'] })
|
|
138
|
+
.then((variants) => {
|
|
139
|
+
this.variants = variants;
|
|
140
|
+
this.isLoadingVariants = false;
|
|
141
|
+
|
|
142
|
+
resolve(variants);
|
|
143
|
+
})
|
|
144
|
+
.catch((error) => {
|
|
145
|
+
this.isLoadingVariants = false;
|
|
146
|
+
resolve([]);
|
|
147
|
+
throw error;
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
loadHours() {
|
|
153
|
+
const owner = getOwner(this);
|
|
154
|
+
const store = owner.lookup(`service:store`);
|
|
155
|
+
|
|
156
|
+
this.isLoadingHours = true;
|
|
157
|
+
|
|
158
|
+
return new Promise((resolve) => {
|
|
159
|
+
return store
|
|
160
|
+
.query('product-hour', { product_uuid: this.id })
|
|
161
|
+
.then((hours) => {
|
|
162
|
+
this.hours = hours;
|
|
163
|
+
this.isLoadingHours = false;
|
|
164
|
+
|
|
165
|
+
resolve(hours);
|
|
166
|
+
})
|
|
167
|
+
.catch((error) => {
|
|
168
|
+
this.isLoadingHours = false;
|
|
169
|
+
resolve([]);
|
|
170
|
+
throw error;
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
loadFiles() {
|
|
176
|
+
const owner = getOwner(this);
|
|
177
|
+
const store = owner.lookup(`service:store`);
|
|
178
|
+
|
|
179
|
+
this.isLoadingFiles = true;
|
|
180
|
+
|
|
181
|
+
return new Promise((resolve) => {
|
|
182
|
+
return store
|
|
183
|
+
.query('file', { subject_uuid: this.id, type: 'storefront_product' })
|
|
184
|
+
.then((files) => {
|
|
185
|
+
this.files = files;
|
|
186
|
+
|
|
187
|
+
// set the primary image if applicable
|
|
188
|
+
for (let i = 0; i < files.length; i++) {
|
|
189
|
+
const file = files.objectAt(i);
|
|
190
|
+
|
|
191
|
+
if (file.id === this.primary_image_uuid) {
|
|
192
|
+
this.primary_image = file;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
this.isLoadingFiles = false;
|
|
198
|
+
|
|
199
|
+
resolve(files);
|
|
200
|
+
})
|
|
201
|
+
.catch((error) => {
|
|
202
|
+
this.isLoadingFiles = false;
|
|
203
|
+
resolve([]);
|
|
204
|
+
throw error;
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import Model, { attr, belongsTo } from '@ember-data/model';
|
|
2
|
+
import { computed } from '@ember/object';
|
|
3
|
+
import { format, formatDistanceToNow, parse, isValid } from 'date-fns';
|
|
4
|
+
|
|
5
|
+
export default class StoreHourModel extends Model {
|
|
6
|
+
/** @ids */
|
|
7
|
+
@attr('string') store_location_uuid;
|
|
8
|
+
|
|
9
|
+
/** @relationships */
|
|
10
|
+
@belongsTo('store-location') store_location;
|
|
11
|
+
|
|
12
|
+
/** @attributes */
|
|
13
|
+
@attr('string') day_of_week;
|
|
14
|
+
@attr('string') start;
|
|
15
|
+
@attr('string') end;
|
|
16
|
+
|
|
17
|
+
/** @dates */
|
|
18
|
+
@attr('date') created_at;
|
|
19
|
+
@attr('date') updated_at;
|
|
20
|
+
|
|
21
|
+
/** @methods */
|
|
22
|
+
toJSON() {
|
|
23
|
+
return this.serialize();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** @computed */
|
|
27
|
+
@computed('start') get startDateInstance() {
|
|
28
|
+
if (!this.start) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const includesSeconds = this.start.split(':').length === 3;
|
|
33
|
+
const format = includesSeconds ? 'k:mm:ss' : 'k:mm';
|
|
34
|
+
|
|
35
|
+
return parse(this.start, format, new Date());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@computed('end') get endDateInstance() {
|
|
39
|
+
if (!this.end) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const includesSeconds = this.end.split(':').length === 3;
|
|
44
|
+
const format = includesSeconds ? 'k:mm:ss' : 'k:mm';
|
|
45
|
+
|
|
46
|
+
return parse(this.end, format, new Date());
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@computed('end', 'endDateInstance', 'start', 'startDateInstance') get humanReadableHours() {
|
|
50
|
+
if (!isValid(this.startDateInstance) || !isValid(this.endDateInstance)) {
|
|
51
|
+
return `${this.start} - ${this.end}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return `${format(this.startDateInstance, 'p')} - ${format(this.endDateInstance, 'p')}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get updatedAgo() {
|
|
58
|
+
return formatDistanceToNow(this.updated_at);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get updatedAt() {
|
|
62
|
+
return format(this.updated_at, 'PPP');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get createdAgo() {
|
|
66
|
+
return formatDistanceToNow(this.created_at);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get createdAt() {
|
|
70
|
+
return format(this.created_at, 'PPP p');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
|
|
2
|
+
import { computed } from '@ember/object';
|
|
3
|
+
import { isArray } from '@ember/array';
|
|
4
|
+
import { getOwner } from '@ember/application';
|
|
5
|
+
import { format, formatDistanceToNow } from 'date-fns';
|
|
6
|
+
|
|
7
|
+
export default class StoreLocationModel extends Model {
|
|
8
|
+
/** @ids */
|
|
9
|
+
@attr('string') store_uuid;
|
|
10
|
+
@attr('string') created_by_uuid;
|
|
11
|
+
@attr('string') place_uuid;
|
|
12
|
+
|
|
13
|
+
/** @relationships */
|
|
14
|
+
@belongsTo('place', { async: false }) place;
|
|
15
|
+
@hasMany('store-hour') hours;
|
|
16
|
+
|
|
17
|
+
/** @attributes */
|
|
18
|
+
@attr('string') name;
|
|
19
|
+
@attr('string') address;
|
|
20
|
+
|
|
21
|
+
/** @dates */
|
|
22
|
+
@attr('date') created_at;
|
|
23
|
+
@attr('date') updated_at;
|
|
24
|
+
|
|
25
|
+
/** @methods */
|
|
26
|
+
toJSON() {
|
|
27
|
+
return this.serialize();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
loadPlace() {
|
|
31
|
+
const owner = getOwner(this);
|
|
32
|
+
const store = owner.lookup(`service:store`);
|
|
33
|
+
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
if (!this.place_uuid) {
|
|
36
|
+
return resolve(null);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (this.place) {
|
|
40
|
+
return resolve(this.place);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return store
|
|
44
|
+
.findRecord('place', this.place_uuid)
|
|
45
|
+
.then((place) => {
|
|
46
|
+
this.place = place;
|
|
47
|
+
|
|
48
|
+
resolve(place);
|
|
49
|
+
})
|
|
50
|
+
.catch(() => resolve(null));
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** @computed */
|
|
55
|
+
@computed('hours.[]') get schedule() {
|
|
56
|
+
const schedule = {};
|
|
57
|
+
const week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
|
|
58
|
+
|
|
59
|
+
for (let i = 0; i < week.length; i++) {
|
|
60
|
+
const day = week.objectAt(i);
|
|
61
|
+
|
|
62
|
+
schedule[day] = [];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
for (let i = 0; i < this.hours.length; i++) {
|
|
66
|
+
const hour = this.hours.objectAt(i);
|
|
67
|
+
|
|
68
|
+
if (!isArray(schedule[hour.day_of_week])) {
|
|
69
|
+
schedule[hour.day_of_week] = [];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
schedule[hour.day_of_week].pushObject(hour);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return schedule;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
get updatedAgo() {
|
|
79
|
+
return formatDistanceToNow(this.updated_at);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get updatedAt() {
|
|
83
|
+
return format(this.updated_at, 'PPP');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
get createdAgo() {
|
|
87
|
+
return formatDistanceToNow(this.created_at);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
get createdAt() {
|
|
91
|
+
return format(this.created_at, 'PPP p');
|
|
92
|
+
}
|
|
93
|
+
}
|