ordering-ui-admin-external 1.43.68 → 1.43.69
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/_bundles/{ordering-ui-admin.59c9bf5b06564400dbd4.js → ordering-ui-admin.e755a642f2e4b1499824.js} +2 -2
- package/_modules/components/Orders/AllInOne/index.js +2 -3
- package/_modules/components/Orders/OrdersDashboard/index.js +1 -1
- package/_modules/components/Orders/OrdersHeaderFilterGroup/styles.js +1 -1
- package/_modules/components/Orders/OrdersTable/index.js +11 -7
- package/_modules/components/Shared/Pagination/index.js +35 -35
- package/package.json +2 -2
- package/src/components/Orders/AllInOne/index.js +2 -3
- package/src/components/Orders/OrdersDashboard/index.js +1 -1
- package/src/components/Orders/OrdersHeaderFilterGroup/styles.js +4 -1
- package/src/components/Orders/OrdersTable/index.js +18 -11
- package/src/components/Shared/Pagination/index.js +30 -41
- /package/_bundles/{ordering-ui-admin.59c9bf5b06564400dbd4.js.LICENSE.txt → ordering-ui-admin.e755a642f2e4b1499824.js.LICENSE.txt} +0 -0
|
@@ -73,7 +73,7 @@ var OrdersManagerUI = function OrdersManagerUI(props) {
|
|
|
73
73
|
var _useConfig = (0, _orderingComponentsAdminExternal.useConfig)(),
|
|
74
74
|
_useConfig2 = _slicedToArray(_useConfig, 1),
|
|
75
75
|
configState = _useConfig2[0];
|
|
76
|
-
var
|
|
76
|
+
var isFilterDriverGroup = ((configState === null || configState === void 0 || (_configState$configs = configState.configs) === null || _configState$configs === void 0 || (_configState$configs = _configState$configs.filter_order_options) === null || _configState$configs === void 0 ? void 0 : _configState$configs.value.split('|').map(function (value) {
|
|
77
77
|
return value;
|
|
78
78
|
})) || []).includes('driver_group_general');
|
|
79
79
|
var query = new URLSearchParams((0, _reactRouterDom.useLocation)().search);
|
|
@@ -268,9 +268,8 @@ var OrdersManagerUI = function OrdersManagerUI(props) {
|
|
|
268
268
|
disableSocketRoomDriver: true,
|
|
269
269
|
showCompressedInfo: true,
|
|
270
270
|
filterValues: filterValues,
|
|
271
|
-
searchFilterValue: searchValue,
|
|
272
271
|
driverGroupList: driverGroupList,
|
|
273
|
-
|
|
272
|
+
isFilterDriverGroup: isFilterDriverGroup,
|
|
274
273
|
drivers: driversList.drivers,
|
|
275
274
|
setMapsData: setMapsData,
|
|
276
275
|
handleEmtpyOrderSelected: handleBackRedirect,
|
|
@@ -30,7 +30,7 @@ var OrdersDashboard = exports.OrdersDashboard = function OrdersDashboard(props)
|
|
|
30
30
|
configs = _useConfig2[0].configs;
|
|
31
31
|
var ordersDashboardListProps = _objectSpread({}, props);
|
|
32
32
|
if (configs !== null && configs !== void 0 && configs.optimize_order_data && (configs === null || configs === void 0 || (_configs$optimize_ord = configs.optimize_order_data) === null || _configs$optimize_ord === void 0 ? void 0 : _configs$optimize_ord.value) === '1') {
|
|
33
|
-
ordersDashboardListProps.propsToFetch = ['app_id', 'business', 'business_id', 'created_at', 'customer', 'customer_id', 'delivery_type', 'driver_group_id', 'driver_id', 'driver', 'delivery_datetime', 'delivery_datetime_utc', 'external_id', 'eta_time', 'id', 'logistic_status', 'logistic_attemps', 'uuid', 'order_group', 'order_group_id', 'priority', 'summary', 'status', 'time_status', 'total', 'driver_group_business', 'metadata'];
|
|
33
|
+
ordersDashboardListProps.propsToFetch = ['app_id', 'business', 'business_id', 'created_at', 'customer', 'customer_id', 'delivery_type', 'driver_group_id', 'driver_id', 'driver', 'delivery_datetime', 'delivery_datetime_utc', 'external_id', 'eta_time', 'id', 'logistic_status', 'logistic_attemps', 'uuid', 'order_group', 'order_group_id', 'priority', 'summary', 'status', 'time_status', 'total', 'driver_group_business', 'metadata', 'assignable_driver_groups'];
|
|
34
34
|
}
|
|
35
35
|
return /*#__PURE__*/_react.default.createElement(_styles.OrdersManageContainer, null, /*#__PURE__*/_react.default.createElement(_OrdersDashboardList.OrdersDashboardList, _extends({}, ordersDashboardListProps, {
|
|
36
36
|
orderListView: "table"
|
|
@@ -10,7 +10,7 @@ var _templateObject, _templateObject2, _templateObject3;
|
|
|
10
10
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
11
11
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
12
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
13
|
-
var WrapperRow = exports.WrapperRow = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n width: 100%;\n align-items: center;\n padding-bottom: 0px;\n\n & > div {\n width: 100%;\n height: 47px;\n max-width:
|
|
13
|
+
var WrapperRow = exports.WrapperRow = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n width: 100%;\n align-items: center;\n padding-bottom: 0px;\n\n & > div {\n width: 100%;\n height: 47px;\n max-width: 1000px;\n margin-right: 10px;\n background-color: ", ";\n border: none;\n font-size: 14px;\n border-radius: 8px;\n > div:first-child {\n height: 100%;\n }\n @media (min-width: 798px) {\n max-width: 300px;\n }\n }\n\n .order-status-multi-select {\n p {\n padding: 0;\n color: ", " !important;\n }\n }\n\n .date-filter-container {\n z-index: 100;\n }\n\n input {\n width: 100%;\n height: 47px;\n padding: 10px 25px;\n box-sizing: border-box;\n &::-webkit-outer-spin-button,\n &::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n -moz-appearance: textfield;\n }\n\n .close {\n right: 8px;\n }\n\n .external_id {\n @media (max-width: 1200px) {\n flex: auto;\n }\n }\n\n @media (max-width: 798px) {\n flex-direction: column !important;\n padding: 10px 15px 0 0px;\n & > div {\n margin-top: 15px;\n }\n }\n\n ", "\n"])), function (props) {
|
|
14
14
|
return props.theme.colors.secundary;
|
|
15
15
|
}, function (props) {
|
|
16
16
|
return props.theme.colors.headingColor;
|
|
@@ -76,13 +76,17 @@ var OrdersTable = exports.OrdersTable = /*#__PURE__*/(0, _react.memo)(function (
|
|
|
76
76
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
77
77
|
dragOverd = _useState4[0],
|
|
78
78
|
setDragOverd = _useState4[1];
|
|
79
|
-
var handleChangePage = function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
var handleChangePage = (0, _react.useCallback)(function (page) {
|
|
80
|
+
if (page !== pagination.currentPage) {
|
|
81
|
+
getPageOrders(pagination.pageSize, page);
|
|
82
|
+
}
|
|
83
|
+
}, [pagination.currentPage, pagination.pageSize, getPageOrders]);
|
|
84
|
+
var handleChangePageSize = (0, _react.useCallback)(function (pageSize) {
|
|
85
|
+
if (pageSize !== pagination.pageSize) {
|
|
86
|
+
var expectedPage = Math.ceil(pagination.from / pageSize);
|
|
87
|
+
getPageOrders(pageSize, expectedPage);
|
|
88
|
+
}
|
|
89
|
+
}, [pagination.from, pagination.pageSize, getPageOrders]);
|
|
86
90
|
var _useConfig = (0, _orderingComponentsAdminExternal.useConfig)(),
|
|
87
91
|
_useConfig2 = _slicedToArray(_useConfig, 1),
|
|
88
92
|
configState = _useConfig2[0];
|
|
@@ -18,7 +18,25 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
18
18
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
19
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
20
20
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
-
var
|
|
21
|
+
var filterPages = function filterPages(visiblePages, totalPages) {
|
|
22
|
+
return visiblePages.filter(function (page) {
|
|
23
|
+
return page <= totalPages;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var getVisiblePages = function getVisiblePages(page, total) {
|
|
27
|
+
if (total < 7) {
|
|
28
|
+
return filterPages([1, 2, 3, 4, 5, 6], total);
|
|
29
|
+
} else {
|
|
30
|
+
if (page % 5 >= 0 && page > 4 && page + 2 < total) {
|
|
31
|
+
return [1, page - 1, page, page + 1, total];
|
|
32
|
+
} else if (page % 5 >= 0 && page > 4 && page + 2 >= total) {
|
|
33
|
+
return [1, total - 3, total - 2, total - 1, total];
|
|
34
|
+
} else {
|
|
35
|
+
return [1, 2, 3, 4, 5, total];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var Pagination = exports.Pagination = /*#__PURE__*/_react.default.memo(function (props) {
|
|
22
40
|
var currentPage = props.currentPage,
|
|
23
41
|
totalPages = props.totalPages,
|
|
24
42
|
handleChangePage = props.handleChangePage,
|
|
@@ -29,16 +47,18 @@ var Pagination = exports.Pagination = function Pagination(props) {
|
|
|
29
47
|
var _useLanguage = (0, _orderingComponentsAdminExternal.useLanguage)(),
|
|
30
48
|
_useLanguage2 = _slicedToArray(_useLanguage, 2),
|
|
31
49
|
t = _useLanguage2[1];
|
|
32
|
-
var pageSizeOptions =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
var pageSizeOptions = (0, _react.useMemo)(function () {
|
|
51
|
+
return [{
|
|
52
|
+
value: 10,
|
|
53
|
+
content: /*#__PURE__*/_react.default.createElement(_styles.Option, null, "10")
|
|
54
|
+
}, {
|
|
55
|
+
value: 25,
|
|
56
|
+
content: /*#__PURE__*/_react.default.createElement(_styles.Option, null, "25")
|
|
57
|
+
}, {
|
|
58
|
+
value: 50,
|
|
59
|
+
content: /*#__PURE__*/_react.default.createElement(_styles.Option, null, "50")
|
|
60
|
+
}];
|
|
61
|
+
}, []);
|
|
42
62
|
var _useState = (0, _react.useState)([]),
|
|
43
63
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
64
|
visiblePages = _useState2[0],
|
|
@@ -47,33 +67,13 @@ var Pagination = exports.Pagination = function Pagination(props) {
|
|
|
47
67
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
48
68
|
activePage = _useState4[0],
|
|
49
69
|
setActivePage = _useState4[1];
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
return page <= totalPages;
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
var getVisiblePages = function getVisiblePages(page, total) {
|
|
56
|
-
if (total < 7) {
|
|
57
|
-
return filterPages([1, 2, 3, 4, 5, 6], total);
|
|
58
|
-
} else {
|
|
59
|
-
if (page % 5 >= 0 && page > 4 && page + 2 < total) {
|
|
60
|
-
return [1, page - 1, page, page + 1, total];
|
|
61
|
-
} else if (page % 5 >= 0 && page > 4 && page + 2 >= total) {
|
|
62
|
-
return [1, total - 3, total - 2, total - 1, total];
|
|
63
|
-
} else {
|
|
64
|
-
return [1, 2, 3, 4, 5, total];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
var changePage = function changePage(page) {
|
|
69
|
-
if (page === activePage) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
70
|
+
var changePage = (0, _react.useCallback)(function (page) {
|
|
71
|
+
if (page === activePage) return;
|
|
72
72
|
setActivePage(page);
|
|
73
73
|
var _visiblePages = getVisiblePages(page, totalPages);
|
|
74
74
|
setVisiblePages(filterPages(_visiblePages, totalPages));
|
|
75
75
|
handleChangePage(page);
|
|
76
|
-
};
|
|
76
|
+
}, [activePage, totalPages, handleChangePage]);
|
|
77
77
|
(0, _react.useEffect)(function () {
|
|
78
78
|
if (!totalPages) return;
|
|
79
79
|
setVisiblePages(getVisiblePages(null, totalPages));
|
|
@@ -119,4 +119,4 @@ var Pagination = exports.Pagination = function Pagination(props) {
|
|
|
119
119
|
return handleChangePageSize(size);
|
|
120
120
|
}
|
|
121
121
|
})));
|
|
122
|
-
};
|
|
122
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ordering-ui-admin-external",
|
|
3
|
-
"version": "1.43.
|
|
3
|
+
"version": "1.43.69",
|
|
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.
|
|
86
|
+
"ordering-components-admin-external": "1.43.45",
|
|
87
87
|
"polished": "^3.6.7",
|
|
88
88
|
"prop-types": "^15.7.2",
|
|
89
89
|
"react-big-calendar": "^1.4.2",
|
|
@@ -65,7 +65,7 @@ const OrdersManagerUI = (props) => {
|
|
|
65
65
|
const [{ user }] = useSession()
|
|
66
66
|
const [configState] = useConfig()
|
|
67
67
|
|
|
68
|
-
const
|
|
68
|
+
const isFilterDriverGroup = (configState?.configs?.filter_order_options?.value.split('|').map(value => (value)) || []).includes('driver_group_general')
|
|
69
69
|
|
|
70
70
|
const query = new URLSearchParams(useLocation().search)
|
|
71
71
|
const [isOpenOrderDetail, setIsOpenOrderDetail] = useState(false)
|
|
@@ -230,9 +230,8 @@ const OrdersManagerUI = (props) => {
|
|
|
230
230
|
disableSocketRoomDriver
|
|
231
231
|
showCompressedInfo
|
|
232
232
|
filterValues={filterValues}
|
|
233
|
-
searchFilterValue={searchValue}
|
|
234
233
|
driverGroupList={driverGroupList}
|
|
235
|
-
|
|
234
|
+
isFilterDriverGroup={isFilterDriverGroup}
|
|
236
235
|
drivers={driversList.drivers}
|
|
237
236
|
setMapsData={setMapsData}
|
|
238
237
|
handleEmtpyOrderSelected={handleBackRedirect}
|
|
@@ -11,7 +11,7 @@ export const OrdersDashboard = (props) => {
|
|
|
11
11
|
...props
|
|
12
12
|
}
|
|
13
13
|
if ((configs?.optimize_order_data && (configs?.optimize_order_data?.value === '1'))) {
|
|
14
|
-
ordersDashboardListProps.propsToFetch = ['app_id', 'business', 'business_id', 'created_at', 'customer', 'customer_id', 'delivery_type', 'driver_group_id', 'driver_id', 'driver', 'delivery_datetime', 'delivery_datetime_utc', 'external_id', 'eta_time', 'id', 'logistic_status', 'logistic_attemps', 'uuid', 'order_group', 'order_group_id', 'priority', 'summary', 'status', 'time_status', 'total', 'driver_group_business', 'metadata']
|
|
14
|
+
ordersDashboardListProps.propsToFetch = ['app_id', 'business', 'business_id', 'created_at', 'customer', 'customer_id', 'delivery_type', 'driver_group_id', 'driver_id', 'driver', 'delivery_datetime', 'delivery_datetime_utc', 'external_id', 'eta_time', 'id', 'logistic_status', 'logistic_attemps', 'uuid', 'order_group', 'order_group_id', 'priority', 'summary', 'status', 'time_status', 'total', 'driver_group_business', 'metadata', 'assignable_driver_groups']
|
|
15
15
|
}
|
|
16
16
|
return (
|
|
17
17
|
<OrdersManageContainer>
|
|
@@ -9,7 +9,7 @@ export const WrapperRow = styled.div`
|
|
|
9
9
|
& > div {
|
|
10
10
|
width: 100%;
|
|
11
11
|
height: 47px;
|
|
12
|
-
max-width:
|
|
12
|
+
max-width: 1000px;
|
|
13
13
|
margin-right: 10px;
|
|
14
14
|
background-color: ${props => props.theme.colors.secundary};
|
|
15
15
|
border: none;
|
|
@@ -18,6 +18,9 @@ export const WrapperRow = styled.div`
|
|
|
18
18
|
> div:first-child {
|
|
19
19
|
height: 100%;
|
|
20
20
|
}
|
|
21
|
+
@media (min-width: 798px) {
|
|
22
|
+
max-width: 300px;
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
.order-status-multi-select {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo, useEffect, useState } from 'react'
|
|
1
|
+
import React, { memo, useEffect, useState, useCallback } from 'react'
|
|
2
2
|
import moment from 'moment'
|
|
3
3
|
import RiCheckboxBlankLine from '@meronex/icons/ri/RiCheckboxBlankLine'
|
|
4
4
|
import RiCheckboxFill from '@meronex/icons/ri/RiCheckboxFill'
|
|
@@ -70,13 +70,20 @@ export const OrdersTable = memo((props) => {
|
|
|
70
70
|
const [{ parseDate }] = useUtils()
|
|
71
71
|
const [isAllChecked, setIsAllChecked] = useState(false)
|
|
72
72
|
const [dragOverd, setDragOverd] = useState('')
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
|
|
74
|
+
const handleChangePage = useCallback((page) => {
|
|
75
|
+
if (page !== pagination.currentPage) {
|
|
76
|
+
getPageOrders(pagination.pageSize, page)
|
|
77
|
+
}
|
|
78
|
+
}, [pagination.currentPage, pagination.pageSize, getPageOrders])
|
|
79
|
+
|
|
80
|
+
const handleChangePageSize = useCallback((pageSize) => {
|
|
81
|
+
if (pageSize !== pagination.pageSize) {
|
|
82
|
+
const expectedPage = Math.ceil(pagination.from / pageSize)
|
|
83
|
+
getPageOrders(pageSize, expectedPage)
|
|
84
|
+
}
|
|
85
|
+
}, [pagination.from, pagination.pageSize, getPageOrders])
|
|
86
|
+
|
|
80
87
|
const [configState] = useConfig()
|
|
81
88
|
const isEnabledRowInColor = configState?.configs?.row_in_color_enabled?.value === '1'
|
|
82
89
|
const showExternalId = configState?.configs?.change_order_id?.value === '1'
|
|
@@ -269,11 +276,11 @@ export const OrdersTable = memo((props) => {
|
|
|
269
276
|
let _column = {}
|
|
270
277
|
if (type === 'channel') {
|
|
271
278
|
_column = { visable: allowColumns[type]?.visable ?? false, title: t('CHANNEL', 'Channel'), className: 'channelInfo', draggable: true, colSpan: 1, order: 12 }
|
|
272
|
-
|
|
279
|
+
} else if (type === 'pod') {
|
|
273
280
|
_column = { visable: allowColumns[type]?.visable ?? false, title: t('PODS', 'Pod'), className: 'podInfo', draggable: true, colSpan: 1, order: 13 }
|
|
274
|
-
|
|
281
|
+
} else {
|
|
275
282
|
_column = allowColumns[type]
|
|
276
|
-
|
|
283
|
+
}
|
|
277
284
|
const updatedAllowColumns = {
|
|
278
285
|
...allowColumns,
|
|
279
286
|
[type]: { ..._column, visable: !_column?.visable }
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react'
|
|
1
|
+
import React, { useState, useEffect, useMemo, useCallback } from 'react'
|
|
2
2
|
import { useLanguage } from 'ordering-components-admin-external'
|
|
3
3
|
import { Select } from '../../../styles/Select'
|
|
4
4
|
import { ChevronLeft, ChevronRight } from 'react-bootstrap-icons'
|
|
5
|
-
|
|
6
5
|
import {
|
|
7
6
|
PaginationContainer,
|
|
8
7
|
PaginationButtonContainer,
|
|
@@ -12,7 +11,25 @@ import {
|
|
|
12
11
|
Option
|
|
13
12
|
} from './styles'
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
const filterPages = (visiblePages, totalPages) => {
|
|
15
|
+
return visiblePages.filter(page => page <= totalPages)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const getVisiblePages = (page, total) => {
|
|
19
|
+
if (total < 7) {
|
|
20
|
+
return filterPages([1, 2, 3, 4, 5, 6], total)
|
|
21
|
+
} else {
|
|
22
|
+
if (page % 5 >= 0 && page > 4 && page + 2 < total) {
|
|
23
|
+
return [1, page - 1, page, page + 1, total]
|
|
24
|
+
} else if (page % 5 >= 0 && page > 4 && page + 2 >= total) {
|
|
25
|
+
return [1, total - 3, total - 2, total - 1, total]
|
|
26
|
+
} else {
|
|
27
|
+
return [1, 2, 3, 4, 5, total]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const Pagination = React.memo((props) => {
|
|
16
33
|
const {
|
|
17
34
|
currentPage,
|
|
18
35
|
totalPages,
|
|
@@ -24,51 +41,23 @@ export const Pagination = (props) => {
|
|
|
24
41
|
} = props
|
|
25
42
|
|
|
26
43
|
const [, t] = useLanguage()
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
value: 25,
|
|
34
|
-
content: <Option>25</Option>
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
value: 50,
|
|
38
|
-
content: <Option>50</Option>
|
|
39
|
-
}
|
|
40
|
-
]
|
|
44
|
+
|
|
45
|
+
const pageSizeOptions = useMemo(() => [
|
|
46
|
+
{ value: 10, content: <Option>10</Option> },
|
|
47
|
+
{ value: 25, content: <Option>25</Option> },
|
|
48
|
+
{ value: 50, content: <Option>50</Option> }
|
|
49
|
+
], [])
|
|
41
50
|
|
|
42
51
|
const [visiblePages, setVisiblePages] = useState([])
|
|
43
52
|
const [activePage, setActivePage] = useState(currentPage)
|
|
44
53
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const getVisiblePages = (page, total) => {
|
|
50
|
-
if (total < 7) {
|
|
51
|
-
return filterPages([1, 2, 3, 4, 5, 6], total)
|
|
52
|
-
} else {
|
|
53
|
-
if (page % 5 >= 0 && page > 4 && page + 2 < total) {
|
|
54
|
-
return [1, page - 1, page, page + 1, total]
|
|
55
|
-
} else if (page % 5 >= 0 && page > 4 && page + 2 >= total) {
|
|
56
|
-
return [1, total - 3, total - 2, total - 1, total]
|
|
57
|
-
} else {
|
|
58
|
-
return [1, 2, 3, 4, 5, total]
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const changePage = (page) => {
|
|
64
|
-
if (page === activePage) {
|
|
65
|
-
return
|
|
66
|
-
}
|
|
54
|
+
const changePage = useCallback((page) => {
|
|
55
|
+
if (page === activePage) return
|
|
67
56
|
setActivePage(page)
|
|
68
57
|
const _visiblePages = getVisiblePages(page, totalPages)
|
|
69
58
|
setVisiblePages(filterPages(_visiblePages, totalPages))
|
|
70
59
|
handleChangePage(page)
|
|
71
|
-
}
|
|
60
|
+
}, [activePage, totalPages, handleChangePage])
|
|
72
61
|
|
|
73
62
|
useEffect(() => {
|
|
74
63
|
if (!totalPages) return
|
|
@@ -140,4 +129,4 @@ export const Pagination = (props) => {
|
|
|
140
129
|
)}
|
|
141
130
|
</PaginationContainer>
|
|
142
131
|
)
|
|
143
|
-
}
|
|
132
|
+
})
|