ordering-ui-admin-external 1.40.6 → 1.40.7

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.
Files changed (21) hide show
  1. package/_bundles/{ordering-ui-admin.d02d845770d3dce923e9.js → ordering-ui-admin.dfe73eabfdf7ae04cad1.js} +2 -2
  2. package/_modules/components/Settings/AddressFieldsSetting/index.js +119 -12
  3. package/_modules/components/Settings/AddressFieldsSetting/styles.js +31 -6
  4. package/_modules/components/Settings/CardFieldsSetting/index.js +120 -12
  5. package/_modules/components/Settings/CardFieldsSetting/styles.js +31 -6
  6. package/_modules/components/Settings/CheckoutFieldsSetting/index.js +117 -11
  7. package/_modules/components/Settings/CheckoutFieldsSetting/styles.js +32 -7
  8. package/_modules/components/Settings/GuestCheckoutFieldsSetting/index.js +19 -1
  9. package/_modules/components/Settings/GuestCheckoutFieldsSetting/styles.js +1 -1
  10. package/_modules/components/Settings/Settings/index.js +97 -10
  11. package/package.json +2 -2
  12. package/src/components/Settings/AddressFieldsSetting/index.js +159 -45
  13. package/src/components/Settings/AddressFieldsSetting/styles.js +60 -0
  14. package/src/components/Settings/CardFieldsSetting/index.js +161 -46
  15. package/src/components/Settings/CardFieldsSetting/styles.js +60 -0
  16. package/src/components/Settings/CheckoutFieldsSetting/index.js +157 -44
  17. package/src/components/Settings/CheckoutFieldsSetting/styles.js +64 -0
  18. package/src/components/Settings/GuestCheckoutFieldsSetting/index.js +10 -0
  19. package/src/components/Settings/GuestCheckoutFieldsSetting/styles.js +7 -0
  20. package/src/components/Settings/Settings/index.js +90 -15
  21. /package/_bundles/{ordering-ui-admin.d02d845770d3dce923e9.js.LICENSE.txt → ordering-ui-admin.dfe73eabfdf7ae04cad1.js.LICENSE.txt} +0 -0
@@ -1,66 +1,179 @@
1
- import React from 'react'
1
+ import React, { useState, useEffect } from 'react'
2
2
  import { useLanguage, CheckoutFieldsSetting as CheckoutFieldsSettingController } from 'ordering-components-admin-external'
3
- import { Switch } from '../../../styles'
3
+ import { useHistory, useLocation } from 'react-router-dom'
4
+ import { IconButton, Switch } from '../../../styles'
4
5
  import Skeleton from 'react-loading-skeleton'
6
+ import { useWindowSize } from '../../../hooks/useWindowSize'
7
+ import BsChevronRight from '@meronex/icons/bs/BsChevronRight'
8
+ import { ArrowsAngleContract, ArrowsAngleExpand } from 'react-bootstrap-icons'
9
+ import { SideBar, Alert } from '../../Shared'
5
10
 
6
11
  import {
7
12
  CheckoutFieldsDetailsContainer,
8
- FieldContainer
13
+ FieldContainer,
14
+ SitesListContainer,
15
+ Header,
16
+ SitesWrapper,
17
+ SiteItem
9
18
  } from './styles'
10
19
 
