ordering-ui-admin-external 1.23.4 → 1.24.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.
Files changed (106) hide show
  1. package/_bundles/{ordering-ui-admin.152c2c4d99f05215f0c3.js → ordering-ui-admin.0c354f3e7da49f56465b.js} +2 -2
  2. package/_modules/components/CartRecovery/RecoveryActionAdd/index.js +325 -0
  3. package/_modules/components/CartRecovery/RecoveryGeneral/index.js +41 -17
  4. package/_modules/components/Delivery/DriversCompaniesList/styles.js +1 -1
  5. package/_modules/components/Delivery/DriversCompaniesListing/index.js +20 -2
  6. package/_modules/components/Delivery/DriversCompaniesListing/styles.js +2 -2
  7. package/_modules/components/Delivery/DriversCompanyAddForm/GeneralForm/index.js +122 -0
  8. package/_modules/components/Delivery/DriversCompanyAddForm/GeneralForm/styles.js +21 -0
  9. package/_modules/components/Delivery/DriversCompanyAddForm/ScheduleForm/index.js +27 -0
  10. package/_modules/components/Delivery/DriversCompanyAddForm/ScheduleForm/styles.js +14 -0
  11. package/_modules/components/Delivery/DriversCompanyAddForm/WebhooksForm/index.js +60 -0
  12. package/_modules/components/Delivery/DriversCompanyAddForm/WebhooksForm/styles.js +16 -0
  13. package/_modules/components/Delivery/DriversCompanyAddForm/index.js +114 -0
  14. package/_modules/components/Delivery/DriversCompanyAddForm/styles.js +18 -0
  15. package/_modules/components/MyProducts/AdvancedSettings/index.js +66 -82
  16. package/_modules/components/MyProducts/AdvancedSettings/styles.js +40 -44
  17. package/_modules/components/MyProducts/CustomDomain/index.js +150 -0
  18. package/_modules/components/MyProducts/CustomDomain/styles.js +38 -0
  19. package/_modules/components/MyProducts/OrderingWebsite/SelectBusiness.js +59 -0
  20. package/_modules/components/MyProducts/OrderingWebsite/SelectFranchise.js +59 -0
  21. package/_modules/components/MyProducts/OrderingWebsite/index.js +65 -36
  22. package/_modules/components/MyProducts/OrderingWebsite/styles.js +70 -35
  23. package/_modules/components/MyProducts/UploadAudio/index.js +170 -0
  24. package/_modules/components/MyProducts/UploadAudio/styles.js +30 -0
  25. package/_modules/components/MyProducts/index.js +8 -1
  26. package/_modules/components/Orders/DeliveriesLocation/index.js +1 -0
  27. package/_modules/components/Orders/OrderBill/index.js +4 -3
  28. package/_modules/components/Orders/OrderContactInformation/index.js +14 -12
  29. package/_modules/components/Orders/OrderDetails/index.js +6 -131
  30. package/_modules/components/Orders/OrdersTable/index.js +2 -2
  31. package/_modules/components/Settings/NotificationSetting/index.js +1 -1
  32. package/_modules/components/Settings/SettingsList/index.js +1 -1
  33. package/_modules/components/Settings/SettingsList/styles.js +2 -2
  34. package/_modules/components/Shared/InputPhoneNumber/index.js +3 -2
  35. package/_modules/components/SidebarMenu/index.js +22 -22
  36. package/_modules/components/Stores/BusinessDetails/index.js +6 -3
  37. package/_modules/components/Stores/BusinessDeviceDetail/index.js +66 -16
  38. package/_modules/components/Stores/BusinessDeviceDetail/styles.js +7 -5
  39. package/_modules/components/Stores/BusinessProductsListing/index.js +18 -16
  40. package/_modules/components/Stores/BusinessSalesChannel/index.js +13 -4
  41. package/_modules/components/Stores/BusinessSalesFacebook/FacebookProfile.js +2 -2
  42. package/_modules/components/Stores/BusinessSalesFacebook/index.js +2 -2
  43. package/_modules/components/Stores/BusinessSalesGoogle/index.js +2 -2
  44. package/_modules/components/Stores/BusinessSalesInstagram/AdvancedInstagram.js +3 -2
  45. package/_modules/components/Stores/BusinessSalesInstagram/GeneralInstagram.js +2 -2
  46. package/_modules/components/Stores/BusinessSalesInstagram/index.js +3 -5
  47. package/_modules/components/Stores/BusinessSummary/index.js +11 -9
  48. package/_modules/components/Users/CustomersListing/index.js +5 -3
  49. package/_modules/utils/index.js +211 -3
  50. package/index-template.js +1 -1
  51. package/index.html +1 -0
  52. package/package.json +2 -2
  53. package/public/push/onesignal/OneSignalSDKUpdaterWorker.js +1 -0
  54. package/public/push/onesignal/OneSignalSDKWorker.js +1 -0
  55. package/src/components/CartRecovery/RecoveryActionAdd/index.js +355 -0
  56. package/src/components/CartRecovery/RecoveryGeneral/index.js +23 -4
  57. package/src/components/Delivery/DriversCompaniesList/styles.js +1 -1
  58. package/src/components/Delivery/DriversCompaniesListing/index.js +29 -12
  59. package/src/components/Delivery/DriversCompaniesListing/styles.js +1 -1
  60. package/src/components/Delivery/DriversCompanyAddForm/GeneralForm/index.js +120 -0
  61. package/src/components/Delivery/DriversCompanyAddForm/GeneralForm/styles.js +32 -0
  62. package/src/components/Delivery/DriversCompanyAddForm/ScheduleForm/index.js +29 -0
  63. package/src/components/Delivery/DriversCompanyAddForm/ScheduleForm/styles.js +11 -0
  64. package/src/components/Delivery/DriversCompanyAddForm/WebhooksForm/index.js +69 -0
  65. package/src/components/Delivery/DriversCompanyAddForm/WebhooksForm/styles.js +24 -0
  66. package/src/components/Delivery/DriversCompanyAddForm/index.js +121 -0
  67. package/src/components/Delivery/DriversCompanyAddForm/styles.js +39 -0
  68. package/src/components/MyProducts/AdvancedSettings/index.js +35 -36
  69. package/src/components/MyProducts/AdvancedSettings/styles.js +3 -11
  70. package/src/components/MyProducts/CustomDomain/index.js +137 -0
  71. package/src/components/MyProducts/CustomDomain/styles.js +103 -0
  72. package/src/components/MyProducts/OrderingWebsite/SelectBusiness.js +47 -0
  73. package/src/components/MyProducts/OrderingWebsite/SelectFranchise.js +47 -0
  74. package/src/components/MyProducts/OrderingWebsite/index.js +99 -42
  75. package/src/components/MyProducts/OrderingWebsite/styles.js +126 -7
  76. package/src/components/MyProducts/UploadAudio/index.js +168 -0
  77. package/src/components/MyProducts/UploadAudio/styles.js +120 -0
  78. package/src/components/MyProducts/index.js +3 -1
  79. package/src/components/Orders/DeliveriesLocation/index.js +1 -0
  80. package/src/components/Orders/OrderBill/index.js +9 -6
  81. package/src/components/Orders/OrderContactInformation/index.js +5 -1
  82. package/src/components/Orders/OrderDetails/index.js +7 -35
  83. package/src/components/Orders/OrdersTable/index.js +3 -1
  84. package/src/components/Settings/NotificationSetting/index.js +2 -0
  85. package/src/components/Settings/SettingsList/index.js +53 -53
  86. package/src/components/Settings/SettingsList/styles.js +2 -1
  87. package/src/components/Settings/SettingsSelectUI/index.js +1 -1
  88. package/src/components/Shared/InputPhoneNumber/index.js +2 -2
  89. package/src/components/SidebarMenu/index.js +1 -0
  90. package/src/components/Stores/BusinessDetails/index.js +4 -1
  91. package/src/components/Stores/BusinessDeviceDetail/index.js +46 -7
  92. package/src/components/Stores/BusinessDeviceDetail/styles.js +11 -0
  93. package/src/components/Stores/BusinessProductsListing/index.js +6 -2
  94. package/src/components/Stores/BusinessSalesChannel/index.js +12 -6
  95. package/src/components/Stores/BusinessSalesFacebook/FacebookProfile.js +2 -2
  96. package/src/components/Stores/BusinessSalesFacebook/index.js +3 -3
  97. package/src/components/Stores/BusinessSalesGoogle/index.js +3 -3
  98. package/src/components/Stores/BusinessSalesInstagram/AdvancedInstagram.js +2 -2
  99. package/src/components/Stores/BusinessSalesInstagram/GeneralInstagram.js +2 -2
  100. package/src/components/Stores/BusinessSalesInstagram/index.js +3 -3
  101. package/src/components/Stores/BusinessSummary/index.js +6 -2
  102. package/src/components/Users/CustomersListing/index.js +2 -3
  103. package/src/utils/index.js +59 -1
  104. package/template/app.js +76 -3
  105. package/template/config.json +1 -0
  106. /package/_bundles/{ordering-ui-admin.152c2c4d99f05215f0c3.js.LICENSE.txt → ordering-ui-admin.0c354f3e7da49f56465b.js.LICENSE.txt} +0 -0
