@ozdao/prometheus-framework 0.2.137 → 0.2.139

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. package/dist/auth.server.js +29 -14
  2. package/dist/auth.server.mjs +29 -14
  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/main-DTHFR7H_.mjs +14510 -0
  14. package/dist/main-wXdocsbd.js +92 -0
  15. package/dist/main.css +1 -1
  16. package/dist/orders.server.js +9 -8
  17. package/dist/orders.server.mjs +9 -8
  18. package/dist/organizations.server.js +32 -17
  19. package/dist/organizations.server.mjs +32 -17
  20. package/dist/products.server.js +37 -5
  21. package/dist/products.server.mjs +37 -5
  22. package/dist/prometheus-framework/src/components/Block/Block.vue.cjs +1 -1
  23. package/dist/prometheus-framework/src/components/Block/Block.vue.js +1 -1
  24. package/dist/prometheus-framework/src/components/Completion/Completion.vue.cjs +1 -1
  25. package/dist/prometheus-framework/src/components/Completion/Completion.vue.js +19 -19
  26. package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
  27. package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +1 -1
  28. package/dist/prometheus-framework/src/components/Map/Map.vue.cjs +1 -1
  29. package/dist/prometheus-framework/src/components/Map/Map.vue.js +3 -2
  30. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  31. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +32 -31
  32. package/dist/prometheus-framework/src/modules/auth/store/auth.cjs +1 -1
  33. package/dist/prometheus-framework/src/modules/auth/store/auth.js +50 -47
  34. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
  35. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +1 -1
  36. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.cjs +1 -1
  37. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.js +1 -1
  38. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  39. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +2 -2
  40. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  41. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +1 -1
  42. package/dist/prometheus-framework/src/modules/marketplace/store/marketplace.cjs +1 -1
  43. package/dist/prometheus-framework/src/modules/marketplace/store/marketplace.js +1 -1
  44. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
  45. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +12 -12
  46. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -1
  47. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.js +2 -2
  48. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.cjs +1 -1
  49. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.js +41 -38
  50. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  51. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +123 -114
  52. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  53. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +51 -52
  54. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -1
  55. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
  56. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.cjs +1 -1
  57. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.js +16 -15
  58. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  59. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +120 -60
  60. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  61. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +1 -1
  62. package/dist/prometheus-framework/src/modules/organizations/store/invites.cjs +1 -1
  63. package/dist/prometheus-framework/src/modules/organizations/store/invites.js +25 -24
  64. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.cjs +1 -1
  65. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.js +7 -7
  66. package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
  67. package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.js +3 -3
  68. package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.cjs +1 -1
  69. package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.js +65 -66
  70. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.cjs +1 -1
  71. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.js +81 -76
  72. package/dist/prometheus-framework/src/modules/spots/router/spots.cjs +1 -1
  73. package/dist/prometheus-framework/src/modules/spots/router/spots.js +1 -1
  74. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  75. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +2 -2
  76. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  77. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +78 -74
  78. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
  79. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.js +2 -2
  80. package/dist/prometheus-framework.cjs.js +1 -1
  81. package/dist/prometheus-framework.es.js +1 -1
  82. package/dist/reports.server.js +0 -3
  83. package/dist/reports.server.mjs +0 -3
  84. package/dist/spots.server.js +3 -3
  85. package/dist/spots.server.mjs +3 -3
  86. package/dist/style.css +1 -1
  87. package/dist/wallet.server.js +5 -5
  88. package/dist/wallet.server.mjs +8 -8
  89. package/dist/web-Dh669DqQ.mjs +54 -0
  90. package/dist/web-Dt2RCU54.js +1 -0
  91. package/package.json +1 -1
  92. package/src/components/Completion/Completion.vue +29 -30
  93. package/src/components/Map/Map.vue +2 -2
  94. package/src/modules/auth/components/pages/Invite.vue +4 -2
  95. package/src/modules/auth/controllers/auth.controller.js +30 -12
  96. package/src/modules/auth/middlewares/authJwt.js +80 -0
  97. package/src/modules/{middlewares/server → auth/middlewares}/index.js +1 -3
  98. package/src/modules/{middlewares/server → auth/middlewares}/verifyAccesses.js +1 -1
  99. package/src/modules/auth/routes/auth.routes.js +2 -2
  100. package/src/modules/auth/routes/twofa.routes.js +1 -1
  101. package/src/modules/auth/store/auth.js +9 -0
  102. package/src/modules/chats/routes/chats.routes.js +1 -1
  103. package/src/modules/community/routes/blog.routes.js +2 -2
  104. package/src/modules/events/routes/events.routes.js +2 -2
  105. package/src/modules/files/routes/files.routes.js +2 -2
  106. package/src/modules/gallery/routes/gallery.routes.js +4 -5
  107. package/src/modules/globals/services/globals.crud.js +2 -2
  108. package/src/modules/marketplace/store/marketplace.js +1 -1
  109. package/src/modules/orders/components/pages/OrderCreateBackoffice.vue +2 -2
  110. package/src/modules/orders/components/sections/FormAddCustomer.vue +2 -2
  111. package/src/modules/orders/controllers/orders.controller.js +1 -0
  112. package/src/modules/orders/routes/applications.routes.js +2 -2
  113. package/src/modules/orders/routes/orders.routes.js +2 -2
  114. package/src/modules/organizations/components/blocks/CardOrganization.vue +9 -7
  115. package/src/modules/organizations/components/pages/Members.vue +26 -15
  116. package/src/modules/organizations/components/pages/Organization.vue +3 -3
  117. package/src/modules/organizations/components/sections/DetailsTab.vue +1 -1
  118. package/src/modules/organizations/components/sections/MembersAdd.vue +101 -43
  119. package/src/modules/organizations/controllers/invites.controller.js +18 -13
  120. package/src/modules/organizations/controllers/memberships.controller.js +18 -11
  121. package/src/modules/organizations/controllers/organizations.controller.js +3 -4
  122. package/src/modules/organizations/models/membership.model.js +2 -0
  123. package/src/modules/organizations/models/organization.model.js +4 -0
  124. package/src/modules/organizations/routes/invites.routes.js +2 -2
  125. package/src/modules/organizations/store/invites.js +2 -1
  126. package/src/modules/products/controllers/leftovers.controller.js +1 -1
  127. package/src/modules/products/middlewares/index.js +11 -0
  128. package/src/modules/products/routes/categories.routes.js +2 -2
  129. package/src/modules/reports/routes/reports.routes.js +2 -2
  130. package/src/modules/spots/components/blocks/CardSpot.vue +0 -1
  131. package/src/modules/spots/components/layouts/Spots.vue +2 -2
  132. package/src/modules/spots/components/pages/Map.vue +79 -78
  133. package/src/modules/spots/components/pages/SpotEdit.vue +8 -5
  134. package/src/modules/spots/controllers/spots.controller.js +1 -5
  135. package/src/modules/spots/router/spots.js +1 -1
  136. package/src/modules/users/components/pages/ProfileEdit.vue +37 -22
  137. package/src/modules/wallet/controllers/routes/payments.routes.js +2 -2
  138. package/src/modules/wallet/controllers/routes/rewards.routes.js +2 -2
  139. package/src/modules/middlewares/server/authJwt.js +0 -68
  140. /package/src/modules/{middlewares/server → auth/middlewares}/authSecret.js +0 -0
  141. /package/src/modules/{middlewares/server → auth/middlewares}/verifyInvites.js +0 -0
  142. /package/src/modules/{middlewares/server → auth/middlewares}/verifySignUp.js +0 -0
  143. /package/src/modules/{middlewares/server → auth/middlewares}/verifyUser.js +0 -0
  144. /package/src/modules/globals/services/{globals.cashe.js → globals.cache.js} +0 -0
  145. /package/src/modules/{middlewares/server → products/middlewares}/verifyCategory.js +0 -0
