@ozdao/prometheus-framework 0.2.40 → 0.2.42

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/events.server.js +9 -0
  2. package/dist/events.server.mjs +9 -0
  3. package/dist/files.server.js +4 -1
  4. package/dist/files.server.mjs +4 -1
  5. package/dist/prometheus-framework/src/components/Button/Button.vue.cjs +1 -1
  6. package/dist/prometheus-framework/src/components/Button/Button.vue.js +2 -225
  7. package/dist/prometheus-framework/src/components/Button/Button.vue2.cjs +1 -1
  8. package/dist/prometheus-framework/src/components/Button/Button.vue2.js +225 -2
  9. package/dist/prometheus-framework/src/components/Checkbox/Checkbox.vue.cjs +1 -1
  10. package/dist/prometheus-framework/src/components/Checkbox/Checkbox.vue.js +2 -61
  11. package/dist/prometheus-framework/src/components/Checkbox/Checkbox.vue2.cjs +1 -1
  12. package/dist/prometheus-framework/src/components/Checkbox/Checkbox.vue2.js +61 -2
  13. package/dist/prometheus-framework/src/components/Countdown/Countdown.vue.cjs +1 -1
  14. package/dist/prometheus-framework/src/components/Countdown/Countdown.vue.js +26 -28
  15. package/dist/prometheus-framework/src/components/Field/Field.vue.cjs +1 -1
  16. package/dist/prometheus-framework/src/components/Field/Field.vue.js +2 -76
  17. package/dist/prometheus-framework/src/components/Field/Field.vue2.cjs +1 -1
  18. package/dist/prometheus-framework/src/components/Field/Field.vue2.js +76 -2
  19. package/dist/prometheus-framework/src/components/Popup/Popup.vue.cjs +1 -1
  20. package/dist/prometheus-framework/src/components/Popup/Popup.vue.js +2 -70
  21. package/dist/prometheus-framework/src/components/Popup/Popup.vue2.cjs +1 -1
  22. package/dist/prometheus-framework/src/components/Popup/Popup.vue2.js +70 -2
  23. package/dist/prometheus-framework/src/components/Select/Select.vue.cjs +1 -1
  24. package/dist/prometheus-framework/src/components/Select/Select.vue.js +2 -95
  25. package/dist/prometheus-framework/src/components/Select/Select.vue2.cjs +1 -1
  26. package/dist/prometheus-framework/src/components/Select/Select.vue2.js +95 -2
  27. package/dist/prometheus-framework/src/components/Tab/Tab.vue.cjs +1 -1
  28. package/dist/prometheus-framework/src/components/Tab/Tab.vue.js +2 -44
  29. package/dist/prometheus-framework/src/components/Tab/Tab.vue2.cjs +1 -1
  30. package/dist/prometheus-framework/src/components/Tab/Tab.vue2.js +44 -2
  31. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.cjs +1 -1
  32. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.js +3 -3
  33. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.cjs +1 -1
  34. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.js +1 -1
  35. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.cjs +1 -1
  36. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.js +3 -3
  37. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  38. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +3 -3
  39. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.cjs +1 -1
  40. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.js +3 -3
  41. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.cjs +1 -1
  42. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.js +3 -3
  43. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.cjs +1 -1
  44. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.js +3 -3
  45. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.cjs +1 -1
  46. package/dist/prometheus-framework/src/modules/community/components/layouts/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 +24 -23
  49. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.cjs +1 -1
  50. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.js +1 -1
  51. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.cjs +1 -5
  52. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.js +2 -65
  53. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.cjs +5 -1
  54. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.js +65 -2
  55. package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.vue.cjs +1 -1
  56. package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.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/layouts/layoutEvents.vue.cjs +1 -1
  60. package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.vue.js +1 -1
  61. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
  62. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +125 -81
  63. package/dist/prometheus-framework/src/modules/events/components/pages/Event.vue.cjs +3 -3
  64. package/dist/prometheus-framework/src/modules/events/components/pages/Event.vue.js +65 -56
  65. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.cjs +1 -1
  66. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.js +3 -3
  67. package/dist/prometheus-framework/src/modules/events/components/sections/HeroEvent.vue.cjs +1 -1
  68. package/dist/prometheus-framework/src/modules/events/components/sections/HeroEvent.vue.js +67 -53
  69. package/dist/prometheus-framework/src/modules/events/components/sections/SectionMainGuest.vue.cjs +2 -2
  70. package/dist/prometheus-framework/src/modules/events/components/sections/SectionMainGuest.vue.js +48 -37
  71. package/dist/prometheus-framework/src/modules/events/components/sections/SectionPreviousEvents.vue.cjs +1 -1
  72. package/dist/prometheus-framework/src/modules/events/components/sections/SectionPreviousEvents.vue.js +71 -57
  73. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
  74. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +3 -3
  75. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.cjs +1 -1
  76. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.js +3 -3
  77. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  78. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +1 -1
  79. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  80. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +2 -2
  81. package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.cjs +1 -1
  82. package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.js +1 -1
  83. package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.cjs +1 -1
  84. package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.js +1 -1
  85. package/dist/prometheus-framework/src/modules/orders/components/sections/FormOrderDetails.vue.cjs +1 -1
  86. package/dist/prometheus-framework/src/modules/orders/components/sections/FormOrderDetails.vue.js +2 -2
  87. package/dist/prometheus-framework/src/modules/orders/store/shopcart.cjs +1 -1
  88. package/dist/prometheus-framework/src/modules/orders/store/shopcart.js +20 -11
  89. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.cjs +1 -1
  90. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.js +2 -2
  91. package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.cjs +1 -1
  92. package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.js +1 -1
  93. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
  94. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +6 -6
  95. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  96. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +1 -1
  97. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
  98. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +5 -5
  99. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organizations.vue.cjs +1 -1
  100. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organizations.vue.js +1 -1
  101. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
  102. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +3 -3
  103. package/dist/prometheus-framework/src/modules/organizations/components/sections/FeedDepartments.vue.cjs +1 -1
  104. package/dist/prometheus-framework/src/modules/organizations/components/sections/FeedDepartments.vue.js +1 -1
  105. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  106. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +3 -3
  107. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersList.vue.cjs +1 -1
  108. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersList.vue.js +1 -1
  109. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  110. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +5 -5
  111. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
  112. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +2 -2
  113. package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.cjs +1 -1
  114. package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.js +1 -1
  115. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
  116. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +2 -2
  117. package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.cjs +1 -1
  118. package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.js +1 -1
  119. package/dist/prometheus-framework/src/modules/products/components/pages/Product.vue.cjs +1 -1
  120. package/dist/prometheus-framework/src/modules/products/components/pages/Product.vue.js +22 -19
  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 +6 -6
  123. package/dist/prometheus-framework/src/modules/products/components/pages/ProductsBackoffice.vue.cjs +1 -1
  124. package/dist/prometheus-framework/src/modules/products/components/pages/ProductsBackoffice.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/FilterProducts.vue.cjs +1 -1
  128. package/dist/prometheus-framework/src/modules/products/components/sections/FilterProducts.vue.js +1 -1
  129. package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.cjs +1 -1
  130. package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.js +31 -28
  131. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
  132. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +3 -3
  133. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  134. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +2 -2
  135. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileBlogposts.vue.cjs +1 -1
  136. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileBlogposts.vue.js +1 -1
  137. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  138. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +3 -3
  139. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEvents.vue.cjs +1 -1
  140. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEvents.vue.js +1 -1
  141. package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.cjs +1 -1
  142. package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.js +78 -80
  143. package/dist/style.css +1 -1
  144. package/package.json +1 -1
  145. package/src/components/Countdown/Countdown.vue +4 -3
  146. package/src/components/Header/Header.vue +2 -0
  147. package/src/modules/community/components/layouts/Community.vue +2 -2
  148. package/src/modules/community/components/pages/CreateBlogPost.vue +1 -0
  149. package/src/modules/constructor/components/sections/Constructor.vue +1 -1
  150. package/src/modules/events/components/pages/EditEvent.vue +48 -3
  151. package/src/modules/events/components/pages/Event.vue +16 -8
  152. package/src/modules/events/components/sections/HeroEvent.vue +32 -28
  153. package/src/modules/events/components/sections/SectionMainGuest.vue +3 -2
  154. package/src/modules/events/components/sections/SectionPreviousEvents.vue +22 -15
  155. package/src/modules/events/models/event.model.js +9 -0
  156. package/src/modules/files/middlewares/server/middlewareBusboy.js +13 -2
  157. package/src/modules/marketplace/components/layouts/Marketplace.vue +1 -1
  158. package/src/modules/orders/store/shopcart.js +21 -5
  159. package/src/modules/payments/controller/payments.controller.js +54 -200
  160. package/src/modules/payments/controller/payments.tinkoff.controller.js +242 -0
  161. package/src/modules/payments/models/payment.model.js +22 -0
  162. package/src/modules/payments/routes/payments.routes.js +4 -25
  163. package/src/modules/payments/routes/payments.tinkoff.routes.js +58 -0
  164. package/src/modules/products/components/pages/Product.vue +3 -1
  165. package/src/modules/products/components/sections/SectionProduct.vue +3 -0
  166. package/src/modules/products/controllers/products.controller.js +188 -109
  167. package/src/modules/products/models/product.model.js +1 -0
  168. package/src/modules/wallet/components/pages/Wallet.vue +72 -87
  169. package/src/modules/wallet/controllers/crypto.controller.js +79 -0
  170. package/src/modules/wallet/models/wallet.model.js +27 -0
  171. /package/src/modules/{orders/models/payment.model.js → payments/models/payment.tinkoff.model.js} +0 -0
