@ozdao/prometheus-framework 0.2.32 → 0.2.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. package/dist/events.server.js +31 -0
  2. package/dist/events.server.mjs +31 -0
  3. package/dist/files.server.js +99 -78
  4. package/dist/files.server.mjs +99 -78
  5. package/dist/globals.server.js +0 -1
  6. package/dist/globals.server.mjs +0 -1
  7. package/dist/main.css +1 -1
  8. package/dist/prometheus-framework.cjs.js +21 -21
  9. package/dist/prometheus-framework.es.js +1037 -1023
  10. package/package.json +1 -1
  11. package/src/components/Countdown/Countdown.vue +75 -0
  12. package/src/components/EditImages/EditImages.vue +10 -2
  13. package/src/components/Upload/Upload.vue +32 -6
  14. package/src/components/UploadImage/UploadImage.vue +12 -8
  15. package/src/components/UploadImageMultiple/UploadImageMultiple.vue +4 -2
  16. package/src/modules/events/components/pages/EditEvent.vue +304 -2
  17. package/src/modules/events/components/pages/Event.vue +128 -46
  18. package/src/modules/events/components/sections/HeroEvent.vue +161 -0
  19. package/src/modules/events/components/sections/SectionLineup.vue +42 -0
  20. package/src/modules/events/components/sections/SectionMainGuest.vue +104 -0
  21. package/src/modules/events/components/sections/SectionPreviousEvents.vue +119 -0
  22. package/src/modules/events/components/sections/SectionSpecialGuests.vue +47 -0
  23. package/src/modules/events/controllers/events.controller.js +1 -0
  24. package/src/modules/events/controllers/utils/queryProcessor.js +2 -0
  25. package/src/modules/events/models/event.model.js +29 -0
  26. package/src/modules/events/store/events.js +4 -0
  27. package/src/modules/files/controllers/files.controller.js +3 -0
  28. package/src/modules/files/middlewares/server/middlewareBusboy.js +115 -100
  29. package/src/modules/files/routes/files.routes.js +3 -4
  30. package/src/modules/globals/globals.server.js +0 -1
  31. package/src/modules/marketplace/components/pages/Catalog.vue +1 -0
  32. package/src/modules/orders/components/blocks/CardOrder.vue +5 -5
  33. package/src/modules/orders/components/blocks/StatusHistory.vue +84 -0
  34. package/src/modules/orders/components/pages/Order.vue +11 -54
  35. package/src/modules/orders/controllers/orders.controller.js +17 -9
  36. package/src/modules/orders/models/order.model.js +19 -0
  37. package/src/modules/orders/routes/orders.routes.js +4 -1
  38. package/src/modules/organizations/components/blocks/CardOrganization.vue +1 -1
  39. package/src/modules/users/components/pages/Profile.vue +1 -1
@@ -28,6 +28,35 @@ module.exports = (db) => {
28
28
  end: {
29
29
  type: Date,
30
30
  }
31
+ },
32
+ specialData: {
33
+ type: Object,
34
+ default: () => ({
35
+ subtitle: 'NMS Presents',
36
+ ticketPrice: '499',
37
+ ticketImage: null,
38
+ ticketLinkStripe: null,
39
+ video: null,
40
+ guests: [],
41
+ guestVideo: null,
42
+ guestTitle: null,
43
+ guestDescription: null,
44
+ guestFacebook: null,
45
+ guestInstagram: null,
46
+ guestTelegram: null,
47
+ guestTwitter: null,
48
+ guestSoundcloud: null,
49
+ guestSpotify: null,
50
+ logos: [],
51
+ lineup: [],
52
+ lineupBackground: null,
53
+ previousVideo: null
54
+ })
55
+ },
56
+ // Adding special boolean property
57
+ special: {
58
+ type: Boolean,
59
+ default: false
31
60
  }
