ordering-ui-admin-external 1.43.84 → 1.43.86
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.07960ab695ace0aabf06.js → ordering-ui-admin.89cc92ea829107eb0896.js} +2 -2
- package/_modules/components/Delivery/DriversGroupAddForm/BusinessesForm/index.js +54 -10
- package/_modules/components/Delivery/DriversGroupBusinesses/index.js +45 -1
- package/_modules/components/Delivery/DriversGroupDrivers/index.js +45 -1
- package/_modules/components/Delivery/DriversGroupsList/index.js +32 -44
- package/_modules/components/Delivery/DriversGroupsListing/index.js +6 -2
- package/_modules/components/Orders/DriversGroupTypeSelector/index.js +4 -8
- package/_modules/components/Shared/Pagination/styles.js +1 -1
- package/_modules/components/Stores/BusinessDeliveryGroupsDetails/index.js +6 -2
- package/_modules/styles/Select/index.js +28 -4
- package/package.json +2 -2
- package/src/components/Delivery/DriversGroupAddForm/BusinessesForm/index.js +50 -2
- package/src/components/Delivery/DriversGroupBusinesses/index.js +50 -2
- package/src/components/Delivery/DriversGroupDrivers/index.js +50 -3
- package/src/components/Delivery/DriversGroupsList/index.js +22 -31
- package/src/components/Delivery/DriversGroupsListing/index.js +5 -1
- package/src/components/Orders/DriversGroupTypeSelector/index.js +5 -10
- package/src/components/Shared/Pagination/styles.js +2 -1
- package/src/components/Stores/BusinessDeliveryGroupsDetails/index.js +5 -1
- package/src/styles/Select/index.js +37 -4
- /package/_bundles/{ordering-ui-admin.07960ab695ace0aabf06.js.LICENSE.txt → ordering-ui-admin.89cc92ea829107eb0896.js.LICENSE.txt} +0 -0
|
@@ -2,7 +2,8 @@ import React, { useEffect, useState } from 'react'
|
|
|
2
2
|
import { useLanguage } from 'ordering-components-admin-external'
|
|
3
3
|
|
|
4
4
|
import { Checkbox, Button } from '../../../../styles'
|
|
5
|
-
import { SearchBar } from '../../../Shared'
|
|
5
|
+
import { Pagination, SearchBar } from '../../../Shared'
|
|
6
|
+
import { PaginationWrapper } from '../../../../styles/MultiSelect/styles'
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
9
|
Container,
|
|
@@ -30,6 +31,36 @@ export const BusinessesForm = (props) => {
|
|
|
30
31
|
const [, t] = useLanguage()
|
|
31
32
|
const [searchValue, setSearchValue] = useState(null)
|
|
32
33
|
const [filteredBusinesses, setFilteredBusinesses] = useState([])
|
|
34
|
+
const [pagination, setPagination] = useState({
|
|
35
|
+
currentPage: 1,
|
|
36
|
+
pageSize: 10,
|
|
37
|
+
totalItems: null,
|
|
38
|
+
totalPages: null
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const handleChangePage = (page) => {
|
|
42
|
+
setPagination({
|
|
43
|
+
...pagination,
|
|
44
|
+
currentPage: page
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const handleChangePageSize = (pageSize) => {
|
|
49
|
+
const expectedPage = Math.ceil(((pagination?.currentPage - 1) * pagination?.pageSize + 1) / pageSize)
|
|
50
|
+
setPagination({
|
|
51
|
+
...pagination,
|
|
52
|
+
currentPage: expectedPage,
|
|
53
|
+
pageSize,
|
|
54
|
+
totalPages: Math.ceil(filteredBusinesses?.length / pageSize)
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const filterFunction = (_, index) => {
|
|
59
|
+
const validation = pagination?.currentPage === 1
|
|
60
|
+
? index < (pagination.pageSize * pagination.currentPage)
|
|
61
|
+
: (index >= (pagination.pageSize * (pagination.currentPage - 1))) && (index < (pagination.pageSize * pagination.currentPage))
|
|
62
|
+
return validation
|
|
63
|
+
}
|
|
33
64
|
|
|
34
65
|
useEffect(() => {
|
|
35
66
|
let _filteredBusinesses = []
|
|
@@ -39,6 +70,12 @@ export const BusinessesForm = (props) => {
|
|
|
39
70
|
_filteredBusinesses = [...businesses]
|
|
40
71
|
}
|
|
41
72
|
setFilteredBusinesses(_filteredBusinesses)
|
|
73
|
+
setPagination({
|
|
74
|
+
...pagination,
|
|
75
|
+
currentPage: 1,
|
|
76
|
+
totalItems: _filteredBusinesses?.length,
|
|
77
|
+
totalPages: Math.ceil(_filteredBusinesses?.length / pagination.pageSize)
|
|
78
|
+
})
|
|
42
79
|
}, [searchValue, businesses])
|
|
43
80
|
|
|
44
81
|
return (
|
|
@@ -92,7 +129,7 @@ export const BusinessesForm = (props) => {
|
|
|
92
129
|
</>
|
|
93
130
|
) : (
|
|
94
131
|
<>
|
|
95
|
-
{filteredBusinesses.map(business => (
|
|
132
|
+
{filteredBusinesses.filter(filterFunction).map(business => (
|
|
96
133
|
<BusinessWrapper
|
|
97
134
|
key={business.id}
|
|
98
135
|
isDisabed={actionState.loading}
|
|
@@ -110,6 +147,17 @@ export const BusinessesForm = (props) => {
|
|
|
110
147
|
</>
|
|
111
148
|
)}
|
|
112
149
|
</BusinessesContainer>
|
|
150
|
+
{pagination && handleChangePageSize && handleChangePage && (
|
|
151
|
+
<PaginationWrapper>
|
|
152
|
+
<Pagination
|
|
153
|
+
currentPage={pagination?.currentPage}
|
|
154
|
+
totalPages={pagination?.totalPages}
|
|
155
|
+
handleChangePage={handleChangePage}
|
|
156
|
+
handleChangePageSize={handleChangePageSize}
|
|
157
|
+
defaultPageSize={pagination?.pageSize}
|
|
158
|
+
/>
|
|
159
|
+
</PaginationWrapper>
|
|
160
|
+
)}
|
|
113
161
|
</Container>
|
|
114
162
|
)
|
|
115
163
|
}
|
|
@@ -3,7 +3,7 @@ import { useLanguage } from 'ordering-components-admin-external'
|
|
|
3
3
|
import { useForm } from 'react-hook-form'
|
|
4
4
|
|
|
5
5
|
import { Checkbox, Button } from '../../../styles'
|
|
6
|
-
import { SearchBar } from '../../Shared'
|
|
6
|
+
import { Pagination, SearchBar } from '../../Shared'
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
Container,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
SkeletonContainer
|
|
18
18
|
} from './styles'
|
|
19
19
|
import Skeleton from 'react-loading-skeleton'
|
|
20
|
+
import { PaginationWrapper } from '../../../styles/MultiSelect/styles'
|
|
20
21
|
|
|
21
22
|
export const DriversGroupBusinesses = (props) => {
|
|
22
23
|
const {
|
|
@@ -38,6 +39,36 @@ export const DriversGroupBusinesses = (props) => {
|
|
|
38
39
|
|
|
39
40
|
const [searchValue, setSearchValue] = useState(null)
|
|
40
41
|
const [filteredBusinesses, setFilteredBusinesses] = useState([])
|
|
42
|
+
const [pagination, setPagination] = useState({
|
|
43
|
+
currentPage: 1,
|
|
44
|
+
pageSize: 10,
|
|
45
|
+
totalItems: null,
|
|
46
|
+
totalPages: null
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const handleChangePage = (page) => {
|
|
50
|
+
setPagination({
|
|
51
|
+
...pagination,
|
|
52
|
+
currentPage: page
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const handleChangePageSize = (pageSize) => {
|
|
57
|
+
const expectedPage = Math.ceil(((pagination?.currentPage - 1) * pagination?.pageSize + 1) / pageSize)
|
|
58
|
+
setPagination({
|
|
59
|
+
...pagination,
|
|
60
|
+
currentPage: expectedPage,
|
|
61
|
+
pageSize,
|
|
62
|
+
totalPages: Math.ceil(filteredBusinesses?.length / pageSize)
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const filterFunction = (_, index) => {
|
|
67
|
+
const validation = pagination?.currentPage === 1
|
|
68
|
+
? index < (pagination.pageSize * pagination.currentPage)
|
|
69
|
+
: (index >= (pagination.pageSize * (pagination.currentPage - 1))) && (index < (pagination.pageSize * pagination.currentPage))
|
|
70
|
+
return validation
|
|
71
|
+
}
|
|
41
72
|
|
|
42
73
|
useEffect(() => {
|
|
43
74
|
let _filteredBusinesses = []
|
|
@@ -47,6 +78,12 @@ export const DriversGroupBusinesses = (props) => {
|
|
|
47
78
|
_filteredBusinesses = [...businesses]
|
|
48
79
|
}
|
|
49
80
|
setFilteredBusinesses(_filteredBusinesses)
|
|
81
|
+
setPagination({
|
|
82
|
+
...pagination,
|
|
83
|
+
currentPage: 1,
|
|
84
|
+
totalItems: _filteredBusinesses?.length,
|
|
85
|
+
totalPages: Math.ceil(_filteredBusinesses?.length / pagination.pageSize)
|
|
86
|
+
})
|
|
50
87
|
}, [searchValue, businesses])
|
|
51
88
|
|
|
52
89
|
const onSubmit = () => {
|
|
@@ -111,7 +148,7 @@ export const DriversGroupBusinesses = (props) => {
|
|
|
111
148
|
</>
|
|
112
149
|
) : (
|
|
113
150
|
<>
|
|
114
|
-
{filteredBusinesses.map(business => (
|
|
151
|
+
{filteredBusinesses.filter(filterFunction).map(business => (
|
|
115
152
|
<BusinessWrapper
|
|
116
153
|
key={business.id}
|
|
117
154
|
isDisabed={actionState.loading}
|
|
@@ -128,6 +165,17 @@ export const DriversGroupBusinesses = (props) => {
|
|
|
128
165
|
))}
|
|
129
166
|
</>
|
|
130
167
|
)}
|
|
168
|
+
{pagination && handleChangePageSize && handleChangePage && (
|
|
169
|
+
<PaginationWrapper>
|
|
170
|
+
<Pagination
|
|
171
|
+
currentPage={pagination?.currentPage}
|
|
172
|
+
totalPages={pagination?.totalPages}
|
|
173
|
+
handleChangePage={handleChangePage}
|
|
174
|
+
handleChangePageSize={handleChangePageSize}
|
|
175
|
+
defaultPageSize={pagination?.pageSize}
|
|
176
|
+
/>
|
|
177
|
+
</PaginationWrapper>
|
|
178
|
+
)}
|
|
131
179
|
</BusinessesContainer>
|
|
132
180
|
<Button
|
|
133
181
|
borderRadius='8px'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
2
|
import { useLanguage } from 'ordering-components-admin-external'
|
|
3
|
-
import { SearchBar, Modal } from '../../Shared'
|
|
3
|
+
import { SearchBar, Modal, Pagination } from '../../Shared'
|
|
4
4
|
import { Button, Checkbox } from '../../../styles'
|
|
5
5
|
import { DriverTemporalSchedule } from '../DriverTemporalSchedule'
|
|
6
6
|
import FaUserAlt from '@meronex/icons/fa/FaUserAlt'
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
DriverTemporaryContainer
|
|
18
18
|
} from './styles'
|
|
19
19
|
import moment from 'moment'
|
|
20
|
+
import { PaginationWrapper } from '../../../styles/MultiSelect/styles'
|
|
20
21
|
|
|
21
22
|
export const DriversGroupDrivers = (props) => {
|
|
22
23
|
const {
|
|
@@ -33,12 +34,42 @@ export const DriversGroupDrivers = (props) => {
|
|
|
33
34
|
const [filteredDrivers, setFilteredDrivers] = useState([])
|
|
34
35
|
const [driverTemporalSchedule, setDriverTemporalScheduleModal] = useState(false)
|
|
35
36
|
const [driverSchedule, setDriverSchedule] = useState(null)
|
|
37
|
+
const [pagination, setPagination] = useState({
|
|
38
|
+
currentPage: 1,
|
|
39
|
+
pageSize: 10,
|
|
40
|
+
totalItems: null,
|
|
41
|
+
totalPages: null
|
|
42
|
+
})
|
|
36
43
|
|
|
37
44
|
const handleOpenModal = (driver) => {
|
|
38
45
|
setDriverSchedule(driver)
|
|
39
46
|
setDriverTemporalScheduleModal(true)
|
|
40
47
|
}
|
|
41
48
|
|
|
49
|
+
const handleChangePage = (page) => {
|
|
50
|
+
setPagination({
|
|
51
|
+
...pagination,
|
|
52
|
+
currentPage: page
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const handleChangePageSize = (pageSize) => {
|
|
57
|
+
const expectedPage = Math.ceil(((pagination?.currentPage - 1) * pagination?.pageSize + 1) / pageSize)
|
|
58
|
+
setPagination({
|
|
59
|
+
...pagination,
|
|
60
|
+
currentPage: expectedPage,
|
|
61
|
+
pageSize,
|
|
62
|
+
totalPages: Math.ceil(filteredDrivers?.length / pageSize)
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const filterFunction = (_, index) => {
|
|
67
|
+
const validation = pagination?.currentPage === 1
|
|
68
|
+
? index < (pagination.pageSize * pagination.currentPage)
|
|
69
|
+
: (index >= (pagination.pageSize * (pagination.currentPage - 1))) && (index < (pagination.pageSize * pagination.currentPage))
|
|
70
|
+
return validation
|
|
71
|
+
}
|
|
72
|
+
|
|
42
73
|
useEffect(() => {
|
|
43
74
|
let _filteredDrivers = []
|
|
44
75
|
if (searchValue) {
|
|
@@ -53,6 +84,12 @@ export const DriversGroupDrivers = (props) => {
|
|
|
53
84
|
_filteredDrivers = [...drivers]
|
|
54
85
|
}
|
|
55
86
|
setFilteredDrivers(_filteredDrivers)
|
|
87
|
+
setPagination({
|
|
88
|
+
...pagination,
|
|
89
|
+
currentPage: 1,
|
|
90
|
+
totalItems: _filteredDrivers?.length,
|
|
91
|
+
totalPages: Math.ceil(_filteredDrivers?.length / pagination.pageSize)
|
|
92
|
+
})
|
|
56
93
|
}, [searchValue])
|
|
57
94
|
|
|
58
95
|
return (
|
|
@@ -83,7 +120,7 @@ export const DriversGroupDrivers = (props) => {
|
|
|
83
120
|
</Button>
|
|
84
121
|
</ButtonGroup>
|
|
85
122
|
<BusinessesContainer>
|
|
86
|
-
{filteredDrivers.map(driver => (
|
|
123
|
+
{filteredDrivers.filter(filterFunction).map(driver => (
|
|
87
124
|
<BusinessWrapper
|
|
88
125
|
key={driver.id}
|
|
89
126
|
isDisabed={actionState.loading}
|
|
@@ -117,7 +154,17 @@ export const DriversGroupDrivers = (props) => {
|
|
|
117
154
|
</BusinessWrapper>
|
|
118
155
|
))}
|
|
119
156
|
</BusinessesContainer>
|
|
120
|
-
|
|
157
|
+
{pagination && handleChangePageSize && handleChangePage && (
|
|
158
|
+
<PaginationWrapper>
|
|
159
|
+
<Pagination
|
|
160
|
+
currentPage={pagination?.currentPage}
|
|
161
|
+
totalPages={pagination?.totalPages}
|
|
162
|
+
handleChangePage={handleChangePage}
|
|
163
|
+
handleChangePageSize={handleChangePageSize}
|
|
164
|
+
defaultPageSize={pagination?.pageSize}
|
|
165
|
+
/>
|
|
166
|
+
</PaginationWrapper>
|
|
167
|
+
)}
|
|
121
168
|
<Modal
|
|
122
169
|
width='385px'
|
|
123
170
|
height='auto'
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
|
-
import { useLocation } from 'react-router-dom'
|
|
3
2
|
import { useLanguage } from 'ordering-components-admin-external'
|
|
4
3
|
import Skeleton from 'react-loading-skeleton'
|
|
5
4
|
import MdCheckBoxOutlineBlank from '@meronex/icons/md/MdCheckBoxOutlineBlank'
|
|
@@ -38,50 +37,42 @@ export const DriversGroupsList = (props) => {
|
|
|
38
37
|
handleSelectGroup,
|
|
39
38
|
handleAllSelectGroup,
|
|
40
39
|
actionDisabled,
|
|
41
|
-
isUseQuery
|
|
40
|
+
isUseQuery,
|
|
41
|
+
pagination,
|
|
42
|
+
setPagination
|
|
42
43
|
} = props
|
|
43
44
|
|
|
44
45
|
const [, t] = useLanguage()
|
|
45
|
-
const query = new URLSearchParams(useLocation().search)
|
|
46
|
-
const defaultPage = query.get('page') || 1
|
|
47
|
-
const defaultPageSize = query.get('pageSize') || 10
|
|
48
|
-
|
|
49
|
-
// Change page
|
|
50
|
-
const [currentPage, setCurrentPage] = useState(Number(defaultPage) || 1)
|
|
51
|
-
const [groupsPerPage, setGroupsPerPage] = useState(Number(defaultPageSize) || 10)
|
|
52
46
|
|
|
53
47
|
// Get current groups
|
|
54
48
|
const [currentGroups, setCurrentGroups] = useState([])
|
|
55
49
|
const [totalPages, setTotalPages] = useState(null)
|
|
56
50
|
|
|
57
51
|
const handleChangePage = (page) => {
|
|
58
|
-
|
|
52
|
+
setPagination({
|
|
53
|
+
...pagination,
|
|
54
|
+
currentPage: page
|
|
55
|
+
})
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
const handleChangePageSize = (pageSize) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
setPagination({
|
|
60
|
+
...pagination,
|
|
61
|
+
pageSize
|
|
62
|
+
})
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
useEffect(() => {
|
|
68
66
|
if (driversGroupsState.loading) return
|
|
69
|
-
let _totalPages
|
|
70
67
|
let groups = []
|
|
71
68
|
if (searchValue) {
|
|
72
69
|
groups = driversGroupsState.groups.filter(plugin => plugin.name?.toLowerCase().includes(searchValue?.toLowerCase()))
|
|
73
70
|
} else {
|
|
74
71
|
groups = [...driversGroupsState.groups]
|
|
75
72
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const indexOfLastPost = currentPage * groupsPerPage
|
|
80
|
-
const indexOfFirstPost = indexOfLastPost - groupsPerPage
|
|
81
|
-
const _currentGroups = groups.slice(indexOfFirstPost, indexOfLastPost)
|
|
82
|
-
setTotalPages(_totalPages)
|
|
83
|
-
setCurrentGroups(_currentGroups)
|
|
84
|
-
}, [driversGroupsState, currentPage, groupsPerPage, searchValue])
|
|
73
|
+
setTotalPages(pagination.totalPages)
|
|
74
|
+
setCurrentGroups(groups)
|
|
75
|
+
}, [driversGroupsState, searchValue])
|
|
85
76
|
|
|
86
77
|
const handleClickDriverGroup = (e, group) => {
|
|
87
78
|
const isInvalid = e.target.closest('.group-checkbox') || e.target.closest('.group-enabled')
|
|
@@ -99,12 +90,12 @@ export const DriversGroupsList = (props) => {
|
|
|
99
90
|
}
|
|
100
91
|
|
|
101
92
|
useEffect(() => {
|
|
102
|
-
if (!isUseQuery || !
|
|
93
|
+
if (!isUseQuery || !totalPages) return
|
|
103
94
|
addQueryToUrl({
|
|
104
|
-
page: currentPage,
|
|
105
|
-
pageSize:
|
|
95
|
+
page: pagination.currentPage,
|
|
96
|
+
pageSize: pagination.pageSize
|
|
106
97
|
})
|
|
107
|
-
}, [
|
|
98
|
+
}, [pagination, totalPages])
|
|
108
99
|
|
|
109
100
|
return (
|
|
110
101
|
<>
|
|
@@ -157,7 +148,7 @@ export const DriversGroupsList = (props) => {
|
|
|
157
148
|
</tr>
|
|
158
149
|
</thead>
|
|
159
150
|
{driversGroupsState.loading ? (
|
|
160
|
-
[...Array(
|
|
151
|
+
[...Array(pagination.pageSize).keys()].map(i => (
|
|
161
152
|
<tbody key={i}>
|
|
162
153
|
<tr>
|
|
163
154
|
<td>
|
|
@@ -286,10 +277,10 @@ export const DriversGroupsList = (props) => {
|
|
|
286
277
|
)}
|
|
287
278
|
{currentGroups?.length > 0 && (
|
|
288
279
|
<Pagination
|
|
289
|
-
currentPage={currentPage}
|
|
290
|
-
totalPages={totalPages}
|
|
280
|
+
currentPage={pagination.currentPage}
|
|
281
|
+
totalPages={pagination.totalPages}
|
|
291
282
|
handleChangePage={handleChangePage}
|
|
292
|
-
defaultPageSize={
|
|
283
|
+
defaultPageSize={pagination.pageSize}
|
|
293
284
|
handleChangePageSize={handleChangePageSize}
|
|
294
285
|
/>
|
|
295
286
|
)}
|
|
@@ -36,7 +36,9 @@ const DriversGroupsListingUI = (props) => {
|
|
|
36
36
|
handleDeleteDriversGroup,
|
|
37
37
|
driversCompanyList,
|
|
38
38
|
actionDisabled,
|
|
39
|
-
isUseQuery
|
|
39
|
+
isUseQuery,
|
|
40
|
+
pagination,
|
|
41
|
+
setPagination
|
|
40
42
|
} = props
|
|
41
43
|
|
|
42
44
|
const history = useHistory()
|
|
@@ -210,6 +212,8 @@ const DriversGroupsListingUI = (props) => {
|
|
|
210
212
|
handleAllSelectGroup={handleAllSelectGroup}
|
|
211
213
|
actionDisabled={actionDisabled}
|
|
212
214
|
isUseQuery={isUseQuery}
|
|
215
|
+
pagination={pagination}
|
|
216
|
+
setPagination={setPagination}
|
|
213
217
|
/>
|
|
214
218
|
) : (
|
|
215
219
|
<DriversGroupAddForm
|
|
@@ -66,18 +66,13 @@ export const DriversGroupTypeSelector = (props) => {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
setGroupTypes(_groupList)
|
|
69
|
+
setPagination({
|
|
70
|
+
...pagination,
|
|
71
|
+
totalItems: _groupList?.length,
|
|
72
|
+
totalPages: Math.ceil(_groupList?.length / pagination.pageSize)
|
|
73
|
+
})
|
|
69
74
|
}, [driverGroupList, searchValue])
|
|
70
75
|
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (groupTypes?.length) {
|
|
73
|
-
setPagination({
|
|
74
|
-
...pagination,
|
|
75
|
-
totalItems: groupTypes?.length,
|
|
76
|
-
totalPages: Math.ceil(groupTypes?.length / 10)
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
}, [groupTypes])
|
|
80
|
-
|
|
81
76
|
return (
|
|
82
77
|
<>
|
|
83
78
|
{!driverGroupList.loading ? (
|
|
@@ -17,7 +17,7 @@ export const PaginationButtonContainer = styled.div`
|
|
|
17
17
|
`}
|
|
18
18
|
`
|
|
19
19
|
|
|
20
|
-
export const PageButton = styled.
|
|
20
|
+
export const PageButton = styled.div`
|
|
21
21
|
background-color: transparent;
|
|
22
22
|
font-size: 14px;
|
|
23
23
|
color: ${props => props.theme.colors.headingColor};
|
|
@@ -29,6 +29,7 @@ export const PageButton = styled.button`
|
|
|
29
29
|
display: flex;
|
|
30
30
|
align-items: center;
|
|
31
31
|
justify-content: center;
|
|
32
|
+
cursor: pointer;
|
|
32
33
|
padding: 0px 7px;
|
|
33
34
|
|
|
34
35
|
${props => props.theme?.rtl ? css`
|
|
@@ -19,7 +19,9 @@ const DriversGroupsListingDetailsUI = (props) => {
|
|
|
19
19
|
handleAllSelectGroup,
|
|
20
20
|
actionState,
|
|
21
21
|
handleUpdateDriversGroup,
|
|
22
|
-
paginationSettings
|
|
22
|
+
paginationSettings,
|
|
23
|
+
pagination,
|
|
24
|
+
setPagination
|
|
23
25
|
} = props
|
|
24
26
|
|
|
25
27
|
const history = useHistory()
|
|
@@ -72,6 +74,8 @@ const DriversGroupsListingDetailsUI = (props) => {
|
|
|
72
74
|
handleSelectGroup={handleSelectGroup}
|
|
73
75
|
handleAllSelectGroup={handleAllSelectGroup}
|
|
74
76
|
paginationSettings={paginationSettings}
|
|
77
|
+
pagination={pagination}
|
|
78
|
+
setPagination={setPagination}
|
|
75
79
|
/>
|
|
76
80
|
</DriversGroupsListingContainer>
|
|
77
81
|
<Alert
|
|
@@ -3,7 +3,7 @@ import { useSession } from 'ordering-components-admin-external'
|
|
|
3
3
|
import { usePopper } from 'react-popper'
|
|
4
4
|
import { CaretDownFill } from 'react-bootstrap-icons'
|
|
5
5
|
import FiChevronDown from '@meronex/icons/fi/FiChevronDown'
|
|
6
|
-
import { SearchBar } from '../../components/Shared'
|
|
6
|
+
import { Pagination, SearchBar } from '../../components/Shared'
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
Selected,
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
HeaderItem,
|
|
20
20
|
PopoverBody
|
|
21
21
|
} from './styles'
|
|
22
|
+
import { PaginationWrapper } from '../MultiSelect/styles'
|
|
22
23
|
|
|
23
24
|
export const Select = (props) => {
|
|
24
25
|
const {
|
|
@@ -38,7 +39,12 @@ export const Select = (props) => {
|
|
|
38
39
|
className,
|
|
39
40
|
isShowCustomOption,
|
|
40
41
|
customOptionTitle,
|
|
41
|
-
handleCustomOptionClick
|
|
42
|
+
handleCustomOptionClick,
|
|
43
|
+
pagination,
|
|
44
|
+
handleChangePage,
|
|
45
|
+
handleChangePageSize,
|
|
46
|
+
useLazyPagination,
|
|
47
|
+
isHidePagecontrol
|
|
42
48
|
} = props
|
|
43
49
|
const defaultOption = options?.find(
|
|
44
50
|
(option) => option.value === defaultValue
|
|
@@ -89,6 +95,11 @@ export const Select = (props) => {
|
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
|
|
98
|
+
const handlerChangePage = (page) => {
|
|
99
|
+
setOpen(true)
|
|
100
|
+
handleChangePage(page)
|
|
101
|
+
}
|
|
102
|
+
|
|
92
103
|
useEffect(() => {
|
|
93
104
|
window.addEventListener('mouseup', handleClickOutside)
|
|
94
105
|
window.addEventListener('keydown', handleKeyDown)
|
|
@@ -104,7 +115,9 @@ export const Select = (props) => {
|
|
|
104
115
|
const _defaultOption = options?.find(
|
|
105
116
|
(option) => option.value === defaultValue
|
|
106
117
|
)
|
|
107
|
-
|
|
118
|
+
if (!(useLazyPagination && pagination)) {
|
|
119
|
+
setSelectedOption(_defaultOption)
|
|
120
|
+
}
|
|
108
121
|
setValue(defaultValue)
|
|
109
122
|
}
|
|
110
123
|
}, [defaultValue, options, searchValue])
|
|
@@ -124,6 +137,14 @@ export const Select = (props) => {
|
|
|
124
137
|
setOpen(!open)
|
|
125
138
|
}
|
|
126
139
|
|
|
140
|
+
const filterFunction = (_, index) => {
|
|
141
|
+
if (!pagination || useLazyPagination) return true
|
|
142
|
+
const validation = pagination?.currentPage === 1
|
|
143
|
+
? index < (pagination.pageSize * pagination.currentPage)
|
|
144
|
+
: (index >= (pagination.pageSize * (pagination.currentPage - 1))) && (index < (pagination.pageSize * pagination.currentPage))
|
|
145
|
+
return validation
|
|
146
|
+
}
|
|
147
|
+
|
|
127
148
|
const popStyle = { ...styles.popper, display: open ? 'block' : 'none', minWidth: referenceElement?.current?.offsetWidth || '100px' }
|
|
128
149
|
if (!open) {
|
|
129
150
|
popStyle.transform = 'translate3d(0px, 0px, 0px)'
|
|
@@ -173,7 +194,7 @@ export const Select = (props) => {
|
|
|
173
194
|
optionInnerMargin={props.optionInnerMargin}
|
|
174
195
|
optionInnerMaxHeight={props.optionInnerMaxHeight}
|
|
175
196
|
>
|
|
176
|
-
{options.map((option, i) => (
|
|
197
|
+
{options.filter(filterFunction).map((option, i) => (
|
|
177
198
|
<Option
|
|
178
199
|
key={i}
|
|
179
200
|
selected={value === option.value}
|
|
@@ -200,6 +221,18 @@ export const Select = (props) => {
|
|
|
200
221
|
{customOptionTitle}
|
|
201
222
|
</Option>
|
|
202
223
|
)}
|
|
224
|
+
{pagination && handleChangePageSize && handleChangePage && (
|
|
225
|
+
<PaginationWrapper>
|
|
226
|
+
<Pagination
|
|
227
|
+
currentPage={pagination?.currentPage}
|
|
228
|
+
totalPages={pagination?.totalPages}
|
|
229
|
+
handleChangePage={handlerChangePage}
|
|
230
|
+
handleChangePageSize={handleChangePageSize}
|
|
231
|
+
defaultPageSize={pagination?.pageSize}
|
|
232
|
+
isHidePagecontrol={isHidePagecontrol}
|
|
233
|
+
/>
|
|
234
|
+
</PaginationWrapper>
|
|
235
|
+
)}
|
|
203
236
|
</Options>
|
|
204
237
|
</PopoverBody>
|
|
205
238
|
</div>
|