@ozdao/prometheus-framework 0.2.50 → 0.2.52

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. package/dist/main-482dc398.mjs +13626 -0
  2. package/dist/main-b2JI9sFg.js +91 -0
  3. package/dist/main-c56d4c09.js +91 -0
  4. package/dist/main-x-9D8zvb.mjs +13604 -0
  5. package/dist/main.css +1 -1
  6. package/dist/organizations.server.js +22 -16
  7. package/dist/organizations.server.mjs +22 -16
  8. package/dist/products.server.js +32 -16
  9. package/dist/products.server.mjs +32 -16
  10. package/dist/prometheus-framework/src/components/Button/Button.vue.cjs +1 -1
  11. package/dist/prometheus-framework/src/components/Button/Button.vue.js +223 -2
  12. package/dist/prometheus-framework/src/components/Button/Button.vue2.cjs +1 -1
  13. package/dist/prometheus-framework/src/components/Button/Button.vue2.js +2 -225
  14. package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
  15. package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +19 -19
  16. package/dist/prometheus-framework/src/components/Field/Field.vue.cjs +1 -1
  17. package/dist/prometheus-framework/src/components/Field/Field.vue.js +76 -2
  18. package/dist/prometheus-framework/src/components/Field/Field.vue2.cjs +1 -1
  19. package/dist/prometheus-framework/src/components/Field/Field.vue2.js +2 -76
  20. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.cjs +1 -1
  21. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.js +1 -1
  22. package/dist/prometheus-framework/src/components/LocationMarker/LocationMarker.vue2.cjs +1 -1
  23. package/dist/prometheus-framework/src/components/LocationMarker/LocationMarker.vue2.js +2 -2
  24. package/dist/prometheus-framework/src/components/Map/Map.vue.cjs +1 -1
  25. package/dist/prometheus-framework/src/components/Map/Map.vue.js +35 -2
  26. package/dist/prometheus-framework/src/components/Map/Map.vue2.cjs +1 -1
  27. package/dist/prometheus-framework/src/components/Map/Map.vue2.js +2 -35
  28. package/dist/prometheus-framework/src/components/Tab/Tab.vue.cjs +1 -1
  29. package/dist/prometheus-framework/src/components/Tab/Tab.vue.js +44 -2
  30. package/dist/prometheus-framework/src/components/Tab/Tab.vue2.cjs +1 -1
  31. package/dist/prometheus-framework/src/components/Tab/Tab.vue2.js +2 -44
  32. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.cjs +1 -1
  33. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.js +3 -3
  34. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.cjs +1 -1
  35. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.js +1 -1
  36. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.cjs +1 -1
  37. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.js +3 -3
  38. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  39. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +3 -3
  40. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.cjs +1 -1
  41. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.js +3 -3
  42. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.cjs +1 -1
  43. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.js +3 -3
  44. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.cjs +1 -1
  45. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.js +3 -3
  46. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
  47. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +1 -1
  48. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
  49. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +2 -2
  50. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.cjs +1 -1
  51. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.js +1 -1
  52. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.cjs +1 -1
  53. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.js +1 -1
  54. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
  55. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +2 -2
  56. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.cjs +1 -1
  57. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.js +1 -1
  58. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
  59. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +2 -2
  60. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.cjs +1 -1
  61. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.js +2 -2
  62. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.cjs +1 -0
  63. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.js +37 -0
  64. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  65. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +1 -1
  66. package/dist/prometheus-framework/src/modules/icons/entities/IconShopcart.vue.cjs +1 -1
  67. package/dist/prometheus-framework/src/modules/icons/entities/IconShopcart.vue.js +21 -14
  68. package/dist/prometheus-framework/src/modules/icons/navigation/IconSearch.vue.cjs +1 -0
  69. package/dist/prometheus-framework/src/modules/icons/navigation/IconSearch.vue.js +24 -0
  70. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  71. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +3 -3
  72. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue.cjs +1 -1
  73. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue.js +2 -11
  74. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue2.cjs +1 -1
  75. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue2.js +11 -2
  76. package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.cjs +1 -1
  77. package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.js +1 -1
  78. package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.cjs +1 -1
  79. package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.js +1 -1
  80. package/dist/prometheus-framework/src/modules/orders/components/sections/FormOrderDetails.vue.cjs +1 -1
  81. package/dist/prometheus-framework/src/modules/orders/components/sections/FormOrderDetails.vue.js +1 -1
  82. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardDepartment.vue.cjs +1 -1
  83. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardDepartment.vue.js +49 -101
  84. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.js +25 -25
  85. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.cjs +1 -1
  86. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.js +68 -39
  87. package/dist/prometheus-framework/src/modules/organizations/components/blocks/User.vue.cjs +1 -1
  88. package/dist/prometheus-framework/src/modules/organizations/components/blocks/User.vue.js +38 -47
  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/Department.vue.cjs +1 -1
  92. package/dist/prometheus-framework/src/modules/organizations/components/pages/Department.vue.js +69 -62
  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 +134 -129
  95. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  96. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +2 -2
  97. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  98. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +128 -158
  99. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
  100. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +3 -3
  101. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organizations.vue.cjs +1 -1
  102. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organizations.vue.js +1 -1
  103. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
  104. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +2 -2
  105. package/dist/prometheus-framework/src/modules/organizations/components/sections/Feed.vue.cjs +1 -1
  106. package/dist/prometheus-framework/src/modules/organizations/components/sections/Feed.vue.js +13 -13
  107. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  108. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +2 -2
  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 +3 -3
  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 +1 -1
  113. package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.cjs +1 -1
  114. package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.js +1 -1
  115. package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.cjs +1 -1
  116. package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.js +1 -1
  117. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
  118. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +44 -44
  119. package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.cjs +1 -1
  120. package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.js +1 -1
  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/pages/Products.vue.cjs +1 -1
  124. package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.js +64 -51
  125. package/dist/prometheus-framework/src/modules/products/components/pages/ProductsBackoffice.vue.cjs +1 -1
  126. package/dist/prometheus-framework/src/modules/products/components/pages/ProductsBackoffice.vue.js +1 -1
  127. package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.cjs +1 -1
  128. package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.js +1 -1
  129. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
  130. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +2 -2
  131. package/dist/prometheus-framework/src/modules/products/components/sections/FilterProducts.vue.cjs +1 -1
  132. package/dist/prometheus-framework/src/modules/products/components/sections/FilterProducts.vue.js +22 -23
  133. package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.cjs +1 -1
  134. package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.js +1 -1
  135. package/dist/prometheus-framework/src/modules/products/store/products.cjs +1 -1
  136. package/dist/prometheus-framework/src/modules/products/store/products.js +23 -23
  137. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
  138. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +1 -1
  139. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.cjs +1 -1
  140. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.js +1 -1
  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/ProfileBlogposts.vue.cjs +1 -1
  144. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileBlogposts.vue.js +1 -1
  145. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  146. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +3 -3
  147. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEvents.vue.cjs +1 -1
  148. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEvents.vue.js +1 -1
  149. package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.cjs +1 -1
  150. package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.js +1 -1
  151. package/dist/prometheus-framework.cjs.js +1 -1
  152. package/dist/prometheus-framework.es.js +1 -1
  153. package/dist/style.css +1 -1
  154. package/dist/web-6dcbb74b.mjs +55 -0
  155. package/dist/web-caJAdsxy.js +1 -0
  156. package/dist/web-ee302c1d.js +1 -0
  157. package/dist/web-i08OVMw9.mjs +55 -0
  158. package/package.json +1 -1
  159. package/src/components/Button/Button.vue +3 -3
  160. package/src/components/Feed/Feed.vue +2 -1
  161. package/src/components/LocationMarker/LocationMarker.vue +1 -0
  162. package/src/modules/applications/applications.client.js +0 -1
  163. package/src/modules/globals/components/blocks/BlockSearch.vue +42 -0
  164. package/src/modules/icons/entities/IconProfile.vue +10 -1
  165. package/src/modules/icons/entities/IconShopcart.vue +12 -2
  166. package/src/modules/marketplace/components/layouts/Marketplace.vue +7 -14
  167. package/src/modules/mobile/components/BottomNavigation/BottomNavigation.vue +86 -0
  168. package/src/modules/mobile/components/BottomSheet/BottomSheet.vue +86 -0
  169. package/src/modules/mobile/components/NavigationBar/NavigationBar.vue +152 -0
  170. package/src/modules/mobile/components/Walkthrough/Walkthrough.vue +195 -0
  171. package/src/modules/orders/components/partials/ShopCart.vue +4 -1
  172. package/src/modules/organizations/components/blocks/CardDepartment.vue +34 -66
  173. package/src/modules/organizations/components/blocks/DepartmentMemberModify.vue +50 -13
  174. package/src/modules/organizations/components/blocks/User.vue +19 -10
  175. package/src/modules/organizations/components/pages/Department.vue +19 -3
  176. package/src/modules/organizations/components/pages/DepartmentEdit.vue +14 -10
  177. package/src/modules/organizations/components/pages/Organization.vue +38 -72
  178. package/src/modules/organizations/components/sections/Feed.vue +1 -1
  179. package/src/modules/organizations/controllers/memberships.controller.js +27 -24
  180. package/src/modules/organizations/controllers/organizations.controller.js +0 -1
  181. package/src/modules/products/components/pages/EditLeftover.vue +6 -4
  182. package/src/modules/products/components/pages/Products.vue +58 -38
  183. package/src/modules/products/components/sections/FilterProducts.vue +5 -5
  184. package/src/modules/products/controllers/leftovers.controller.js +12 -5
  185. package/src/modules/products/controllers/products.controller.js +30 -9
  186. package/src/modules/products/store/products.js +4 -0
  187. package/src/styles/layout.scss +1 -1
