@ozdao/prometheus-framework 0.2.138 → 0.2.140

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. package/dist/auth.server.js +30 -15
  2. package/dist/auth.server.mjs +30 -15
  3. package/dist/community.server.js +3 -3
  4. package/dist/community.server.mjs +3 -3
  5. package/dist/events.server.js +3 -3
  6. package/dist/events.server.mjs +3 -3
  7. package/dist/files.server.js +3 -3
  8. package/dist/files.server.mjs +3 -3
  9. package/dist/gallery.server.js +4 -4
  10. package/dist/gallery.server.mjs +4 -4
  11. package/dist/index-DNI4aUP2.js +259 -0
  12. package/dist/index-Tcyehi73.mjs +260 -0
  13. package/dist/orders.server.js +9 -8
  14. package/dist/orders.server.mjs +9 -8
  15. package/dist/organizations.server.js +31 -15
  16. package/dist/organizations.server.mjs +31 -15
  17. package/dist/products.server.js +37 -5
  18. package/dist/products.server.mjs +37 -5
  19. package/dist/prometheus-framework/src/components/Completion/Completion.vue.cjs +1 -1
  20. package/dist/prometheus-framework/src/components/Completion/Completion.vue.js +19 -19
  21. package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
  22. package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +1 -1
  23. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.cjs +1 -1
  24. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.js +1 -1
  25. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.cjs +1 -1
  26. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.js +2 -2
  27. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.cjs +1 -1
  28. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.js +1 -1
  29. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.cjs +1 -1
  30. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.js +2 -2
  31. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  32. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +32 -31
  33. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.cjs +1 -1
  34. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.js +2 -2
  35. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.cjs +1 -1
  36. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.js +2 -2
  37. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.cjs +1 -1
  38. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.js +2 -2
  39. package/dist/prometheus-framework/src/modules/auth/store/auth.cjs +1 -1
  40. package/dist/prometheus-framework/src/modules/auth/store/auth.js +50 -47
  41. package/dist/prometheus-framework/src/modules/community/components/blocks/CardBlogpost.vue.cjs +1 -1
  42. package/dist/prometheus-framework/src/modules/community/components/blocks/CardBlogpost.vue.js +1 -1
  43. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.cjs +1 -1
  44. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.js +1 -1
  45. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.cjs +1 -1
  46. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.js +3 -3
  47. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
  48. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +3 -3
  49. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.cjs +1 -1
  50. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.js +2 -2
  51. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.cjs +1 -1
  52. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.js +1 -1
  53. package/dist/prometheus-framework/src/modules/events/components/blocks/CardEvent.vue.cjs +1 -1
  54. package/dist/prometheus-framework/src/modules/events/components/blocks/CardEvent.vue.js +1 -1
  55. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.cjs +1 -1
  56. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.js +2 -2
  57. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.cjs +1 -1
  58. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.js +1 -1
  59. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
  60. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +3 -3
  61. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.cjs +1 -1
  62. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.js +3 -3
  63. package/dist/prometheus-framework/src/modules/gallery/components/pages/Gallery.vue.cjs +1 -1
  64. package/dist/prometheus-framework/src/modules/gallery/components/pages/Gallery.vue.js +2 -2
  65. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
  66. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +5 -5
  67. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.cjs +1 -1
  68. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.js +1 -1
  69. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  70. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +2 -2
  71. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  72. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +2 -2
  73. package/dist/prometheus-framework/src/modules/marketplace/store/marketplace.cjs +1 -1
  74. package/dist/prometheus-framework/src/modules/marketplace/store/marketplace.js +1 -1
  75. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +1 -1
  76. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderBackoffice.vue.js +1 -1
  77. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
  78. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +16 -16
  79. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -1
  80. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.js +5 -5
  81. package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.cjs +1 -1
  82. package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.js +2 -2
  83. package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.cjs +1 -1
  84. package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.js +1 -1
  85. package/dist/prometheus-framework/src/modules/orders/components/sections/FormPayment.vue.cjs +1 -1
  86. package/dist/prometheus-framework/src/modules/orders/components/sections/FormPayment.vue.js +1 -1
  87. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.cjs +1 -1
  88. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.js +42 -39
  89. package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.cjs +1 -1
  90. package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.js +1 -1
  91. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
  92. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +4 -4
  93. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  94. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +121 -112
  95. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
  96. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +4 -4
  97. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.cjs +1 -1
  98. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.js +17 -16
  99. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
  100. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +3 -3
  101. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  102. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +121 -61
  103. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  104. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +6 -6
  105. package/dist/prometheus-framework/src/modules/organizations/store/invites.cjs +1 -1
  106. package/dist/prometheus-framework/src/modules/organizations/store/invites.js +25 -24
  107. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
  108. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +2 -2
  109. package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.cjs +1 -1
  110. package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.js +1 -1
  111. package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.cjs +1 -1
  112. package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.js +1 -1
  113. package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.cjs +1 -1
  114. package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.js +1 -1
  115. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.cjs +1 -1
  116. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.js +1 -1
  117. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -1
  118. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +3 -3
  119. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
  120. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +3 -3
  121. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.cjs +1 -1
  122. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js +3 -3
  123. package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.cjs +1 -1
  124. package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.js +1 -1
  125. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
  126. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +3 -3
  127. package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.cjs +1 -1
  128. package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.js +1 -1
  129. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
  130. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +3 -3
  131. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.cjs +1 -1
  132. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.js +1 -1
  133. package/dist/prometheus-framework/src/modules/spots/components/blocks/SpotMemberModify.vue.cjs +1 -1
  134. package/dist/prometheus-framework/src/modules/spots/components/blocks/SpotMemberModify.vue.js +2 -2
  135. package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
  136. package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.js +4 -4
  137. package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.cjs +1 -1
  138. package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.js +66 -67
  139. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.cjs +1 -1
  140. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.js +4 -4
  141. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  142. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +3 -3
  143. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  144. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +78 -74
  145. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CardDeposit.vue.cjs +1 -1
  146. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CardDeposit.vue.js +1 -1
  147. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.cjs +1 -1
  148. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.js +2 -2
  149. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
  150. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.js +5 -5
  151. package/dist/reports.server.js +0 -3
  152. package/dist/reports.server.mjs +0 -3
  153. package/dist/style.css +1 -1
  154. package/dist/wallet.server.js +5 -5
  155. package/dist/wallet.server.mjs +8 -8
  156. package/package.json +1 -1
  157. package/src/components/Completion/Completion.vue +29 -30
  158. package/src/modules/auth/components/pages/Invite.vue +4 -2
  159. package/src/modules/auth/controllers/auth.controller.js +31 -13
  160. package/src/modules/auth/middlewares/authJwt.js +80 -0
  161. package/src/modules/{middlewares/server → auth/middlewares}/index.js +1 -3
  162. package/src/modules/{middlewares/server → auth/middlewares}/verifyAccesses.js +1 -1
  163. package/src/modules/auth/routes/auth.routes.js +2 -2
  164. package/src/modules/auth/routes/twofa.routes.js +1 -1
  165. package/src/modules/auth/store/auth.js +9 -0
  166. package/src/modules/chats/routes/chats.routes.js +1 -1
  167. package/src/modules/community/routes/blog.routes.js +2 -2
  168. package/src/modules/events/routes/events.routes.js +2 -2
  169. package/src/modules/files/routes/files.routes.js +2 -2
  170. package/src/modules/gallery/components/pages/Gallery.vue +1 -1
  171. package/src/modules/gallery/routes/gallery.routes.js +4 -5
  172. package/src/modules/globals/services/globals.crud.js +2 -2
  173. package/src/modules/marketplace/store/marketplace.js +1 -1
  174. package/src/modules/orders/components/pages/OrderCreateBackoffice.vue +2 -2
  175. package/src/modules/orders/components/sections/FormAddCustomer.vue +2 -2
  176. package/src/modules/orders/controllers/orders.controller.js +1 -2
  177. package/src/modules/orders/routes/applications.routes.js +2 -2
  178. package/src/modules/orders/routes/orders.routes.js +2 -2
  179. package/src/modules/organizations/components/blocks/CardOrganization.vue +9 -7
  180. package/src/modules/organizations/components/pages/Members.vue +26 -15
  181. package/src/modules/organizations/components/sections/DetailsTab.vue +1 -1
  182. package/src/modules/organizations/components/sections/MembersAdd.vue +101 -43
  183. package/src/modules/organizations/controllers/invites.controller.js +18 -13
  184. package/src/modules/organizations/controllers/memberships.controller.js +16 -9
  185. package/src/modules/organizations/controllers/organizations.controller.js +3 -4
  186. package/src/modules/organizations/models/membership.model.js +2 -0
  187. package/src/modules/organizations/models/organization.model.js +4 -0
  188. package/src/modules/organizations/routes/invites.routes.js +2 -2
  189. package/src/modules/organizations/store/invites.js +2 -1
  190. package/src/modules/products/controllers/leftovers.controller.js +1 -1
  191. package/src/modules/products/middlewares/index.js +11 -0
  192. package/src/modules/products/routes/categories.routes.js +2 -2
  193. package/src/modules/reports/routes/reports.routes.js +2 -2
  194. package/src/modules/spots/components/layouts/Spots.vue +2 -2
  195. package/src/modules/spots/components/pages/Map.vue +79 -78
  196. package/src/modules/users/components/pages/ProfileEdit.vue +37 -22
  197. package/src/modules/wallet/controllers/routes/payments.routes.js +2 -2
  198. package/src/modules/wallet/controllers/routes/rewards.routes.js +2 -2
  199. package/src/modules/middlewares/server/authJwt.js +0 -68
  200. /package/src/modules/{middlewares/server → auth/middlewares}/authSecret.js +0 -0
  201. /package/src/modules/{middlewares/server → auth/middlewares}/verifyInvites.js +0 -0
  202. /package/src/modules/{middlewares/server → auth/middlewares}/verifySignUp.js +0 -0
  203. /package/src/modules/{middlewares/server → auth/middlewares}/verifyUser.js +0 -0
  204. /package/src/modules/globals/services/{globals.cashe.js → globals.cache.js} +0 -0
  205. /package/src/modules/{middlewares/server → products/middlewares}/verifyCategory.js +0 -0
