@ozdao/prometheus-framework 0.2.309 → 0.2.311

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. package/dist/products.server.js +192 -195
  2. package/dist/products.server.mjs +192 -195
  3. package/dist/prometheus-framework/src/components/Block/Block.vue.cjs +1 -1
  4. package/dist/prometheus-framework/src/components/Block/Block.vue.cjs.map +1 -1
  5. package/dist/prometheus-framework/src/components/Block/Block.vue.js +1 -1
  6. package/dist/prometheus-framework/src/components/Block/Block.vue.js.map +1 -1
  7. package/dist/prometheus-framework/src/components/Chips/Chips.vue2.cjs +2 -1
  8. package/dist/prometheus-framework/src/components/Chips/Chips.vue2.cjs.map +1 -1
  9. package/dist/prometheus-framework/src/components/Chips/Chips.vue2.js +3 -2
  10. package/dist/prometheus-framework/src/components/Chips/Chips.vue2.js.map +1 -1
  11. package/dist/prometheus-framework/src/components/EditImages/EditImages.vue2.cjs +1 -1
  12. package/dist/prometheus-framework/src/components/EditImages/EditImages.vue2.cjs.map +1 -1
  13. package/dist/prometheus-framework/src/components/EditImages/EditImages.vue2.js +1 -1
  14. package/dist/prometheus-framework/src/components/EditImages/EditImages.vue2.js.map +1 -1
  15. package/dist/prometheus-framework/src/components/Field/Field.vue.cjs +13 -12
  16. package/dist/prometheus-framework/src/components/Field/Field.vue.cjs.map +1 -1
  17. package/dist/prometheus-framework/src/components/Field/Field.vue.js +13 -12
  18. package/dist/prometheus-framework/src/components/Field/Field.vue.js.map +1 -1
  19. package/dist/prometheus-framework/src/modules/auth/views/middlewares/auth.validation.cjs +1 -0
  20. package/dist/prometheus-framework/src/modules/auth/views/middlewares/auth.validation.cjs.map +1 -1
  21. package/dist/prometheus-framework/src/modules/auth/views/middlewares/auth.validation.js +1 -0
  22. package/dist/prometheus-framework/src/modules/auth/views/middlewares/auth.validation.js.map +1 -1
  23. package/dist/prometheus-framework/src/modules/auth/views/store/auth.cjs +6 -2
  24. package/dist/prometheus-framework/src/modules/auth/views/store/auth.cjs.map +1 -1
  25. package/dist/prometheus-framework/src/modules/auth/views/store/auth.js +6 -2
  26. package/dist/prometheus-framework/src/modules/auth/views/store/auth.js.map +1 -1
  27. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +2 -4
  28. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs.map +1 -1
  29. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +3 -5
  30. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js.map +1 -1
  31. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.cjs +1 -1
  32. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.js +1 -1
  33. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.cjs +1 -1
  34. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.js +1 -1
  35. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
  36. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +1 -1
  37. package/dist/prometheus-framework/src/modules/globals/views/components/partials/BottomNavigationBar.vue.cjs +3 -3
  38. package/dist/prometheus-framework/src/modules/globals/views/components/partials/BottomNavigationBar.vue.cjs.map +1 -1
  39. package/dist/prometheus-framework/src/modules/globals/views/components/partials/BottomNavigationBar.vue.js +3 -3
  40. package/dist/prometheus-framework/src/modules/globals/views/components/partials/BottomNavigationBar.vue.js.map +1 -1
  41. package/dist/prometheus-framework/src/modules/globals/views/components/partials/Header.vue.cjs +1 -1
  42. package/dist/prometheus-framework/src/modules/globals/views/components/partials/Header.vue.js +1 -1
  43. package/dist/prometheus-framework/src/modules/globals/views/components/partials/NavigationBar.vue.cjs +18 -15
  44. package/dist/prometheus-framework/src/modules/globals/views/components/partials/NavigationBar.vue.cjs.map +1 -1
  45. package/dist/prometheus-framework/src/modules/globals/views/components/partials/NavigationBar.vue.js +21 -18
  46. package/dist/prometheus-framework/src/modules/globals/views/components/partials/NavigationBar.vue.js.map +1 -1
  47. package/dist/prometheus-framework/src/modules/globals/views/store/globals.cjs +4 -0
  48. package/dist/prometheus-framework/src/modules/globals/views/store/globals.cjs.map +1 -1
  49. package/dist/prometheus-framework/src/modules/globals/views/store/globals.js +4 -0
  50. package/dist/prometheus-framework/src/modules/globals/views/store/globals.js.map +1 -1
  51. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
  52. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +1 -1
  53. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -1
  54. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.js +1 -1
  55. package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.cjs +1 -1
  56. package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.js +1 -1
  57. package/dist/prometheus-framework/src/modules/orders/components/sections/FormPayment.vue.cjs +1 -1
  58. package/dist/prometheus-framework/src/modules/orders/components/sections/FormPayment.vue.js +1 -1
  59. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
  60. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +1 -1
  61. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  62. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs.map +1 -1
  63. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +1 -1
  64. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js.map +1 -1
  65. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -2
  66. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs.map +1 -1
  67. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +2 -3
  68. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js.map +1 -1
  69. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
  70. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +1 -1
  71. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  72. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +1 -1
  73. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  74. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +1 -1
  75. package/dist/prometheus-framework/src/modules/pages/pages.client.cjs +554 -554
  76. package/dist/prometheus-framework/src/modules/pages/pages.client.js +554 -554
  77. package/dist/prometheus-framework/src/modules/products/components/blocks/CardCategory.vue.cjs +3 -3
  78. package/dist/prometheus-framework/src/modules/products/components/blocks/CardCategory.vue.cjs.map +1 -1
  79. package/dist/prometheus-framework/src/modules/products/components/blocks/CardCategory.vue.js +3 -3
  80. package/dist/prometheus-framework/src/modules/products/components/blocks/CardCategory.vue.js.map +1 -1
  81. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
  82. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +1 -1
  83. package/dist/prometheus-framework/src/modules/products/components/blocks/CardProduct.vue.cjs +11 -10
  84. package/dist/prometheus-framework/src/modules/products/components/blocks/CardProduct.vue.cjs.map +1 -1
  85. package/dist/prometheus-framework/src/modules/products/components/blocks/CardProduct.vue.js +11 -10
  86. package/dist/prometheus-framework/src/modules/products/components/blocks/CardProduct.vue.js.map +1 -1
  87. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.cjs +78 -43
  88. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.cjs.map +1 -1
  89. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.js +83 -48
  90. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.js.map +1 -1
  91. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs +80 -30
  92. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs.map +1 -1
  93. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +91 -41
  94. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js.map +1 -1
  95. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
  96. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +1 -1
  97. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.cjs +119 -80
  98. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.cjs.map +1 -1
  99. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js +132 -93
  100. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js.map +1 -1
  101. package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.cjs +39 -21
  102. package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.cjs.map +1 -1
  103. package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.js +51 -33
  104. package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.js.map +1 -1
  105. package/dist/prometheus-framework/src/modules/products/components/sections/CategoriesTree.vue.cjs +96 -0
  106. package/dist/prometheus-framework/src/modules/products/components/sections/CategoriesTree.vue.cjs.map +1 -0
  107. package/dist/prometheus-framework/src/modules/products/components/sections/CategoriesTree.vue.js +96 -0
  108. package/dist/prometheus-framework/src/modules/products/components/sections/CategoriesTree.vue.js.map +1 -0
  109. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +21 -7
  110. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs.map +1 -1
  111. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +21 -7
  112. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js.map +1 -1
  113. package/dist/prometheus-framework/src/modules/products/components/sections/Filters.vue.cjs +1 -1
  114. package/dist/prometheus-framework/src/modules/products/components/sections/Filters.vue.js +1 -1
  115. package/dist/prometheus-framework/src/modules/products/products.client.cjs.map +1 -1
  116. package/dist/prometheus-framework/src/modules/products/products.client.js.map +1 -1
  117. package/dist/prometheus-framework/src/modules/products/router/categories.router.cjs +17 -5
  118. package/dist/prometheus-framework/src/modules/products/router/categories.router.cjs.map +1 -1
  119. package/dist/prometheus-framework/src/modules/products/router/categories.router.js +17 -5
  120. package/dist/prometheus-framework/src/modules/products/router/categories.router.js.map +1 -1
  121. package/dist/prometheus-framework/src/modules/products/router/products.router.cjs +1 -12
  122. package/dist/prometheus-framework/src/modules/products/router/products.router.cjs.map +1 -1
  123. package/dist/prometheus-framework/src/modules/products/router/products.router.js +1 -12
  124. package/dist/prometheus-framework/src/modules/products/router/products.router.js.map +1 -1
  125. package/dist/prometheus-framework/src/modules/products/store/categories.cjs +52 -71
  126. package/dist/prometheus-framework/src/modules/products/store/categories.cjs.map +1 -1
  127. package/dist/prometheus-framework/src/modules/products/store/categories.js +52 -71
  128. package/dist/prometheus-framework/src/modules/products/store/categories.js.map +1 -1
  129. package/dist/prometheus-framework/src/modules/products/store/products.cjs +6 -8
  130. package/dist/prometheus-framework/src/modules/products/store/products.cjs.map +1 -1
  131. package/dist/prometheus-framework/src/modules/products/store/products.js +6 -8
  132. package/dist/prometheus-framework/src/modules/products/store/products.js.map +1 -1
  133. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
  134. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +1 -1
  135. package/dist/prometheus-framework/src/modules/spots/components/blocks/SpotMemberModify.vue.cjs +1 -1
  136. package/dist/prometheus-framework/src/modules/spots/components/blocks/SpotMemberModify.vue.js +1 -1
  137. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.cjs +1 -1
  138. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.js +1 -1
  139. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.cjs +1 -1
  140. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.js +1 -1
  141. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
  142. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.js +1 -1
  143. package/package.json +1 -1
  144. package/src/components/Block/Block.vue +1 -1
  145. package/src/components/EditImages/EditImages.vue +1 -1
  146. package/src/modules/auth/views/middlewares/auth.validation.js +1 -0
  147. package/src/modules/auth/views/store/auth.js +6 -2
  148. package/src/modules/backoffice/components/pages/Dashboard.vue +1 -3
  149. package/src/modules/globals/views/components/partials/BottomNavigationBar.vue +3 -3
  150. package/src/modules/globals/views/components/partials/NavigationBar.vue +4 -4
  151. package/src/modules/globals/views/store/globals.js +5 -0
  152. package/src/modules/organizations/components/pages/Organization.vue +1 -1
  153. package/src/modules/organizations/components/pages/OrganizationBackoffice.vue +1 -2
  154. package/src/modules/products/components/blocks/CardCategory.vue +14 -3
  155. package/src/modules/products/components/blocks/CardProduct.vue +12 -11
  156. package/src/modules/products/components/pages/Categories.vue +120 -28
  157. package/src/modules/products/components/pages/CategoryEdit.vue +206 -151
  158. package/src/modules/products/components/pages/ProductEdit.vue +107 -69
  159. package/src/modules/products/components/pages/Products.vue +35 -20
  160. package/src/modules/products/components/sections/CategoriesTree.vue +102 -0
  161. package/src/modules/products/components/sections/EditProductInfo.vue +53 -40
  162. package/src/modules/products/controllers/categories.controller.js +175 -97
  163. package/src/modules/products/controllers/products.controller.js +4 -2
  164. package/src/modules/products/models/category.model.js +15 -66
  165. package/src/modules/products/models/product.model.js +15 -12
  166. package/src/modules/products/products.client.js +0 -1
  167. package/src/modules/products/router/categories.router.js +17 -5
  168. package/src/modules/products/router/products.router.js +0 -12
  169. package/src/modules/products/routes/categories.routes.js +5 -34
  170. package/src/modules/products/store/categories.js +69 -83
  171. package/src/modules/products/store/products.js +6 -8