@@ -1,47 +1,57 @@
1
1
  <template>
2
- <div class="cols-2-1_3 bg-grey radius-big gap-thin pd-thin">
2
+ <div class="cols-2-1_3 bg-grey pd-thin radius-big gap-thin">
3
+
3
4
  <FilterProducts
4
5
 
5
6
  />
6
- <Feed
7
- :states="{
8
- empty: {
9
- title: 'No Products Found',
10
- description: 'Currently, there are no products available.'
11
- }
12
- }"
13
- :store="{
14
- read: (options) => products.actions.read(options),
15
- state: products.state
16
- }"
17
- :options="{
18
- limit: 15,
19
- organization: route.params._id,
20
- categories: route.query.categories,
21
- prices: route.query.prices,
22
- delivery: route.query.delivery,
23
- // user: user
24
- }"
25
- v-slot="{
26
- items
27
- }"
28
- class="cols-3 gap-thin"
29
- >
30
- <CardProduct
31
- v-for="product in items"
32
- :key="product._id"
33
- :product="product"
34
- class="h-max"
35
- @click="$router.push({
36
- name: 'Product Organization',
37
- params: {
38
- _id: route.params._id,
39
- product: product._id
40
- }
41
- })"
7
+
8
+ <div>
9
+ <BlockSearch
10
+ @search="updateSearch"
11
+ placeholder="Enter product name"
12
+ class="bg-white mn-b-thin"
42
13
  />