11
20
  const CheckoutFieldsSettingUI = (props) => {
12
21
  const {
13
22
  checkoutFieldsState,
14
- handleChangeCheckoutFieldSetting
23
+ handleChangeCheckoutFieldSetting,
24
+ sitesState,
25
+ setMoveDistance,
26
+ selectedSiteId,
27
+ setSelectedSiteId,
28
+ actionState
15
29
  } = props
16
30
 
17
31
  const [, t] = useLanguage()
32
+ const { width } = useWindowSize()
33
+ const history = useHistory()
34
+ const [alertState, setAlertState] = useState({ open: false, content: [] })
35
+ const query = new URLSearchParams(useLocation().search)
36
+
37
+ const [isExpand, setIsExpand] = useState(false)
38
+
39
+ const orderValidationFields = ['name', 'middle_name', 'lastname', 'second_lastname', 'email', 'mobile_phone', 'city_dropdown_option', 'address', 'zipcode', 'address_notes', 'coupon', 'driver_tip', 'comments', 'birthdate']
40
+
41
+ const handleOpenSiteSettingDetails = (siteId, isInitialRender) => {
42
+ // handleGetSiteConfigs(siteId)
43
+ setSelectedSiteId(siteId)
44
+ setMoveDistance(500)
45
+ if (!isInitialRender) {
46
+ const category = query.get('category')
47
+ history.replace(`${location.pathname}?category=${category}&site=${siteId}`)
48
+ }
49
+ }
50
+
51
+ const expandSideBar = () => {
52
+ const element = document.getElementById('sideSlider')
53
+ if (isExpand) element.style.width = '500px'
54
+ else element.style.width = '100vw'
55
+ setIsExpand(prev => !prev)
56
+ }
57
+
58
+ const handleCloseDetails = () => {
59
+ setSelectedSiteId(null)
60
+ setMoveDistance(0)
61
+ const category = query.get('category')
62
+ history.replace(`${location.pathname}?category=${category}`)
63
+ }
64
+
65
+ useEffect(() => {
66
+ if (!actionState?.error) return
67
+ setAlertState({
68
+ open: true,
69
+ content: actionState?.error
70
+ })
71
+ }, [actionState?.error])
18
72
 
19
73
  return (
20
74
  <>
21
- <CheckoutFieldsDetailsContainer>
22
- <h1>{t('CHECKOUT_CUSTOMER_FIELDS', 'Checkout and Customer fields')}</h1>
23
- <FieldContainer isHeader>
24
- <div className='name'>{t('FIELD', 'Field')}</div>
25
- <div className='required'>{t('REQUIRED', 'Required')}</div>
26
- <div className='status'>{t('STATE', 'Status')}</div>
27
- </FieldContainer>
28
- {checkoutFieldsState?.loading ? (
29
- [...Array(10).keys()].map(i => (
30
- <FieldContainer key={i}>
31
- <div className='name'><Skeleton width={120} /></div>
32
- <div className='required'>
33
- <Skeleton width={30} style={{ borderRadius: 20 }} />
34
- </div>
35
- <div className='status'>
36
- <Skeleton width={30} style={{ borderRadius: 20 }} />
37
- </div>
38
- </FieldContainer>
39
- ))
75
+ <SitesListContainer>
76
+ <Header>
77
+ <h1>{t('CHECKOUT_CUSTOMER_FIELDS', 'Checkout and Customer fields')}</h1>
78
+ {width > 576 && !selectedSiteId && (
79
+ <IconButton
80
+ color='black'
81
+ onClick={expandSideBar}
82
+ >
83
+ {isExpand ? <ArrowsAngleContract /> : <ArrowsAngleExpand />}
84
+ </IconButton>
85
+ )}
86
+ </Header>
87
+ {sitesState.loading ? (
88
+ <SitesWrapper>
89
+ {[...Array(5).keys()].map(i => (
90
+ <SiteItem key={i}>
91
+ <Skeleton width={100} height={14} />
92
+ </SiteItem>
93
+ ))}
94
+ </SitesWrapper>
40
95
  ) : (
41
- <>
42
- {checkoutFieldsState.fields.map(field => (
43
- <FieldContainer key={field.id}>
44
- <div className='name'>{t(field.code.toUpperCase())}</div>
45
- <div className='required'>
46
- <Switch
47
- defaultChecked={field.required}
48
- disabled={field.code === 'email'}
49
- onChange={(val) => handleChangeCheckoutFieldSetting(field.id, { required: val })}
50
- />
51
- </div>
52
- <div className='status'>
53
- <Switch
54
- defaultChecked={field.enabled}
55
- disabled={field.code === 'email'}
56
- onChange={(val) => handleChangeCheckoutFieldSetting(field.id, { enabled: val })}
57
- />
58
- </div>
59
- </FieldContainer>
96
+ <SitesWrapper>
97
+ {sitesState.sites.map(site => (
98
+ <SiteItem
99
+ key={site.id}
100
+ active={site.id === selectedSiteId}
101
+ onClick={() => handleOpenSiteSettingDetails(site.id)}
102
+ >
103
+ <span>{site.name}</span>
104
+ <BsChevronRight />
105
+ </SiteItem>
60
106
  ))}
61
- </>
107
+ </SitesWrapper>
62
108
  )}
63
- </CheckoutFieldsDetailsContainer>
109
+ </SitesListContainer>
110
+ {selectedSiteId && (
111
+ <SideBar
112
+ isBorderShow
113
+ open={selectedSiteId}
114
+ onClose={() => handleCloseDetails()}
115
+ >
116
+ <CheckoutFieldsDetailsContainer>
117
+ <h1>{t('SETTINGS', 'Settings')}</h1>
118
+ <FieldContainer isHeader>
119
+ <div className='name'>{t('FIELD', 'Field')}</div>
120
+ <div className='required'>{t('REQUIRED', 'Required')}</div>
121
+ <div className='status'>{t('STATE', 'Status')}</div>
122
+ </FieldContainer>
123
+ {(actionState?.loading && actionState?.isPost) ? (
124
+ [...Array(10).keys()].map(i => (
125
+ <FieldContainer key={i}>
126
+ <div className='name'><Skeleton width={120} /></div>
127
+ <div className='required'>
128
+ <Skeleton width={30} style={{ borderRadius: 20 }} />
129
+ </div>
130
+ <div className='status'>
131
+ <Skeleton width={30} style={{ borderRadius: 20 }} />
132
+ </div>
133
+ </FieldContainer>
134
+ ))
135
+ ) : (
136
+ <>
137
+ {checkoutFieldsState.fields
138
+ .filter(item => item?.site_id === parseInt(selectedSiteId))
139
+ .sort((a, b) => {
140
+ const indexA = orderValidationFields.indexOf(a?.validation_field.code)
141
+ const indexB = orderValidationFields.indexOf(b?.validation_field.code)
142
+ return indexA - indexB
143
+ })
144
+ .map(field => (
145
+ <FieldContainer key={field.id}>
146
+ <div className='name'>{t(field?.validation_field?.code.toUpperCase())}</div>
147
+ <div className='required'>
148
+ <Switch
149
+ defaultChecked={field.required}
150
+ disabled={field?.validation_field?.code === 'email'}
151
+ onChange={(val) => handleChangeCheckoutFieldSetting(field.validation_field_id, selectedSiteId, { required: val })}
152
+ />
153
+ </div>
154
+ <div className='status'>
155
+ <Switch
156
+ defaultChecked={field.enabled}
157
+ disabled={field?.validation_field?.code === 'email'}
158
+ onChange={(val) => handleChangeCheckoutFieldSetting(field.validation_field_id, selectedSiteId, { enabled: val })}
159
+ />
160
+ </div>
161
+ </FieldContainer>
162
+ ))}
163
+ </>
164
+ )}
165
+ </CheckoutFieldsDetailsContainer>
166
+ </SideBar>
167
+ )}
168
+ <Alert
169
+ title={t('WEB_APPNAME', 'Ordering')}
170
+ content={alertState.content}
171
+ acceptText={t('ACCEPT', 'Accept')}
172
+ open={alertState.open}
173
+ onClose={() => setAlertState({ open: false, content: [] })}
174
+ onAccept={() => setAlertState({ open: false, content: [] })}
175
+ closeOnBackdrop={false}
176
+ />
64
177
  </>
65
178
  )
66
179
  }
@@ -1,5 +1,69 @@
1
1
  import styled, { css } from 'styled-components'
2
2
 
3
+ export const SitesListContainer = styled.div`
4
+ padding: 20px;
5
+ box-sizing: border-box;
6
+ width: 100%;
7
+ overflow-x: hidden;
8
+ `
9
+
10
+ export const Header = styled.div`
11
+ display: flex;
12
+ align-items: flex-start;
13
+ justify-content: space-between;
14
+
15
+ h1 {
16
+ font-weight: 700;
17
+ font-size: 20px;
18
+ margin: 0;
19
+ }
20
+
21
+ margin-right: 35px;
22
+ ${props => props.theme.rtl && css`
23
+ margin-left: 35px;
24
+ margin-right: 0;
25
+ `}
26
+ `
27
+
28
+ export const SitesWrapper = styled.div`
29
+ margin-top: 35px;
30
+ border: 1px solid ${props => props.theme.colors.borderColor};
31
+ border-radius: 8px;
32
+ overflow: hidden;
33
+ > div:first-child {
34
+ border-top: none !important;
35
+ }
36
+
37
+ > div:last-child {
38
+ border-bottom: none !important;
39
+ }
40
+ `
41
+ export const SiteItem = styled.div`
42
+ cursor: pointer;
43
+ padding: 12px 15px;
44
+ display: flex;
45
+ align-items: center;
46
+ justify-content: space-between;
47
+ color: ${props => props.theme.colors.lightGray};
48
+ border-bottom: 1px solid ${props => props.theme.colors.borderColor};
49
+
50
+ &:hover {
51
+ background-color: ${props => props.theme.colors.lightPrimary};
52
+ }
53
+ span {
54
+ font-size: 14px;
55
+ }
56
+ svg {
57
+ font-size: 20px;
58
+ }
59
+ ${({ active }) => active && css`
60
+ color: ${props => props.theme.colors.headingColor};
61
+ border-top: 1px solid ${props => props.theme.colors.primary};
62
+ border-bottom: 1px solid ${props => props.theme.colors.primary} !important;
63
+ background-color: ${props => props.theme.colors.lightPrimary};
64
+ `}
65
+ `
66
+
3
67
  export const CheckoutFieldsDetailsContainer = styled.div`
4
68
  padding: 26px 15px;
5
69
  box-sizing: border-box;
@@ -62,6 +62,7 @@ const GuestCheckoutFieldsSettingUI = (props) => {
62
62
  <div className='name'>{t('FIELD', 'Field')}</div>
63
63
  <div className='required'>{t('REQUIRED', 'Required')}</div>
64
64
  <div className='status'>{t('STATE', 'Status')}</div>
65
+ <div className='guest'>{t('REQUIRED_WITH_GUEST', 'Required with guest')}</div>
65
66
  </FieldContainer>
66
67
  {checkoutFieldsState?.loading ? (
67
68
  [...Array(10).keys()].map(i => (
@@ -73,6 +74,9 @@ const GuestCheckoutFieldsSettingUI = (props) => {
73
74
  <div className='status'>
74
75
  <Skeleton width={30} style={{ borderRadius: 20 }} />
75
76
  </div>
77
+ <div className='guest'>
78
+ <Skeleton width={30} style={{ borderRadius: 20 }} />
79
+ </div>
76
80
  </FieldContainer>
77
81
  ))
78
82
  ) : (
@@ -99,6 +103,12 @@ const GuestCheckoutFieldsSettingUI = (props) => {
99
103
  onChange={(val) => handleChangeCheckoutFieldSetting(field?.validation_field_id, field?.order_type_id, { enabled: val })}
100
104
  />
101
105
  </div>
106
+ <div className='guest'>
107
+ <Switch
108
+ defaultChecked={field?.required_with_guest}
109
+ onChange={(val) => handleChangeCheckoutFieldSetting(field?.validation_field_id, field?.order_type_id, { required_with_guest: val })}
110
+ />
111
+ </div>
102
112
  </FieldContainer>
103
113
  ))}
104
114
  </>
@@ -92,6 +92,13 @@ export const FieldContainer = styled.div`
92
92
  justify-content: center;
93
93
  align-items: center;
94
94
  }
95
+
96
+ .guest {
97
+ width: 80px;
98
+ display: flex;
99
+ justify-content: center;
100
+ align-items: center;
101
+ }
95
102
  `
96
103
 
97
104
  export const TitleWrapper = styled.div`
@@ -47,6 +47,9 @@ const SettingsUI = (props) => {
47
47
  const [isOpenSettingDetails, setIsOpenSettingDetails] = useState(null)
48
48
  const [openSitesAuthSettings, setOpenSitesAuthSettings] = useState(false)
49
49
  const [openMultiCountrySettings, setOpenMultiCountrySettings] = useState(false)
50
+ const [openCheckoutSettings, setOpenCheckoutSettings] = useState(false)
51
+ const [openAddressSettings, setOpenAddressSettings] = useState(false)
52
+ const [openCardSettings, setOpenCardSettings] = useState(false)
50
53
  const [moveDistance, setMoveDistance] = useState(0)
51
54
 
52
55
  const [events] = useEvent()
@@ -74,6 +77,9 @@ const SettingsUI = (props) => {
74
77
  setIsOpenSettingDetails(null)
75
78
  setOpenSitesAuthSettings(false)
76
79
  setOpenMultiCountrySettings(false)
80
+ setOpenCheckoutSettings(false)
81
+ setOpenAddressSettings(false)
82
+ setOpenCardSettings(false)
77
83
  setIsOpenDescription(true)
78
84
  setSelectedCategory(category)
79
85
  handChangeConfig && handChangeConfig(false)
@@ -85,7 +91,10 @@ const SettingsUI = (props) => {
85
91
  const handleOpenSettingDetails = (item, isInitialRender) => {
86
92
  setIsOpenDescription(false)
87
93
  setOpenSitesAuthSettings(false)
94
+ setOpenCheckoutSettings(false)
88
95
  setOpenMultiCountrySettings(false)
96
+ setOpenCardSettings(false)
97
+ setOpenAddressSettings(false)
89
98
  setSelectedCategory(null)
90
99
  setIsOpenSettingDetails(item)
91
100
  if (!isInitialRender) {
@@ -111,13 +120,52 @@ const SettingsUI = (props) => {
111
120
  }
112
121
  }
113
122
 
123
+ const handleOpenCheckout = (isInitialRender) => {
124
+ setIsOpenDescription(false)
125
+ setIsOpenSettingDetails(null)
126
+ setOpenSitesAuthSettings(false)
127
+ setOpenAddressSettings(false)
128
+ setOpenCardSettings(false)
129
+ setOpenCheckoutSettings(true)
130
+ if (!isInitialRender) {
131
+ history.replace(`${location.pathname}?category=checkout`)
132
+ }
133
+ }
134
+
135
+ const handleOpenAddress = (isInitialRender) => {
136
+ setIsOpenDescription(false)
137
+ setIsOpenSettingDetails(null)
138
+ setOpenSitesAuthSettings(false)
139
+ setOpenCheckoutSettings(false)
140
+ setOpenCardSettings(false)
141
+ setOpenAddressSettings(true)
142
+ if (!isInitialRender) {
143
+ history.replace(`${location.pathname}?category=address`)
144
+ }
145
+ }
146
+
147
+ const handleOpenCard = (isInitialRender) => {
148
+ setIsOpenDescription(false)
149
+ setIsOpenSettingDetails(null)
150
+ setOpenSitesAuthSettings(false)
151
+ setOpenCheckoutSettings(false)
152
+ setOpenAddressSettings(false)
153
+ setOpenCardSettings(true)
154
+ if (!isInitialRender) {
155
+ history.replace(`${location.pathname}?category=card`)
156
+ }
157
+ }
158
+
114
159
  const handleBackRedirect = () => {
115
160
  setIsOpenDescription(false)
116
161
  setSelectedCategory(null)
117
162
  setIsOpenSettingDetails(null)
118
163
  setMoveDistance(0)
119
164
  setOpenMultiCountrySettings(false)
165
+ setOpenCheckoutSettings(false)
120
166
  setOpenSitesAuthSettings(false)
167
+ setOpenAddressSettings(false)
168
+ setOpenCardSettings(false)
121
169
  history.replace(`${location.pathname}`)
122
170
  }
123
171
 
@@ -130,6 +178,12 @@ const SettingsUI = (props) => {
130
178
  handleOpenSites(true)
131
179
  } else if (categoryId === 'multi_country') {
132
180
  handleOpenMultiCountry(true)
181
+ } else if (categoryId === 'checkout') {
182
+ setOpenCheckoutSettings(true)
183
+ } else if (categoryId === 'address') {
184
+ setOpenAddressSettings(true)
185
+ } else if (categoryId === 'card') {
186
+ setOpenCardSettings(true)
133
187
  } else {
134
188
  handleOpenSettingDetails(categoryId, true)
135
189
  }
@@ -190,13 +244,13 @@ const SettingsUI = (props) => {
190
244
  </SettingItemWrapper>
191
245
  <SettingItemWrapper
192
246
  className='col-md-4 col-sm-6'
193
- onClick={() => handleOpenSettingDetails('checkout')}
247
+ onClick={() => handleOpenCheckout()}
194
248
  >
195
249
  <SettingItemUI
196
250
  title={t('CHECKOUT_FIELDS', 'Checkout fields')}
197
251
  description={t('CHECKOUT_FIELDS_DESC')}
198
252
  icon={<CheckCircleFill />}
199
- active={isOpenSettingDetails === 'checkout'}
253
+ active={openCheckoutSettings}
200
254
  />
201
255
  </SettingItemWrapper>
202
256
  <SettingItemWrapper
@@ -212,24 +266,24 @@ const SettingsUI = (props) => {
212
266
  </SettingItemWrapper>
213
267
  <SettingItemWrapper
214
268
  className='col-md-4 col-sm-6'
215
- onClick={() => handleOpenSettingDetails('address')}
269
+ onClick={() => handleOpenAddress()}
216
270
  >
217
271
  <SettingItemUI
218
272
  title={t('ADDRESS_FIELDS', 'Address fields')}
219
273
  description={t('ADDRESS_FIELDS_DESC')}
220
274
  icon={<GeoAltFill />}
221
- active={isOpenSettingDetails === 'address'}
275
+ active={openAddressSettings}
222
276
  />
223
277
  </SettingItemWrapper>
224
278
  <SettingItemWrapper
225
279
  className='col-md-4 col-sm-6'
226
- onClick={() => handleOpenSettingDetails('card')}
280
+ onClick={() => handleOpenCard()}
227
281
  >
228
282
  <SettingItemUI
229
283
  title={t('CARD_FIELDS', 'Card fields')}
230
284
  description={t('CARD_FIELDS_DESC', 'Manage your card fields')}
231
285
  icon={<CreditCard />}
232
- active={isOpenSettingDetails === 'card'}
286
+ active={openCardSettings}
233
287
  />
234
288
  </SettingItemWrapper>
235
289
  <SettingItemWrapper
@@ -324,6 +378,36 @@ const SettingsUI = (props) => {
324
378
  <MultiCountrySettings setMoveDistance={setMoveDistance} />
325
379
  </SideBar>
326
380
  )}
381
+ {openCheckoutSettings && (
382
+ <SideBar
383
+ defaultSideBarWidth={500 + moveDistance}
384
+ moveDistance={moveDistance}
385
+ open={openCheckoutSettings}
386
+ onClose={() => handleBackRedirect()}
387
+ >
388
+ <CheckoutFieldsSetting setMoveDistance={setMoveDistance} />
389
+ </SideBar>
390
+ )}
391
+ {openAddressSettings && (
392
+ <SideBar
393
+ defaultSideBarWidth={500 + moveDistance}
394
+ moveDistance={moveDistance}
395
+ open={openAddressSettings}
396
+ onClose={() => handleBackRedirect()}
397
+ >
398
+ <AddressFieldsSetting setMoveDistance={setMoveDistance} />
399
+ </SideBar>
400
+ )}
401
+ {openCardSettings && (
402
+ <SideBar
403
+ defaultSideBarWidth={500 + moveDistance}
404
+ moveDistance={moveDistance}
405
+ open={openCardSettings}
406
+ onClose={() => handleBackRedirect()}
407
+ >
408
+ <CardFieldsSetting setMoveDistance={setMoveDistance} />
409
+ </SideBar>
410
+ )}
327
411
  {
328
412
  isOpenSettingDetails && (
329
413
  <SideBar
@@ -333,18 +417,9 @@ const SettingsUI = (props) => {
333
417
  onClose={() => handleBackRedirect()}
334
418
  showExpandIcon
335
419
  >
336
- {isOpenSettingDetails === 'checkout' && (
337
- <CheckoutFieldsSetting />
338
- )}
339
420
  {isOpenSettingDetails === 'guest_checkout' && (
340
421
  <GuestCheckoutFieldsSetting />
341
422
  )}
342
- {isOpenSettingDetails === 'address' && (
343
- <AddressFieldsSetting />
344
- )}
345
- {isOpenSettingDetails === 'card' && (
346
- <CardFieldsSetting />
347
- )}
348
423
  {isOpenSettingDetails === 'language' && (
349
424
  <LanguageSetting />
350
425
  )}