@@ -167,77 +167,142 @@ const controllerFactory = (db) => {
167
167
 
168
168
  const getProducts = (req, res) => {
169
169
 
170
- Product.aggregate([{
171
- $lookup: {
172
- from: "modifications",
173
- let: { "productId": "$_id" },
174
- pipeline: [{
175
- $match: {
176
- "$expr": {
177
- "$eq": ["$product", "$$productId"]
178
- }
170
+ // {
171
+ // $lookup: {
172
+ // from: "modifications",
173
+ // let: { "productId": "$_id" },
174
+ // pipeline: [{
175
+ // $match: {
176
+ // "$expr": {
177
+ // "$eq": ["$product", "$$productId"]
178
+ // }
179
+ // }
180
+ // },{
181
+ // $lookup: {
182
+ // from: "leftovers",
183
+ // let: { "productId": "$_id" },
184
+ // pipeline: [{
185
+ // $unwind: "$positions"
186
+ // },{
187
+ // "$match": { "$expr": { "$eq": ["$positions._id", "$$productId"] }}
188
+ // },{
189
+ // "$project": {
190
+ // _id: "$positions._id",
191
+ // quantity: "$positions.quantity",
192
+ // name: "$positions.name",
193
+ // }
194
+ // }],
195
+ // as: "variantsMods"
196
+ // },
197
+ // },{
198
+ // $set: {
199
+ // quantity:{
200
+ // $sum:["$quantity",{$sum:"$variantsMods.quantity"}]
201
+ // }
202
+ // }
203
+ // },{
204
+ // $unset: "variants"
205
+ // }],
206
+ // as: "modifications"
207
+ // },
208
+ // }
209
+
210
+ Product.aggregate([
211
+ {
212
+ $facet: {
213
+ "withIngredients": [
214
+ {
215
+ $match: {
216
+ ingridients: { $exists: true, $not: {$size: 0} } // Продукты с ингредиентами
179
217
  }
180
- },{
218
+ },
219
+ {
220
+ $lookup: {
221
+ from: "products",
222
+ localField: "ingridients",
223
+ foreignField: "_id",
224
+ as: "ingredientDetails"
225
+ }
226
+ },
227
+ { $unwind: "$ingredientDetails" },
228
+ {
229
+ $lookup: {
230
+ from: "leftovers",
231
+ let: { "ingredientId": "$ingredientDetails._id" },
232
+ pipeline: [
233
+ { $unwind: "$positions" },
234
+ {
235
+ $match: {
236
+ $expr: {
237
+ $eq: ["$positions._id", "$$ingredientId"]
238
+ }
239
+ }
240
+ },
241
+ {
242
+ $project: {
243
+ quantity: "$positions.quantity"
244
+ }
245
+ }
246
+ ],
247
+ as: "ingredientLeftovers"
248
+ }
249
+ },
250
+ {
251
+ $group: {
252
+ _id: "$_id",
253
+ name: { $first: "$name" },
254
+ minQuantity: { $min: "$ingredientLeftovers.quantity" }
255
+ }
256
+ }
257
+ ],
258
+ "withoutIngredients": [
259
+ {
260
+ $match: {
261
+ $or: [
262
+ { ingridients: { $exists: false } }, // Продукты без ингредиентов
263
+ { ingridients: { $size: 0 } }
264
+ ]
265
+ }
266
+ },
267
+ {
181
268
  $lookup: {
182
269
  from: "leftovers",
183
270
  let: { "productId": "$_id" },
184
- pipeline: [{
185
- $unwind: "$positions"
186
- },{
187
- "$match": { "$expr": { "$eq": ["$positions._id", "$$productId"] }}
188
- },{
189
- "$project": {
190
- _id: "$positions._id",
191
- quantity: "$positions.quantity",
192
- name: "$positions.name",
271
+ pipeline: [
272
+ { $unwind: "$positions" },
273
+ {
274
+ $match: {
275
+ $expr: {
276
+ $eq: ["$positions._id", "$$productId"]
277
+ }
278
+ }
279
+ },
280
+ {
281
+ $project: {
282
+ quantity: "$positions.quantity"
283
+ }
193
284
  }
194
- }],
195
- as: "variantsMods"
196
- },
197
- },{
198
- $set: {
199
- quantity:{
200
- $sum:["$quantity",{$sum:"$variantsMods.quantity"}]
201
- }
285
+ ],
286
+ as: "productLeftovers"
202
287
  }
203
- },{
204
- $unset: "variants"
205
- }],
206
- as: "modifications"
207
- },
208
- },
209
- {
210
- $lookup: {
211
- from: "leftovers",
212
- let: { "productId": "$_id" },
213
- pipeline: [
214
- {
215
- $unwind: "$positions"
216
- },
217
-
218
- {
219
- "$match": { "$expr": { "$eq": ["$positions._id", "$$productId"] }}
220
- },
221
- {
222
- "$project": {
223
- _id: "$positions._id",
224
- quantity: "$positions.quantity",
225
- name: "$positions.name",
288
+ },
289
+ {
290
+ $set: {
291
+ minQuantity: { $sum: "$productLeftovers.quantity" }
226
292
  }
227
293
  }
228
- ],
229
- as: "variants"
230
- }
231
- },
232
- {
233
- $set: {
234
- quantity:{
235
- $sum:["$quantity",{$sum:"$variants.quantity"}]
236
- }
237
- }
238
- },
239
- { $unset: "variants" }
240
- ])
294
+ ]
295
+ }
296
+ },
297
+ {
298
+ $project: {
299
+ products: { $setUnion: ["$withIngredients", "$withoutIngredients"] }
300
+ }
301
+ },
302
+ { $unwind: "$products" },
303
+ { $replaceRoot: { newRoot: "$products" } }
304
+ ])
305
+
241
306
  .exec((err, products) => {
242
307
  // If error
243
308
  if (err) {return res.status(500).send({ message: err }); }
@@ -338,58 +403,72 @@ const controllerFactory = (db) => {
338
403
  // Get product
339
404
  const getProduct = async (req, res) => {
340
405
  try {
341
- const product = await Product.aggregate([{
342
- $match: { "_id" : new ObjectId(req.params._id) }
343
- },{
344
- $lookup: {
345
- from: "leftovers",
346
- let: { "productId": "$_id" },
347
- pipeline: [
348
- {
349
- $unwind: "$positions"
350
- },
351
- {
352
- "$match": { "$expr": { "$eq": ["$positions._id", "$$productId"] }}
353
- },
354
- {
355
- "$project": {
356
- _id: "$positions._id",
357
- quantity: "$positions.quantity",
358
- name: "$positions.name",
359
- // "quantity": "$$quantity"
406
+ const product = await Product.aggregate([
407
+ {
408
+ $match: { "_id": new ObjectId(req.params._id) }
409
+ },
410
+ {
411
+ $lookup: {
412
+ from: "leftovers",
413
+ let: { productId: "$_id", ingredients: { $ifNull: ["$ingredients", []] } },
414
+ pipeline: [
415
+ {
416
+ $unwind: "$positions"
417
+ },
418
+ {
419
+ "$match": { "$expr": { "$eq": ["$positions._id", "$$productId"] }}
420
+ },
421
+ {
422
+ "$addFields": {
423
+ "positions.quantity": {
424
+ $cond: {
425
+ if: { $eq: ["$type", "stock-in"] },
426
+ then: "$positions.quantity",
427
+ else: { $multiply: ["$positions.quantity", -1] }
428
+ }
429
+ }
430
+ }
431
+ },
432
+ {
433
+ "$project": {
434
+ _id: "$positions._id",
435
+ quantity: "$positions.quantity",
436
+ name: "$positions.name",
437
+ }
360
438
  }
361
- }
362
- ],
363
- as: "variants"
364
- }
365
- },{
366
- $set: {
367
- quantity:{
368
- $sum:["$quantity",{$sum:"$variants.quantity"}]
439
+ ],
440
+ as: "variants"
441
+ }
442
+ },
443
+ {
444
+ $set: {
445
+ quantity: {
446
+ $sum: ["$quantity", {$sum: "$variants.quantity"}]
447
+ }
369
448
  }
370
- }
371
- },
372
- { $unset: "variants" }
373
- ])
449
+ },
374
450
 
375
- if (!product || product.length < 1) {
376
- return res.status(404).send({ message: "Product not found." });
377
- }
451
+ { $unset: "variants" }
452
+ ]);
378
453
 
379
- const updatedProduct = await Product.findOneAndUpdate(
380
- { _id: req.params._id },
381
- { $inc: { popularity: 1 } },
382
- { new: true }
383
- );
454
+ if (!product || product.length < 1) {
455
+ return res.status(404).send({ message: "Product not found." });
456
+ }
384
457
 
385
- console.log('Popularity updated:', updatedProduct);
458
+ const updatedProduct = await Product.findOneAndUpdate(
459
+ { _id: req.params._id },
460
+ { $inc: { popularity: 1 } },
461
+ { new: true }
462
+ );
386
463
 
387
- res.status(200).send(product);
388
- } catch (err) {
389
- console.error('Error:', err);
390
- res.status(500).send({ message: err });
391
- }
392
- };
464
+ console.log('Popularity updated:', updatedProduct);
465
+
466
+ res.status(200).send(product);
467
+ } catch (err) {
468
+ console.error('Error:', err);
469
+ res.status(500).send({ message: err });
470
+ }
471
+ };
393
472
 
394
473
  return {
395
474
  Create,
@@ -18,6 +18,7 @@ module.exports = (mongoose) => {
18
18
  images: {type: Array},
19
19
  popularity: {type: Number},
20
20
  localization: {type: Array},
21
+ ingredients: {type: Array},
21
22
  information: [{
22
23
  name: {type: String},
23
24
  value: {type: String}
@@ -1,108 +1,93 @@
1
1
  <template>
2
- <section class="pd-big">
3
- <h1 class="mn-b-small">Your Wallet</h1>
2
+ <section class="pd-thin">
4
3
 
5
- <p class="mn-b-semi p-big">
6
- Earn Weeder Token Crypto with buying our weed, use it as money when buying our products or withdraw and trade
7
- </p>
4
+ <section class="bg-black t-white mn-b-thin radius-big pd-big">
5
+ <h1 class="mn-b-medium ">Your Wallet</h1>
8
6
 
9
- <div class="mn-b-semi cols-2 gap-thin">
10
- <div
11
- v-if="!state.account"
12
- class="w-100 pd-medium radius-medium t-center bg-grey"
13
- >
14
- <h3 class="mn-b-small">Make first order and start earning Weeder Token</h3>
15
- <button class="mn-l-auto mn-r-auto bg-main button">Explore marketplace</button>
16
- </div>
7
+ <p class="mn-b-semi t-transp p-big">
8
+ Earn Weeder Tokens by purchasing our weed or contributing to the community.
9
+ </p>
17
10
 
18
- <div
11
+ <div
19
12
  v-if="state.account"
20
- class="w-100 pd-medium radius-medium bg-grey"
13
+ class="gap-thin flex-nowrap bg-black radius-extra t-white br-solid br-white-transp-10 br-1px flex-v-center flex pd-medium"
21
14
  >
22
- <p class="h4 mn-b-thin">You own:</p>
23
- <h3 class="mn-b-small">{{state.share}}% of Weeder</h3>
24
- <button class="w-100 bg-main button">Get More</button>
25
- </div>
26
-
27
- <div class="w-100 bg-black radius-semi pd-medium t-white">
28
- <p class="h4 mn-b-thin">Your Metamask</p>
29
-
30
- <div
31
- v-if="state.account"
32
- class="mn-b-small pd-small br-solid br-1px br-white-transp-10 radius-small"
33
- >
34
- {{state.account}}
15
+ <div class="flex-v-center flex-nowrap flex mn-r-auto">
16
+ <!-- <img src="/logo/wdt.svg" class="mn-r-thin i-big"> -->
17
+ <h2>{{state.tokenBalance}} WDT</h2>
35
18
  </div>
36
19
 
37
- <p
38
- v-if="!state.account"
39
- class="p-medium t-transp mn-b-small"
40
- >
41
- Connect Metamask to withdrawal your earnings.
42
- </p>
43
-
44
- <button
45
- v-if="!state.account"
46
- @click="actions.connectWallet"
47
- class="w-100 br-solid br-2px br-white t-white button"
48
- >
49
- Connect Wallet
50
- </button>
51
-
52
- <button
53
- v-if="state.account"
54
- @click="actions.disconnectWallet"
55
- class="w-100 bg-red button"
56
- >
57
- Disconnect Wallet
58
- </button>
20
+ <button class="w-max bg-main t-medium button">Get More</button>
21
+ <button class="w-max bg-white t-black t-medium button" @click="actions.collectRewards">Withdraw</button>
59
22
  </div>
60
- </div>
61
23
 
62
- <div
63
- v-if="state.account"
64
- class="w-100 pd-medium radius-medium bg-grey"
65
- >
66
- <p class="h4 mn-b-thin">You earn:</p>
67
- <h3 class="mn-b-small">{{state.tokenBalance}} WDT</h3>
68
- <button class="w-100 bg-main button" @click="actions.collectRewards">Withdraw</button>
69
- </div>
70
-
71
-
72
- <h3 class="mn-b-small" v-if="state.rewards.length > 0">Latest Rewards </h3>
24
+ </section>
73
25
 
74
- <section class="cols-3 gap-thin">
75
- <div
76
- class="radius-medium bg-grey"
77
- v-for="income in state.rewards"
78
- >
79
- <!-- <pre>{{income}}</pre> -->
80
-
81
- <div class="pd-medium">
82
- <span class="w-max mn-b-small d-block pd-t-nano pd-b-nano pd-l-thin pd-r-thin bg-main radius-extra t-semi p-small">{{income.type === 'blogpost' ? 'Community Reward' : income.type}}</span>
83
- <h4 class="mn-b-thin">{{income.name}}</h4>
84
- <p class="mn-b-small p-small">{{income.content[0].content}}</p>
26
+ <div v-if="!state.account" class="mn-b-semi cols-2 gap-thin">
27
+ <div
28
+ class="w-100 pd-medium radius-medium t-center bg-grey"
29
+ >
30
+ <h3 class="mn-b-small">Make first order and start earning Weeder Token</h3>
31
+ <button class="mn-l-auto mn-r-auto bg-main button">Explore marketplace</button>
32
+ </div>
85
33
 
86
- <div class="bg-black t-white radius-extra pd-thin flex-center flex-nowrap flex">
87
- <!-- <img src="/logo/wdt-plus.svg" class="mn-r-thin i-semi"> -->
88
- <p class="t-semi">{{income.amount}} WDT</p>
34
+ <div
35
+ class="w-100 pd-medium flex-center flex flex-column radius-medium t-center bg-grey"
36
+ >
37
+ <h3
38
+ v-if="!state.account"
39
+ class="mn-b-small"
40
+ >
41
+ Connect Metamask to withdrawal your earnings.
42
+ </h3>
43
+
44
+ <button
45
+ v-if="!state.account"
46
+ @click="actions.connectWallet"
47
+ class="br-solid br-2px br-black-transp-10 t-black button"
48
+ >
49
+ Connect Wallet
50
+ </button>
89
51
  </div>
90
52
  </div>
91
-
92
-
93
- <!-- <CardBlogpost
94
- :key="income._id"
95
- :blogpost="income"
96
- class=""
97
- /> -->
98
53
 
99
- </div>
54
+ <div
55
+ v-if="state.account"
56
+ class="w-100 mn-b-semi flex-column flex pd-big radius-big bg-main t-black"
57
+ >
58
+ <p class="t-transp t-medium mn-b-thin">You own:</p>
59
+ <p class="h1 mn-b-small">{{state.share}}%</p>
60
+ <p class="t-white p-big t-medium mn-b-semi">of all shares</p>
61
+
62
+ <div
63
+ class="flex-v-center mn-b-small flex-nowrap flex pd-small bg-black-transp-5 radius-extra"
64
+ >
65
+ <!-- <img src="@/assets/icons/metamask.svg" class="mn-r-small i-big" > -->
66
+
67
+ <p v-if="state.account" class="t-transp t-medium ">
68
+ <span class="uppercase p-small t-medium t-transp">Connected Metamask</span><br>
69
+ <span>{{state.account}}</span>
70
+ </p>
71
+
72
+ <button
73
+ v-if="state.account"
74
+ @click="actions.disconnectWallet"
75
+ class="mn-l-auto bg-red button"
76
+ >
77
+ Disconnect Wallet
78
+ </button>
79
+ </div>
80
+
81
+
82
+ </div>
83
+ <h2 class="mn-b-small" v-if="state.rewards.length > 0">Latest Rewards </h2>
100
84
 
85
+ <section class="cols-3 gap-thin">
101
86
  <div
102
87
  class="radius-medium bg-grey"
103
88
  v-for="income in state.rewards"
104
89
  >
105
- <div class="flex-nowrap bg-white flex pd-medium">
90
+ <div class="flex-nowrap br-b br-black-transp-10 br-solid flex pd-medium">
106
91
  <!-- <img src="/logo/wdt-plus.svg" class="mn-r-thin i-semi"> -->
107
92
  <p class="t-semi mn-r-auto">{{income.amount}} WDT</p>
108
93
 
@@ -110,8 +95,8 @@
110
95
  </div>
111
96
 
112
97
  <div class="pd-medium">
113
- <h4 class="mn-b-thin">{{income.name}}</h4>
114
- <p class="p-small">{{income.content[0].content}}</p>
98
+ <h4 class="t-regular mn-b-thin">{{income.name}}</h4>
99
+ <!-- <p class="p-small">{{income.content[0].content}}</p> -->
115
100
  </div>
116
101
 
117
102
  </div>
@@ -26,6 +26,85 @@ const cryptoControllerFactory = (db, wdmClient) => {
26
26
  const Comment = db.comment;
27
27
  const Reward = db.reward;
28
28
 
29
+ // const listRewards = async (req, res) => {
30
+ // try {
31
+ // const rewards = await Blogpost.aggregate([
32
+ // // Шаг 1: Фильтрация блогпостов по создателю
33
+ // { $match: { "creator.target": req.userId } },
34
+ // // Шаг 2: Соединение с Reaction для подсчета реакций
35
+ // {
36
+ // $lookup: {
37
+ // from: "reactions",
38
+ // localField: "_id",
39
+ // foreignField: "target",
40
+ // as: "reactions"
41
+ // }
42
+ // },
43
+ // // Шаг 3: Соединение с Comment для подсчета комментариев
44
+ // {
45
+ // $lookup: {
46
+ // from: "comments",
47
+ // localField: "_id",
48
+ // foreignField: "target",
49
+ // as: "comments"
50
+ // }
51
+ // },
52
+ // // Шаг 4: Соединение с Reward для получения предыдущих наград
53
+ // {
54
+ // $lookup: {
55
+ // from: "rewards",
56
+ // let: { blogId: "$_id", userId: req.userId },
57
+ // pipeline: [
58
+ // { $match: {
59
+ // $expr: {
60
+ // $and: [
61
+ // { $eq: ["$user", "$$userId"] },
62
+ // { $eq: ["$type", "blogpost"] },
63
+ // { $eq: ["$target", "$$blogId"] }
64
+ // ]
65
+ // }
66
+ // }
67
+ // },
68
+ // { $sort: { createdAt: -1 } },
69
+ // { $limit: 1 }
70
+ // ],
71
+ // as: "previousReward"
72
+ // }
73
+ // },
74
+ // // Шаг 5: Проецирование результата и преобразование массивов в счетчики
75
+ // {
76
+ // $project: {
77
+ // user: req.userId,
78
+ // type: 'blogpost',
79
+ // name: "$name",
80
+ // content: "$content",
81
+ // url: "$url",
82
+ // views: "$views",
83
+ // reactionsCount: { $size: "$reactions" },
84
+ // commentsCount: { $size: "$comments" },
85
+ // previousRewardSnapshot: { $arrayElemAt: ["$previousReward.snapshot", 0] },
86
+ // }
87
+ // }
88
+ // ]).exec();
89
+
90
+ // // Пересчет наград на основе полученных данных
91
+ // const calculatedRewards = rewards.map(reward => ({
92
+ // ...reward,
93
+ // amount: calculateRewardForPost(
94
+ // reward.previousRewardSnapshot,
95
+ // reward.views,
96
+ // reward.reactionsCount,
97
+ // reward.commentsCount
98
+ // ).toString(),
99
+ // }));
100
+
101
+ // res.status(200).send(calculatedRewards);
102
+ // } catch (error) {
103
+ // console.error("Error listing rewards:", error);
104
+ // res.status(500).send({ message: "Internal server error" });
105
+ // }
106
+ // };
107
+
29
108
  const listRewards = async (req, res) => {
30
109
  const blogs = await Blogpost.find({ "creator.target": req.userId }).exec();
31
110
 
@@ -0,0 +1,27 @@
1
+ module.exports = (mongoose) => {
2
+ const WalletSchema = new mongoose.Schema(
3
+ {
4
+ owner: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: () => {
7
+ if (this.owner.type === 'user') return 'User';
8
+ if (this.owner.type === 'organization') return 'Organization';
9
+ },
10
+ required: true,
11
+ },
12
+ amount: {
13
+ type: Number,
14
+ required: true,
15
+ default: 0
16
+ },
17
+ },
18
+ {
19
+ timestamps: {
20
+ currentTime: () => Date.now(),
21
+ },
22
+ },
23
+ { strict: false },
24
+ );
25
+
26
+ return mongoose.model("Wallet", WalletSchema);
27
+ };