@@ -0,0 +1,355 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import {
3
+ useLanguage,
4
+ RecoveryActionDetail as RecoveryActionDetailController
5
+ } from 'ordering-components-admin-external'
6
+ import { useForm } from 'react-hook-form'
7
+ import {
8
+ Circle as UnCheckIcon,
9
+ RecordCircleFill as CheckIcon
10
+ } from 'react-bootstrap-icons'
11
+ import NumericInput from 'react-numeric-input'
12
+ import { Button, Input, TextArea } from '../../../styles'
13
+ import { Alert, HtmlEditor } from '../../Shared'
14
+ import { Select } from '../../../styles/Select'
15
+
16
+ import {
17
+ RecoveryActionAddContainer,
18
+ CardContainer,
19
+ ButtonsContainer,
20
+ InputWrapper,
21
+ LastTimeWrapper,
22
+ TypeWrapper,
23
+ ParentCheckBoxWrapper,
24
+ TimeBlock,
25
+ TimeContent,
26
+ DaysContent,
27
+ Option
28
+ } from './styles'
29
+
30
+ export const RecoveryActionAddUI = (props) => {
31
+ const {
32
+ onClose,
33
+ formState,
34
+ handleAddRecoveryAction,
35
+ handleChangeInput,
36
+ handleChangeItem,
37
+ actionState
38
+ } = props
39
+
40
+ const [, t] = useLanguage()
41
+ const { register, handleSubmit, errors } = useForm()
42
+ const [alertState, setAlertState] = useState({ open: false, content: [] })
43
+
44
+ const [hours, setHours] = useState([])
45
+ const [minutes, setMinutes] = useState([])
46
+ const [seconds, setSeconds] = useState([])
47
+ const [curPreorderTime, setCurPreorderTime] = useState({ hour: '0', minute: '0', second: '0' })
48
+ const [curDayTime, setCurDayTime] = useState(0)
49
+ const [isTime, setIsTime] = useState(true)
50
+
51
+ const channelList = [
52
+ { value: 'email', content: <Option>{t('EMAIL', 'Email')}</Option> },
53
+ { value: 'sms', content: <Option>{t('SMS', 'SMS')}</Option> },
54
+ { value: 'notification', content: <Option>{t('PUSH_NOTIFICATION', 'Push notification')}</Option> }
55
+ ]
56
+
57
+ const setTimeList = () => {
58
+ const _hours = []
59
+ const _minutes = []
60
+ const _seconds = []
61
+ for (let i = 0; i < 24; i++) {
62
+ const text = (i < 10 ? '0' : ' ') + i
63
+ _hours.push({
64
+ text: text,
65
+ hour: i
66
+ })
67
+ }
68
+ for (let i = 0; i < 60; i++) {
69
+ const text = (i < 10 ? '0' : '') + i
70
+ _minutes.push({
71
+ text: text,
72
+ minute: i
73
+ })
74
+ _seconds.push({
75
+ text: text,
76
+ second: i
77
+ })
78
+ }
79
+ setHours(_hours)
80
+ setMinutes(_minutes)
81
+ setSeconds(_seconds)
82
+ }
83
+
84
+ const handleChangePreorderTime = (evt) => {
85
+ const type = evt.target.name
86
+ const value = evt.target.value
87
+ setCurPreorderTime({
88
+ ...curPreorderTime,
89
+ [type]: value
90
+ })
91
+ let preorderTime = 0
92
+ if (type === 'hour') preorderTime = parseInt(value) * 3600 + parseInt(curPreorderTime?.minute) * 60 + parseInt(curPreorderTime?.second)
93
+ else if (type === 'minute') preorderTime = parseInt(curPreorderTime?.hour) * 3600 + parseInt(value) * 60 + parseInt(curPreorderTime?.second)
94
+ else preorderTime = parseInt(curPreorderTime?.hour) * 3600 + parseInt(curPreorderTime?.minute) * 60 + parseInt(value)
95
+ handleChangeItem({ times: [preorderTime], launch_type: 'times' })
96
+ }
97
+
98
+ const handleChangeDay = (value) => {
99
+ setCurDayTime(value)
100
+ handleChangeItem({ times: [value * 24 * 3600], launch_type: 'times' })
101
+ }
102
+
103
+ const onSubmit = () => {
104
+ if (!formState.changes?.times?.[0]) {
105
+ setAlertState({
106
+ open: true,
107
+ content: [t(
108
+ 'VALIDATION_ERROR_REQUIRED',
109
+ 'Name is required'
110
+ ).replace('_attribute_', t('TIME', 'Time'))]
111
+ })
112
+ return
113
+ }
114
+ if (!formState.changes?.channel) {
115
+ setAlertState({
116
+ open: true,
117
+ content: [t(
118
+ 'VALIDATION_ERROR_REQUIRED',
119
+ 'Name is required'
120
+ ).replace('_attribute_', t('CHANNEL', 'Channel'))]
121
+ })
122
+ return
123
+ }
124
+ if (!formState.changes?.body) {
125
+ setAlertState({
126
+ open: true,
127
+ content: [t(
128
+ 'VALIDATION_ERROR_REQUIRED',
129
+ 'Name is required'
130
+ ).replace('_attribute_', t('MESSAGE', 'Message'))]
131
+ })
132
+ return
133
+ }
134
+ handleAddRecoveryAction()
135
+ }
136
+
137
+ const handleSwitchTime = () => {
138
+ setIsTime(prev => !prev)
139
+ }
140
+
141
+ useEffect(() => {
142
+ setTimeList()
143
+ }, [])
144
+
145
+ useEffect(() => {
146
+ if (!actionState?.error || actionState.loading) return
147
+ setAlertState({
148
+ open: true,
149
+ content: actionState?.error
150
+ })
151
+ }, [actionState])
152
+
153
+ useEffect(() => {
154
+ if (Object.keys(errors).length > 0) {
155
+ setAlertState({
156
+ open: true,
157
+ content: Object.values(errors).map(error => error.message)
158
+ })
159
+ }
160
+ }, [errors])
161
+
162
+ return (
163
+ <>
164
+ <RecoveryActionAddContainer onSubmit={handleSubmit(onSubmit)}>
165
+ <CardContainer>
166
+ <h2>{t('GENERAL', 'General')}</h2>
167
+ <InputWrapper>
168
+ <label>{t('NAME', 'Name')}</label>
169
+ <Input
170
+ name='name'
171
+ type='text'
172
+ placeholder={t('NAME', 'name')}
173
+ value={formState?.changes?.name ?? ''}
174
+ ref={register({
175
+ required: t(
176
+ 'VALIDATION_ERROR_REQUIRED',
177
+ 'Name is required'
178
+ ).replace('_attribute_', t('NAME', 'Name'))
179
+ })}
180
+ onChange={handleChangeInput}
181
+ disabled={formState.loading}
182
+ autoComplete='off'
183
+ />
184
+ </InputWrapper>
185
+ <InputWrapper>
186
+ <label>{t('DESCRIPTION', 'Description')}</label>
187
+ <TextArea
188
+ placeholder={t('WRITE_LITTLE_DESCRIPTION', 'Write a little description')}
189
+ name='description'
190
+ rows={3}
191
+ value={
192
+ formState?.changes?.description ?? ''
193
+ }
194
+ onChange={handleChangeInput}
195
+ disabled={formState.loading}
196
+ autoComplete='off'
197
+ />
198
+ </InputWrapper>
199
+ <LastTimeWrapper>
200
+ <h3>{t('LAST_TIME_CART_WAS_OPENED', 'Last time the cart was opened')}</h3>
201
+ <TypeWrapper>
202
+ <ParentCheckBoxWrapper>
203
+ <div onClick={() => handleSwitchTime()}>
204
+ {isTime ? <CheckIcon className='checked-icon' /> : <UnCheckIcon />}
205
+ <span>{t('TIME', 'Time')}</span>
206
+ </div>
207
+ </ParentCheckBoxWrapper>
208
+ {isTime && (
209
+ <TimeContent>
210
+ <TimeBlock>
211
+ <select
212
+ value={curPreorderTime?.hour}
213
+ name='hour'
214
+ onChange={handleChangePreorderTime}
215
+ >
216
+ {
217
+ hours?.map((hour, i) => (
218
+ <option value={hour.hour} key={i}>{hour.text}</option>
219
+ ))
220
+ }
221
+ </select>
222
+ <span>:</span>
223
+ <select
224
+ value={curPreorderTime?.minute}
225
+ name='minute'
226
+ onChange={handleChangePreorderTime}
227
+ >
228
+ {minutes?.map((minute, i) => (
229
+ <option value={minute.minute} key={i}>{minute.text}</option>
230
+ ))}
231
+ </select>
232
+ <span>:</span>
233
+ <select
234
+ value={curPreorderTime?.second}
235
+ name='second'
236
+ onChange={handleChangePreorderTime}
237
+ >
238
+ {seconds?.map((second, i) => (
239
+ <option value={second.second} key={i}>{second.text}</option>
240
+ ))}
241
+ </select>
242
+ </TimeBlock>
243
+ </TimeContent>
244
+ )}
245
+ </TypeWrapper>
246
+ <TypeWrapper>
247
+ <ParentCheckBoxWrapper>
248
+ <div onClick={() => handleSwitchTime()}>
249
+ {!isTime ? <CheckIcon className='checked-icon' /> : <UnCheckIcon />}
250
+ <span>{t('DAYS', 'Days')}</span>
251
+ </div>
252
+ </ParentCheckBoxWrapper>
253
+ {!isTime && (
254
+ <DaysContent>
255
+ <NumericInput
256
+ placeholder='00'
257
+ onKeyPress={(e) => {
258
+ if (!/^[0-9]$/.test(e.key)) {
259
+ e.preventDefault()
260
+ }
261
+ }}
262
+ value={curDayTime || ''}
263
+ onChange={(value) => handleChangeDay(value)}
264
+ min={0}
265
+ />
266
+ </DaysContent>
267
+ )}
268
+ </TypeWrapper>
269
+ </LastTimeWrapper>
270
+ </CardContainer>
271
+ <CardContainer>
272
+ <h2>{t('NOTIFICATIONS', 'Notifications')}</h2>
273
+ <InputWrapper>
274
+ <label>{t('TITLE', 'Title')}</label>
275
+ <Input
276
+ name='title'
277
+ placeholder={t('TITLE', 'Title')}
278
+ defaultValue={formState?.changes?.title ?? ''}
279
+ onChange={handleChangeInput}
280
+ ref={register({
281
+ required: t(
282
+ 'VALIDATION_ERROR_REQUIRED',
283
+ 'Name is required'
284
+ ).replace('_attribute_', t('TITLE', 'Title'))
285
+ })}
286
+ />
287
+ </InputWrapper>
288
+ <InputWrapper>
289
+ <label>{t('CHANNEL', 'Channel')}</label>
290
+ <Select
291
+ placeholder={<Option>{t('SELECT_CHANNEL', 'Select a channel')}</Option>}
292
+ defaultValue={formState?.changes?.channel ?? ''}
293
+ options={channelList}
294
+ onChange={val => handleChangeItem({ channel: val })}
295
+ />
296
+ </InputWrapper>
297
+ <InputWrapper>
298
+ <label>{t('MESSAGE', 'Message')}</label>
299
+ {formState.changes?.channel === 'email' ? (
300
+ <HtmlEditor
301
+ handleChangeBody={val => handleChangeItem({ body: val })}
302
+ />
303
+ ) : (
304
+ <TextArea
305
+ name='body'
306
+ rows={3}
307
+ placeholder={t('WRITE_MESSAGE', 'Write a message')}
308
+ defaultValue={formState?.changes?.body ?? ''}
309
+ onChange={handleChangeInput}
310
+ ref={register({
311
+ required: t(
312
+ 'VALIDATION_ERROR_REQUIRED',
313
+ 'Name is required'
314
+ ).replace('_attribute_', t('MESSAGE', 'Message'))
315
+ })}
316
+ />
317
+ )}
318
+ </InputWrapper>
319
+ </CardContainer>
320
+ <ButtonsContainer>
321
+ <Button
322
+ color='secundary'
323
+ onClick={() => onClose()}
324
+ >
325
+ {t('CANCEL', 'Cancel')}
326
+ </Button>
327
+ <Button
328
+ color='primary'
329
+ type='submit'
330
+ disabled={Object.keys(formState.changes).length === 0 || formState.loading}
331
+ >
332
+ {t('SAVE', 'Save')}
333
+ </Button>
334
+ </ButtonsContainer>
335
+ </RecoveryActionAddContainer>
336
+ <Alert
337
+ title={t('RECOVERY_ACTIONS', 'Recovery actions')}
338
+ content={alertState.content}
339
+ acceptText={t('ACCEPT', 'Accept')}
340
+ open={alertState.open}
341
+ onClose={() => setAlertState({ open: false, content: [] })}
342
+ onAccept={() => setAlertState({ open: false, content: [] })}
343
+ closeOnBackdrop={false}
344
+ />
345
+ </>
346
+ )
347
+ }
348
+
349
+ export const RecoveryActionAdd = (props) => {
350
+ const recoveryActionDetailProps = {
351
+ ...props,
352
+ UIComponent: RecoveryActionAddUI
353
+ }
354
+ return <RecoveryActionDetailController {...recoveryActionDetailProps} />
355
+ }
@@ -42,13 +42,15 @@ export const RecoveryGeneral = (props) => {
42
42
 
43
43
  const [hours, setHours] = useState([])
44
44
  const [minutes, setMinutes] = useState([])
45
- const [curPreorderTime, setCurPreorderTime] = useState({})
45
+ const [seconds, setSeconds] = useState([])
46
+ const [curPreorderTime, setCurPreorderTime] = useState({ hour: '0', minute: '0', second: '0' })
46
47
  const [curDayTime, setCurDayTime] = useState(0)
47
48
  const [isTime, setIsTime] = useState(true)
48
49
 
49
50
  const setTimeList = () => {
50
51
  const _hours = []
51
52
  const _minutes = []
53
+ const _seconds = []
52
54
  for (let i = 0; i < 24; i++) {
53
55
  const text = (i < 10 ? '0' : ' ') + i
54
56
  _hours.push({
@@ -62,9 +64,14 @@ export const RecoveryGeneral = (props) => {
62
64
  text: text,
63
65
  minute: i
64
66
  })
67
+ _seconds.push({
68
+ text: text,
69
+ second: i
70
+ })
65
71
  }
66
72
  setHours(_hours)
67
73
  setMinutes(_minutes)
74
+ setSeconds(_seconds)
68
75
  }
69
76
 
70
77
  const handleChangePreorderTime = (evt) => {
@@ -75,8 +82,9 @@ export const RecoveryGeneral = (props) => {
75
82
  [type]: value
76
83
  })
77
84
  let preorderTime = 0
78
- if (type === 'hour') preorderTime = parseInt(value) * 3600 + parseInt(curPreorderTime?.minute) * 60
79
- else preorderTime = parseInt(curPreorderTime?.hour) * 3600 + parseInt(value) * 60
85
+ if (type === 'hour') preorderTime = parseInt(value) * 3600 + parseInt(curPreorderTime?.minute) * 60 + parseInt(curPreorderTime?.second)
86
+ else if (type === 'minute') preorderTime = parseInt(curPreorderTime?.hour) * 3600 + parseInt(value) * 60 + parseInt(curPreorderTime?.second)
87
+ else preorderTime = parseInt(curPreorderTime?.hour) * 3600 + parseInt(curPreorderTime?.minute) * 60 + parseInt(value)
80
88
  handleChangeItem({ times: [preorderTime], launch_type: 'times' })
81
89
  }
82
90
 
@@ -103,7 +111,8 @@ export const RecoveryGeneral = (props) => {
103
111
  setTimeList()
104
112
  setCurPreorderTime({
105
113
  hour: recoveryActionState?.action?.times ? (parseInt(recoveryActionState?.action?.times[0] / 3600)) : '0',
106
- minute: recoveryActionState?.action?.times ? (recoveryActionState?.action?.times[0] % 3600 / 60) : '0'
114
+ minute: recoveryActionState?.action?.times ? (parseInt(recoveryActionState?.action?.times[0] % 3600 / 60)) : '0',
115
+ second: recoveryActionState?.action?.times ? (recoveryActionState?.action?.times[0] % 3600 % 60) : '0'
107
116
  })
108
117
  if (!recoveryActionState?.action?.times) return
109
118
 
@@ -231,6 +240,16 @@ export const RecoveryGeneral = (props) => {
231
240
  <option value={minute.minute} key={i}>{minute.text}</option>
232
241
  ))}