32
61
  }, {
33
62
  timestamps: {
@@ -27,6 +27,10 @@ const state = reactive({
27
27
  },
28
28
  current: {
29
29
  _id: "",
30
+ special: false,
31
+ specialData: {
32
+ subtitle: null
33
+ },
30
34
  cover: "",
31
35
  url: "",
32
36
  status: "",
@@ -3,6 +3,9 @@ const path = require('path');
3
3
  const controllerFactory = (db, publicPath) => {
4
4
 
5
5
  const uploadMultipleFileController = async (req, res, next) => {
6
+ console.log('uploadMultipleFileController called');
7
+ console.log("Files received:", req.files ? req.files.length : 0); // Лог
8
+
6
9
  if (!req.files || req.files.length === 0) {
7
10
  return res.status(400).send({ message: 'No files uploaded.' });
8
11
  }
@@ -1,8 +1,6 @@
1
- // middlewareFactory.js
2
1
  const sharp = require('sharp');
3
2
  const fs = require('fs');
4
3
  const fsp = require('fs/promises');
5
- const os = require('os');
6
4
  const path = require('path');
7
5
  const busboy = require('busboy');
8
6
 
@@ -11,127 +9,144 @@ const createThumbnail = async (originalPath) => {
11
9
  path.dirname(originalPath),
12
10
  'thumbnail_' + path.basename(originalPath)
13
11
  );
12
+
14
13
  try {
14
+ const metadata = await sharp(originalPath).metadata();
15
+
16
+ const resizeOptions = {};
17
+
18
+ if (metadata.width > 800) {
19
+ resizeOptions.width = 800;
20
+ }
21
+
15
22
  await sharp(originalPath)
16
- .rotate()
17
- .resize({ width: 800 })
23
+ .rotate()
24
+ .resize(resizeOptions)
18
25
  .toFile(thumbnailPath);
19
26
  } catch (error) {
20
27
  console.error("Error creating thumbnail:", error);
28
+ throw error;
21
29
  }
22
30
  };
23
31
 
24
32
 
25
- const middlewareFactory = (db, publicPath) => {
26
-
27
- const generatePreviewMiddleware = async (req, res, next) => {
28
- const files = req.file ? [req.file] : req.files;
29
-
30
- try {
31
- await Promise.all(files.map(file => createThumbnail(file)));
32
- } catch (error) {
33
- console.error('Error generating previews:', error);
33
+ const handleFileUpload = (req, res, next, publicPath, { folderNameDefault = 'unsorted', maxSize = 10 * 1024 * 1024, allowedTypes = null }) => {
34
+ console.log('handleFileUpload middleware called');
35
+ console.log('Options:' + folderNameDefault + maxSize + allowedTypes);
36
+
37
+ let folderName = req.query.folderName || folderNameDefault;
38
+ folderName = decodeURIComponent(folderName);
39
+ folderName = folderName.startsWith('/') ? folderName : '/' + folderName;
40
+ const filePath = path.join(publicPath, folderName);
41
+ let files = [];
42
+ let filesWrongSize = [];
43
+ let filesWrongType = [];
44
+ let fileProcessingPromises = []; // Массив для отслеживания промисов обработки файлов
45
+
46
+ const bb = busboy({
47
+ headers: req.headers,
48
+ limits: { fileSize: maxSize },
49
+ });
50
+
51
+ bb.on('file', (name, file, info) => {
52
+ console.log(`Received file: ${info.filename}, Type: ${info.mimeType}`);
53
+
54
+ const isValidType = !allowedTypes || allowedTypes.includes(info.mimeType);
55
+ if (!isValidType) {
56
+ console.log(`File of wrong type: ${info.filename}`);
57
+ filesWrongType.push(info.filename);
58
+ file.resume();
59
+ return;
34
60
  }
35
- next();
36
- };
37
-
38
- const uploadMultipleFilesMiddleware = (req, res, next) => {
39
- let folderName = req.query.folderName || 'unsorted';
40
61
 
41
- if (!folderName.startsWith('/')) {
42
- folderName = '/' + folderName;
43
- }
44
-
45
- let files = [];
46
- let filesWrongSize = [];
47
- let filesWrongType = [];
48
-
49
- let filePath = path.join(publicPath, folderName);
50
- let filePromise;
51
-
52
- try {
53
- const bb = busboy({
54
- headers: req.headers,
55
- limits: {
56
- fileSize: 10*1024*1024
57
- }
58
- });
59
-
60
- bb.on('error', err => {
61
- next(err);
62
- });
63
-
64
- let fileFullPath
65
-
66
- bb.on('file', (name, file, info) => {
67
- if(info.filename.length > 0) {
68
- file.resume();
69
- }
70
-
71
- if(info.mimeType != 'image/png' && info.mimeType != 'image/jpeg' && info.mimeType != 'image/gif') {
72
- filesWrongType.push(info.filename);
73
- file.resume();
74
- }
62
+ const fileName = `${Math.floor(Math.random() * 10000)}-${info.filename}`;
63
+ const fileFullPath = path.join(filePath, fileName);
75
64
 
76
- let fileName = `${Math.floor(Math.random() * 10000)}-${info.filename}`;
77
-
78
- fileFullPath = path.join(filePath, fileName);
79
- fileRelativePath = path.join(folderName, fileName);
80
-
81
- filePromise = new Promise((resolve, reject) => {
82
- const writeStream = fs.createWriteStream(fileFullPath).on('error', reject).on('finish', resolve);
83
- file.on('error', reject);
84
- file.pipe(writeStream);
65
+ const fileProcess = fsp.mkdir(path.dirname(fileFullPath), { recursive: true })
66
+ .then(() => new Promise((resolve, reject) => {
67
+ const stream = file.pipe(fs.createWriteStream(fileFullPath));
68
+ stream.on('finish', () => {
69
+ files.push(path.relative(publicPath, fileFullPath));
70
+ resolve(); // This line replaces the thumbnail creation process
85
71
  });
86
-
87
- files.push(fileFullPath)
88
-
89
- file.on('limit', () => {
90
- filesWrongSize.push(info.filename);
91
-
92
- fsp.unlink(fileFullPath);
93
-
94
- const index = files.indexOf(fileFullPath);
95
-
96
- if (index !== -1) {
97
- files.splice(index, 1);
72
+ stream.on('error', reject);
73
+ }));
74
+
75
+
76
+ fileProcessingPromises.push(fileProcess);
77
+
78
+ file.on('limit', () => {
79
+ filesWrongSize.push(info.filename);
80
+ fsp.unlink(fileFullPath).catch(err => console.error(`Error deleting oversized file: ${err.message}`));
81
+ });
82
+ });
83
+
84
+ bb.on('finish', () => {
85
+ Promise.all(fileProcessingPromises)
86
+ .then(() => {
87
+ console.log(`Upload finished. Files: ${files.length}, Wrong Size: ${filesWrongSize.length}, Wrong Type: ${filesWrongType.length}`);
88
+ req.files = files;
89
+ if (files.length === 0 && (filesWrongSize.length > 0 || filesWrongType.length > 0)) {
90
+ let errorMessage = 'No files uploaded.';
91
+ if (filesWrongSize.length > 0) {
92
+ errorMessage += ' Some files were too large.';
98
93
  }
99
-
100
- file.resume();
101
- });
102
-
103
- });
104
-
105
- bb.on('close', async () => {
106
- try {
107
- if (!filePromise) {
108
- res.status(400).json({ message: `Uploaded file '${name}' is missing` });
109
- return;
94
+ if (filesWrongType.length > 0) {
95
+ errorMessage += ' Some files were of an unsupported type.';
110
96
  }
97
+ return res.status(400).json({ message: errorMessage });
98
+ }
99
+ next();
100
+ })
101
+ .catch((error) => {
102
+ console.error('Failed processing one or more files', error);
103
+ res.status(500).json({ message: 'Error processing files' });
104
+ });
105
+ });
111
106
 
112
- await filePromise
107
+ req.pipe(bb);
108
+ };
113
109
 
114
- req.files = files
115
110
 
116
- next()
117
- } catch (err) {
118
- next(err);
111
+ const middlewareFactory = (db, publicPath) => {
112
+ const generatePreviewMiddleware = async (req, res, next) => {
113
+ const files = req.files;
114
+ try {
115
+ await Promise.all(files.map(file => createThumbnail(path.join(publicPath, file))));
116
+ } catch (error) {
117
+ console.error('Error generating previews:', error);
118
+ return res.status(500).json({ message: 'Internal server error while generating previews.' });
119
+ }
120
+ next();
121
+ };
119
122
 
120
- } finally {
121
- bb.removeAllListeners();
122
- }
123
- });
123
+ const uploadFilesMiddleware = (req, res, next) => {
124
+ const allowedTypes = [
125
+ 'image/png',
126
+ 'image/jpeg',
127
+ 'image/jpg',
128
+ 'image/gif',
129
+ 'application/pdf',
130
+ 'image/svg+xml',
131
+ 'video/mp4',
132
+ 'video/quicktime', // MOV
133
+ 'video/webm'
134
+ ];
135
+
136
+
137
+ handleFileUpload(req, res, next, publicPath, { folderNameDefault: 'unsorted', maxSize: 10 * 1024 * 1024, allowedTypes });
138
+ };
124
139
 
125
- req.pipe(bb);
126
- } catch (err) {
127
- res.status(400).json({ message: `Could not retrieve file from request - ${err.message}`});
128
- }
140
+ const uploadImagesMiddleware = (req, res, next) => {
141
+ const allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'];
142
+ handleFileUpload(req, res, next, publicPath, { folderNameDefault: 'unsorted', maxSize: 10 * 1024 * 1024, allowedTypes });
129
143
  };
130
144
 
131
- return {
132
- uploadMultipleFilesMiddleware,
145
+ return {
146
+ uploadImagesMiddleware,
147
+ uploadFilesMiddleware,
133
148
  generatePreviewMiddleware
134
149
  };
135
150
  };
136
151
 
137
- module.exports = middlewareFactory;
152
+ module.exports = middlewareFactory;
@@ -27,7 +27,7 @@ module.exports = function(app, db, origins, publicPath) {
27
27
  app.post(
28
28
  "/api/upload/image",
29
29
  [
30
- middlewareBusboy.uploadMultipleFilesMiddleware,
30
+ middlewareBusboy.uploadImagesMiddleware,
31
31
  middlewareBusboy.generatePreviewMiddleware
32
32
  ],
33
33
  controller.uploadMultipleFileController
@@ -36,8 +36,7 @@ module.exports = function(app, db, origins, publicPath) {
36
36
  app.post(
37
37
  "/api/upload/file",
38
38
  [
39
- middlewareBusboy.uploadMultipleFilesMiddleware,
40
- middlewareBusboy.generatePreviewMiddleware
39
+ middlewareBusboy.uploadFilesMiddleware,
41
40
  ],
42
41
  controller.uploadMultipleFileController
43
42
  );
@@ -45,7 +44,7 @@ module.exports = function(app, db, origins, publicPath) {
45
44
  app.post(
46
45
  "/api/upload/multiple",
47
46
  [
48
- middlewareBusboy.uploadMultipleFilesMiddleware,
47
+ middlewareBusboy.uploadImagesMiddleware,
49
48
  middlewareBusboy.generatePreviewMiddleware
50
49
  ],
51
50
  controller.uploadMultipleFileController
@@ -7,7 +7,6 @@ const parseCookie = require('./utils/parseCookie.js');
7
7
 
8
8
  // Exporting middlewares and utils
9
9
  module.exports = {
10
- middlewareFactory,
11
10
  sitemap,
12
11
  mailing,
13
12
  parseCookie
@@ -19,6 +19,7 @@
19
19
  :organization="organization"
20
20
  :showRating="true"
21
21
  :showFollowers="false"
22
+ :showProducts="true"
22
23
  class="bg-grey w-100 o-hidden radius-big pd-small "
23
24
  />
24
25
  </div>
@@ -1,11 +1,11 @@
1
1
  <template>
2
2
  <div class="pd-big mn-regular order-client-card col">
3
3
  <p class="mn-regular flex-center flex-nowrap flex w-100">
4
- <!-- <img v-if="order.status === 'Created'" class="mn-r-small" src="@/assets/icons/status/created.svg"/>
5
- <img v-if="order.status === 'Confirmed'" class="mn-r-small" src="@/assets/icons/status/confirmed.svg"/>
6
- <img v-if="order.status === 'Awaiting shipment'" class="mn-r-small" src="@/assets/icons/status/paid.svg"/>
7
- <img v-if="order.status === 'In delivery'" class="mn-r-small" src="@/assets/icons/status/finished.svg"/>
8
- <img v-if="order.status === 'Finished'" class="mn-r-small" src="@/assets/icons/status/finished.svg"/> -->
4
+ <!-- <img v-if="order.status === 'Created'" class="mn-r-small" src="@/assets/icons/status/created.svg"/>
5
+ <img v-if="order.status === 'Confirmed'" class="mn-r-small" src="@/assets/icons/status/confirmed.svg"/>
6
+ <img v-if="order.status === 'Awaiting shipment'" class="mn-r-small" src="@/assets/icons/status/paid.svg"/>
7
+ <img v-if="order.status === 'In delivery'" class="mn-r-small" src="@/assets/icons/status/finished.svg"/>
8
+ <img v-if="order.status === 'Finished'" class="mn-r-small" src="@/assets/icons/status/finished.svg"/> -->
9
9
  <span class="w-100 t-medium p-big">{{order.status}}</span>
10
10
  </p>
11
11
 
@@ -0,0 +1,84 @@
1
+ <template>
2
+ <div class="bg-grey radius-medium w-100">
3
+ <h3 class="pd-medium">Tracking History</h3>
4
+ <div v-for="status in statuses" :key="status.value" class="w-100 br-t br-solid br-black-transp-10 pd-medium flex-v-center flex-nowrap flex">
5
+ <div v-if="isStatusInHistory(status.value)" class="flex-center flex i-big radius-extra br-solid br-2px br-black-transp-10 mn-r-small">✔</div>
6
+ <p class="h4 w-8r">{{status.name}}</p>
7
+ <button :disabled="!isNextPossibleStatus(status.value)" @click="setStatus(status)" class="mn-l-auto bg-main button radius-big">Set status</button>
8
+ </div>
9
+ </div>
10
+ </template>
11
+
12
+ <script setup>
13
+ import { ref, computed } from 'vue';
14
+
15
+ const props = defineProps({
16
+ statusHistory: {
17
+ type: Array
18
+ },
19
+ statusCurrent: {
20
+ type: String
21
+ }
22
+ })
23
+
24
+ // Инициализация состояния компонента
25
+ const statuses = ref([{
26
+ value: 'created',
27
+ name: 'Received',
28
+ nextstatus: 'Confirming order...',
29
+ description: 'Your order has been successfully created. Our manager will contact you within five minutes to confirm your order.'
30
+ },{
31
+ value: 'confirming',
32
+ name: 'Confirming',
33
+ nextstatus: 'Confirming order...',
34
+ description: 'Your order has been confirmed. We are now processing your items and preparing them for shipment.'
35
+ },{
36
+ value: 'confirmed',
37
+ name: 'Confirmed',
38
+ nextstatus: 'Order is confirmed. Packing order...',
39
+ description: 'Your order has been confirmed. We are now processing your items and preparing them for shipment.'
40
+ },{
41
+ value: 'packing',
42
+ name: 'Packing',
43
+ nextstatus: 'Packing order...',
44
+ description: 'Your order is now awaiting shipment. Once shipped, you will receive a notification with tracking information.'
45
+ },{
46
+ value: 'packed',
47
+ name: 'Packed',
48
+ nextstatus: 'Delivering order...',
49
+ description: 'Your order is now awaiting shipment. Once shipped, you will receive a notification with tracking information.'
50
+ },{
51
+ value: 'in delivery',
52
+ name: 'Delivering',
53
+ description: 'Your order is currently in transit. Our delivery team is working hard to get your items to you as soon as possible.'
54
+ },{
55
+ value: 'delivered',
56
+ name: 'Delivered',
57
+ description: 'Congratulations! Your order has been successfully delivered. If you have any concerns or feedback, feel free to contact us.'
58
+ }]);
59
+
60
+ const statusCurrent = ref(props.statusCurrent);
61
+ const statusHistory = ref(props.statusHistory);
62
+
63
+ // Проверка, был ли статус уже установлен
64
+ const isStatusInHistory = (statusValue) => {
65
+ return statusHistory.value.some(status => status.status === statusValue);
66
+ };
67
+
68
+ // Проверка, является ли статус следующим возможным действием
69
+ const isNextPossibleStatus = (statusValue) => {
70
+ const currentIndex = statuses.value.findIndex(status => status.value === statusCurrent.value);
71
+ console.log(status.status === statusCurrent.value)
72
+ console.log(statusCurrent.value)
73
+ console.log(status)
74
+ const nextIndex = currentIndex + 1;
75
+ return statuses.value[nextIndex] && statuses.value[nextIndex].value === statusValue;
76
+ };
77
+
78
+ // Функция установки нового статуса
79
+ const setStatus = async (newStatus) => {
80
+ console.log(status)
81
+ // orders.state.current.status = status.value
82
+ // await orders.actions.update(orders.state.current)
83
+ }
84
+ </script>
@@ -9,7 +9,7 @@
9
9
  <p class="mn-b-medium w-m-40r p-medium">Your order has been successfully created. Our manager will contact you within five minutes to confirm your order.</p>
10
10
 
11
11
 
12
- <p class="p-medium mn-b-thin t-semi">{{ statuses.find(status => status.value === order.status).nextstatus}}</p>
12
+ <!-- <p class="p-medium mn-b-thin t-semi">{{ statuses.find(status => status.value === order.status).nextstatus}}</p> -->
13
13
 
14
14
  <div class="radius-extra mn-b-medium flex-nowrap flex h-1r pos-relativew-40r">
15
15
  <div
@@ -126,19 +126,16 @@
126
126
  </div>
127
127
 
128
128
  </div>
129
-
130
129
 
131
- <div class="bg-grey radius-medium w-100">
132
- <h3 class="pd-medium">Tracking History</h3>
133
- <div v-for="status in statuses"
134
- class="w-100 br-t br-solid br-black-transp-10 pd-medium flex-nowrap flex"
135
- >
136
- <img class="mn-r-small" src="@/assets/icons/status/created.svg"/>
137
- <p class="h4 w-8r">{{status.name}}<br><span class="p-small">16:30, 29th Aug 2021</span></p>
138
- <button @click="setStatus(status)" class="bg-main button radius-big">Set status</button>
139
- </div>
140
- </div>
130
+ <div class="pd-big bg-red">
131
+ {{orders.state.current.status_history}}
132
+ </div>
141
133
 
134
+ <StatusHistory
135
+ v-if="orders.state.current.status_history"
136
+ :statusHistory="orders.state.current.status_history"
137
+ :statusCurrent="orders.state.current.status"
138
+ />
142
139
 
143
140
  <!-- <button
144
141
  @click="requestPayment(order)"
@@ -204,6 +201,7 @@
204
201
 
205
202
  import ChatWindow from '@pf/src/modules/chats/components/pages/ChatPage.vue';
206
203
 
204
+ import StatusHistory from '@pf/src/modules/orders/components/blocks/StatusHistory.vue'
207
205
 
208
206
  import * as orders from '@pf/src/modules/orders/store/orders'
209
207
  import * as products from '@pf/src/modules/products/store/products'
@@ -216,40 +214,6 @@
216
214
 
217
215
  let order = ref(orders.state.current)
218
216
 
219
- let statuses = [{
220
- value: 'created',
221
- name: 'Received',
222
- nextstatus: 'Confirming order...',
223
- description: 'Your order has been successfully created. Our manager will contact you within five minutes to confirm your order.'
224
- },{
225
- value: 'confirming',
226
- name: 'Confirming',
227
- nextstatus: 'Confirming order...',
228
- description: 'Your order has been confirmed. We are now processing your items and preparing them for shipment.'
229
- },{
230
- value: 'confirmed',
231
- name: 'Confirmed',
232
- nextstatus: 'Order is confirmed. Packing order...',
233
- description: 'Your order has been confirmed. We are now processing your items and preparing them for shipment.'
234
- },{
235
- value: 'packing',
236
- name: 'Packing',
237
- nextstatus: 'Packing order...',
238
- description: 'Your order is now awaiting shipment. Once shipped, you will receive a notification with tracking information.'
239
- },{
240
- value: 'packing',
241
- name: 'Packed',
242
- nextstatus: 'Delivering order...',
243
- description: 'Your order is now awaiting shipment. Once shipped, you will receive a notification with tracking information.'
244
- },{
245
- value: 'in delivery',
246
- name: 'Delivering',
247
- description: 'Your order is currently in transit. Our delivery team is working hard to get your items to you as soon as possible.'
248
- },{
249
- value: 'delivered',
250
- name: 'Delivered',
251
- description: 'Congratulations! Your order has been successfully delivered. If you have any concerns or feedback, feel free to contact us.'
252
- }]
253
217
 
254
218
  const productsOrganization = ref([])
255
219
  const orderOrganization = ref([])
@@ -297,14 +261,7 @@
297
261
 
298
262
  // const payment = computed(() => store.state.payments.current)
299
263
 
300
- async function setStatus(status) {
301
- console.log(status)
302
- orders.state.current.status = status.value
303
-
304
-
305
-
306
- await orders.actions.update(orders.state.current)
307
- }
264
+
308
265
 
309
266
  function requestPayment(order) {
310
267
  // store.dispatch("payments/newPayment", order);
@@ -74,17 +74,25 @@ const controllerFactory = (db) => {
74
74
 
75
75
  // Обновление заказа
76
76
  const update = async (req, res) => {
77
- console.log(req.body)
78
- console.log(req.params._id)
77
+ const order = await Order.findById(req.body._id);
78
+
79
+ if (!order) {
80
+ return res.status(404).send({ errorCode: "ORDER_NOT_FOUND", message: "Order not found." });
81
+ }
82
+
83
+ if (req.body.status && req.body.status !== order.status) {
84
+ order.status = req.body.status; // Обновление текущего статуса заказа
85
+ // Добавление записи в историю изменений статусов
86
+ order.status_history.push({
87
+ status: req.body.status,
88
+ changedBy: req.userId,
89
+ timestamp: new Date(),
90
+ comment: ''
91
+ });
92
+ }
79
93
 
80
94
  try {
81
- const order = await Order.findOneAndUpdate(
82
- { _id: req.params._id },
83
- req.body,
84
- ).exec();
85
- if (!order) {
86
- return res.status(404).send({ errorCode: "ORDER_UPDATE_FAILED", message: "Failed to update the order." });
87
- }
95
+ await order.save(); // Сохранение обновленного заказа
88
96
  res.status(200).send(order);
89
97
  } catch (err) {
90
98
  res.status(500).send({ errorCode: "UPDATE_ORDER_FAILED", message: "Error occurred while updating the order.", error: err });
@@ -24,6 +24,25 @@ module.exports = (db) => {
24
24
  status: {
25
25
  type: String
26
26
  },
27
+ status_history: [{
28
+ status: {
29
+ type: String,
30
+ trim: true
31
+ },
32
+ changedBy: {
33
+ type: db.mongoose.Schema.Types.ObjectId,
34
+ ref: 'User',
35
+ },
36
+ timestamp: {
37
+ type: Date,
38
+ default: Date.now
39
+ },
40
+ comment: {
41
+ type: String,
42
+ trim: true
43
+ }
44
+ // Здесь вы можете добавить любые другие поля, которые считаете нужными
45
+ }],
27
46
  comment: {
28
47
  type: String,
29
48
  trim: true
@@ -5,7 +5,7 @@ const middlewareFactory = require('@pf/src/modules/middlewares/server');
5
5
  // Routes
6
6
  module.exports = function(app, db) {
7
7
  const controller = controllerFactory(db);
8
- const { verifySignUp, verifyUser } = middlewareFactory(db);
8
+ const { authJwt } = middlewareFactory(db);
9
9
 
10
10
  app.use(function(req, res, next) {
11
11
  res.header(
@@ -33,6 +33,9 @@ module.exports = function(app, db) {
33
33
  );
34
34
  app.post(
35
35
  "/api/orders/update",
36
+ [
37
+ authJwt.verifyToken
38
+ ],
36
39
  controller.update
37
40
  );
38
41
  // Update order
@@ -127,7 +127,7 @@
127
127
  // View
128
128
  showProducts: {
129
129
  type: Boolean,
130
- default: true
130
+ default: false
131
131
  },
132
132
  showFollowers: {
133
133
  type: Boolean,
@@ -172,7 +172,7 @@
172
172
  </MenuItem>
173
173
  </Menu>
174
174
 
175
- <Menu class="mn-b-regular bg-grey">
175
+ <Menu v-if="APP_NAME === 'Weeder'"class="mn-b-regular bg-grey">
176
176
  <MenuItem @click="router.push({name: 'User Wallet', params: {_id: route.params._id}})" class="cursor-pointer">
177
177
  <IconGroups class="i-semi" :icon="true"/>
178
178
  <span>Wallet</span>