@@ -4,6 +4,7 @@ const queryProcessorGlobals = require('@pf/src/modules/globals/controllers/utils
4
4
 
5
5
  const controllerFactory = (db) => {
6
6
  const Membership = db.membership;
7
+ const Department = db.department;
7
8
 
8
9
  const read = async (req, res) => {
9
10
  try {
@@ -109,21 +110,27 @@ const controllerFactory = (db) => {
109
110
  const deleteMembership = async (req, res) => {
110
111
  const { _id, type, target, user, role } = req.body;
111
112
 
112
-
113
- console.log(req.body)
114
-
115
113
  try {
116
- // const membership = await Membership.findOne({ type, target, user, role });
117
- const membership = _id ? await Membership.findOneAndDelete({ _id: new ObjectId(req.body._id)}) : await Membership.findOne({ type, target, user, role })
114
+ // Обрабатываем сценарий когда мы не знаем _id нашего membership
115
+ const membership = _id
116
+ ? await Membership.findOneAndDelete({ _id: new ObjectId(_id) })
117
+ : await Membership.findOneAndDelete({ type, target, user, role });
118
118
 
119
119
  if (!membership) {
120
120
  return res.status(404).send({ errorCode: 'MEMBERSHIP_NOT_FOUND' });
121
- } else {
122
- await Membership.deleteOne({ _id: membership._id });
123
- res.status(200).send(membership);
124
121
  }
122
+
123
+ // Удаление пользователя из departments
124
+ if (membership.type === 'organization') {
125
+ await Department.updateMany(
126
+ { organization: target },
127
+ { $pull: { members: { user: user } } }
128
+ );
129
+ }
130
+
131
+ res.status(200).send(membership);
125
132
  } catch (error) {
126
- console.log(error)
133
+ console.log(error);
127
134
  res.status(500).send({ errorCode: 'SERVER_ERROR' });
128
135
  }
129
136
  };
@@ -27,7 +27,6 @@ const controllerFactory = (db) => {
27
27
  const sort = {
28
28
  ...(sortParam === 'distance' ? { 'distanceExist': -1 } : {}),
29
29
  [sortParam]: sortOrder === 'desc' ? -1 : 1,
30
- 'numberOfProducts': -1,
31
30
  "_id": 1
32
31
  };
33
32
  console.log(sort)
@@ -140,7 +139,7 @@ const controllerFactory = (db) => {
140
139
  }
141
140
 
142
141
  // Determine the search radius based on the level of specificity
143
- const radius = city ? 500 : state ? 1000 : 5000;
142
+ const radius = city ? 25 : state ? 50 : 250;
144
143
 
145
144
  // Use MongoDB's $geoNear to find organizations within a certain radius
146
145
  matchConditions.push({
@@ -185,9 +184,9 @@ const controllerFactory = (db) => {
185
184
  if (locationRadius) {
186
185
  radius = parseFloat(locationRadius) / earthRadiusKm;
187
186
  } else if (city) {
188
- radius = 500 / earthRadiusKm;
187
+ radius = 25 / earthRadiusKm;
189
188
  } else if (state) {
190
- radius = 1000 / earthRadiusKm;
189
+ radius = 50 / earthRadiusKm;
191
190
  } else {
192
191
  radius = null
193
192
  }
@@ -31,6 +31,8 @@ module.exports = (mongoose) => {
31
31
  timestamps: true
32
32
  });
33
33
 
34
+ MembershipSchema.index({ user: 1, target: 1});
35
+
34
36
  const Membership = mongoose.model('Membership', MembershipSchema);
35
37
 
36
38
  return Membership;
@@ -67,6 +67,10 @@ module.exports = (db) => {
67
67
  });
68
68
 
69
69
  applyEngagementSchema(OrganizationSchema,db);
70
+
71
+
72
+ OrganizationSchema.index({ _id: 1, owner: 1 });
73
+
70
74
 
71
75
  // const Testimonial = require('./testimonial.model');
72
76
 
@@ -1,11 +1,11 @@
1
1
  // Factories
2
2
  const controllerFactory = require("../controllers/invites.controller");
3
3
  // Middlewares
4
- const middlewareFactory = require('@pf/src/modules/middlewares/server');
4
+ const middlewareFactoryAuth = require('@pf/src/modules/auth/middlewares');
5
5
  // Routes
6
6
  module.exports = function(app, db) {
7
7
  const controller = controllerFactory(db);
8
- const { verifyInvites } = middlewareFactory(db);
8
+ const { verifyInvites } = middlewareFactoryAuth(db);
9
9
 
10
10
  // Get one invite
11
11
  app.get(
@@ -38,7 +38,8 @@ const actions = {
38
38
  },
39
39
  async create(invites) {
40
40
  try {
41
- await $axios.post(`/api/invites/create`, invites);
41
+ const response = await $axios.post(`/api/invites/create`, invites);
42
+ return Promise.resolve(response.data);
42
43
  state.error = null;
43
44
  } catch (error) {
44
45
  setError(error);
@@ -59,7 +59,7 @@ const controllerFactory = (db) => {
59
59
 
60
60
  const leftoveres = await Leftover.aggregate(stages).exec();
61
61
 
62
- if (!leftoveres.length) {
62
+ if (!leftoveres) {
63
63
  return res.status(404).send({ message: "LEFTOVERES_NOT_FOUND" });
64
64
  }
65
65
 
@@ -0,0 +1,11 @@
1
+ // middlewareIndexFactory.js
2
+
3
+ const middlewareIndexFactory = (db) => {
4
+ const verifyCategory = require("./verifyCategory")(db);
5
+
6
+ return {
7
+ verifyCategory
8
+ };
9
+ };
10
+
11
+ module.exports = middlewareIndexFactory;
@@ -1,12 +1,12 @@
1
1
  // Factories
2
2
  const controllerFactory = require("../controllers/categories.controller");
3
3
  // Middlewares
4
- const middlewareFactory = require('@pf/src/modules/middlewares/server');
4
+ const middlewareFactoryProducts = require('@pf/src/modules/products/middlewares');
5
5
 
6
6
  module.exports = function(app, db) {
7
7
  const controller = controllerFactory(db);
8
8
 
9
- const { verifyCategory } = middlewareFactory(db);
9
+ const { verifyCategory } = middlewareFactoryProducts(db);
10
10
  // Get categorys
11
11
  app.get(
12
12
  "/categories",
@@ -1,11 +1,11 @@
1
1
  const controllerFactory = require("../controllers/reports.controller");
2
2
  // Middlewares
3
- const middlewareFactoryGlobal = require('@pf/src/modules/middlewares/server');
3
+ // const middlewareFactoryGlobal = require('@pf/src/modules/middlewares');
4
4
 
5
5
  module.exports = function(app, db, origins) {
6
6
  const controller = controllerFactory(db);
7
7
 
8
- const { authJwt } = middlewareFactoryGlobal(db);
8
+ // const { authJwt } = middlewareFactoryGlobal(db);
9
9
 
10
10
  app.get(
11
11
  "/reports",
@@ -101,7 +101,7 @@
101
101
  delivery: query.delivery ? query.delivery.split(',') : [],
102
102
  // Продолжайте этот паттерн для остальных полей фильтра
103
103
  };
104
- marketplace.state.filter = newFilterValue;
104
+ marketplace.state.filter.selected = newFilterValue;
105
105
  }
106
106
 
107
107
 
@@ -109,7 +109,7 @@
109
109
  await categories.actions.fetchCategories()
110
110
  })
111
111
 
112
- watch(() => marketplace.state.filter, (newFilterValue, oldFilterValue) => {
112
+ watch(() => marketplace.state.filter.selected, (newFilterValue, oldFilterValue) => {
113
113
  // Переводим фильтр в формат query
114
114
  const query = { ...route.query };
115
115
 
@@ -89,106 +89,107 @@ onMounted(async () => {
89
89
 
90
90
  // Определите уровень зума в зависимости от доступной информации
91
91
  if (route.params.location || globals.state.position?.location) {
92
- zoomLevel = 12;
92
+ zoomLevel = 15;
93
93
  } else if (route.params.country || globals.state.position?.country) {
94
94
  zoomLevel = 9;
95
95
  } else if (route.params.state || globals.state.position?.state) {
96
96
  zoomLevel = 6;
97
97
  } else if (route.params.city || globals.state.position?.city) {
98
- zoomLevel = 4;
98
+ zoomLevel = 14;
99
99
  } else {
100
100
  zoomLevel = 2;
101
101
  }
102
102
 
103
- // Если координаты не заданы, попробуйте их получить
104
- if (!lat || !lng) {
105
- let country
106
-
107
- const geocoder = new google.maps.Geocoder();
103
+ const loader = new GMLoader({
104
+ apiKey: props.apiKey,
105
+ version: "weekly",
106
+ libraries: ["places"],
107
+ language: 'en'
108
+ });
108
109
 
109
- try {
110
- country = await getCountry();
111
- } catch {
112
- country = 'Thailand'
113
- console.log(error)
114
- }
110
+ loader.load().then(async () => {
115
111
 
116
- try {
117
- const results = await geocoder.geocode({ 'address': country })
112
+ // Если координаты не заданы, попробуйте их получить
113
+ if (!lat || !lng) {
114
+ let country
118
115
 
119
- console.log(results);
116
+ const geocoder = new google.maps.Geocoder();
120
117
 
121
- if (results) {
122
- lat = results.results[0].geometry.location.lat();
123
- lng = results.results[0].geometry.location.lng();
124
- zoomLevel = 6;
125
- } else {
126
- console.error('No results found for the country code.');
127
- }
128
- } catch (error) {
129
- console.error('Error getting coordinates from country code:', error);
130
- }
131
- }
132
-
133
- // If there's no lat/lng in the query, try to use country/state/city to get the lat/lng
134
- if (!lat && !lng && (route.params.country || route.params.state || route.params.city)) {
135
- const geocoder = new google.maps.Geocoder();
136
-
137
- const address = [
138
- route.params.city,
139
- route.params.state,
140
- route.params.country
141
- ].filter(Boolean).join(', ');
142
-
143
- try {
144
- const results = await geocoder.geocode({ address });
145
-
146
- if (results[0]) {
147
- lat = results[0].geometry.location.lat();
148
- lng = results[0].geometry.location.lng();
118
+ try {
119
+ country = await getCountry();
120
+ } catch {
121
+ country = 'Thailand'
122
+ console.log(error)
149
123
  }
150
124
 
151
- } catch (error) {
152
- console.error('Error getting coordinates:', error);
153
- }
154
- }
125
+ try {
126
+ const results = await geocoder.geocode({ 'address': country })
155
127
 
156
- const loader = new GMLoader({
157
- apiKey: props.apiKey,
158
- version: "weekly",
159
- libraries: ["places"],
160
- language: 'en'
161
- });
128
+ console.log(results);
162
129
 
163
- skip.value += limit.value;
130
+ if (results) {
131
+ lat = results.results[0].geometry.location.lat();
132
+ lng = results.results[0].geometry.location.lng();
133
+ zoomLevel = 6;
134
+ } else {
135
+ console.error('No results found for the country code.');
136
+ }
137
+ } catch (error) {
138
+ console.error('Error getting coordinates from country code:', error);
139
+ }
140
+ }
141
+
142
+ // If there's no lat/lng in the query, try to use country/state/city to get the lat/lng
143
+ if (!lat && !lng && (route.params.country || route.params.state || route.params.city)) {
144
+ const geocoder = new google.maps.Geocoder();
145
+
146
+ const address = [
147
+ route.params.city,
148
+ route.params.state,
149
+ route.params.country
150
+ ].filter(Boolean).join(', ');
151
+
152
+ try {
153
+ const results = await geocoder.geocode({ address });
154
+
155
+ if (results[0]) {
156
+ lat = results[0].geometry.location.lat();
157
+ lng = results[0].geometry.location.lng();
158
+ }
164
159
 
165
- const params = {
166
- // country: route.params.country,
167
- // state: route.params.state,
168
- // city: route.params.city,
169
- // categories: route.query.categories,
170
- // prices: route.query.prices,
171
- // delivery: route.query.delivery,
172
- country: route.params.country,
173
- state: route.params.state,
174
- city: route.params.city,
175
- categories: route.query.categories,
176
- prices: route.query.prices,
177
- delivery: route.query.delivery,
178
- sortParam: route.query.sortParam || marketplace.state.sort.param,
179
- sortOrder: route.query.sortOrder || marketplace.state.sort.order,
180
- location: {coordinates: [lng,lat] },
181
- locationRadius: 1000,
182
- limit: 500,
183
- };
160
+ } catch (error) {
161
+ console.error('Error getting coordinates:', error);
162
+ }
163
+ }
184
164
 
185
- console.log(params)
186
165
 
187
- const data = await actions.read(params);
166
+ skip.value += limit.value;
167
+
168
+ const params = {
169
+ // country: route.params.country,
170
+ // state: route.params.state,
171
+ // city: route.params.city,
172
+ // categories: route.query.categories,
173
+ // prices: route.query.prices,
174
+ // delivery: route.query.delivery,
175
+ country: route.params.country,
176
+ state: route.params.state,
177
+ city: route.params.city,
178
+ categories: route.query.categories,
179
+ prices: route.query.prices,
180
+ delivery: route.query.delivery,
181
+ sortParam: route.query.sortParam || marketplace.state.sort.param,
182
+ sortOrder: route.query.sortOrder || marketplace.state.sort.order,
183
+ location: {coordinates: [lng,lat] },
184
+ locationRadius: 1000,
185
+ limit: 500,
186
+ };
187
+
188
+ console.log(params)
188
189
 
189
- state.all = [...state.all, ...data];
190
+ const data = await actions.read(params);
190
191
 
191
- loader.load().then(() => {
192
+ state.all = [...state.all, ...data];
192
193
 
193
194
  map.value = new google.maps.Map(document.getElementById('map'), {
194
195
  mapTypeControl: false,
@@ -1,17 +1,17 @@
1
1
  <template>
2
- <div class="pd-medium for-transition w-100">
2
+ <div v-if="show" class="pd-medium for-transition w-100">
3
3
 
4
4
  <ProfileCompletion
5
5
  v-if="route.params._id === auth.state.user._id"
6
- :user="auth.state.user._id"
7
- :target="user"
6
+ :user="auth.state.user._id"
7
+ :target="users.state.current"
8
8
  :cta="false"
9
9
  />
10
10
  <!-- -->
11
11
  <h3 class="mn-b-small">Username</h3>
12
12
 
13
13
  <Field
14
- v-model:field="user.username"
14
+ v-model:field="users.state.current.username"
15
15
  label="@"
16
16
  placeholder="Not specified"
17
17
  class="mn-b-thin w-100 bg-light pd-medium radius-small"
@@ -25,15 +25,15 @@
25
25
 
26
26
  <div class="mn-b-thin radius-small w-100 h-10r bg-light flex-center flex-column flex">
27
27
  <UploadImage
28
- v-model:photo="user.profile.photo"
29
- :uploadPath="'users/' + user._id + '/avatars'"
28
+ v-model:photo="users.state.current.profile.photo"
29
+ :uploadPath="'users/' + users.state.current._id + '/avatars'"
30
30
  class="h-4r w-4r aspect-1x1 o-hidden bg-white mn-b-thin radius-extra"
31
31
  />
32
32
  <h4>Upload userpic</h4>
33
33
  </div>
34
34
 
35
35
  <Field
36
- v-model:field="user.profile.name"
36
+ v-model:field="users.state.current.profile.name"
37
37
  label="Name"
38
38
  placeholder="Not specified"
39
39
  class="mn-b-thin bg-light pd-medium radius-small"
@@ -41,18 +41,17 @@
41
41
  />
42
42
 
43
43
  <Field
44
- v-model:field="user.profile.description"
44
+ v-model:field="users.state.current.profile.description"
45
45
  label="Description"
46
46
  placeholder="Not specified"
47
47
  class="mn-b-semi bg-light pd-medium radius-small"
48
- disabled="true"
49
48
  :validation="organizationName"
50
49
  />
51
50
 
52
51
  <!-- <p class="mn-b-thin">Select your birthday if you want to receive your birthday gift.</p>
53
52
 
54
53
  <Field
55
- v-model:field="user.birthday"
54
+ v-model:field="users.state.current.birthday"
56
55
  label="Birthday"
57
56
  type="date"
58
57
  placeholder="Not specified"
@@ -63,25 +62,25 @@
63
62
  <p class="mn-b-thin">Please provide only the username for social media profiles, without full links.</p>
64
63
 
65
64
  <Field
66
- v-model:field="user.socials.instagram"
65
+ v-model:field="users.state.current.socials.instagram"
67
66
  label="Instagram"
68
67
  placeholder=""
69
68
  class="mn-b-thin bg-light pd-medium radius-small"
70
69
  />
71
70
  <Field
72
- v-model:field="user.socials.twitter"
71
+ v-model:field="users.state.current.socials.twitter"
73
72
  label="Twitter"
74
73
  placeholder=""
75
74
  class="mn-b-thin bg-light pd-medium radius-small"
76
75
  />
77
76
  <Field
78
- v-model:field="user.socials.facebook"
77
+ v-model:field="users.state.current.socials.facebook"
79
78
  label="Facebook"
80
79
  placeholder=""
81
80
  class="mn-b-thin bg-light pd-medium radius-small"
82
81
  />
83
82
  <Field
84
- v-model:field="user.socials.telegram"
83
+ v-model:field="users.state.current.socials.telegram"
85
84
  label="Telegram"
86
85
  placeholder=""
87
86
  class="mn-b-semi bg-light pd-medium radius-small"
@@ -90,7 +89,7 @@
90
89
  <h3 class="mn-b-small">Account</h3>
91
90
 
92
91
  <Field
93
- v-model:field="user.phone"
92
+ v-model:field="users.state.current.phone"
94
93
  label="Phone"
95
94
  placeholder="Not specified"
96
95
  class="mn-b-thin bg-light pd-medium mn-b-thin radius-small"
@@ -99,17 +98,29 @@
99
98
  />
100
99
 
101
100
  <Field
102
- v-model:field="user.email"
101
+ v-model:field="users.state.current.email"
103
102
  label="Email"
104
103
  placeholder="Not specified"
105
- class="mn-b-semi bg-light pd-medium radius-small"
104
+ class="mn-b-semi bg-light pd-medium radius-small"
106
105
  :disabled="true"
107
106
  :validation="organizationName"
108
107
  />
109
108
 
110
- <Button :submit="onSubmit" :callback="redirectTo" class="mn-b-thin">Save</Button>
109
+ <Button
110
+ :submit="onSubmit"
111
+ :callback="redirectTo"
112
+ class="mn-b-thin bg-main w-100"
113
+ >
114
+ Save
115
+ </Button>
111
116
 
112
- <Button :submit="onSubmitDelete" :callback="a = () => {router.push({name: 'Sign In'})}" class="mn-b-thin bg-red t-white">Delete Account</Button>
117
+ <Button
118
+ :submit="onSubmitDelete"
119
+ :callback="a = () => {router.push({name: 'Sign In'})}"
120
+ class="mn-b-thin w-100 bg-red t-white"
121
+ >
122
+ Delete Account
123
+ </Button>
113
124
  </div>
114
125
  </template>
115
126
 
@@ -132,10 +143,14 @@
132
143
  // Accessing router
133
144
  const route = useRoute()
134
145
  const router = useRouter()
135
- // Async requests
136
- const user = ref(users.state.current);
146
+
147
+ const user = ref(null)
148
+ const show = ref(false)
149
+
150
+
137
151
  onMounted(async () => {
138
- await users.actions.read({ _id: route.params._id });
152
+ await users.actions.read({ _id: route.params._id, user: auth.state.user._id });
153
+ show.value = true
139
154
  })
140
155
  // Methods
141
156
  async function onSubmit() {
@@ -1,5 +1,5 @@
1
1
  // Middlewares
2
- const middlewareFactory = require('@pf/src/modules/middlewares/server');
2
+ const middlewareFactoryAuth = require('@pf/src/modules/auth/middlewares');
3
3
  // Factories
4
4
  const controllerFactory = require("../factories/payments.factory");
5
5
  const controllerFactoryTickets = require("@pf/src/modules/events/controllers/tickets.controller");
@@ -16,7 +16,7 @@ module.exports = function(app, db, origins, publicPath) {
16
16
  const controller = controllerFactory(db);
17
17
  const controllerTickets = controllerFactoryTickets(db, publicPath);
18
18
 
19
- const { verifySignUp, verifyUser } = middlewareFactory(db);
19
+ const { verifySignUp, verifyUser } = middlewareFactoryAuth(db);
20
20
 
21
21
  observer.subscribe('checkout.session.completed', async (paymentIntent) => {
22
22
  const event = await db.event.findOne({ _id: paymentIntent.metadata.product });
@@ -2,13 +2,13 @@
2
2
  const rewardsControllerFactory = require('../factories/rewards.factory');
3
3
 
4
4
  // Middlewares
5
- const middlewareFactory = require('@pf/src/modules/middlewares/server');
5
+ const middlewareFactoryAuth = require('@pf/src/modules/auth/middlewares');
6
6
 
7
7
  // Routes
8
8
  module.exports = (app, db, wss, wdmClient, origins) => {
9
9
  const controller = rewardsControllerFactory(db, wdmClient, wss);
10
10
 
11
- const { authJwt, authSecret } = middlewareFactory(db);
11
+ const { authJwt, authSecret } = middlewareFactoryAuth(db);
12
12
 
13
13
  app.use((req, res, next) => {
14
14
  const origin = req.headers.origin;
@@ -1,68 +0,0 @@
1
- const jwt = require("jsonwebtoken");
2
-
3
- const middlewareFactory = (db) => {
4
- const User = db.user;
5
- const Role = db.role;
6
-
7
- const verifyToken = async (req, res, next) => {
8
- try {
9
- if (!req.cookies.user) {
10
- // Вместо возврата ошибки, просто устанавливаем req.userId как null
11
- req.userId = null;
12
- return next();
13
- }
14
-
15
- let user = JSON.parse(req.cookies.user);
16
- let token = req.headers["x-access-token"] || user.accessToken;
17
-
18
- if (!token) {
19
- // Также устанавливаем req.userId как null
20
- req.userId = null;
21
- return next();
22
- }
23
-
24
- const decoded = jwt.verify(token, process.env.SECRET_KEY);
25
- req.userId = decoded._id;
26
-
27
- next();
28
- } catch (err) {
29
- console.log(err);
30
- req.userId = null;
31
- next();
32
- }
33
- };
34
-
35
- const checkRole = roleToCheck => async (req, res, next) => {
36
- try {
37
- const user = await User.findById(req.userId).exec();
38
-
39
- if (!user) {
40
- return res.status(404).send({ message: "User Not found." });
41
- }
42
-
43
- const roles = await Role.find({ _id: { $in: user.roles }}).exec();
44
-
45
- for (let role of roles) {
46
- if (role.name === roleToCheck) {
47
- next();
48
- return;
49
- }
50
- }
51
-
52
- res.status(403).send({ message: `Require ${roleToCheck} Role!` });
53
- } catch (err) {
54
- res.status(500).send({ message: err.message });
55
- }
56
- };
57
-
58
- const isAdmin = checkRole("admin");
59
- const isModerator = checkRole("moderator");
60
-
61
- return {
62
- verifyToken,
63
- isAdmin,
64
- isModerator
65
- };
66
- };
67
-
68
- module.exports = middlewareFactory;