@@ -0,0 +1,80 @@
1
+ const jwt = require("jsonwebtoken");
2
+
3
+ const middlewareFactory = (db) => {
4
+ const User = db.user;
5
+ const Role = db.role;
6
+
7
+ const verifyToken = (continueOnFail = false) => {
8
+ return async (req, res, next) => {
9
+ try {
10
+ if (!req.cookies.user) {
11
+ req.userId = null;
12
+ if (continueOnFail) {
13
+ return next();
14
+ } else {
15
+ return res.status(401).send({ message: "Unauthorized: No user cookie" });
16
+ }
17
+ }
18
+
19
+ let user = JSON.parse(req.cookies.user);
20
+ let token = req.headers["x-access-token"] || user.accessToken;
21
+
22
+ if (!token) {
23
+ req.userId = null;
24
+ if (continueOnFail) {
25
+ return next();
26
+ } else {
27
+ return res.status(401).send({ message: "Unauthorized: No token provided" });
28
+ }
29
+ }
30
+
31
+ const decoded = jwt.verify(token, process.env.SECRET_KEY);
32
+ req.userId = decoded._id;
33
+
34
+ next();
35
+ } catch (err) {
36
+ console.log(err);
37
+ req.userId = null;
38
+ if (continueOnFail) {
39
+ next();
40
+ } else {
41
+ res.status(401).send({ message: "Unauthorized: Invalid token" });
42
+ }
43
+ }
44
+ };
45
+ };
46
+
47
+ const checkRole = roleToCheck => async (req, res, next) => {
48
+ try {
49
+ const user = await User.findById(req.userId).exec();
50
+
51
+ if (!user) {
52
+ return res.status(404).send({ message: "User Not found." });
53
+ }
54
+
55
+ const roles = await Role.find({ _id: { $in: user.roles }}).exec();
56
+
57
+ for (let role of roles) {
58
+ if (role.name === roleToCheck) {
59
+ next();
60
+ return;
61
+ }
62
+ }
63
+
64
+ res.status(403).send({ message: `Require ${roleToCheck} Role!` });
65
+ } catch (err) {
66
+ res.status(500).send({ message: err.message });
67
+ }
68
+ };
69
+
70
+ const isAdmin = checkRole("admin");
71
+ const isModerator = checkRole("moderator");
72
+
73
+ return {
74
+ verifyToken,
75
+ isAdmin,
76
+ isModerator
77
+ };
78
+ };
79
+
80
+ module.exports = middlewareFactory;
@@ -6,15 +6,13 @@ const middlewareIndexFactory = (db) => {
6
6
  const verifySignUp = require("./verifySignUp")(db);
7
7
  const verifyUser = require("./verifyUser")(db);
8
8
  const verifyInvites = require("./verifyInvites")(db);
9
- const verifyCategory = require("./verifyCategory")(db);
10
9
 
11
10
  return {
12
11
  authJwt,
13
12
  authSecret,
14
13
  verifySignUp,
15
14
  verifyUser,
16
- verifyInvites,
17
- verifyCategory
15
+ verifyInvites
18
16
  };
19
17
  };
