ordering-ui-admin-external 1.7.4 → 1.8.0
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.215ac926de72666d96e4.js → ordering-ui-admin.22db20d62f2d39ead727.js} +2 -2
- package/_bundles/{ordering-ui-admin.215ac926de72666d96e4.js.LICENSE.txt → ordering-ui-admin.22db20d62f2d39ead727.js.LICENSE.txt} +0 -0
- package/_modules/components/Delivery/DriversGroupDeliveryDetails/index.js +104 -0
- package/_modules/components/Delivery/DriversGroupDeliveryDetails/styles.js +12 -0
- package/_modules/components/Delivery/DriversGroupDeliveryZoneInformation/index.js +274 -0
- package/_modules/components/Delivery/DriversGroupDeliveryZoneInformation/styles.js +40 -0
- package/_modules/components/Delivery/DriversGroupDeliveryZoneList/index.js +119 -0
- package/_modules/components/Delivery/DriversGroupDeliveryZoneList/styles.js +54 -0
- package/_modules/components/Delivery/DriversGroupDetails/index.js +37 -8
- package/_modules/components/Delivery/DriversGroupsDeliveryZoneDetails/index.js +125 -0
- package/_modules/components/Delivery/DriversGroupsDeliveryZoneDetails/styles.js +62 -0
- package/_modules/components/Delivery/DriversGroupsList/index.js +2 -1
- package/_modules/components/Delivery/DriversGroupsListing/index.js +12 -6
- package/_modules/components/Home/HomePage/index.js +2 -2
- package/_modules/components/Orders/Messages/index.js +1 -1
- package/_modules/components/SidebarMenu/index.js +4 -3
- package/_modules/components/SidebarMenu/styles.js +22 -18
- package/_modules/components/Stores/BusinessDelete/index.js +99 -0
- package/_modules/components/Stores/BusinessDelete/styles.js +19 -0
- package/_modules/components/Stores/BusinessDeliveryGroupsDetails/index.js +181 -0
- package/_modules/components/Stores/BusinessDeliveryGroupsDetails/styles.js +14 -0
- package/_modules/components/Stores/BusinessDeliveryPickupMore/index.js +5 -1
- package/_modules/components/Stores/BusinessDeliveryZoneInformation/index.js +34 -12
- package/_modules/components/Stores/BusinessDeliveryZoneInformation/styles.js +1 -1
- package/_modules/components/Stores/BusinessProductAddForm/index.js +4 -4
- package/_modules/components/Stores/BusinessesList/index.js +75 -10
- package/_modules/components/Stores/BusinessesList/styles.js +26 -3
- package/_modules/components/Stores/BusinessesListing/index.js +19 -4
- package/_modules/components/Stores/BusinessesListing/styles.js +10 -3
- package/_modules/components/Stores/PaymentOptionMethods/index.js +11 -12
- package/_modules/components/Stores/PaymentOptionMethods/styles.js +1 -5
- package/_modules/components/Stores/PaymentOptionPaypal/index.js +6 -7
- package/_modules/components/Stores/PaymentOptionPaypal/styles.js +1 -5
- package/_modules/components/Stores/PaymentOptionSquare/index.js +1 -1
- package/_modules/components/Stores/PaymentOptionStripeDirect/index.js +11 -12
- package/_modules/components/Stores/PaymentOptionStripeDirect/styles.js +1 -5
- package/_modules/components/Stores/PaymethodOptionPaypalExpress/index.js +11 -12
- package/_modules/components/Stores/PaymethodOptionPaypalExpress/styles.js +1 -5
- package/_modules/components/Stores/PaymethodOptionStripeRedirect/index.js +11 -12
- package/_modules/components/Stores/PaymethodOptionStripeRedirect/styles.js +1 -5
- package/_modules/components/Stores/SingleBusiness/index.js +37 -19
- package/_modules/components/Stores/SingleBusiness/styles.js +20 -3
- package/_modules/components/Stores/index.js +7 -0
- package/package.json +2 -2
- package/src/components/Delivery/DriversGroupDeliveryDetails/index.js +84 -0
- package/src/components/Delivery/DriversGroupDeliveryDetails/styles.js +11 -0
- package/src/components/Delivery/DriversGroupDeliveryZoneInformation/index.js +278 -0
- package/src/components/Delivery/DriversGroupDeliveryZoneInformation/styles.js +93 -0
- package/src/components/Delivery/DriversGroupDeliveryZoneList/index.js +134 -0
- package/src/components/Delivery/DriversGroupDeliveryZoneList/styles.js +87 -0
- package/src/components/Delivery/DriversGroupDetails/index.js +29 -6
- package/src/components/Delivery/DriversGroupsDeliveryZoneDetails/index.js +123 -0
- package/src/components/Delivery/DriversGroupsDeliveryZoneDetails/styles.js +125 -0
- package/src/components/Delivery/DriversGroupsList/index.js +2 -2
- package/src/components/Delivery/DriversGroupsListing/index.js +4 -1
- package/src/components/Home/HomePage/index.js +3 -3
- package/src/components/Orders/Messages/index.js +1 -1
- package/src/components/SidebarMenu/index.js +25 -15
- package/src/components/SidebarMenu/styles.js +10 -2
- package/src/components/Stores/BusinessDelete/index.js +99 -0
- package/src/components/Stores/BusinessDelete/styles.js +40 -0
- package/src/components/Stores/BusinessDeliveryGroupsDetails/index.js +127 -0
- package/src/components/Stores/BusinessDeliveryGroupsDetails/styles.js +16 -0
- package/src/components/Stores/BusinessDeliveryPickupMore/index.js +6 -1
- package/src/components/Stores/BusinessDeliveryZoneInformation/index.js +35 -10
- package/src/components/Stores/BusinessDeliveryZoneInformation/styles.js +1 -1
- package/src/components/Stores/BusinessProductAddForm/index.js +2 -2
- package/src/components/Stores/BusinessesList/index.js +83 -10
- package/src/components/Stores/BusinessesList/styles.js +52 -0
- package/src/components/Stores/BusinessesListing/index.js +27 -8
- package/src/components/Stores/BusinessesListing/styles.js +34 -0
- package/src/components/Stores/PaymentOptionMethods/index.js +9 -12
- package/src/components/Stores/PaymentOptionMethods/styles.js +0 -10
- package/src/components/Stores/PaymentOptionPaypal/index.js +9 -12
- package/src/components/Stores/PaymentOptionPaypal/styles.js +0 -10
- package/src/components/Stores/PaymentOptionSquare/index.js +1 -1
- package/src/components/Stores/PaymentOptionStripeDirect/index.js +9 -12
- package/src/components/Stores/PaymentOptionStripeDirect/styles.js +0 -10
- package/src/components/Stores/PaymethodOptionPaypalExpress/index.js +9 -12
- package/src/components/Stores/PaymethodOptionPaypalExpress/styles.js +0 -10
- package/src/components/Stores/PaymethodOptionStripeRedirect/index.js +9 -12
- package/src/components/Stores/PaymethodOptionStripeRedirect/styles.js +0 -10
- package/src/components/Stores/SingleBusiness/index.js +38 -13
- package/src/components/Stores/SingleBusiness/styles.js +30 -0
- package/src/components/Stores/index.js +2 -0
- package/template/assets/images/myProducts/driver-app-brand.png +0 -0
- package/template/assets/images/myProducts/driver-app-free.png +0 -0
- package/template/assets/images/myProducts/multi-store-customer-app.png +0 -0
- package/template/assets/images/myProducts/my-callcenter-app-brand.png +0 -0
- package/template/assets/images/myProducts/my-callcenter-app-live.png +0 -0
- package/template/assets/images/myProducts/my-kiosk-app-brand.png +0 -0
- package/template/assets/images/myProducts/my-kiosk-app-live.png +0 -0
- package/template/assets/images/myProducts/my-pos-app-brand.png +0 -0
- package/template/assets/images/myProducts/my-pos-app-live.png +0 -0
- package/template/assets/images/myProducts/ordering-website.png +0 -0
- package/template/assets/images/myProducts/single-store-customer-app.png +0 -0
- package/template/assets/images/myProducts/store-app-brand.png +0 -0
- package/template/assets/images/myProducts/store-app-free.png +0 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
useConfig, useLanguage, useUtils, ExamineClick, BusinessZoneGoogleMaps as DriverGroupZoneGoogleMaps
|
|
4
|
+
} from 'ordering-components-admin-external'
|
|
5
|
+
import { Select } from '../../../styles/Select/FirstSelect'
|
|
6
|
+
import { Button, Input } from '../../../styles'
|
|
7
|
+
import { Alert } from '../../Shared'
|
|
8
|
+
import { useForm } from 'react-hook-form'
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
FormContainer,
|
|
12
|
+
TypeSelectWrapper,
|
|
13
|
+
WrapperMap,
|
|
14
|
+
ErrorText,
|
|
15
|
+
FormControl,
|
|
16
|
+
Row,
|
|
17
|
+
KmlButtonWrapper
|
|
18
|
+
} from './styles'
|
|
19
|
+
|
|
20
|
+
export const DriverGroupDeliveryZoneInformation = (props) => {
|
|
21
|
+
const {
|
|
22
|
+
zone,
|
|
23
|
+
driverGroupsZones,
|
|
24
|
+
formState,
|
|
25
|
+
handleChangeInput,
|
|
26
|
+
handleChangeFormState,
|
|
27
|
+
handleUpdateDriverGroupDeliveryZone,
|
|
28
|
+
handleAddDriverGroupDeliveryZone,
|
|
29
|
+
handleUploadKmlFiles,
|
|
30
|
+
kmlData
|
|
31
|
+
} = props
|
|
32
|
+
|
|
33
|
+
const [, t] = useLanguage()
|
|
34
|
+
const { handleSubmit, register, errors } = useForm()
|
|
35
|
+
const [{ parseNumber }] = useUtils()
|
|
36
|
+
const [configState] = useConfig()
|
|
37
|
+
const [clearState, setClearState] = useState(false)
|
|
38
|
+
const [infoContentString, setInfoContentString] = useState('')
|
|
39
|
+
const [zoneType, setZoneType] = useState(zone?.type || 2)
|
|
40
|
+
const [zoneData, setZoneData] = useState(zone?.data)
|
|
41
|
+
const [alertState, setAlertState] = useState({ open: false, content: [] })
|
|
42
|
+
const [isShowMap, setIsShowMap] = useState(false)
|
|
43
|
+
const kmlRef = useRef(null)
|
|
44
|
+
|
|
45
|
+
const typeOptions = [
|
|
46
|
+
{ value: 1, content: t('CIRCLE', 'Circle') },
|
|
47
|
+
{ value: 2, content: t('POLYGON', 'Polygon') },
|
|
48
|
+
{ value: 4, content: t('EVERYWHERE', 'Everywhere') },
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
const googleMapsControls = {
|
|
52
|
+
defaultZoom: 8,
|
|
53
|
+
zoomControl: true,
|
|
54
|
+
streetViewControl: false,
|
|
55
|
+
fullscreenControl: false,
|
|
56
|
+
mapTypeId: 'roadmap', // 'roadmap', 'satellite', 'hybrid', 'terrain'
|
|
57
|
+
mapTypeControl: false,
|
|
58
|
+
mapTypeControlOptions: {
|
|
59
|
+
mapTypeIds: ['roadmap', 'satellite']
|
|
60
|
+
},
|
|
61
|
+
isMarkerDraggable: false,
|
|
62
|
+
defaultPosition: { lat: 40.77473399999999, lng: -73.9653844 }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const fillStyle = {
|
|
66
|
+
fillColor: '#2C7BE5',
|
|
67
|
+
strokeColor: '#03459E',
|
|
68
|
+
fillOpacity: 0.2,
|
|
69
|
+
strokeWeight: 2,
|
|
70
|
+
editable: true
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const greenFillStyle = {
|
|
74
|
+
fillColor: '#008000',
|
|
75
|
+
fillOpacity: 0.3,
|
|
76
|
+
strokeColor: '#008000',
|
|
77
|
+
strokeOpacity: 0.8,
|
|
78
|
+
strokeWeight: 2
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const handleChangeType = (type) => {
|
|
82
|
+
handleChangeFormState({ type: type })
|
|
83
|
+
setClearState(true)
|
|
84
|
+
setZoneType(type)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const handleZoneData = (data) => {
|
|
88
|
+
setZoneData(data)
|
|
89
|
+
handleChangeFormState({ data: data })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const onSubmit = () => {
|
|
93
|
+
if (formState?.changes?.data || zoneType === 4) {
|
|
94
|
+
if (!zone) handleAddDriverGroupDeliveryZone()
|
|
95
|
+
else handleUpdateDriverGroupDeliveryZone()
|
|
96
|
+
} else {
|
|
97
|
+
setAlertState({
|
|
98
|
+
open: true,
|
|
99
|
+
content: t('REQUIRED_POLYGON_CIRCLE', 'Add a distance based or draw a polygon or circle.')
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const closeAlert = () => {
|
|
105
|
+
setAlertState({
|
|
106
|
+
open: false,
|
|
107
|
+
content: []
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (clearState) {
|
|
113
|
+
handleZoneData(null)
|
|
114
|
+
}
|
|
115
|
+
}, [clearState])
|
|
116
|
+
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
if (zoneType === 2 || zoneType === 4) return
|
|
119
|
+
let content = '<div style="width: 90px; height: 30px">' + '<span>Radius: </span>'
|
|
120
|
+
content += parseNumber(zoneData?.radio || zoneData?.distance)
|
|
121
|
+
content += `<span>${zoneType === 5 ? configState?.configs?.distance_unit?.value : 'km'}</span>` + '</div>'
|
|
122
|
+
setInfoContentString(content)
|
|
123
|
+
}, [zoneData, zoneType])
|
|
124
|
+
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
setClearState(false)
|
|
127
|
+
setZoneType(zone?.type || 2)
|
|
128
|
+
setZoneData(zone?.data)
|
|
129
|
+
setIsShowMap(false)
|
|
130
|
+
setTimeout(() => {
|
|
131
|
+
setIsShowMap(true)
|
|
132
|
+
}, [100])
|
|
133
|
+
}, [zone?.id])
|
|
134
|
+
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (Object?.keys(errors)?.length > 0) {
|
|
137
|
+
setAlertState({
|
|
138
|
+
open: true,
|
|
139
|
+
content: Object?.values(errors)?.map((error) => error?.message)
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
}, [errors])
|
|
143
|
+
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
if (formState?.error) {
|
|
146
|
+
setAlertState({
|
|
147
|
+
open: true,
|
|
148
|
+
content: formState?.error
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
}, [formState])
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<>
|
|
155
|
+
<FormContainer onSubmit={handleSubmit(onSubmit)} autoComplete='off'>
|
|
156
|
+
<Row>
|
|
157
|
+
<FormControl>
|
|
158
|
+
<label>{t('NAME', 'Name')}</label>
|
|
159
|
+
<Input
|
|
160
|
+
placeholder={t('NAME', 'Name')}
|
|
161
|
+
name='name'
|
|
162
|
+
value={formState?.changes?.name ?? zone?.name ?? ''}
|
|
163
|
+
onChange={handleChangeInput}
|
|
164
|
+
ref={register({
|
|
165
|
+
required: t('NAME_REQUIRED', 'The name is required.')
|
|
166
|
+
})}
|
|
167
|
+
/>
|
|
168
|
+
</FormControl>
|
|
169
|
+
<FormControl>
|
|
170
|
+
<label>{t('TYPE', 'Type')}</label>
|
|
171
|
+
<TypeSelectWrapper>
|
|
172
|
+
<Select
|
|
173
|
+
defaultValue={parseInt(formState?.changes?.type || zoneType)}
|
|
174
|
+
options={typeOptions}
|
|
175
|
+
onChange={handleChangeType}
|
|
176
|
+
/>
|
|
177
|
+
</TypeSelectWrapper>
|
|
178
|
+
</FormControl>
|
|
179
|
+
</Row>
|
|
180
|
+
<Row>
|
|
181
|
+
<FormControl>
|
|
182
|
+
<label>{t('MINIMUN_PURCHASED', 'Minimum purchase')}</label>
|
|
183
|
+
<Input
|
|
184
|
+
placeholder='$0.00'
|
|
185
|
+
name='minimum'
|
|
186
|
+
value={formState?.changes?.minimum ?? zone?.minimum ?? ''}
|
|
187
|
+
onChange={handleChangeInput}
|
|
188
|
+
ref={register({
|
|
189
|
+
required: t('MINIMUN_PURCHASED_REQUIRED', 'The minimum purchase is required.')
|
|
190
|
+
})}
|
|
191
|
+
/>
|
|
192
|
+
</FormControl>
|
|
193
|
+
<FormControl>
|
|
194
|
+
<label>{t('DELIVERY_FEE', 'Delivery fee')}</label>
|
|
195
|
+
<Input
|
|
196
|
+
placeholder='$0.00'
|
|
197
|
+
name='price'
|
|
198
|
+
value={formState?.changes?.price ?? zone?.price ?? ''}
|
|
199
|
+
onChange={handleChangeInput}
|
|
200
|
+
ref={register({
|
|
201
|
+
required: t('DELIVERY_PRICE_REQUIRED', 'The delivery price is required.')
|
|
202
|
+
})}
|
|
203
|
+
/>
|
|
204
|
+
</FormControl>
|
|
205
|
+
</Row>
|
|
206
|
+
{zoneType !== 4 && isShowMap && (
|
|
207
|
+
configState?.configs?.google_maps_api_key?.value ? (
|
|
208
|
+
<WrapperMap>
|
|
209
|
+
<button
|
|
210
|
+
type='button'
|
|
211
|
+
onClick={() => setClearState(true)}
|
|
212
|
+
>
|
|
213
|
+
{t('CLEAR', 'Clear')}
|
|
214
|
+
</button>
|
|
215
|
+
<DriverGroupZoneGoogleMaps
|
|
216
|
+
distance={formState?.changes?.data?.distance}
|
|
217
|
+
apiKey={configState?.configs?.google_maps_api_key?.value}
|
|
218
|
+
mapControls={googleMapsControls}
|
|
219
|
+
clearState={clearState}
|
|
220
|
+
setClearState={setClearState}
|
|
221
|
+
type={zoneType}
|
|
222
|
+
data={formState?.changes?.data || zoneData}
|
|
223
|
+
handleData={handleZoneData}
|
|
224
|
+
fillStyle={fillStyle}
|
|
225
|
+
infoContentString={infoContentString}
|
|
226
|
+
greenFillStyle={greenFillStyle}
|
|
227
|
+
isAddMode={!zone}
|
|
228
|
+
businessZones={driverGroupsZones}
|
|
229
|
+
kmlData={kmlData}
|
|
230
|
+
isDriverGroup
|
|
231
|
+
/>
|
|
232
|
+
</WrapperMap>
|
|
233
|
+
) : (
|
|
234
|
+
<ErrorText>{t('REQUIRED_GOOGLE_MAP_API_KEY', 'Google Maps api key is required')}</ErrorText>
|
|
235
|
+
)
|
|
236
|
+
)}
|
|
237
|
+
{!zone && (
|
|
238
|
+
<KmlButtonWrapper>
|
|
239
|
+
<Button
|
|
240
|
+
color='primary'
|
|
241
|
+
borderRadius='8px'
|
|
242
|
+
type='button'
|
|
243
|
+
onClick={() => kmlRef.current.click()}
|
|
244
|
+
>
|
|
245
|
+
<ExamineClick
|
|
246
|
+
onFiles={files => handleUploadKmlFiles(files)}
|
|
247
|
+
childRef={e => { kmlRef.current = e }}
|
|
248
|
+
accept='.kml,.kmz'
|
|
249
|
+
>
|
|
250
|
+
<span>{t('UPLOAD_KML', 'Upload KML')}</span>
|
|
251
|
+
</ExamineClick>
|
|
252
|
+
</Button>
|
|
253
|
+
</KmlButtonWrapper>
|
|
254
|
+
)}
|
|
255
|
+
|
|
256
|
+
<Button
|
|
257
|
+
color='primary'
|
|
258
|
+
borderRadius='8px'
|
|
259
|
+
type='submit'
|
|
260
|
+
disabled={formState?.loading || Object?.keys(formState?.changes)?.length === 0}
|
|
261
|
+
>
|
|
262
|
+
{
|
|
263
|
+
!zone ? t('ADD', 'Add') : t('SAVE', 'Save')
|
|
264
|
+
}
|
|
265
|
+
</Button>
|
|
266
|
+
</FormContainer>
|
|
267
|
+
<Alert
|
|
268
|
+
title={t('WEB_APPNAME', 'Ordering')}
|
|
269
|
+
content={alertState?.content}
|
|
270
|
+
acceptText={t('ACCEPT', 'Accept')}
|
|
271
|
+
open={alertState?.open}
|
|
272
|
+
onClose={() => closeAlert()}
|
|
273
|
+
onAccept={() => closeAlert()}
|
|
274
|
+
closeOnBackdrop={false}
|
|
275
|
+
/>
|
|
276
|
+
</>
|
|
277
|
+
)
|
|
278
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components'
|
|
2
|
+
|
|
3
|
+
export const FormContainer = styled.form`
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
min-height: calc(100% - 130px);
|
|
7
|
+
|
|
8
|
+
> button {
|
|
9
|
+
width: fit-content;
|
|
10
|
+
position: sticky;
|
|
11
|
+
top: 100%;
|
|
12
|
+
margin-top: 30px;
|
|
13
|
+
height: 42px;
|
|
14
|
+
}
|
|
15
|
+
`
|
|
16
|
+
export const TypeSelectWrapper = styled.div`
|
|
17
|
+
.select {
|
|
18
|
+
background: ${props => props.theme.colors.secundary};
|
|
19
|
+
width: 100%;
|
|
20
|
+
border: none;
|
|
21
|
+
font-size: 14px;
|
|
22
|
+
color: ${props => props.theme.colors.headingColor};
|
|
23
|
+
> div:first-child {
|
|
24
|
+
padding-top: 4px;
|
|
25
|
+
padding-bottom: 4px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`
|
|
29
|
+
export const WrapperMap = styled.div`
|
|
30
|
+
width: 100%;
|
|
31
|
+
height: 300px;
|
|
32
|
+
display: flex;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
margin: 29px 0 20px 0;
|
|
36
|
+
position: relative;
|
|
37
|
+
> div {
|
|
38
|
+
position: relative !important;
|
|
39
|
+
width: 100% !important;
|
|
40
|
+
height: 100% !important;
|
|
41
|
+
border-radius: 8px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
> button {
|
|
45
|
+
position: absolute;
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
padding: 0 5px;
|
|
48
|
+
background: ${props => props.theme.colors?.backgroundPage || '#FFF'};
|
|
49
|
+
top: 10px;
|
|
50
|
+
z-index: 10;
|
|
51
|
+
border: none;
|
|
52
|
+
box-shadow: rgb(0 0 0 / 30%) 0px 1px 4px;
|
|
53
|
+
color: ${props => props.theme.colors.headingColor};
|
|
54
|
+
${props => props.theme?.rtl ? css`
|
|
55
|
+
right: 10px;
|
|
56
|
+
` : css`
|
|
57
|
+
left: 10px;
|
|
58
|
+
`}
|
|
59
|
+
&:hover {
|
|
60
|
+
background: #eee;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
`
|
|
64
|
+
|
|
65
|
+
export const ErrorText = styled.div`
|
|
66
|
+
font-size: 14px;
|
|
67
|
+
color: ${props => props.theme.colors.lightGray};
|
|
68
|
+
text-align: center;
|
|
69
|
+
margin: 20px 0;
|
|
70
|
+
`
|
|
71
|
+
export const FormControl = styled.div`
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
label {
|
|
75
|
+
font-size: 14px;
|
|
76
|
+
margin-bottom: 9px;
|
|
77
|
+
}
|
|
78
|
+
input {
|
|
79
|
+
width: 100%;
|
|
80
|
+
}
|
|
81
|
+
`
|
|
82
|
+
export const Row = styled.div`
|
|
83
|
+
display: flex;
|
|
84
|
+
justify-content: space-between;
|
|
85
|
+
margin-bottom: 29px;
|
|
86
|
+
|
|
87
|
+
> div {
|
|
88
|
+
width: 45%;
|
|
89
|
+
}
|
|
90
|
+
`
|
|
91
|
+
export const KmlButtonWrapper = styled.div`
|
|
92
|
+
margin-bottom: 20px;
|
|
93
|
+
`
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { useLanguage } from 'ordering-components-admin-external'
|
|
3
|
+
import { DriverGroupDeliveryZoneDetails } from '../DriversGroupsDeliveryZoneDetails'
|
|
4
|
+
import { SideBar } from '../../Shared'
|
|
5
|
+
import { ChevronRight } from 'react-bootstrap-icons'
|
|
6
|
+
import { Checkbox } from '../../../styles'
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ZoneContainer,
|
|
10
|
+
DeliveryZonesTable,
|
|
11
|
+
AddDeliveryZoneButton,
|
|
12
|
+
ZoneTbody,
|
|
13
|
+
CheckboxWrapper,
|
|
14
|
+
DeliveryZonesTableWrapper,
|
|
15
|
+
CheckSkeleteon,
|
|
16
|
+
InfoBlock
|
|
17
|
+
} from './styles'
|
|
18
|
+
import Skeleton from 'react-loading-skeleton'
|
|
19
|
+
|
|
20
|
+
export const DriverGroupDeliveryZoneList = (props) => {
|
|
21
|
+
const {
|
|
22
|
+
drivergroup,
|
|
23
|
+
setIsExtendExtraOpen,
|
|
24
|
+
handleSuccessUpdate,
|
|
25
|
+
zoneListState,
|
|
26
|
+
handleChangeZoneState,
|
|
27
|
+
handleChangeAllZoneState,
|
|
28
|
+
handleParentSidebarMove,
|
|
29
|
+
zoneList,
|
|
30
|
+
setZoneList,
|
|
31
|
+
setIsOpenDetails,
|
|
32
|
+
isOpenDetails
|
|
33
|
+
} = props
|
|
34
|
+
|
|
35
|
+
const [, t] = useLanguage()
|
|
36
|
+
const [curZone, setCurZone] = useState(null)
|
|
37
|
+
|
|
38
|
+
const handleCloseOption = () => {
|
|
39
|
+
setIsOpenDetails(false)
|
|
40
|
+
setIsExtendExtraOpen(false)
|
|
41
|
+
setCurZone(null)
|
|
42
|
+
handleParentSidebarMove(0)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const handleOpenZone = (e, zone) => {
|
|
46
|
+
const isInvalid = e.target.closest('.zone-enabled')
|
|
47
|
+
if (isInvalid) return
|
|
48
|
+
setCurZone(zone)
|
|
49
|
+
handleParentSidebarMove(500)
|
|
50
|
+
setIsExtendExtraOpen(true)
|
|
51
|
+
setIsOpenDetails(true)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<>
|
|
56
|
+
<ZoneContainer>
|
|
57
|
+
{zoneList.loading ? (
|
|
58
|
+
[...Array(5).keys()].map(i => (
|
|
59
|
+
<DeliveryZonesTableWrapper key={i}>
|
|
60
|
+
<CheckSkeleteon>
|
|
61
|
+
<Skeleton width={18} height={18} />
|
|
62
|
+
</CheckSkeleteon>
|
|
63
|
+
<InfoBlock>
|
|
64
|
+
<Skeleton width='100%' height={18} />
|
|
65
|
+
</InfoBlock>
|
|
66
|
+
</DeliveryZonesTableWrapper>
|
|
67
|
+
))
|
|
68
|
+
) :
|
|
69
|
+
<DeliveryZonesTable>
|
|
70
|
+
<thead>
|
|
71
|
+
<tr>
|
|
72
|
+
<th>
|
|
73
|
+
<CheckboxWrapper>
|
|
74
|
+
<Checkbox
|
|
75
|
+
checked={zoneListState?.isCheckAll}
|
|
76
|
+
onChange={e => handleChangeAllZoneState(e.target.checked)}
|
|
77
|
+
/>
|
|
78
|
+
</CheckboxWrapper>
|
|
79
|
+
</th>
|
|
80
|
+
<th>{t('NAME', 'Name')}</th>
|
|
81
|
+
<th>{t('MINIMUM', 'Minimum')}</th>
|
|
82
|
+
<th>{t('PRICE', 'Price')}</th>
|
|
83
|
+
<th />
|
|
84
|
+
</tr>
|
|
85
|
+
</thead>
|
|
86
|
+
{zoneList?.zones?.filter(zone => zone?.type !== 3)?.map(zone => (
|
|
87
|
+
<ZoneTbody
|
|
88
|
+
key={zone?.id}
|
|
89
|
+
active={zone?.id === curZone?.id}
|
|
90
|
+
onClick={(e) => handleOpenZone(e, zone)}
|
|
91
|
+
>
|
|
92
|
+
<tr>
|
|
93
|
+
<td>
|
|
94
|
+
<CheckboxWrapper className='zone-enabled'>
|
|
95
|
+
<Checkbox
|
|
96
|
+
checked={!!zoneListState?.changes[zone.id]}
|
|
97
|
+
onChange={e => handleChangeZoneState(zone?.id, e?.target?.checked)}
|
|
98
|
+
/>
|
|
99
|
+
</CheckboxWrapper>
|
|
100
|
+
</td>
|
|
101
|
+
<td>{zone?.name}</td>
|
|
102
|
+
<td>{zone?.minimum}</td>
|
|
103
|
+
<td>{zone?.price}</td>
|
|
104
|
+
<td className='arrow'><ChevronRight /></td>
|
|
105
|
+
</tr>
|
|
106
|
+
</ZoneTbody>
|
|
107
|
+
))}
|
|
108
|
+
</DeliveryZonesTable>
|
|
109
|
+
}
|
|
110
|
+
<AddDeliveryZoneButton
|
|
111
|
+
onClick={(e) => handleOpenZone(e, null)}
|
|
112
|
+
>
|
|
113
|
+
{t('ADD_DELIVERY_ZONE', 'Add delivery zone')}
|
|
114
|
+
</AddDeliveryZoneButton>
|
|
115
|
+
</ZoneContainer>
|
|
116
|
+
{isOpenDetails && (
|
|
117
|
+
<SideBar
|
|
118
|
+
isBorderShow
|
|
119
|
+
open={isOpenDetails}
|
|
120
|
+
onClose={() => handleCloseOption()}
|
|
121
|
+
>
|
|
122
|
+
<DriverGroupDeliveryZoneDetails
|
|
123
|
+
zone={curZone}
|
|
124
|
+
setZoneList={setZoneList}
|
|
125
|
+
drivergroup={drivergroup}
|
|
126
|
+
onClose={() => handleCloseOption()}
|
|
127
|
+
handleSuccessUpdate={handleSuccessUpdate}
|
|
128
|
+
driverGroupsZones={zoneList}
|
|
129
|
+
/>
|
|
130
|
+
</SideBar>
|
|
131
|
+
)}
|
|
132
|
+
</>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components'
|
|
2
|
+
|
|
3
|
+
export const ZoneContainer = styled.div`
|
|
4
|
+
margin: 30px 0 20px 0;
|
|
5
|
+
@media (min-width: 1000px) {
|
|
6
|
+
max-width: 500px;
|
|
7
|
+
}
|
|
8
|
+
`
|
|
9
|
+
|
|
10
|
+
export const DeliveryZonesTable = styled.table`
|
|
11
|
+
width: 100%;
|
|
12
|
+
border-collapse: collapse;
|
|
13
|
+
thead {
|
|
14
|
+
border-bottom: 1px solid ${props => props.theme.colors.borderColor};
|
|
15
|
+
tr {
|
|
16
|
+
th {
|
|
17
|
+
font-size: 12px;
|
|
18
|
+
font-weight: 700;
|
|
19
|
+
padding: 10px 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`
|
|
24
|
+
|
|
25
|
+
export const DeliveryZonesTableWrapper = styled.div`
|
|
26
|
+
width: 100%;
|
|
27
|
+
display: flex;
|
|
28
|
+
margin-bottom: 20px;
|
|
29
|
+
`
|
|
30
|
+
|
|
31
|
+
export const CheckSkeleteon = styled.div`
|
|
32
|
+
width: 18px;
|
|
33
|
+
height: 18px;
|
|
34
|
+
margin-right: 5px;
|
|
35
|
+
`
|
|
36
|
+
|
|
37
|
+
export const InfoBlock = styled.div`
|
|
38
|
+
width: 100%;
|
|
39
|
+
`
|
|
40
|
+
|
|
41
|
+
export const ZoneTbody = styled.tbody`
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
border-bottom: 1px solid ${props => props.theme.colors.borderColor};
|
|
44
|
+
tr {
|
|
45
|
+
td {
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
padding: 13px 0;
|
|
48
|
+
&.arrow {
|
|
49
|
+
font-size: 13px;
|
|
50
|
+
color: ${props => props.theme.colors.secundaryLight};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
&:hover {
|
|
55
|
+
background-color: ${props => props.theme.colors.lightPrimary};
|
|
56
|
+
}
|
|
57
|
+
${({ active }) => active && css`
|
|
58
|
+
background-color: ${props => props.theme.colors.lightPrimary};
|
|
59
|
+
td {
|
|
60
|
+
border-top: 1px solid ${props => props.theme.colors.primary};
|
|
61
|
+
border-bottom: 1px solid ${props => props.theme.colors.primary};
|
|
62
|
+
}
|
|
63
|
+
`}
|
|
64
|
+
`
|
|
65
|
+
export const ActionsWrapper = styled.div`
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
`
|
|
69
|
+
|
|
70
|
+
export const AddDeliveryZoneButton = styled.div`
|
|
71
|
+
color: ${props => props.theme.colors.lightGray};
|
|
72
|
+
font-size: 14px;
|
|
73
|
+
padding: 10px 0;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
width: fit-content;
|
|
76
|
+
&:hover {
|
|
77
|
+
color: ${props => props.theme.colors.primary};
|
|
78
|
+
}
|
|
79
|
+
`
|
|
80
|
+
export const CheckboxWrapper = styled.div`
|
|
81
|
+
display: flex;
|
|
82
|
+
${props => props.theme?.rtl ? css`
|
|
83
|
+
margin-left: 10px;
|
|
84
|
+
` : css`
|
|
85
|
+
margin-right: 10px;
|
|
86
|
+
`}
|
|
87
|
+
`
|
|
@@ -14,6 +14,8 @@ import { DriversGroupBusinesses } from '../DriversGroupBusinesses'
|
|
|
14
14
|
import { DriversGroupPaymethods } from '../DriversGroupPaymethods'
|
|
15
15
|
import { DriversGroupLogistics } from '../DriversGroupLogistics'
|
|
16
16
|
import { DriversGroupLogs } from '../DriversGroupLogs'
|
|
17
|
+
import { DriverGroupDeliveryDetails } from '../DriversGroupDeliveryDetails'
|
|
18
|
+
import { useWindowSize } from '../../../hooks/useWindowSize'
|
|
17
19
|
|
|
18
20
|
import {
|
|
19
21
|
DetailsContainer,
|
|
@@ -30,11 +32,13 @@ const DriversGroupDetailsUI = (props) => {
|
|
|
30
32
|
handleParentSidebarMove,
|
|
31
33
|
handleDeleteDriversGroup,
|
|
32
34
|
handleNextTour,
|
|
33
|
-
handleUpdateDriversGroup
|
|
35
|
+
handleUpdateDriversGroup,
|
|
36
|
+
setIsExtendExtraOpen
|
|
34
37
|
} = props
|
|
35
38
|
|
|
36
39
|
const theme = useTheme()
|
|
37
40
|
const [, t] = useLanguage()
|
|
41
|
+
const { width } = useWindowSize()
|
|
38
42
|
const [configState] = useConfig()
|
|
39
43
|
|
|
40
44
|
const autoAssignType = configState?.configs?.autoassign_type?.value
|
|
@@ -44,12 +48,14 @@ const DriversGroupDetailsUI = (props) => {
|
|
|
44
48
|
const [driversGroupMenus, setDriversGroupMenus] = useState([])
|
|
45
49
|
const [confirm, setConfirm] = useState({ open: false, content: null, handleOnAccept: null })
|
|
46
50
|
const [alertState, setAlertState] = useState({ open: false, content: [] })
|
|
51
|
+
const [isOpenDetails, setIsOpenDetails] = useState(false)
|
|
47
52
|
|
|
48
53
|
useEffect(() => {
|
|
49
54
|
const _driversGroupMenus = !driversGroupState.driversGroup
|
|
50
55
|
? [
|
|
51
56
|
{ key: 'general', value: t('GENERAL', 'General') },
|
|
52
|
-
{ key: 'businesses', value: t('BUSINESSES', 'Businesses') }
|
|
57
|
+
{ key: 'businesses', value: t('BUSINESSES', 'Businesses') },
|
|
58
|
+
{ key: 'delivery_zones', value: t('DELIVERY_ZONES', 'Delivery Zones') }
|
|
53
59
|
]
|
|
54
60
|
: (useAdvanced && autoAssignType !== 'basic')
|
|
55
61
|
? [
|
|
@@ -57,18 +63,20 @@ const DriversGroupDetailsUI = (props) => {
|
|
|
57
63
|
{ key: 'businesses', value: t('BUSINESSES', 'Businesses') },
|
|
58
64
|
{ key: 'paymethods', value: t('PAYMENT_METHODS', 'Payment methods') },
|
|
59
65
|
{ key: 'advanced_logistics', value: t('ADVANCED_LOGISTICS', 'Advanced logistics') },
|
|
60
|
-
{ key: 'logs', value: t('LOGS', 'Logs') }
|
|
66
|
+
{ key: 'logs', value: t('LOGS', 'Logs') },
|
|
67
|
+
{ key: 'delivery_zones', value: t('DELIVERY_ZONES', 'Delivery Zones') }
|
|
61
68
|
]
|
|
62
69
|
: [
|
|
63
70
|
{ key: 'general', value: t('GENERAL', 'General') },
|
|
64
71
|
{ key: 'businesses', value: t('BUSINESSES', 'Businesses') },
|
|
65
72
|
{ key: 'paymethods', value: t('PAYMENT_METHODS', 'Payment methods') },
|
|
66
|
-
{ key: 'logs', value: t('LOGS', 'Logs') }
|
|
73
|
+
{ key: 'logs', value: t('LOGS', 'Logs') },
|
|
74
|
+
{ key: 'delivery_zones', value: t('DELIVERY_ZONES', 'Delivery Zones') }
|
|
67
75
|
]
|
|
68
76
|
setDriversGroupMenus(_driversGroupMenus)
|
|
69
77
|
}, [useAdvanced])
|
|
70
78
|
|
|
71
|
-
const onDeleteGroup = (
|
|
79
|
+
const onDeleteGroup = () => {
|
|
72
80
|
setConfirm({
|
|
73
81
|
open: true,
|
|
74
82
|
content: t('QUESTION_DELETE_DRIVER_GROUP', 'Are you sure to remove this driver group?'),
|
|
@@ -79,6 +87,10 @@ const DriversGroupDetailsUI = (props) => {
|
|
|
79
87
|
})
|
|
80
88
|
}
|
|
81
89
|
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (width > 1000) setIsExtendExtraOpen(false)
|
|
92
|
+
}, [width])
|
|
93
|
+
|
|
82
94
|
const handleNextClick = () => {
|
|
83
95
|
setShowMenu('businesses')
|
|
84
96
|
handleNextTour()
|
|
@@ -90,7 +102,9 @@ const DriversGroupDetailsUI = (props) => {
|
|
|
90
102
|
|
|
91
103
|
useEffect(() => {
|
|
92
104
|
handleParentSidebarMove(0)
|
|
93
|
-
|
|
105
|
+
setIsOpenDetails(false)
|
|
106
|
+
setIsExtendExtraOpen(false)
|
|
107
|
+
}, [showMenu, driversGroupState.driversGroup?.id])
|
|
94
108
|
|
|
95
109
|
useEffect(() => {
|
|
96
110
|
if (!actionState?.error) return
|
|
@@ -166,6 +180,15 @@ const DriversGroupDetailsUI = (props) => {
|
|
|
166
180
|
{showMenu === 'logs' && (
|
|
167
181
|
<DriversGroupLogs driversGroupId={driversGroupState.driversGroup?.id} />
|
|
168
182
|
)}
|
|
183
|
+
{showMenu === 'delivery_zones' && (
|
|
184
|
+
<DriverGroupDeliveryDetails {...props}
|
|
185
|
+
handleParentSidebarMove={handleParentSidebarMove}
|
|
186
|
+
drivergroup={driversGroupState.driversGroup}
|
|
187
|
+
setIsExtendExtraOpen={setIsExtendExtraOpen}
|
|
188
|
+
setIsOpenDetails={setIsOpenDetails}
|
|
189
|
+
isOpenDetails={isOpenDetails}
|
|
190
|
+
/>
|
|
191
|
+
)}
|
|
169
192
|
</DetailsContainer>
|
|
170
193
|
<Alert
|
|
171
194
|
title={t('WEB_APPNAME', 'Ordering')}
|