43
- </Feed>
44
14
 
15
+ <Feed
16
+ :states="{
17
+ empty: {
18
+ title: 'No Products Found',
19
+ description: 'Currently, there are no products available.'
20
+ }
21
+ }"
22
+ :store="{
23
+ read: (options) => products.actions.read(options),
24
+ state: products.state
25
+ }"
26
+ :options="{
27
+ limit: 15,
28
+ organization: route.params._id,
29
+ categories: route.query.categories,
30
+ prices: route.query.prices,
31
+ delivery: route.query.delivery,
32
+ search: route.query.search
33
+ // user: user
34
+ }"
35
+ v-slot="{
36
+ items
37
+ }"
38
+ class="cols-3 gap-thin"
39
+ >
40
+ <CardProduct
41
+ v-for="product in items"
42
+ :key="product._id"
43
+ :product="product"
44
+ class="h-max"
45
+ @click="$router.push({
46
+ name: 'Product Organization',
47
+ params: {
48
+ _id: route.params._id,
49
+ product: product._id
50
+ }
51
+ })"
52
+ />
53
+ </Feed>
54
+ </div>
45
55
  </div>
46
56
  </template>
47
57
 
@@ -54,6 +64,8 @@
54
64
 
55
65
  // Import components
56
66
  import FilterProducts from '@pf/src/modules/products/components/sections/FilterProducts.vue'