@@ -1,75 +1,24 @@
1
1
  module.exports = (db) => {
2
- const СategorySchema = new db.mongoose.Schema({
3
- name: {
4
- type: String,
5
- required: true,
6
- trim: true
7
- },
2
+ const CategorySchema = new db.mongoose.Schema({
3
+ name: { type: String, required: true, trim: true },
8
4
  status: {
9
5
  type: String,
10
- enum: ['draft','internal','published','removed'],
6
+ enum: ['draft','internal','published','removed'],
11
7
  default: 'draft',
12
8
  required: true,
13
9
  },
14
- order: {
15
- type: Number,
16
- required: true
17
- },
18
- url: {
19
- type: String,
20
- required: true,
21
- trim: true
22
- },
23
- subcategories: {
24
- type: Array
25
- },
26
- localization: {
27
- type: Array
28
- },
29
- filters: {
30
- type: Array
31
- },
32
- // owner: {
33
- // type: {
34
- // type: String,
35
- // required: true
36
- // },
37
- // target: {
38
- // type: mongoose.Schema.Types.ObjectId,
39
- // ref: function (value) {
40
- // if (this.owner.type === 'user') return 'User';
41
- // if (this.owner.type === 'organization') return 'Organization';
42
- // },
43
- // required: true,
44
- // },
45
- // },
46
- // creator: {
47
- // hidden: {
48
- // type: Boolean,
49
- // required: true
50
- // },
51
- // type: {
52
- // type: String,
53
- // required: true
54
- // },
55
- // target: {
56
- // type: mongoose.Schema.Types.ObjectId,
57
- // ref: function (value) {
58
- // if (this.owner.type === 'user') return 'User';
59
- // if (this.owner.type === 'organization') return 'Organization';
60
- // },
61
- // required: true,
62
- // },
63
- // }
10
+ order: { type: Number, required: true },
11
+ url: { type: String, required: true, trim: true },
12
+ parent: { type: db.mongoose.Schema.Types.ObjectId, ref: 'Category' },
13
+ localization: { type: Array },
14
+ filters: { type: Array }
64
15
  }, {
65
- timestamps: {
66
- currentTime: () => Date.now()
67
- }
16
+ timestamps: { currentTime: () => Date.now() }
68
17
  });
69
18
 
70
- СategorySchema.index({ 'owner.target': 1, 'creator.target': 1});
71
-
72
- const Сategory = db.mongoose.model('Сategory', СategorySchema, 'categories');
73
-
74
- return Сategory;
75
- }
19
+ CategorySchema.index({ parent: 1 });
20
+ CategorySchema.index({ 'owner.target': 1, 'creator.target': 1});
21
+
22
+ const Category = db.mongoose.model('Category', CategorySchema, 'categories');
23
+ return Category;
24
+ };
@@ -2,7 +2,13 @@ const applyOwnershipSchema = require('@pf/src/modules/globals/models/schemas/own
2
2
 
3
3
  module.exports = (db) => {
4
4
  const ProductSchema = new db.mongoose.Schema({
5
- status: {type: String},
5
+ status: {
6
+ type: String
7
+ },
8
+ listing: {
9
+ type: String,
10
+ enum: ['sale', 'rent']
11
+ },
6
12
  name: {type: String},
7
13
  category: {type: Array},
8
14
  description: {type: String},
@@ -17,7 +23,13 @@ module.exports = (db) => {
17
23
  value: {type: String}
18
24
  }],
19
25
  // ЗАДАЧА: Нужно отрефачить price, перенести его в default variant
20
- price: { type: Number },
26
+ price: {
27
+ type: Number
28
+ },
29
+ price_currency: {
30
+ type: String,
31
+ default: '$',
32
+ },
21
33
  prices: { type: Array},
22
34
  //
23
35
  variants: [{
@@ -64,16 +76,7 @@ module.exports = (db) => {
64
76
  min: [0, 'Quantity-based discount cannot be less than 0'],
65
77
  max: [100, 'Quantity-based discount cannot be more than 100']
66
78
  },
67
- }],
68
- // Refactor
69
- owner: {
70
- type: db.mongoose.Schema.Types.ObjectId,
71
- ref: 'User',
72
- },
73
- organization: {
74
- type: db.mongoose.Schema.Types.ObjectId,
75
- ref: 'Organization',
76
- },
79
+ }]
77
80
  }, {
78
81
  timestamps: {
79
82
  currentTime: () => Date.now()
@@ -51,7 +51,6 @@ function initializeProducts(app, store, router, options = {}) {
51
51
  const routesProducts = createProductRoutes();
52
52
 
53
53
  router.addRoute(route, routesProducts);
54
-
55
54
  router.addRoute(route, routerMarketplace);
56
55
 
57
56
  store.addStore('categories', storeCategories);
@@ -2,21 +2,33 @@ import * as validationAuth from '@pf/src/modules/auth/views/middlewares/auth.val
2
2
 
3
3
  const categoriesRoutes = [{
4
4
  path: 'categories',
5
- name: 'Categories Organization',
5
+ name: 'Categories',
6
6
  meta: {
7
7
  title: {
8
- en: 'Category',
9
- ru: 'Категория'
8
+ en: 'Categories',
9
+ ru: 'Категории'
10
10
  }
11
11
  },
12
12
  component: () => import('@pf/src/modules/products/components/pages/Categories.vue')
13
13
  }, {
14
14
  path: 'categories/add',
15
- name: 'CategoryAdd',
15
+ name: 'Category Add',
16
+ meta: {
17
+ title: {
18
+ en: 'Add Category',
19
+ ru: 'Добавить Категорию'
20
+ }
21
+ },
16
22
  component: () => import('@pf/src/modules/products/components/pages/CategoryEdit.vue')
17
23
  },{
18
24
  path: 'categories/:category/edit',
19
- name: 'CategoryEdit',
25
+ name: 'Category Edit',
26
+ meta: {
27
+ title: {
28
+ en: 'Edit Category',
29
+ ru: 'Редактировать Категорию'
30
+ }
31
+ },
20
32
  beforeEnter: [validationAuth.requiresAuth],
21
33
  component: () => import('@pf/src/modules/products/components/pages/CategoryEdit.vue')
22
34
  }];
@@ -2,7 +2,6 @@ import * as validationAuth from '@pf/src/modules/auth/views/middlewares/auth.val
2
2
 
3
3
  import * as auth from '@pf/src/modules/auth/views/store/auth';
4
4
 
5
- import IconPlus from '@pf/src/modules/icons/navigation/IconPlus.vue'
6
5
 
7
6
  export function createProductRoutes(prefix = '', options = {}) {
8
7
  const nameWithPrefix = (name) => prefix ? `${prefix}${name}` : name;
@@ -18,17 +17,6 @@ export function createProductRoutes(prefix = '', options = {}) {
18
17
  en: 'Products',
19
18
  ru: 'Товары'
20
19
  },
21
-
22
- actions: [
23
- {
24
- component: IconPlus,
25
- props: {
26
- fill: "rgb(var(--main))"
27
- },
28
- condition: () => auth.state.user && auth.state.user._id,
29
- action: (router) => router.push({ name: 'ProductAdd' })
30
- }
31
- ],
32
20
  authorize: options.productsAuthorize || []
33
21
  },
34
22
  component: () => import(/* webpackChunkName: 'Products' */ '@pf/src/modules/products/components/pages/Products.vue'),
@@ -7,40 +7,11 @@ module.exports = function(app, db) {
7
7
  const controller = controllerFactory(db);
8
8
 
9
9
  const { verifyCategory } = middlewareFactoryProducts(db);
10
- // Get categorys
11
- app.get(
12
- "/categories",
13
- controller.getCategories
14
- );
15
- app.post(
16
- "/categories",
17
- controller.updateCategories
18
- );
19
- // Get category
20
- app.get(
21
- "/categories/:url",
22
- controller.getCategory
23
- );
24
- // Add category
25
- app.post(
26
- "/categories/add",
27
- [
28
- verifyCategory.checkCategoryExistOrNot,
29
- ],
30
- controller.addCategory
31
- );
32
- // Update catagory
33
- app.post(
34
- "/categories/:url",
35
- controller.updateCategory
36
- );
37
- // Delete category
38
- app.delete(
39
- "/categories/:url",
40
- controller.deleteCategory
41
- );
42
10
 
11
+ app.get('/api/categories', controller.read);
12
+ app.post('/api/categories/create', [verifyCategory.checkCategoryExistOrNot], controller.create);
13
+ app.post('/api/categories/update', controller.update);
14
+ app.post('/api/categories/delete', controller.delete);
43
15
  };
44
16
 
45
-
46
-
17
+ module.exports.controllerFactory = controllerFactory;
@@ -1,114 +1,97 @@
1
- /////////////////////////////
2
- // DEPENDENCIES
3
- /////////////////////////////
4
- import { reactive, watch, computed } from "vue";
5
- // Globals
6
- import { setError } from '@pf/src/modules/globals/views/store/globals'
7
- // Setup Axios
1
+ // Dependencies
2
+ import { reactive, watch } from "vue";
3
+ import { setError } from '@pf/src/modules/globals/views/store/globals';
4
+
8
5
  import $axios from '@pf/src/modules/globals/views/utils/axios-instance.js';
9
6
 
7
+ // State
10
8
  const state = reactive({
11
9
  all: [],
10
+ filter: {
11
+ status: null,
12
+ search: null
13
+ },
12
14
  current: {
13
15
  order: 1,
14
16
  name: "",
15
17
  url: "",
16
18
  status: "draft",
17
- subcategories: [],
19
+ parent: null,
20
+ children: [],
18
21
  filters: [],
19
22
  localization: [],
20
- },
23
+ }
21
24
  });
22
25
 
26
+ // Methods
23
27
  const actions = {
24
- async fetchCategories(options) {
25
- return await $axios.get(`/categories`, { params: options }).then(
26
- categories => {
27
- state.all = categories.data;
28
- return Promise.resolve(categories.data);
29
- },
30
- error => {
31
- setError(error);
32
- return Promise.reject(error);
28
+ async read(options = {}) {
29
+ try {
30
+ const response = await $axios.get('/api/categories', { params: options });
31
+
32
+ if (options.url) {
33
+ state.current = {...response.data[0]};
34
+ return Promise.resolve(response.data[0]);
35
+ } else {
36
+ return Promise.resolve(response.data);
33
37
  }
34
- );
38
+ } catch (error) {
39
+ setError(error);
40
+ return Promise.reject(error);
41
+ }
35
42
  },
36
43
 
37
- updateCategories(categories) {
38
- return $axios.post(`/categories`, categories).then(
39
- (categoriesUpdated) => {
40
- state.all = categories;
41
- return Promise.resolve(categories);
42
- },
43
- (error) => {
44
- setError(error);
45
- return Promise.reject(error);
46
- }
47
- );
44
+ async create(category) {
45
+ try {
46
+ const response = await $axios.post('/api/categories/create', category);
47
+ state.all.push(response.data);
48
+ return Promise.resolve(response.data);
49
+ } catch (error) {
50
+ setError(error);
51
+ return Promise.reject(error);
52
+ }
48
53
  },
49
54
 
50
- fetchCategory(url) {
51
- return $axios.get("/categories/" + url).then(
52
- (category) => {
53
- state.current = category.data;
54
- return Promise.resolve(category.data);
55
- },
56
- (error) => {
57
- setError(error);
58
- return Promise.reject(error);
59
- }
60
- );
61
- },
55
+ async update(categories) {
56
+ try {
57
+ // Handle both single category and bulk update
58
+ const isArray = Array.isArray(categories);
62
59
 
63
- addCategory() {
64
- return $axios.post("/categories/add", state.current).then(
65
- (category) => {
66
- state.all.push(category.data);
67
- return Promise.resolve(category.data);
68
- },
69
- (error) => {
70
- setError(error);
71
- return Promise.reject(error);
72
- }
73
- );
60
+ const response = await $axios.post('/api/categories/update', {
61
+ categories: isArray ? categories : [categories],
62
+ });
63
+
64
+ // state.all = response.data;
65
+ return Promise.resolve(response.data);
66
+ } catch (error) {
67
+ setError(error);
68
+ return Promise.reject(error);
69
+ }
74
70
  },
75
71
 
76
- updateCategory(url) {
77
- return $axios.post("/categories/" + url, state.current).then(
78
- (category) => {
79
- state.current = category.data;
80
- return Promise.resolve(category.data);
81
- },
82
- (error) => {
83
- setError(error);
84
- return Promise.reject(error);
85
- }
86
- );
72
+ async delete(url) {
73
+ try {
74
+ await $axios.post('/api/categories/delete', { url });
75
+ state.all = state.all.filter(c => c.url !== url);
76
+ return Promise.resolve();
77
+ } catch (error) {
78
+ setError(error);
79
+ return Promise.reject(error);
80
+ }
87
81
  },
88
82
 
89
- resetCategory(){
83
+ clean() {
90
84
  state.current = {
91
- order: 0,
85
+ order: 1,
92
86
  name: "",
93
87
  url: "",
94
88
  status: "draft",
95
- subcategories: [],
89
+ parent: null,
90
+ children: [],
96
91
  filters: [],
97
92
  localization: [],
98
- }
99
- },
100
-
101
- deleteCategory(url) {
102
- return $axios.delete("/categories/" + url).then(
103
- (response) => {
104
- const index = state.all.findIndex((c) => c.url === url);
105
- state.all.splice(index, 1);
106
- },
107
- (error) => {
108
- setError(error);
109
- }
110
- );
111
- },
93
+ };
94
+ }
112
95
  };
113
96
 
114
97
  const history = [];
@@ -116,6 +99,9 @@ history.push(state);
116
99
 
117
100
  watch(state, (newState) => {
118
101
  history.push(newState);
119
- });
102
+ }, { deep: true });
120
103
 
121
- export { state, actions };
104
+ export {
105
+ state,
106
+ actions
107
+ };
@@ -15,6 +15,7 @@ const state = reactive({
15
15
  recommendation: false,
16
16
  category: [],
17
17
  status: 'unpublished',
18
+ listing: 'sale',
18
19
  information: [],
19
20
  images: [],
20
21
  files: [],
@@ -22,6 +23,7 @@ const state = reactive({
22
23
  name: '',
23
24
  sale: 0,
24
25
  price: 0,
26
+ price_currency: '$',
25
27
  localization: [],
26
28
  modifications: [],
27
29
  quantityDiscount: [],
@@ -35,12 +37,8 @@ const state = reactive({
35
37
  /////////////////////////////
36
38
  const actions = {
37
39
 
38
- async create(organization, product) {
39
- const newProduct = {
40
- ...product,
41
- organization: organization
42
- }
43
- return await $axios.post("/api/products/create", newProduct).then(
40
+ async create(product) {
41
+ return await $axios.post("/api/products/create", product).then(
44
42
  (response) => {
45
43
  set(response.data, 'current')
46
44
  return Promise.resolve(response.data);
@@ -67,8 +65,8 @@ const actions = {
67
65
  query.category = options.category;
68
66
  }
69
67
 
70
- if (options.organization) {
71
- query.organization = options.organization;
68
+ if (options.owner) {
69
+ query.owner = options.owner;
72
70
  }
73
71
 
74
72
  if (options.count) {