ordering-ui-admin-external 1.43.30 → 1.43.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/_modules/index.js CHANGED
@@ -321,6 +321,12 @@ Object.defineProperty(exports, "BusinessLocation", {
321
321
  return _Stores.BusinessLocation;
322
322
  }
323
323
  });
324
+ Object.defineProperty(exports, "BusinessLogs", {
325
+ enumerable: true,
326
+ get: function get() {
327
+ return _Stores.BusinessLogs;
328
+ }
329
+ });
324
330
  Object.defineProperty(exports, "BusinessManagerBusinesses", {
325
331
  enumerable: true,
326
332
  get: function get() {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.widgetURL = exports.verifyDecimals = exports.stringToSlug = exports.sortInputFields = exports.shape = exports.setStorageItem = exports.scrollTo = exports.ribbonValues = exports.reviewCommentList = exports.removeStorageItem = exports.removeQueryToUrl = exports.queryStringToObject = exports.orderStatus = exports.orderRejectCommentList = exports.optimizeImage = exports.getUniqueId = exports.getStorageItem = exports.getStarWidth = exports.getSeconds = exports.getOrderStatus = exports.getOrderStatuPickUp = exports.getMinutes = exports.getLocale = exports.getIconCard = exports.getHours = exports.getCurrenySymbol = exports.getCurrentDiffDays = exports.getAgoMinutes = exports.formatUrlVideo = exports.formatSeconds = exports.firstLetterCapital = exports.findExitingCountryPhoneCode = exports.findExitingCode = exports.fieldsToSort = exports.disableReasons = exports.convertHoursToMinutes = exports.convertHMS = exports.checkValidUrlFormat = exports.checkSiteUrl = exports.checkPreSiteUrl = exports.capitalize = exports.bytesConverter = exports.addQueryToUrl = exports.TwentyFourHours = exports.TwelveHours = exports.DriverTipsOptions = void 0;
6
+ exports.widgetURL = exports.verifyDecimals = exports.stringToSlug = exports.sortInputFields = exports.shape = exports.setStorageItem = exports.scrollTo = exports.ribbonValues = exports.reviewCommentList = exports.removeStorageItem = exports.removeQueryToUrl = exports.queryStringToObject = exports.orderStatus = exports.orderRejectCommentList = exports.optimizeImage = exports.getUniqueId = exports.getStorageItem = exports.getStarWidth = exports.getSeconds = exports.getOrderStatus = exports.getOrderStatuPickUp = exports.getMinutes = exports.getLocale = exports.getIconCard = exports.getHours = exports.getCurrenySymbol = exports.getCurrentDiffDays = exports.getAttributeName = exports.getAgoMinutes = exports.formatUrlVideo = exports.formatSeconds = exports.firstLetterCapital = exports.findExitingCountryPhoneCode = exports.findExitingCode = exports.fieldsToSort = exports.disableReasons = exports.convertHoursToMinutes = exports.convertHMS = exports.checkValidUrlFormat = exports.checkSiteUrl = exports.checkPreSiteUrl = exports.capitalize = exports.bytesConverter = exports.addQueryToUrl = exports.TwentyFourHours = exports.TwelveHours = exports.DriverTipsOptions = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _FaCcMastercard = _interopRequireDefault(require("@meronex/icons/fa/FaCcMastercard"));
9
9
  var _FaCcVisa = _interopRequireDefault(require("@meronex/icons/fa/FaCcVisa"));
@@ -437,104 +437,104 @@ var reviewCommentList = exports.reviewCommentList = function reviewCommentList(t
437
437
  var reviews = {
438
438
  1: {
439
439
  1: {
440
- title: t('CUSTOMER_QUICK_COMMENT_TITLE_1', "What went wrong?"),
440
+ title: t('CUSTOMER_QUICK_COMMENT_TITLE_1', 'What went wrong?'),
441
441
  list: [{
442
442
  key: 0,
443
- content: t('CUSTOMER_QUICK_COMMENT_1_0', "Not handled with care")
443
+ content: t('CUSTOMER_QUICK_COMMENT_1_0', 'Not handled with care')
444
444
  }, {
445
445
  key: 1,
446
- content: t('CUSTOMER_QUICK_COMMENT_1_1', "Poor communication")
446
+ content: t('CUSTOMER_QUICK_COMMENT_1_1', 'Poor communication')
447
447
  }, {
448
448
  key: 2,
449
- content: t('CUSTOMER_QUICK_COMMENT_1_2', "COVID-19 issue")
449
+ content: t('CUSTOMER_QUICK_COMMENT_1_2', 'COVID-19 issue')
450
450
  }, {
451
451
  key: 3,
452
452
  content: t('CUSTOMER_QUICK_COMMENT_1_3', "Didn't follow instructions")
453
453
  }, {
454
454
  key: 4,
455
- content: t('CUSTOMER_QUICK_COMMENT_1_4', "Rude")
455
+ content: t('CUSTOMER_QUICK_COMMENT_1_4', 'Rude')
456
456
  }, {
457
457
  key: 5,
458
- content: t('CUSTOMER_QUICK_COMMENT_1_5', "Not on-time")
458
+ content: t('CUSTOMER_QUICK_COMMENT_1_5', 'Not on-time')
459
459
  }]
460
460
  },
461
461
  2: {
462
- title: t('CUSTOMER_QUICK_COMMENT_TITLE_2', "What went wrong?"),
462
+ title: t('CUSTOMER_QUICK_COMMENT_TITLE_2', 'What went wrong?'),
463
463
  list: [{
464
464
  key: 0,
465
- content: t('CUSTOMER_QUICK_COMMENT_2_0', "Not handled with care")
465
+ content: t('CUSTOMER_QUICK_COMMENT_2_0', 'Not handled with care')
466
466
  }, {
467
467
  key: 1,
468
- content: t('CUSTOMER_QUICK_COMMENT_2_1', "Poor communication")
468
+ content: t('CUSTOMER_QUICK_COMMENT_2_1', 'Poor communication')
469
469
  }, {
470
470
  key: 2,
471
- content: t('CUSTOMER_QUICK_COMMENT_2_2', "COVID-19 issue")
471
+ content: t('CUSTOMER_QUICK_COMMENT_2_2', 'COVID-19 issue')
472
472
  }, {
473
473
  key: 3,
474
474
  content: t('CUSTOMER_QUICK_COMMENT_2_3', "Didn't follow instructions")
475
475
  }, {
476
476
  key: 4,
477
- content: t('CUSTOMER_QUICK_COMMENT_2_4', "Rude")
477
+ content: t('CUSTOMER_QUICK_COMMENT_2_4', 'Rude')
478
478
  }, {
479
479
  key: 5,
480
- content: t('CUSTOMER_QUICK_COMMENT_2_5', "Not on-time")
480
+ content: t('CUSTOMER_QUICK_COMMENT_2_5', 'Not on-time')
481
481
  }]
482
482
  },
483
483
  3: {
484
- title: t('CUSTOMER_QUICK_COMMENT_TITLE_3', "What could have been better?"),
484
+ title: t('CUSTOMER_QUICK_COMMENT_TITLE_3', 'What could have been better?'),
485
485
  list: [{
486
486
  key: 0,
487
- content: t('CUSTOMER_QUICK_COMMENT_3_0', "Not handled with care")
487
+ content: t('CUSTOMER_QUICK_COMMENT_3_0', 'Not handled with care')
488
488
  }, {
489
489
  key: 1,
490
- content: t('CUSTOMER_QUICK_COMMENT_3_1', "Poor communication")
490
+ content: t('CUSTOMER_QUICK_COMMENT_3_1', 'Poor communication')
491
491
  }, {
492
492
  key: 2,
493
- content: t('CUSTOMER_QUICK_COMMENT_3_2', "COVID-19 issue")
493
+ content: t('CUSTOMER_QUICK_COMMENT_3_2', 'COVID-19 issue')
494
494
  }, {
495
495
  key: 3,
496
496
  content: t('CUSTOMER_QUICK_COMMENT_3_3', "Didn't follow instructions")
497
497
  }, {
498
498
  key: 4,
499
- content: t('CUSTOMER_QUICK_COMMENT_3_4', "Rude")
499
+ content: t('CUSTOMER_QUICK_COMMENT_3_4', 'Rude')
500
500
  }, {
501
501
  key: 5,
502
- content: t('CUSTOMER_QUICK_COMMENT_3_5', "Not on-time")
502
+ content: t('CUSTOMER_QUICK_COMMENT_3_5', 'Not on-time')
503
503
  }]
504
504
  },
505
505
  4: {
506
- title: t('CUSTOMER_QUICK_COMMENT_TITLE_4', " Tell us more"),
506
+ title: t('CUSTOMER_QUICK_COMMENT_TITLE_4', ' Tell us more'),
507
507
  list: [{
508
508
  key: 0,
509
- content: t('CUSTOMER_QUICK_COMMENT_4_0', "Not handled with care")
509
+ content: t('CUSTOMER_QUICK_COMMENT_4_0', 'Not handled with care')
510
510
  }, {
511
511
  key: 1,
512
- content: t('CUSTOMER_QUICK_COMMENT_4_1', "Poor communication")
512
+ content: t('CUSTOMER_QUICK_COMMENT_4_1', 'Poor communication')
513
513
  }, {
514
514
  key: 2,
515
- content: t('CUSTOMER_QUICK_COMMENT_4_2', "COVID-19 issue")
515
+ content: t('CUSTOMER_QUICK_COMMENT_4_2', 'COVID-19 issue')
516
516
  }, {
517
517
  key: 3,
518
518
  content: t('CUSTOMER_QUICK_COMMENT_4_3', "Didn't follow instructions")
519
519
  }, {
520
520
  key: 4,
521
- content: t('CUSTOMER_QUICK_COMMENT_4_4', "Rude")
521
+ content: t('CUSTOMER_QUICK_COMMENT_4_4', 'Rude')
522
522
  }, {
523
523
  key: 5,
524
- content: t('CUSTOMER_QUICK_COMMENT_4_5', "Not on-time")
524
+ content: t('CUSTOMER_QUICK_COMMENT_4_5', 'Not on-time')
525
525
  }]
526
526
  },
527
527
  5: {
528
- title: t('CUSTOMER_QUICK_COMMENT_TITLE_5', "What went well?"),
528
+ title: t('CUSTOMER_QUICK_COMMENT_TITLE_5', 'What went well?'),
529
529
  list: [{
530
530
  key: 0,
531
- content: t('CUSTOMER_QUICK_COMMENT_5_0', "Good communication")
531
+ content: t('CUSTOMER_QUICK_COMMENT_5_0', 'Good communication')
532
532
  }, {
533
533
  key: 1,
534
- content: t('CUSTOMER_QUICK_COMMENT_5_1', "Friendly")
534
+ content: t('CUSTOMER_QUICK_COMMENT_5_1', 'Friendly')
535
535
  }, {
536
536
  key: 2,
537
- content: t('CUSTOMER_QUICK_COMMENT_5_2', "Above and beyond")
537
+ content: t('CUSTOMER_QUICK_COMMENT_5_2', 'Above and beyond')
538
538
  }]
539
539
  }
540
540
  }
@@ -895,4 +895,81 @@ var disableReasons = exports.disableReasons = function disableReasons() {
895
895
  return disableReasonDictionary;
896
896
  };
897
897
  var TwelveHours = exports.TwelveHours = ['12:00 AM', '01:00 AM', '02:00 AM', '03:00 AM', '04:00 AM', '05:00 AM', '06:00 AM', '07:00 AM', '08:00 AM', '09:00 AM', '10:00 AM', '11:00 AM', '12:00 PM', '01:00 PM', '02:00 PM', '03:00 PM', '04:00 PM', '05:00 PM', '06:00 PM', '07:00 PM', '08:00 PM', '09:00 PM', '10:00 PM', '11:00 PM'];
898
- var TwentyFourHours = exports.TwentyFourHours = ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'];
898
+ var TwentyFourHours = exports.TwentyFourHours = ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'];
899
+ var getAttributeName = exports.getAttributeName = function getAttributeName(key) {
900
+ var _useLanguage5 = (0, _orderingComponentsAdminExternal.useLanguage)(),
901
+ _useLanguage6 = _slicedToArray(_useLanguage5, 2),
902
+ t = _useLanguage6[1];
903
+ var attributes = [{
904
+ key: 'autoassign_amount_drivers',
905
+ content: t('AUTO_ASSIGN_GROUP_ORDERS_TO_DRIVERS', 'Auto assign the order of group to this amount of drivers')
906
+ }, {
907
+ key: 'orders_group_max_orders',
908
+ content: t('MAX_NUMBER_ORDERS', 'Maximum Number of Orders')
909
+ }, {
910
+ key: 'autoassign_autoaccept_by_driver',
911
+ content: t('ORDER_CONFIRMED_ACCEPTED_BY_DRIVER', 'Accepted by Driver')
912
+ }, {
913
+ key: 'orders_group_max_time_between',
914
+ content: t('MAX_ORDER_TIME_BETWEEN', 'Maximum time between orders in seconds')
915
+ }, {
916
+ key: 'orders_group_max_distance_between_pickup',
917
+ content: t('MAX_DISTANCE_BETWEEN_BUSINESS', 'Maximum distance between businesses in meters')
918
+ }, {
919
+ key: 'orders_group_max_distance_between_delivery',
920
+ content: t('MAX_DISTANCE_BETWEEN_DELIVERY', 'Maximum distance between deliveries in meters')
921
+ }, {
922
+ key: 'orders_group_use_maps_api',
923
+ content: t('USE_MAPS_API', 'Use maps api')
924
+ }, {
925
+ key: 'orders_group_max_time_between_pickup',
926
+ content: t('MAX_DISTANCE_BETWEEN_BUSINESS', 'Maximum distance between businesses in meters')
927
+ }, {
928
+ key: 'orders_group_max_time_between_delivery',
929
+ content: t('MAX_DISTANCE_BETWEEN_DELIVERY', 'Maximum distance between deliveries in meters')
930
+ }, {
931
+ key: 'autoassign_forced_assignment',
932
+ content: t('AUTO_ASSIGN_FORCED_ASSIGNMENT', 'Forced assignment')
933
+ }, {
934
+ key: 'autoassign_customer_max_distance_from_business',
935
+ content: t('MAX_CUSTOMER_DISTANCE_FROM_BUSINESS', 'Max distance between customer and business')
936
+ }, {
937
+ key: 'autoassign_initial_radius',
938
+ content: t('INITIAL_RADIUS', 'Initial radius in meters')
939
+ }, {
940
+ key: 'autoassign_increment_radius',
941
+ content: t('INCREMENT_RADIUS', 'Radius increase in meters')
942
+ }, {
943
+ key: 'autoassign_max_radius',
944
+ content: t('MAX_RADIUS', 'Maximum radius in meters')
945
+ }, {
946
+ key: 'autoassign_autoreject_time',
947
+ content: t('AUTO_REJECT_ORDER_GROUP_AFTER', 'Auto reject Orders After')
948
+ }, {
949
+ key: 'autoassign_max_orders',
950
+ content: t('MAX_AMOUNT_ORDERS_PER_DRIVER', 'Maximum amount of orders per drivers')
951
+ }, {
952
+ key: 'autoassign_max_in_pending',
953
+ content: t('ORDER_PENDING', 'Pending')
954
+ }, {
955
+ key: 'available',
956
+ content: t('AVAILABLE', 'Available')
957
+ }, {
958
+ key: 'enabled',
959
+ content: t('ENABLED', 'Enabled')
960
+ }, {
961
+ key: 'last_available_at',
962
+ content: t('LAST_AVAILABLE_AT', 'Last available at')
963
+ }, {
964
+ key: 'busy',
965
+ content: t('BUSY', 'Busy')
966
+ }];
967
+ var found = attributes.find(function (attribute) {
968
+ return attribute.key === key;
969
+ });
970
+ if (found) {
971
+ return found.content;
972
+ } else {
973
+ return key;
974
+ }
975
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-admin-external",
3
- "version": "1.43.30",
3
+ "version": "1.43.31",
4
4
  "description": "Ordering UI Admin Components",
5
5
  "main": "./_modules/index.js",
6
6
  "exports": {
@@ -83,7 +83,7 @@
83
83
  "lodash": "^4.17.20",
84
84
  "moment": "^2.29.1",
85
85
  "moment-range": "^4.0.2",
86
- "ordering-components-admin-external": "1.43.18",
86
+ "ordering-components-admin-external": "1.43.20",
87
87
  "polished": "^3.6.7",
88
88
  "prop-types": "^15.7.2",
89
89
  "react-big-calendar": "^1.4.2",
@@ -2,6 +2,7 @@ import React, { useEffect } from 'react'
2
2
  import { useLanguage, useUtils, DriversGroupLogs as DriversGroupLogsController, useConfig } from 'ordering-components-admin-external'
3
3
  import Skeleton from 'react-loading-skeleton'
4
4
  import { Modal, Pagination } from '../../Shared'
5
+ import { getAttributeName } from '../../../utils'
5
6
 
6
7
  import {
7
8
  DriversGroupLogsContainer,
@@ -40,38 +41,6 @@ export const DriversGroupLogsUI = (props) => {
40
41
  const [{ configs }] = useConfig()
41
42
  const formatTime = configs?.general_hour_format?.value
42
43
 
43
- const getAttributeName = (key) => {
44
- const attributes = [
45
- { key: 'autoassign_amount_drivers', content: t('AUTO_ASSIGN_GROUP_ORDERS_TO_DRIVERS', 'Auto assign the order of group to this amount of drivers') },
46
- { key: 'orders_group_max_orders', content: t('MAX_NUMBER_ORDERS', 'Maximum Number of Orders') },
47
- { key: 'autoassign_autoaccept_by_driver', content: t('ORDER_CONFIRMED_ACCEPTED_BY_DRIVER', 'Accepted by Driver') },
48
- { key: 'orders_group_max_time_between', content: t('MAX_ORDER_TIME_BETWEEN', 'Maximum time between orders in seconds') },
49
- { key: 'orders_group_max_distance_between_pickup', content: t('MAX_DISTANCE_BETWEEN_BUSINESS', 'Maximum distance between businesses in meters') },
50
- { key: 'orders_group_max_distance_between_delivery', content: t('MAX_DISTANCE_BETWEEN_DELIVERY', 'Maximum distance between deliveries in meters') },
51
- { key: 'orders_group_use_maps_api', content: t('USE_MAPS_API', 'Use maps api') },
52
- { key: 'orders_group_max_time_between_pickup', content: t('MAX_DISTANCE_BETWEEN_BUSINESS', 'Maximum distance between businesses in meters') },
53
- { key: 'orders_group_max_time_between_delivery', content: t('MAX_DISTANCE_BETWEEN_DELIVERY', 'Maximum distance between deliveries in meters') },
54
- { key: 'autoassign_forced_assignment', content: t('AUTO_ASSIGN_FORCED_ASSIGNMENT', 'Forced assignment') },
55
- { key: 'autoassign_customer_max_distance_from_business', content: t('MAX_CUSTOMER_DISTANCE_FROM_BUSINESS', 'Max distance between customer and business') },
56
- { key: 'autoassign_initial_radius', content: t('INITIAL_RADIUS', 'Initial radius in meters') },
57
- { key: 'autoassign_increment_radius', content: t('INCREMENT_RADIUS', 'Radius increase in meters') },
58
- { key: 'autoassign_max_radius', content: t('MAX_RADIUS', 'Maximum radius in meters') },
59
- { key: 'autoassign_autoreject_time', content: t('AUTO_REJECT_ORDER_GROUP_AFTER', 'Auto reject Orders After') },
60
- { key: 'autoassign_max_orders', content: t('MAX_AMOUNT_ORDERS_PER_DRIVER', 'Maximum amount of orders per drivers') },
61
- { key: 'autoassign_max_in_pending', content: t('ORDER_PENDING', 'Pending') },
62
- { key: 'available', content: t('AVAILABLE', 'Available') },
63
- { key: 'enabled', content: t('ENABLED', 'Enabled') },
64
- { key: 'last_available_at', content: t('LAST_AVAILABLE_AT', 'Last available at') },
65
- { key: 'busy', content: t('BUSY', 'Busy') }
66
- ]
67
- const found = attributes.find(attribute => attribute.key === key)
68
- if (found) {
69
- return found.content
70
- } else {
71
- return key
72
- }
73
- }
74
-
75
44
  const handleChangePage = (page) => {
76
45
  getDriversGroupLogs(page, 10)
77
46
  }
@@ -19,6 +19,7 @@ import { BusinessOrderingChannels } from '../BusinessOrderingChannels'
19
19
  import { BusinessFrontLayout } from '../BusinessFrontLayout'
20
20
  // import { BusinessPublishing } from '../BusinessPublishing'
21
21
  import { BusinessPlaceGroupList } from '../BusinessPlaceGroupList'
22
+ import { BusinessLogs } from '../BusinessLogs'
22
23
  import { SpoonityApiKey } from '../SpoonityApiKey'
23
24
 
24
25
  import { MoreSidebarLayout, Personalization, Alert } from '../../Shared'
@@ -348,6 +349,11 @@ export const BusinessDetailsUI = (props) => {
348
349
  spoonityKeyState={spoonityKeyState}
349
350
  />
350
351
  )}
352
+ {selectedItem === 'logs' && (
353
+ <BusinessLogs
354
+ businessId={businessState?.business?.id}
355
+ />
356
+ )}
351
357
  </MoreSidebarLayout>
352
358
  )}
353
359
 
@@ -0,0 +1,304 @@
1
+ import React, { useEffect } from 'react'
2
+ import { useLanguage, useUtils, useConfig, BusinessLogs as BusinessLogsController } from 'ordering-components-admin-external'
3
+ import Skeleton from 'react-loading-skeleton'
4
+ import { Modal, Pagination } from '../../Shared'
5
+ import { getAttributeName } from '../../../utils'
6
+ import {
7
+ BusinessLogsContainer,
8
+ TableWrapper,
9
+ Table,
10
+ UserInfoContainer,
11
+ DateTimeWrapper,
12
+ NoData,
13
+ WrapperPagination,
14
+ DataListTable,
15
+ EventTypeContainer,
16
+ SeeChanges,
17
+ SchedulesWrapper,
18
+ Schedules,
19
+ ScheduleDay,
20
+ ScheduleLapses,
21
+ ScheduleTitle
22
+ } from './styles'
23
+ import moment from 'moment'
24
+
25
+ export const BusinessLogsUI = (props) => {
26
+ const {
27
+ logsList,
28
+ paginationProps,
29
+ getBusinessLogs,
30
+ actionDisabled
31
+ } = props
32
+
33
+ const [, t] = useLanguage()
34
+ const [{ parseDate }] = useUtils()
35
+ const [open, setOpen] = React.useState(false)
36
+ const [schedules, setSchedules] = React.useState({
37
+ newSchedule: [],
38
+ oldSchedule: []
39
+ })
40
+ const [{ configs }] = useConfig()
41
+ const formatTime = configs?.general_hour_format?.value
42
+
43
+ const handleChangePage = (page) => {
44
+ getBusinessLogs(page, 10)
45
+ }
46
+
47
+ const handleChangePageSize = (pageSize) => {
48
+ const expectedPage = Math.ceil(paginationProps.from / pageSize)
49
+ getBusinessLogs(expectedPage, pageSize)
50
+ }
51
+
52
+ const getValidLogData = (data) => {
53
+ return typeof data === 'object'
54
+ ? Object.values(data)
55
+ : typeof data === 'string' ? JSON.parse(data) : data
56
+ }
57
+
58
+ const handleSchedules = (_schedules) => {
59
+ setSchedules({
60
+ newSchedule: typeof _schedules?.new === 'string' ? JSON.parse(_schedules?.new) : _schedules?.new,
61
+ oldSchedule: typeof _schedules?.old === 'string' ? JSON.parse(_schedules?.old) : _schedules?.old
62
+ })
63
+ }
64
+
65
+ const scheduleModalData = (_schedules) => {
66
+ setOpen(true)
67
+ handleSchedules(_schedules)
68
+ }
69
+
70
+ useEffect(() => {
71
+ if (logsList.loading || logsList.logs.length > 0 || paginationProps.totalPages <= 1 || logsList.error) return
72
+ if (paginationProps.currentPage !== paginationProps.totalPages) {
73
+ handleChangePage(paginationProps.currentPage)
74
+ } else {
75
+ handleChangePage(paginationProps.currentPage - 1)
76
+ }
77
+ }, [logsList.logs, paginationProps])
78
+
79
+ const daysOptions = [
80
+ t('DAY7', 'Sunday'),
81
+ t('DAY1', 'Monday'),
82
+ t('DAY2', 'Tuesday'),
83
+ t('DAY3', 'Wednesday'),
84
+ t('DAY4', 'Thursday'),
85
+ t('DAY5', 'Friday'),
86
+ t('DAY6', 'Saturday')
87
+ ]
88
+
89
+ const checkTime = (val) => (val < 10 ? `0${val}` : val)
90
+ const timeFormated = (time) => {
91
+ return moment(`1900-01-01 ${checkTime(time.hour)}:${checkTime(time.minute)}`).format(formatTime)
92
+ }
93
+
94
+ const getSchedule = (_schedules) => {
95
+ return ((!_schedules?.length && _schedules?.length < 1) ? <p>{t('NONE', 'None')}</p> : _schedules?.map((schedule, i) => {
96
+ return (
97
+ <ScheduleDay key={i}>
98
+ <span>{daysOptions[i]}</span>
99
+ <ScheduleLapses>
100
+ {schedule?.enabled && schedule?.lapses?.map((item, i) => {
101
+ return <p key={i}>{`${timeFormated(item?.open)} - ${timeFormated(item?.close)}`}</p>
102
+ })}
103
+ {!schedule?.enabled && (
104
+ <p>{t('UNAVAILABLE', 'Unavailable')}</p>
105
+ )}
106
+ </ScheduleLapses>
107
+ </ScheduleDay>
108
+ )
109
+ })
110
+ )
111
+ }
112
+
113
+ return (
114
+ <>
115
+ <BusinessLogsContainer
116
+ disabled={actionDisabled}
117
+ >
118
+ <h1>{t('LOGS', 'Logs')}</h1>
119
+ <TableWrapper>
120
+ {(logsList.loading || logsList.logs.length > 0) ? (
121
+ <Table>
122
+ <thead>
123
+ <tr>
124
+ <th>{t('CONTROL_PANEL_USERS', 'Users')}</th>
125
+ <th>{t('EVENTS_TYPE', 'Events type')}</th>
126
+ <th>{t('DETAILS', 'Details')}</th>
127
+ <th>{t('NEW', 'New')}</th>
128
+ <th>{t('OLD', 'Old')}</th>
129
+ <th>{t('EXPORT_DATE', 'Date')}</th>
130
+ <th>{t('USER_AGENT', 'User agent')}</th>
131
+ </tr>
132
+ </thead>
133
+ {logsList.loading ? (
134
+ [...Array(10).keys()].map(i => (
135
+ <tbody key={i}>
136
+ <tr>
137
+ <td>
138
+ <UserInfoContainer>
139
+ <p><Skeleton width={100} /></p>
140
+ <p><Skeleton width={120} /></p>
141
+ </UserInfoContainer>
142
+ </td>
143
+ <td>
144
+ <DataListTable>
145
+ <tbody>
146
+ <tr>
147
+ <td><Skeleton width={100} /></td>
148
+ <td><Skeleton width={20} /></td>
149
+ <td><Skeleton width={20} /></td>
150
+ </tr>
151
+ </tbody>
152
+ </DataListTable>
153
+ </td>
154
+ <td>
155
+ <DateTimeWrapper>
156
+ <Skeleton />
157
+ </DateTimeWrapper>
158
+ </td>
159
+ <td>
160
+ <Skeleton />
161
+ </td>
162
+ </tr>
163
+ </tbody>
164
+ ))
165
+ ) : (
166
+ !logsList.error && logsList.logs?.map(log => (
167
+ <tbody key={log.id}>
168
+ <tr>
169
+ <td>
170
+ <UserInfoContainer>
171
+ <p>{log?.author?.name || log?.user?.name} {log?.author?.lastname || log?.user?.lastname}</p>
172
+ <p>{log?.author?.email || log?.user?.email}</p>
173
+ </UserInfoContainer>
174
+ </td>
175
+ <td>
176
+ <EventTypeContainer>
177
+ <p>{t((log?.event || '').toUpperCase())}</p>
178
+ </EventTypeContainer>
179
+ </td>
180
+ <td>
181
+ <DataListTable>
182
+ {log?.data && getValidLogData(log?.data).filter(item => item.attribute !== 'schedule_ranges').map((item, i) => (
183
+ <tbody key={i}>
184
+ <tr>
185
+ <td>{getAttributeName(item?.attribute)}</td>
186
+ </tr>
187
+ </tbody>
188
+ ))}
189
+ </DataListTable>
190
+ </td>
191
+ <td>
192
+ <DataListTable>
193
+ {log?.data && getValidLogData(log?.data).filter(item => item.attribute !== 'schedule_ranges').map((item, i) => (
194
+ <tbody key={i}>
195
+ <tr>
196
+ {(item.attribute !== 'schedule')
197
+ ? (
198
+ <td>
199
+ {
200
+ (typeof item?.new !== 'undefined' && item?.new !== null)
201
+ ? `${item?.new}`
202
+ : item?.added?.length > 0 ? item?.added?.toString() : t('NONE', 'None')
203
+ }
204
+ </td>
205
+ )
206
+ : (
207
+ <td>
208
+ <SeeChanges onClick={() => scheduleModalData(item, 'new')}>{t('SEE_CHANGES', 'See changes')}</SeeChanges>
209
+ </td>
210
+ )}
211
+ </tr>
212
+ </tbody>
213
+ ))}
214
+ </DataListTable>
215
+ </td>
216
+ <td>
217
+ <DataListTable>
218
+ {log?.data && getValidLogData(log?.data).filter(item => item.attribute !== 'schedule_ranges').map((item, i) => (
219
+ <tbody key={i}>
220
+ <tr>
221
+ {item.attribute !== 'schedule'
222
+ ? (
223
+ <td>
224
+ {
225
+ (typeof item?.old !== 'undefined' && item?.old !== null)
226
+ ? `${item?.old}`
227
+ : item?.removed?.length > 0 ? item?.removed?.toString() : t('NONE', 'None')
228
+ }
229
+ </td>
230
+ )
231
+ : (
232
+ <td>
233
+ <SeeChanges onClick={() => scheduleModalData(item, 'old')}>{t('SEE_CHANGES', 'See changes')}</SeeChanges>
234
+ </td>
235
+ )}
236
+ </tr>
237
+ </tbody>
238
+ ))}
239
+ </DataListTable>
240
+ </td>
241
+ <td>
242
+ <DateTimeWrapper>
243
+ {parseDate(log.created_at, { utc: false })}
244
+ </DateTimeWrapper>
245
+ </td>
246
+ <td>
247
+ {log?.user_agent}
248
+ </td>
249
+ </tr>
250
+ </tbody>
251
+ ))
252
+ )}
253
+ </Table>
254
+ ) : (
255
+ <NoData>{t('NO_DATA', 'No Data')}</NoData>
256
+ )}
257
+ </TableWrapper>
258
+ {logsList?.logs.length > 0 && (
259
+ <WrapperPagination>
260
+ <Pagination
261
+ isHidePagecontrol
262
+ currentPage={paginationProps.currentPage}
263
+ totalPages={paginationProps.totalPages}
264
+ handleChangePage={handleChangePage}
265
+ handleChangePageSize={handleChangePageSize}
266
+ />
267
+ </WrapperPagination>
268
+ )}
269
+ </BusinessLogsContainer>
270
+ <Modal
271
+ width='40%'
272
+ height='60vh'
273
+ style={{ overflowY: 'auto' }}
274
+ padding='30px'
275
+ title={t('SCHEDULE_CHANGES', 'Schedule changes')}
276
+ open={open}
277
+ onClose={() => setOpen(false)}
278
+ >
279
+ <SchedulesWrapper border={!!schedules?.oldSchedule}>
280
+ {schedules?.newSchedule && (
281
+ <Schedules>
282
+ <ScheduleTitle>{t('NEW', 'New')}</ScheduleTitle>
283
+ {getSchedule(schedules?.newSchedule)}
284
+ </Schedules>
285
+ )}
286
+ {schedules?.oldSchedule && (
287
+ <Schedules>
288
+ <ScheduleTitle>{t('OLD', 'Old')}</ScheduleTitle>
289
+ {getSchedule(schedules?.oldSchedule)}
290
+ </Schedules>
291
+ )}
292
+ </SchedulesWrapper>
293
+ </Modal>
294
+ </>
295
+ )
296
+ }
297
+
298
+ export const BusinessLogs = (props) => {
299
+ const businessLogsProps = {
300
+ ...props,
301
+ UIComponent: BusinessLogsUI
302
+ }
303
+ return <BusinessLogsController {...businessLogsProps} />
304
+ }