233
242
  </select>
243
+ <span>:</span>
244
+ <select
245
+ value={curPreorderTime?.second}
246
+ name='second'
247
+ onChange={handleChangePreorderTime}
248
+ >
249
+ {seconds?.map((second, i) => (
250
+ <option value={second.second} key={i}>{second.text}</option>
251
+ ))}
252
+ </select>
234
253
  </TimeBlock>
235
254
  </TimeContent>
236
255
  )}
@@ -1,7 +1,7 @@
1
1
  import styled, { css } from 'styled-components'
2
2
 
3
3
  export const DriversCompaniesContainer = styled.div`
4
- margin-top: 20px;
4
+ padding: 20px;
5
5
  `
6
6
 
7
7
  export const TableWrapper = styled.div`
@@ -10,6 +10,7 @@ import { List as MenuIcon } from 'react-bootstrap-icons'
10
10
  import { Alert, Confirm, SearchBar, SideBar } from '../../Shared'
11
11
  import { DriversCompaniesList } from '../DriversCompaniesList'
12
12
  import { DriversCompanyDetailsForm } from '../DriversCompanyDetailsForm'
13
+ import { DriversCompanyAddForm } from '../DriversCompanyAddForm'
13
14
 
14
15
  import {
15
16
  DriversCompaniesListContainer,
@@ -42,10 +43,15 @@ const DriversCompaniesListingUI = (props) => {
42
43
  const [curDriversCompanyId, setCurDriversCompanyId] = useState(null)
43
44
  const [alertState, setAlertState] = useState({ open: false, content: [] })
44
45
  const [confirm, setConfirm] = useState({ open: false, content: null, handleOnAccept: null })
46
+ const [isAddMode, setIsAddMode] = useState(false)
45
47
 
46
48
  const handleOpenDetails = (driverCompany, isInitialRender) => {
47
49
  setCurDriversCompany(driverCompany)
48
50
  setCurDriversCompanyId(driverCompany?.id)
51
+ if (!driverCompany) {
52
+ setIsAddMode(true)
53
+ return
54
+ }
49
55
  setOpenDetails(true)
50
56
  if (!isInitialRender) {
51
57
  history.replace(`${location.pathname}?id=${driverCompany?.id}`)
@@ -75,6 +81,7 @@ const DriversCompaniesListingUI = (props) => {
75
81
  setCurDriversCompany(null)
76
82
  setCurDriversCompanyId(null)
77
83
  setOpenDetails(false)
84
+ setIsAddMode(false)
78
85
  history.replace(`${location.pathname}`)
79
86
  }
80
87
 
@@ -124,18 +131,28 @@ const DriversCompaniesListingUI = (props) => {
124
131
  />
125
132
  </HeaderRightContainer>
126
133
  </HeaderContainer>
127
- <DriversCompaniesList
128
- driversCompaniesState={driversCompaniesState}
129
- searchValue={searchValue}
130
- handleOpenDetails={handleOpenDetails}
131
- curDriversCompany={curDriversCompany}
132
- handleUpdateDriversCompany={handleUpdateDriversCompany}
133
- handleDeleteDriversCompany={handleDeleteDriversCompany}
134
- handleSelectCompany={handleSelectCompany}
135
- selectedCompanyList={selectedCompanyList}
136
- handleAllSelectCompany={handleAllSelectCompany}
137
- />
138
- {openDetails && (
134
+ {!isAddMode ? (
135
+ <DriversCompaniesList
136
+ driversCompaniesState={driversCompaniesState}
137
+ searchValue={searchValue}
138
+ handleOpenDetails={handleOpenDetails}
139
+ curDriversCompany={curDriversCompany}
140
+ handleUpdateDriversCompany={handleUpdateDriversCompany}
141
+ handleDeleteDriversCompany={handleDeleteDriversCompany}
142
+ handleSelectCompany={handleSelectCompany}
143
+ selectedCompanyList={selectedCompanyList}
144
+ handleAllSelectCompany={handleAllSelectCompany}
145
+ />
146
+ ) : (
147
+ <DriversCompanyAddForm
148
+ driversCompaniesState={driversCompaniesState}
149
+ setDriversCompaniesState={setDriversCompaniesState}
150
+ driversCompany={curDriversCompany}
151
+ driversCompanyId={curDriversCompanyId}
152
+ onClose={() => handleCloseDetails()}
153
+ />
154
+ )}
155
+ {openDetails && !isAddMode && (
139
156
  <SideBar
140
157
  sidebarId='city-details'
141
158
  defaultSideBarWidth={550}
@@ -2,7 +2,6 @@ import styled, { css } from 'styled-components'
2
2
 
3
3
  export const DriversCompaniesListContainer = styled.div`