67
+ import BlockSearch from '@pf/src/modules/globals/components/blocks/BlockSearch.vue'
68
+
57
69
 
58
70
  import Feed from '@pf/src/components/Feed/Feed.vue'
59
71
  import CardProduct from '@pf/src/modules/products/components/blocks/CardProduct.vue'
@@ -61,6 +73,14 @@
61
73
  // Accessing router and store
62
74
  import * as products from '@pf/src/modules/products/store/products';
63
75
 
76
+ function updateSearch(search) {
77
+ let query = { ...route.query}
78
+
79
+ query.search = search
80
+
81
+ router.push({ query });
82
+ }
83
+
64
84
  const route = useRoute()
65
85
  const router = useRouter()
66
86
  </script>
@@ -1,8 +1,8 @@
1
1
  <template>
2
- <div class="pd-medium bg-grey radius-big">
2
+ <div class="pd-medium bg-white-transp-50 radius-big">
3
3
  <!-- Categories Filter -->
4
4
  <Spoiler
5
- class="radius-small o-hidden br-1px br-solid br-grey mn-b-small"
5
+ class="radius-small o-hidden mn-b-small"
6
6
  :status="true"
7
7
  >
8
8
  <template #header>
@@ -22,11 +22,11 @@
22
22
  </template>
23
23
  </Spoiler>
24
24
 
25
- <hr class="mn-b-small">
25
+ <hr class="mn-b-small t-transp">
26
26
 
27
27
  <!-- Prices Filter -->
28
28
  <Spoiler
29
- class="radius-small o-hidden br-1px br-solid br-grey mn-b-small"
29
+ class="radius-small o-hidden mn-b-small"
30
30
  :status="false"
31
31
  >
32
32
  <template #header>
@@ -46,7 +46,7 @@
46
46
  </template>
47
47
  </Spoiler>
48
48
 
49
- <hr class="mn-b-small">
49
+ <!-- <hr class="mn-b-small"> -->
50
50
 
51
51
  <!-- Delivery Filter -->
52
52
  <!-- <Spoiler
@@ -1,5 +1,3 @@
1
- const ObjectId = require('mongoose').Types.ObjectId;
2
-
3
1
  const controllerFactory = (db) => {
4
2
  const Leftover = db.leftover;
5
3
 
@@ -8,16 +6,25 @@ const controllerFactory = (db) => {
8
6
  let query = {};
9
7
  let options = {};
10
8
 
11
- if (req.query.organization) query.organization = new ObjectId(req.query.organization)
9
+ // Проверка наличия req.query.organization
10
+ if (req.query.organization) {
11
+ // Создание ObjectId из строки
12
+ query.organization = new db.mongoose.Types.ObjectId(req.query.organization);
13
+ }
14
+
15
+ console.log(query);
16
+
17
+ const leftoveres = await Leftover.find(query, null, options)
18
+ .sort({ createdAt: "desc" })
19
+ .exec();
12
20
 
13
- const leftoveres = await Leftover.find(query, null, options).sort({ 'createdAt': 'desc' }).exec();
14
-
15
21
  if (!leftoveres) {
16
22
  return res.status(404).send({ message: "LEFTOVERES_NOT_FOUND" });
17
23
  }
18
24
 
19
25
  res.status(200).send(leftoveres);
20
26
  } catch (err) {
27
+ console.error(err);
21
28
  res.status(500).send({ message: "ERROR_GET_ALL_LEFTOVERES" });
22
29
  }
23
30
  };
