@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.
Files changed (296) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +32 -0
  3. package/addon/adapters/addon-category.js +1 -0
  4. package/addon/adapters/customer.js +1 -0
  5. package/addon/adapters/gateway.js +1 -0
  6. package/addon/adapters/network.js +1 -0
  7. package/addon/adapters/notification-channel.js +1 -0
  8. package/addon/adapters/product-addon-category.js +1 -0
  9. package/addon/adapters/product-addon.js +1 -0
  10. package/addon/adapters/product-hour.js +1 -0
  11. package/addon/adapters/product-store-location.js +1 -0
  12. package/addon/adapters/product-variant-option.js +1 -0
  13. package/addon/adapters/product-variant.js +1 -0
  14. package/addon/adapters/product.js +1 -0
  15. package/addon/adapters/store-hour.js +1 -0
  16. package/addon/adapters/store-location.js +1 -0
  17. package/addon/adapters/store.js +1 -0
  18. package/addon/adapters/storefront.js +5 -0
  19. package/addon/components/file-record.hbs +22 -0
  20. package/addon/components/file-record.js +43 -0
  21. package/addon/components/modals/add-store-hours.hbs +8 -0
  22. package/addon/components/modals/add-stores-to-network.hbs +5 -0
  23. package/addon/components/modals/assign-driver.hbs +25 -0
  24. package/addon/components/modals/create-first-store.hbs +21 -0
  25. package/addon/components/modals/create-gateway.hbs +35 -0
  26. package/addon/components/modals/create-network-category.hbs +50 -0
  27. package/addon/components/modals/create-network.hbs +20 -0
  28. package/addon/components/modals/create-new-variant.hbs +15 -0
  29. package/addon/components/modals/create-notification-channel.hbs +45 -0
  30. package/addon/components/modals/create-product-category.hbs +30 -0
  31. package/addon/components/modals/create-store.hbs +9 -0
  32. package/addon/components/modals/edit-network.hbs +1 -0
  33. package/addon/components/modals/import-products.hbs +97 -0
  34. package/addon/components/modals/incoming-order.hbs +242 -0
  35. package/addon/components/modals/manage-addons.hbs +50 -0
  36. package/addon/components/modals/manage-addons.js +86 -0
  37. package/addon/components/modals/order-ready-assign-driver.hbs +36 -0
  38. package/addon/components/modals/select-addon-category.hbs +5 -0
  39. package/addon/components/modals/share-network.hbs +35 -0
  40. package/addon/components/modals/store-location-form.hbs +30 -0
  41. package/addon/components/order-card.hbs +1 -0
  42. package/addon/components/order-card.js +3 -0
  43. package/addon/components/schedule-manager.hbs +22 -0
  44. package/addon/components/schedule-manager.js +73 -0
  45. package/addon/components/settings-container.hbs +7 -0
  46. package/addon/components/store-selector.hbs +21 -0
  47. package/addon/components/store-selector.js +20 -0
  48. package/addon/components/widget/customers.hbs +44 -0
  49. package/addon/components/widget/customers.js +53 -0
  50. package/addon/components/widget/orders.hbs +111 -0
  51. package/addon/components/widget/orders.js +248 -0
  52. package/addon/components/widget/storefront-metrics.hbs +54 -0
  53. package/addon/components/widget/storefront-metrics.js +61 -0
  54. package/addon/controllers/application.js +33 -0
  55. package/addon/controllers/customers/index.js +267 -0
  56. package/addon/controllers/home.js +3 -0
  57. package/addon/controllers/networks/index/network/customers.js +3 -0
  58. package/addon/controllers/networks/index/network/index.js +147 -0
  59. package/addon/controllers/networks/index/network/orders.js +3 -0
  60. package/addon/controllers/networks/index/network/stores.js +370 -0
  61. package/addon/controllers/networks/index/network.js +29 -0
  62. package/addon/controllers/networks/index.js +138 -0
  63. package/addon/controllers/orders/index.js +331 -0
  64. package/addon/controllers/products/index/category/edit.js +62 -0
  65. package/addon/controllers/products/index/category/new.js +287 -0
  66. package/addon/controllers/products/index/category.js +163 -0
  67. package/addon/controllers/products/index/index/edit.js +1 -0
  68. package/addon/controllers/products/index/index.js +136 -0
  69. package/addon/controllers/products/index.js +203 -0
  70. package/addon/controllers/settings/api.js +3 -0
  71. package/addon/controllers/settings/gateways.js +110 -0
  72. package/addon/controllers/settings/index.js +102 -0
  73. package/addon/controllers/settings/locations.js +186 -0
  74. package/addon/controllers/settings/notifications.js +102 -0
  75. package/addon/engine.js +19 -0
  76. package/addon/helpers/get-tip-amount.js +5 -0
  77. package/addon/models/addon-category.js +6 -0
  78. package/addon/models/gateway.js +46 -0
  79. package/addon/models/network.js +166 -0
  80. package/addon/models/notification-channel.js +47 -0
  81. package/addon/models/product-addon-category.js +41 -0
  82. package/addon/models/product-addon.js +41 -0
  83. package/addon/models/product-hour.js +72 -0
  84. package/addon/models/product-store-location.js +41 -0
  85. package/addon/models/product-variant-option.js +39 -0
  86. package/addon/models/product-variant.js +44 -0
  87. package/addon/models/product.js +208 -0
  88. package/addon/models/store-hour.js +72 -0
  89. package/addon/models/store-location.js +93 -0
  90. package/addon/models/store.js +100 -0
  91. package/addon/routes/application.js +47 -0
  92. package/addon/routes/customers/index/edit.js +3 -0
  93. package/addon/routes/customers/index.js +25 -0
  94. package/addon/routes/home.js +3 -0
  95. package/addon/routes/networks/index/network/customers.js +3 -0
  96. package/addon/routes/networks/index/network/index.js +15 -0
  97. package/addon/routes/networks/index/network/orders.js +3 -0
  98. package/addon/routes/networks/index/network/stores.js +28 -0
  99. package/addon/routes/networks/index/network.js +10 -0
  100. package/addon/routes/networks/index.js +19 -0
  101. package/addon/routes/orders/index/edit.js +3 -0
  102. package/addon/routes/orders/index/new.js +3 -0
  103. package/addon/routes/orders/index/view.js +3 -0
  104. package/addon/routes/orders/index.js +29 -0
  105. package/addon/routes/products/index/category/edit.js +15 -0
  106. package/addon/routes/products/index/category/new.js +7 -0
  107. package/addon/routes/products/index/category.js +54 -0
  108. package/addon/routes/products/index/index/edit.js +1 -0
  109. package/addon/routes/products/index/index.js +22 -0
  110. package/addon/routes/products/index.js +21 -0
  111. package/addon/routes/settings/api.js +10 -0
  112. package/addon/routes/settings/gateways.js +11 -0
  113. package/addon/routes/settings/index.js +16 -0
  114. package/addon/routes/settings/locations.js +14 -0
  115. package/addon/routes/settings/notifications.js +11 -0
  116. package/addon/routes.js +48 -0
  117. package/addon/serializers/addon-category.js +15 -0
  118. package/addon/serializers/network.js +19 -0
  119. package/addon/serializers/notification-channel.js +15 -0
  120. package/addon/serializers/product-addon-category.js +15 -0
  121. package/addon/serializers/product-variant.js +15 -0
  122. package/addon/serializers/product.js +20 -0
  123. package/addon/serializers/store-location.js +17 -0
  124. package/addon/serializers/store.js +19 -0
  125. package/addon/services/storefront.js +208 -0
  126. package/addon/templates/application.hbs +16 -0
  127. package/addon/templates/customers/index/edit.hbs +2 -0
  128. package/addon/templates/customers/index.hbs +22 -0
  129. package/addon/templates/home.hbs +7 -0
  130. package/addon/templates/networks/index/network/customers.hbs +2 -0
  131. package/addon/templates/networks/index/network/index.hbs +254 -0
  132. package/addon/templates/networks/index/network/orders.hbs +2 -0
  133. package/addon/templates/networks/index/network/stores.hbs +164 -0
  134. package/addon/templates/networks/index/network.hbs +38 -0
  135. package/addon/templates/networks/index.hbs +60 -0
  136. package/addon/templates/orders/index/edit.hbs +2 -0
  137. package/addon/templates/orders/index/new.hbs +2 -0
  138. package/addon/templates/orders/index/view.hbs +2 -0
  139. package/addon/templates/orders/index.hbs +22 -0
  140. package/addon/templates/products/index/category/edit.hbs +1 -0
  141. package/addon/templates/products/index/category/new.hbs +248 -0
  142. package/addon/templates/products/index/category.hbs +41 -0
  143. package/addon/templates/products/index/index/edit.hbs +1 -0
  144. package/addon/templates/products/index/index.hbs +40 -0
  145. package/addon/templates/products/index.hbs +22 -0
  146. package/addon/templates/settings/api.hbs +18 -0
  147. package/addon/templates/settings/gateways.hbs +48 -0
  148. package/addon/templates/settings/index.hbs +229 -0
  149. package/addon/templates/settings/locations.hbs +39 -0
  150. package/addon/templates/settings/notifications.hbs +35 -0
  151. package/addon/templates/settings.hbs +30 -0
  152. package/addon/utils/get-gateway-schemas.js +34 -0
  153. package/addon/utils/get-notification-schemas.js +18 -0
  154. package/app/adapters/addon-category.js +1 -0
  155. package/app/adapters/gateway.js +1 -0
  156. package/app/adapters/network.js +1 -0
  157. package/app/adapters/notification-channel.js +1 -0
  158. package/app/adapters/product-addon-category.js +1 -0
  159. package/app/adapters/product-addon.js +1 -0
  160. package/app/adapters/product-hour.js +1 -0
  161. package/app/adapters/product-store-location.js +1 -0
  162. package/app/adapters/product-variant-option.js +1 -0
  163. package/app/adapters/product-variant.js +1 -0
  164. package/app/adapters/product.js +1 -0
  165. package/app/adapters/store-hour.js +1 -0
  166. package/app/adapters/store-location.js +1 -0
  167. package/app/adapters/store.js +1 -0
  168. package/app/adapters/storefront.js +1 -0
  169. package/app/components/file-record.js +1 -0
  170. package/app/components/modals/add-store-hours.js +1 -0
  171. package/app/components/modals/add-stores-to-network.js +1 -0
  172. package/app/components/modals/assign-driver.js +1 -0
  173. package/app/components/modals/create-first-store.js +1 -0
  174. package/app/components/modals/create-gateway.js +1 -0
  175. package/app/components/modals/create-network-category.js +1 -0
  176. package/app/components/modals/create-network.js +1 -0
  177. package/app/components/modals/create-new-variant.js +1 -0
  178. package/app/components/modals/create-notification-channel.js +1 -0
  179. package/app/components/modals/create-product-category.js +1 -0
  180. package/app/components/modals/create-store.js +1 -0
  181. package/app/components/modals/edit-network.js +1 -0
  182. package/app/components/modals/import-products.js +1 -0
  183. package/app/components/modals/incoming-order.js +1 -0
  184. package/app/components/modals/manage-addons.js +1 -0
  185. package/app/components/modals/order-ready-assign-driver.js +1 -0
  186. package/app/components/modals/select-addon-category.js +1 -0
  187. package/app/components/modals/share-network.js +1 -0
  188. package/app/components/modals/store-location-form.js +1 -0
  189. package/app/components/order-card.js +1 -0
  190. package/app/components/schedule-manager.js +1 -0
  191. package/app/components/settings-container.js +1 -0
  192. package/app/components/store-selector.js +1 -0
  193. package/app/components/widget/customers.js +1 -0
  194. package/app/components/widget/orders.js +1 -0
  195. package/app/components/widget/storefront-metrics.js +1 -0
  196. package/app/controllers/application.js +1 -0
  197. package/app/controllers/customers/index.js +1 -0
  198. package/app/controllers/home.js +1 -0
  199. package/app/controllers/networks/index/network/customers.js +1 -0
  200. package/app/controllers/networks/index/network/index.js +1 -0
  201. package/app/controllers/networks/index/network/orders.js +1 -0
  202. package/app/controllers/networks/index/network/stores.js +1 -0
  203. package/app/controllers/networks/index/network.js +1 -0
  204. package/app/controllers/networks/index.js +1 -0
  205. package/app/controllers/orders/index.js +1 -0
  206. package/app/controllers/products/index/category/edit.js +1 -0
  207. package/app/controllers/products/index/category/new.js +1 -0
  208. package/app/controllers/products/index/category.js +1 -0
  209. package/app/controllers/products/index/index/edit.js +1 -0
  210. package/app/controllers/products/index/index.js +1 -0
  211. package/app/controllers/products/index.js +1 -0
  212. package/app/controllers/settings/api.js +1 -0
  213. package/app/controllers/settings/gateways.js +1 -0
  214. package/app/controllers/settings/index.js +1 -0
  215. package/app/controllers/settings/locations.js +1 -0
  216. package/app/controllers/settings/notifications.js +1 -0
  217. package/app/helpers/get-tip-amount.js +1 -0
  218. package/app/models/addon-category.js +1 -0
  219. package/app/models/gateway.js +1 -0
  220. package/app/models/network.js +1 -0
  221. package/app/models/notification-channel.js +1 -0
  222. package/app/models/product-addon-category.js +1 -0
  223. package/app/models/product-addon.js +1 -0
  224. package/app/models/product-hour.js +1 -0
  225. package/app/models/product-store-location.js +1 -0
  226. package/app/models/product-variant-option.js +1 -0
  227. package/app/models/product-variant.js +1 -0
  228. package/app/models/product.js +1 -0
  229. package/app/models/store-hour.js +1 -0
  230. package/app/models/store-location.js +1 -0
  231. package/app/models/store.js +1 -0
  232. package/app/routes/application.js +1 -0
  233. package/app/routes/customers/index/edit.js +1 -0
  234. package/app/routes/customers/index.js +1 -0
  235. package/app/routes/home.js +1 -0
  236. package/app/routes/networks/index/network/customers.js +1 -0
  237. package/app/routes/networks/index/network/index.js +1 -0
  238. package/app/routes/networks/index/network/orders.js +1 -0
  239. package/app/routes/networks/index/network/stores.js +1 -0
  240. package/app/routes/networks/index/network.js +1 -0
  241. package/app/routes/networks/index.js +1 -0
  242. package/app/routes/orders/index/edit.js +1 -0
  243. package/app/routes/orders/index/new.js +1 -0
  244. package/app/routes/orders/index/view.js +1 -0
  245. package/app/routes/orders/index.js +1 -0
  246. package/app/routes/products/index/category/edit.js +1 -0
  247. package/app/routes/products/index/category/new.js +1 -0
  248. package/app/routes/products/index/category.js +1 -0
  249. package/app/routes/products/index/index/edit.js +1 -0
  250. package/app/routes/products/index/index.js +1 -0
  251. package/app/routes/products/index.js +1 -0
  252. package/app/routes/settings/api.js +1 -0
  253. package/app/routes/settings/gateways.js +1 -0
  254. package/app/routes/settings/index.js +1 -0
  255. package/app/routes/settings/locations.js +1 -0
  256. package/app/routes/settings/notifications.js +1 -0
  257. package/app/serializers/addon-category.js +1 -0
  258. package/app/serializers/network.js +1 -0
  259. package/app/serializers/notification-channel.js +1 -0
  260. package/app/serializers/product-addon-category.js +1 -0
  261. package/app/serializers/product-variant.js +1 -0
  262. package/app/serializers/product.js +1 -0
  263. package/app/serializers/store-location.js +1 -0
  264. package/app/serializers/store.js +1 -0
  265. package/app/services/storefront.js +1 -0
  266. package/app/templates/customers/index/edit.js +1 -0
  267. package/app/templates/customers/index.js +1 -0
  268. package/app/templates/home.js +1 -0
  269. package/app/templates/networks/index/network/customers.js +1 -0
  270. package/app/templates/networks/index/network/index.js +1 -0
  271. package/app/templates/networks/index/network/orders.js +1 -0
  272. package/app/templates/networks/index/network/stores.js +1 -0
  273. package/app/templates/networks/index/network.js +1 -0
  274. package/app/templates/networks/index.js +1 -0
  275. package/app/templates/orders/index/edit.js +1 -0
  276. package/app/templates/orders/index/new.js +1 -0
  277. package/app/templates/orders/index/view.js +1 -0
  278. package/app/templates/orders/index.js +1 -0
  279. package/app/templates/products/index/category/edit.js +1 -0
  280. package/app/templates/products/index/category/new.js +1 -0
  281. package/app/templates/products/index/category.js +1 -0
  282. package/app/templates/products/index/index/edit.js +1 -0
  283. package/app/templates/products/index/index.js +1 -0
  284. package/app/templates/products/index.js +1 -0
  285. package/app/templates/settings/api.js +1 -0
  286. package/app/templates/settings/gateways.js +1 -0
  287. package/app/templates/settings/index.js +1 -0
  288. package/app/templates/settings/locations.js +1 -0
  289. package/app/templates/settings/notifications.js +1 -0
  290. package/app/templates/settings.js +1 -0
  291. package/app/utils/get-gateway-schemas.js +1 -0
  292. package/app/utils/get-notification-schemas.js +1 -0
  293. package/config/environment.js +21 -0
  294. package/index.js +22 -0
  295. package/package.json +123 -0
  296. 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
+ }