4
4
  flex: 1;
5
- padding: 20px;
6
5
  box-sizing: border-box;
7
6
  transition: all 0.5s;
8
7
  max-height: 100vh;
@@ -12,6 +11,7 @@ export const DriversCompaniesListContainer = styled.div`
12
11
  export const HeaderContainer = styled.div`
13
12
  display: flex;
14
13
  flex-direction: column;
14
+ padding: 20px 20px 0 20px;
15
15
 
16
16
  @media (min-width: 768px) {
17
17
  flex-direction: row;
@@ -0,0 +1,120 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import { useLanguage } from 'ordering-components-admin-external'
3
+ import { Input, DefaultSelect } from '../../../../styles'
4
+ import { timezones } from '../../../../config/constants'
5
+ import { useFormContext } from 'react-hook-form'
6
+
7
+ import {
8
+ FormContainer,
9
+ InputWrapper
10
+ } from './styles'
11
+
12
+ export const GeneralForm = (props) => {
13
+ const {
14
+ changesState,
15
+ handleChangesState
16
+ } = props
17
+
18
+ const [, t] = useLanguage()
19
+ const { register } = useFormContext()
20
+ const [timezoneSearchValue, setTimezoneSearchValue] = useState('')
21
+ const [timezonesOptions, setTimezonesOptions] = useState([])
22
+
23
+ const priorityOptions = [
24
+ { value: -1, content: t('LOW', 'Low') },
25
+ { value: 0, content: t('NORMAL', 'Normal') },
26
+ { value: 1, content: t('HIGH', 'High') },
27
+ { value: 2, content: t('URGENT', 'Urgent') }
28
+ ]
29
+
30
+ useEffect(() => {
31
+ const _timezonesOptions = timezones
32
+ .filter(timezone => timezone.toLocaleLowerCase().includes(timezoneSearchValue.toLocaleLowerCase()))
33
+ .map(timezone => {
34
+ return {
35
+ value: timezone,
36
+ content: timezone
37
+ }
38
+ })
39
+ setTimezonesOptions(_timezonesOptions)
40
+ }, [timezoneSearchValue])
41
+
42
+ return (
43
+ <>
44
+ <FormContainer>
45
+ <h2>{t('GENERAL', 'General')}</h2>
46
+ <InputWrapper>
47
+ <label>{t('NAME', 'Name')}</label>
48
+ <Input
49
+ name='name'
50
+ defaultValue={changesState?.name ?? ''}
51
+ onChange={e => handleChangesState('name', e.target.value)}
52
+ placeholder={t('NAME', 'Name')}
53
+ ref={register({
54
+ required: t(
55
+ 'VALIDATION_ERROR_REQUIRED',
56
+ 'Name is required'
57
+ ).replace('_attribute_', t('NAME', 'Name'))
58
+ })}
59
+ autoComplete='off'
60
+ />
61
+ </InputWrapper>
62
+ <InputWrapper>
63
+ <label>{t('LIMIT', 'Limit')}</label>
64
+ <Input
65
+ name='limit'
66
+ defaultValue={changesState?.limit ?? ''}
67
+ onChange={e => handleChangesState('limit', e.target.value)}
68
+ placeholder={t('LIMIT', 'Limit')}
69
+ autoComplete='off'
70
+ onKeyPress={(e) => {
71
+ if (!/^[0-9]$/.test(e.key)) {
72
+ e.preventDefault()
73
+ }
74
+ }}
75
+ />
76
+ </InputWrapper>
77
+ <InputWrapper>
78
+ <label>{t('PRIORITY', 'Priority')}</label>
79
+ <DefaultSelect
80
+ placeholder={t('SELECT_PRIORITY', 'Select priority')}
81
+ defaultValue={changesState?.priority}
82
+ options={priorityOptions}
83
+ onChange={val => handleChangesState('priority', val)}
84
+ />
85
+ </InputWrapper>
86
+ <InputWrapper isTimezone>
87
+ <label>{t('TIMEZONE', 'Timezone')}</label>
88
+ <DefaultSelect
89
+ placeholder={t('SELECT_TIMEZONE', 'Select a timezone')}
90
+ defaultValue={changesState?.timezone}
91
+ options={timezonesOptions}
92
+ onChange={val => handleChangesState('timezone', val)}
93
+ optionInnerMaxHeight='60vh'
94
+ isShowSearchBar
95
+ searchBarIsCustomLayout
96
+ searchBarIsNotLazyLoad
97
+ searchValue={timezoneSearchValue}
98
+ handleChangeSearch={setTimezoneSearchValue}
99
+ />
100
+ </InputWrapper>
101
+ <InputWrapper>
102
+ <label>{t('ADDRESS', 'Address')}</label>
103
+ <Input
104
+ name='address'
105
+ defaultValue={changesState?.address ?? ''}
106
+ placeholder={t('ADDRESS', 'Address')}
107
+ onChange={e => handleChangesState('address', e.target.value)}
108
+ ref={register({
109
+ required: t(
110
+ 'VALIDATION_ERROR_REQUIRED',
111
+ 'Name is required'
112
+ ).replace('_attribute_', t('ADDRESS', 'Address'))
113
+ })}
114
+ autoComplete='off'
115
+ />
116
+ </InputWrapper>
117
+ </FormContainer>
118
+ </>
119
+ )
120
+ }
@@ -0,0 +1,32 @@
1
+ import styled, { css } from 'styled-components'
2
+
3
+ export const FormContainer = styled.div``
4
+
5
+ export const InputWrapper = styled.div`
6
+ display: flex;
7
+ flex-direction: column;
8
+ margin-bottom: 35px;
9
+
10
+ label {
11
+ font-size: 14px;
12
+ }
13
+
14
+ .select {
15
+ padding-top: 4px;
16
+ padding-bottom: 4px;
17
+ border: none;
18
+ background-color: ${props => props.theme.colors.secundary};
19
+ font-size: 14px;
20
+
21
+ ${({ isTimezone }) => isTimezone && css`
22
+ > div:first-child {
23
+ > div {
24
+ overflow: hidden;
25
+ }
26
+ }
27
+ .list-wrapper {
28
+ font-size: 12px;
29
+ }
30
+ `}
31
+ }
32
+ `