20
18
 
@@ -38,7 +38,6 @@ const middlewareFactory = (db) => {
38
38
  // Если пользователь не является членом организации, ограничиваем доступ к опубликованным ресурсам
39
39
  req.query.status = 'published';
40
40
  } else {
41
- // Пользователь является членом организации, проверяем его права доступа
42
41
 
43
42
  // Находим все департаменты данной организации, к которым относится пользователь
44
43
  const departments = await Department.find({ organization: ownerOrgId });
@@ -48,6 +47,7 @@ const middlewareFactory = (db) => {
48
47
 
49
48
  for (const department of departments) {
50
49
  const accessRights = department.accesses[resource];
50
+
51
51
  if (accessRights && accessRights.read) {
52
52
  // Если хотя бы в одном департаменте есть права на чтение ресурса, разрешаем доступ
53
53
  hasAccess = true;
@@ -2,7 +2,7 @@
2
2
  const controllerFactory = require("../controllers/auth.controller");
3
3
  const controllerFactoryTwofa = require("../controllers/twofa.controller");
4
4
  // Middlewares
5
- const middlewareFactory = require('@pf/src/modules/middlewares/server');
5
+ const middlewareFactory = require('@pf/src/modules/auth/middlewares');
6
6
  // Routes
7
7
  module.exports = function(app, db, origins) {
8
8
  const controller = controllerFactory(db);
@@ -40,7 +40,7 @@ module.exports = function(app, db, origins) {
40
40
  app.get(
41
41
  "/api/auth/check-accesses",
42
42
  [
43
- authJwt.verifyToken,
43
+ authJwt.verifyToken(true),
44
44
  ],
45
45
  controller.checkAccesses
46
46
  );
@@ -1,7 +1,7 @@
1
1
  // Factories
2
2
  const controllerFactory = require("../controllers/twofa.controller");
3
3
  // Middlewares
4
- const middlewareFactory = require('@pf/src/modules/middlewares/server');
4
+ const middlewareFactory = require('@pf/src/modules/auth/middlewares');
5
5
  // Routes
6
6
  module.exports = function(app, db) {
7
7
  const controller = controllerFactory(db);
@@ -85,6 +85,8 @@
85
85
  roles: response.data.roles
86
86
  });
87
87
 
88
+ await initialize();
89
+
88
90
  return response.data;
89
91
  } catch (error) {
90
92
 
@@ -141,6 +143,8 @@
141
143
  roles: response.data.roles
142
144
  });
143
145
 
146
+ await initialize();
147
+
144
148
  return response.data;
145
149
  } catch (error) {
146
150
  setError(error);
@@ -153,6 +157,8 @@
153
157
  removeCookie('user');
154
158
 
155
159
  Object.assign(state.user, {
160
+ _id: undefined,
161
+ username: '',
156
162
  email: '',
157
163
  phone: '',
158
164
  password: '',
@@ -160,9 +166,12 @@
160
166
  });
161
167
 
162
168
  Object.assign(state.access, {
169
+ roles: null,
163
170
  token: null,
164
171
  status: false
165
172
  });
173
+
174
+ state.accesses = []
166
175
  },
167
176
 
168
177
  async resetPassword(user, type) {
@@ -1,7 +1,7 @@
1
1
  // Factories
2
2
  const controllerFactory = require('../controllers/chats.controller.js');
3
3
  // Middlewares
4
- const middlewareFactory = require('@pf/src/modules/middlewares/server');
4
+ const middlewareFactory = require('@pf/src/modules/auth/middlewares');
5
5
  // Routes
6
6
  module.exports = function(app, db, wss) {
7
7
  const controller = controllerFactory(db);
@@ -1,12 +1,12 @@
1
1
  const controllerFactory = require("../controllers/blog.controller");
2
2
 
3
- const middlewareFactoryGlobal = require('@pf/src/modules/middlewares/server');
3
+ const middlewareFactoryAuth = require('@pf/src/modules/auth/middlewares');
4
4
  const middlewareFactoryCommunity = require('../middlewares/server');
5
5
 
6
6
  module.exports = function(app, db, origins) {
7
7
  const controller = controllerFactory(db);
8
8
 
9
- const { authJwt } = middlewareFactoryGlobal(db);
9
+ const { authJwt } = middlewareFactoryAuth(db);
10
10
  const { verifyBlogpost } = middlewareFactoryCommunity(db);
11
11
 
12
12
  app.get(
@@ -1,13 +1,13 @@
1
1
  // Factories
2
2
  const controllerFactory = require("../controllers/events.controller");
3
3
  // Middlewares
4
- const middlewareFactoryGlobal = require('@pf/src/modules/middlewares/server');
4
+ const middlewareFactoryAuth = require('@pf/src/modules/auth/middlewares');
5
5
  const middlewareFactoryEvents = require('../middlewares/server');
6
6
  // Routes
7
7
  module.exports = function(app, db, origins) {
8
8
  const controller = controllerFactory(db);
9
9
 
10
- const { authJwt } = middlewareFactoryGlobal(db);
10
+ const { authJwt } = middlewareFactoryAuth(db);
11
11
  const { verifyEvent } = middlewareFactoryEvents(db);
12
12
 
13
13
  app.get(
@@ -1,13 +1,13 @@
1
1
  // Factories
2
2
  const controllerFactory = require("../controllers/files.controller");
3
3
  // Middlewares
4
- const middlewareFactoryGlobal = require('@pf/src/modules/middlewares/server');
4
+ const middlewareFactoryAuth = require('@pf/src/modules/auth/middlewares');
5
5
  const middlewareFactoryFiles = require('../middlewares/server');
6
6
 
7
7
  module.exports = function(app, db, origins, publicPath) {
8
8
  const controller = controllerFactory(db, publicPath);
9
9
 
10
- const { authJwt } = middlewareFactoryGlobal(db);
10
+ const { authJwt } = middlewareFactoryAuth(db);
11
11
  const { middlewareBusboy } = middlewareFactoryFiles(db, publicPath);
12
12
 
13
13
  app.post(
@@ -1,20 +1,19 @@
1
1
  // Factories
2
2
  const controllerFactory = require("../controllers/gallery.controller");
3
3
  // Middlewares
4
- const middlewareFactoryGlobal = require('@pf/src/modules/middlewares/server');
5
- const middlewareFactoryAccesses = require('@pf/src/modules/middlewares/server/verifyAccesses')
4
+ const middlewareFactoryAuth = require('@pf/src/modules/auth/middlewares');
5
+ const middlewareFactoryAccesses = require('@pf/src/modules/auth/middlewares/verifyAccesses')
6
6
 
7
7
  module.exports = function(app, db, origins) {
8
8
  const controller = controllerFactory(db);
9
9
 
10
- const { authJwt } = middlewareFactoryGlobal(db);
10
+ const { authJwt } = middlewareFactoryAuth(db);
11
11
  const { verifyRead } = middlewareFactoryAccesses(db)
12
12
 
13
-
14
13
  app.get(
15
14
  "/api/gallery/read",
16
15
  [
17
- authJwt.verifyToken,
16
+ authJwt.verifyToken(true),
18
17
  verifyRead('gallery'),
19
18
  ],
20
19
  controller.read
@@ -1,12 +1,12 @@
1
1
  const globalsQuery = require('@pf/src/modules/globals/controllers/utils/queryProcessor');
2
2
 
3
- const Cashe = require('@pf/src/modules/globals/services/globals.cashe');
3
+ const Cache = require('@pf/src/modules/globals/services/globals.cache');
4
4
  const Logger = require('@pf/src/modules/globals/services/globals.logger');
5
5
 
6
6
  class CRUD {
7
7
  constructor(basePath, app, db, model) {
8
8
  this.model = model;
9
- this.cache = new Cashe();
9
+ this.cache = new Cache();
10
10
  this.logger = new Logger(db);
11
11
 
12
12
  this.app = app;
@@ -47,7 +47,7 @@ const state = reactive({
47
47
  value: 'views'
48
48
  },{
49
49
  label: 'Products',
50
- value: 'products'
50
+ value: 'numberOfProducts'
51
51
  }]
52
52
  }
53
53
  });
@@ -117,7 +117,7 @@
117
117
  @click="() => {
118
118
  orders.mutations.resetCustomer(orders.state.current.customer)
119
119
  }"
120
- class="bg-white pd-thin radius-medium w-100 mn-b-thin"
120
+ class="bg-white pd-thin h-4r radius-medium w-100 mn-b-thin"
121
121
  />
122
122
  <Feed
123
123
  v-else
@@ -152,7 +152,7 @@
152
152
  @click="() => {
153
153
  orders.state.current.customer = user
154
154
  }"
155
- class="bg-white pd-thin radius-medium w-100 mn-b-thin"
155
+ class="bg-white pd-thin h-4r radius-medium w-100 mn-b-thin"
156
156
  />
157
157
  </Feed>
158
158
 
@@ -15,7 +15,7 @@
15
15
  @click="() => {
16
16
  dataCustomer.user = null
17
17
  }"
18
- class="bg-white pd-thin radius-medium w-100"
18
+ class="bg-white h-2r pd-thin radius-medium w-100"
19
19
  />
20
20
 
21
21
  <div
@@ -54,7 +54,7 @@
54
54
  dataCustomer.email = user.email
55
55
  dataCustomer.socials = user.socials
56
56
  }"
57
- class="bg-white pd-thin radius-medium w-100 mn-b-thin"
57
+ class="bg-white h-2r pd-thin radius-medium w-100 mn-b-thin"
58
58
  />
59
59
  </Feed>
60
60
  </div>
@@ -76,6 +76,7 @@ async function findOrCreateCustomer(Customer, customerInfo, orderOwner, orderCre
76
76
  const controllerFactory = (db) => {
77
77
  const Order = db.order;
78
78
  const Customer = db.customer;
79
+ const Leftover = db.leftover;
79
80
 
80
81
  // Создание заказа
81
82
  const create = async (req, res) => {
@@ -1,11 +1,11 @@
1
1
  // Factories
2
2
  const controllerFactory = require("../controllers/applications.controller");
3
3
  // Middlewares
4
- const middlewareFactoryGlobal = require('@pf/src/modules/middlewares/server');
4
+ const middlewareFactoryAuth = require('@pf/src/modules/auth/middlewares');
5
5
  module.exports = function(app, db, origins) {
6
6
  const controller = controllerFactory(db);
7
7
 
8
- const { authJwt } = middlewareFactoryGlobal(db);
8
+ const { authJwt } = middlewareFactoryAuth(db);
9
9
 
10
10
  app.post(
11
11
  "/applications",
@@ -1,11 +1,11 @@
1
1
  // Factories
2
2
  const controllerFactory = require("../controllers/orders.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, origins, publicPath) {
7
7
  const controller = controllerFactory(db);
8
- const middleware = middlewareFactory(db);
8
+ const middleware = middlewareFactoryAuth(db);
9
9
 
10
10
  app.post(
11
11
  "/api/orders/create",
@@ -69,14 +69,16 @@
69
69
  <IconTime class="i-medium mn-r-micro"/>
70
70
  <span class="mn-r-thin">{{
71
71
  organization.distance ?
72
- Math.ceil((5 + 5 + 3 * organization.distance) / 5) * 5
73
- + '-'
74
- + Math.ceil((15 + 5 + 3 * organization.distance) / 5) * 5
75
- + ' MIN' : 'Unavailable'
72
+ organization.distance > 50 ?
73
+ '3-5 days' :
74
+ Math.ceil((5 + 5 + 3 * organization.distance) / 5) * 5
75
+ + '-'
76
+ + Math.ceil((15 + 5 + 3 * organization.distance) / 5) * 5
77
+ + ' MIN' : 'Unavailable'
76
78
  }}
77
79
  </span>
78
- <span v-if="organization.distance" class="t-transp mn-r-thin">|</span>
79
- <span class="mn-r-thin">{{organization.distance ? organization.distance.toFixed(1) + ' KM' : ''}} </span>
80
+ <span v-if="organization.distance && organization.distance < 50" class="t-transp mn-r-thin">|</span>
81
+ <span v-if="organization.distance && organization.distance < 50" class="mn-r-thin">{{organization.distance ? organization.distance.toFixed(1) + ' KM' : ''}} </span>
80
82
  <!-- <span class="mn-r-thin">{{organization.nearestSpotDistance}}</span> -->
81
83
  <IconPrice class="i-medium mn-r-micro"/>
82
84
  <span class="mn-r-thin">{{returnCurrency()}}500 </span>
@@ -88,7 +90,7 @@
88
90
  <div class="w-max flex-nowrap flex gap-thin">
89
91
  <CardOrderItem
90
92
  @click.stop="$router.push({name: 'Product Organization', params: {_id: organization._id, product: product._id}})"
91
- v-for="product in organization.products.slice(0,10)"
93
+ v-for="product in organization.products.slice(0,5)"
92
94
  :key="product._id"
93
95
  :editable="false"
94
96
  :product="product"
@@ -120,7 +120,7 @@
120
120
  v-if="tab === 'invites'"
121
121
  >
122
122
  <Feed
123
- :search="true"
123
+ v-model:items="invitesState"
124
124
  :states="{
125
125
  empty: {
126
126
  title: 'No Invites Found',
@@ -183,6 +183,7 @@ import CardDepartment from '@pf/src/modules/organizations/components/blocks/Card
183
183
  import IconDelete from '@pf/src/modules/icons/navigation/IconDelete.vue'
184
184
 
185
185
  import * as auth from '@pf/src/modules/auth/store/auth'
186
+ import * as globals from '@pf/src/modules/globals/store/globals'
186
187
  import * as invites from '@pf/src/modules/organizations/store/invites';
187
188
  import * as memberships from '@pf/src/modules/organizations/store/memberships';
188
189
  import * as organization from '@pf/src/modules/organizations/store/organizations'
@@ -194,6 +195,8 @@ const organizationData = ref(null)
194
195
 
195
196
  // Tab logic
196
197
  const tab = ref('members')
198
+ // States
199
+ const invitesState = ref([])
197
200
  // Popup
198
201
  const isOpenMembersAddPopup = ref(false);
199
202
 
@@ -222,19 +225,27 @@ const FirstLevelDepartments = computed(() => {
222
225
  );
223
226
  });
224
227
 
225
- async function handleSendInvite(list) {
226
- await invites.actions.create({
227
- owner: {
228
- type: 'Organization',
229
- target: organizationData.value._id
230
- },
231
- creator: {
232
- type: 'User',
233
- target: auth.state.user._id
234
- },
235
- invites: list,
236
- });
237
- closeMembersAddPopup()
228
+ async function handleSendInvite(list, resolve, reject) {
229
+ try {
230
+ const response = await invites.actions.create({
231
+ owner: {
232
+ type: 'Organization',
233
+ target: organizationData.value._id
234
+ },
235
+ creator: {
236
+ type: 'User',
237
+ target: auth.state.user._id
238
+ },
239
+ invites: list,
240
+ });
241
+ for (let invite of response.createdInvites) {
242
+ globals.actions.add(invitesState.value, invite)
243
+ }
244
+ closeMembersAddPopup();
245
+ resolve(); // Вызываем resolve, когда все операции завершены успешно
246
+ } catch (error) {
247
+ reject(error); // Вызываем reject, если произошла ошибка
248
+ }
238
249
  }
239
250
 
240
251
  async function removeMember(index,member) {
@@ -246,7 +257,7 @@ async function removeMember(index,member) {
246
257
 
247
258
  async function removeInvite(index,invite) {
248
259
  if (confirm("Confirm remove of member") == true) {
249
- invites.state.invites.splice(index, 1);
260
+ globals.actions.delete(invitesState.value, invite)
250
261
  await invites.actions.delete(invite._id);
251
262
  }
252
263
  }
@@ -220,9 +220,9 @@
220
220
 
221
221
  route.query.tab = tabOrganization.value
222
222
 
223
- watch(tabOrganization, (newValue) => {
224
- router.replace({ query: null});
225
- });
223
+ // watch(tabOrganization, (newValue) => {
224
+ // router.replace({ query: null});
225
+ // });
226
226
  </script>
227
227
 
228
228
  <style lang="scss">
@@ -91,7 +91,7 @@
91
91
  </div>
92
92
 
93
93
  <p class="w-max-50r mn-t-regular mn-b-medium p-big">
94
- <Text :text="organization.profile.description || ''" :maxLen="240" />
94
+ <Text :text="organization.profile.description || ''" :showToggleText="true" :maxLen="320" />
95
95
  </p>
96
96
 
97
97
  <Chips