@@ -5,7 +5,10 @@ const path = require('path');
5
5
 
6
6
  const OpenAI = require("openai");
7
7
 
8
- const openai = new OpenAI();
8
+ console.log(process.env.OPENAI_API_KEY)
9
+ const openai = new OpenAI({
10
+ apiKey: process.env.OPENAI_API_KEY
11
+ });
9
12
 
10
13
  // Factory
11
14
  const controllerFactory = (db) => {
@@ -59,6 +62,24 @@ const controllerFactory = (db) => {
59
62
  query.delivery = { $in: deliveryOptions };
60
63
  }
61
64
 
65
+ const search = req.query.search;
66
+
67
+ if (search) {
68
+ const parts = search.split('.');
69
+
70
+ let regexPattern = '';
71
+
72
+ if (parts.length === 2) {
73
+ // Создаем паттерн, который допускает замену одного символа в каждой части
74
+ regexPattern = parts.map(part => part.substr(0, part.length - 1) + '.{1}').join('\\.');
75
+ } else {
76
+ // Если нет точки, применяем аналогичный подход к всей строке
77
+ regexPattern = search.substr(0, search.length - 1) + '.{1}';
78
+ }
79
+
80
+ query.name = { $regex: regexPattern, $options: 'i' }
81
+ }
82
+
62
83
  // Handle price ranges
63
84
  const prices = req.query.prices?.split(',') || [];
64
85
 
@@ -327,13 +348,13 @@ const controllerFactory = (db) => {
327
348
  return res.status(404).send({ message: "Products not found." });
328
349
  }
329
350
 
330
- const productsList = products.map(p => `
331
- ${p._id}:
332
- ${p.name}
333
- (${p.information[0].value})
334
- (${p.information[1].value}%)
335
- (${p.information[2].value})
336
- `).join(', ');
351
+ const productsList = products.map(p => {
352
+ const info = p.information || [];
353
+ const value0 = info[0] ? info[0].value : '';
354
+ const value1 = info[1] ? `(${info[1].value}%)` : '';
355
+ const value2 = info[2] ? `(${info[2].value})` : '';
356
+ return `${p._id}: ${p.name} (${value0}) ${value1} ${value2}`;
357
+ }).join(', ');
337
358
 
338
359
  const prompt = `
339
360
  1. When asked how the client wants to feel, they responded "${mood}".
@@ -352,7 +373,7 @@ const controllerFactory = (db) => {
352
373
  while (true) {
353
374
  try {
354
375
  response = await openai.chat.completions.create({
355
- model: "gpt-4",
376
+ model: "gpt-3.5-turbo",
356
377
  messages: [{role: "user", content: prompt}],
357
378
  });
358
379
 
@@ -92,6 +92,10 @@ const actions = {
92
92
  query.status = options.status;
93
93
  }
94
94
 
95
+ if (options.search) {
96
+ query.search = options.search;
97
+ }
98
+
95
99
  query.sort = 'createdAt';
96
100
 
97
101
  query.skip = options.skip || 0;
@@ -25,7 +25,7 @@ body {
25
25
  overflow-x: hidden;
26
26
  }
27
27
 
28
- #app {
28
+ #app-wrapper {
29
29
  display: grid;
30
30
  position: relative;
31
31
  height: 100vh;