ordering-ui-admin-external 1.23.5 → 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 (96) hide show
  1. package/_bundles/{ordering-ui-admin.a1255b2c1a2d4b87080d.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/OrderingWebsite/SelectBusiness.js +59 -0
  18. package/_modules/components/MyProducts/OrderingWebsite/SelectFranchise.js +59 -0
  19. package/_modules/components/MyProducts/OrderingWebsite/index.js +21 -29
  20. package/_modules/components/MyProducts/OrderingWebsite/styles.js +1 -1
  21. package/_modules/components/MyProducts/UploadAudio/index.js +170 -0
  22. package/_modules/components/MyProducts/UploadAudio/styles.js +30 -0
  23. package/_modules/components/MyProducts/index.js +8 -1
  24. package/_modules/components/Orders/DeliveriesLocation/index.js +1 -0
  25. package/_modules/components/Orders/OrderBill/index.js +4 -3
  26. package/_modules/components/Orders/OrderContactInformation/index.js +14 -12
  27. package/_modules/components/Orders/OrderDetails/index.js +6 -131
  28. package/_modules/components/Orders/OrdersTable/index.js +2 -2
  29. package/_modules/components/Settings/NotificationSetting/index.js +1 -1
  30. package/_modules/components/Settings/SettingsList/index.js +1 -1
  31. package/_modules/components/Settings/SettingsList/styles.js +2 -2
  32. package/_modules/components/SidebarMenu/index.js +22 -22
  33. package/_modules/components/Stores/BusinessDetails/index.js +2 -1
  34. package/_modules/components/Stores/BusinessDeviceDetail/index.js +66 -16
  35. package/_modules/components/Stores/BusinessDeviceDetail/styles.js +7 -5
  36. package/_modules/components/Stores/BusinessSalesChannel/index.js +13 -4
  37. package/_modules/components/Stores/BusinessSalesFacebook/FacebookProfile.js +2 -2
  38. package/_modules/components/Stores/BusinessSalesFacebook/index.js +2 -2
  39. package/_modules/components/Stores/BusinessSalesGoogle/index.js +2 -2
  40. package/_modules/components/Stores/BusinessSalesInstagram/AdvancedInstagram.js +3 -2
  41. package/_modules/components/Stores/BusinessSalesInstagram/GeneralInstagram.js +2 -2
  42. package/_modules/components/Stores/BusinessSalesInstagram/index.js +3 -5
  43. package/_modules/components/Users/CustomersListing/index.js +5 -3
  44. package/_modules/utils/index.js +203 -2
  45. package/index-template.js +1 -1
  46. package/index.html +1 -0
  47. package/package.json +2 -2
  48. package/public/push/onesignal/OneSignalSDKUpdaterWorker.js +1 -0
  49. package/public/push/onesignal/OneSignalSDKWorker.js +1 -0
  50. package/src/components/CartRecovery/RecoveryActionAdd/index.js +355 -0
  51. package/src/components/CartRecovery/RecoveryGeneral/index.js +23 -4
  52. package/src/components/Delivery/DriversCompaniesList/styles.js +1 -1
  53. package/src/components/Delivery/DriversCompaniesListing/index.js +29 -12
  54. package/src/components/Delivery/DriversCompaniesListing/styles.js +1 -1
  55. package/src/components/Delivery/DriversCompanyAddForm/GeneralForm/index.js +120 -0
  56. package/src/components/Delivery/DriversCompanyAddForm/GeneralForm/styles.js +32 -0
  57. package/src/components/Delivery/DriversCompanyAddForm/ScheduleForm/index.js +29 -0
  58. package/src/components/Delivery/DriversCompanyAddForm/ScheduleForm/styles.js +11 -0
  59. package/src/components/Delivery/DriversCompanyAddForm/WebhooksForm/index.js +69 -0
  60. package/src/components/Delivery/DriversCompanyAddForm/WebhooksForm/styles.js +24 -0
  61. package/src/components/Delivery/DriversCompanyAddForm/index.js +121 -0
  62. package/src/components/Delivery/DriversCompanyAddForm/styles.js +39 -0
  63. package/src/components/MyProducts/AdvancedSettings/index.js +35 -36
  64. package/src/components/MyProducts/AdvancedSettings/styles.js +3 -11
  65. package/src/components/MyProducts/OrderingWebsite/SelectBusiness.js +47 -0
  66. package/src/components/MyProducts/OrderingWebsite/SelectFranchise.js +47 -0
  67. package/src/components/MyProducts/OrderingWebsite/index.js +20 -30
  68. package/src/components/MyProducts/OrderingWebsite/styles.js +0 -4
  69. package/src/components/MyProducts/UploadAudio/index.js +168 -0
  70. package/src/components/MyProducts/UploadAudio/styles.js +120 -0
  71. package/src/components/MyProducts/index.js +3 -1
  72. package/src/components/Orders/DeliveriesLocation/index.js +1 -0
  73. package/src/components/Orders/OrderBill/index.js +9 -6
  74. package/src/components/Orders/OrderContactInformation/index.js +5 -1
  75. package/src/components/Orders/OrderDetails/index.js +7 -35
  76. package/src/components/Orders/OrdersTable/index.js +3 -1
  77. package/src/components/Settings/NotificationSetting/index.js +2 -0
  78. package/src/components/Settings/SettingsList/index.js +53 -53
  79. package/src/components/Settings/SettingsList/styles.js +2 -1
  80. package/src/components/Settings/SettingsSelectUI/index.js +1 -1
  81. package/src/components/SidebarMenu/index.js +1 -0
  82. package/src/components/Stores/BusinessDetails/index.js +1 -0
  83. package/src/components/Stores/BusinessDeviceDetail/index.js +46 -7
  84. package/src/components/Stores/BusinessDeviceDetail/styles.js +11 -0
  85. package/src/components/Stores/BusinessSalesChannel/index.js +12 -6
  86. package/src/components/Stores/BusinessSalesFacebook/FacebookProfile.js +2 -2
  87. package/src/components/Stores/BusinessSalesFacebook/index.js +3 -3
  88. package/src/components/Stores/BusinessSalesGoogle/index.js +3 -3
  89. package/src/components/Stores/BusinessSalesInstagram/AdvancedInstagram.js +2 -2
  90. package/src/components/Stores/BusinessSalesInstagram/GeneralInstagram.js +2 -2
  91. package/src/components/Stores/BusinessSalesInstagram/index.js +3 -3
  92. package/src/components/Users/CustomersListing/index.js +2 -3
  93. package/src/utils/index.js +53 -0
  94. package/template/app.js +76 -3
  95. package/template/config.json +1 -0
  96. /package/_bundles/{ordering-ui-admin.a1255b2c1a2d4b87080d.js.LICENSE.txt → ordering-ui-admin.0c354f3e7da49f56465b.js.LICENSE.txt} +0 -0
@@ -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
+ `
@@ -0,0 +1,29 @@
1
+ import React from 'react'
2
+ import { Schedule } from '../../../Shared'
3
+ import { useLanguage } from 'ordering-components-admin-external'
4
+
5
+ import {
6
+ ScheduleContainer,
7
+ ScheduleInnerContainer
8
+ } from './styles'
9
+
10
+ export const ScheduleForm = (props) => {
11
+ const {
12
+ handleChangeScheduleState
13
+ } = props
14
+
15
+ const [, t] = useLanguage()
16
+
17
+ return (
18
+ <>
19
+ <ScheduleContainer>
20
+ <h2>{t('SCHEDULE', 'Schedule')}</h2>
21
+ <ScheduleInnerContainer>
22
+ <Schedule
23
+ handleChangeScheduleState={handleChangeScheduleState}
24
+ />
25
+ </ScheduleInnerContainer>
26
+ </ScheduleContainer>
27
+ </>
28
+ )
29
+ }
@@ -0,0 +1,11 @@
1
+ import styled from 'styled-components'
2
+
3
+ export const ScheduleContainer = styled.div`
4
+ > button {
5
+ margin: 30px 0 20px;
6
+ height: 44px;
7
+ }
8
+ `
9
+
10
+ export const ScheduleInnerContainer = styled.div`
11
+ `
@@ -0,0 +1,69 @@
1
+ import React from 'react'
2
+ import { useLanguage } from 'ordering-components-admin-external'
3
+ import { Input } from '../../../../styles'
4
+ import { useFormContext } from 'react-hook-form'
5
+
6
+ import {
7
+ FormContainer,
8
+ InputWrapper
9
+ } from './styles'
10
+
11
+ export const WebhooksForm = (props) => {
12
+ const {
13
+ changesState,
14
+ handleChangesState
15
+ } = props
16
+
17
+ const [, t] = useLanguage()
18
+ const { register } = useFormContext()
19
+
20
+ return (
21
+ <>
22
+ <FormContainer>
23
+ <h2>{t('WEBHOOKS', 'Webhooks')}</h2>
24
+ <InputWrapper>
25
+ <label>{t('WEBHOOK_NEW_ORDER', 'Webhook new order')}</label>
26
+ <Input
27
+ name='webhook_new_order'
28
+ defaultValue={changesState?.webhook_new_order ?? ''}
29
+ onChange={e => handleChangesState('webhook_new_order', e.target.value)}
30
+ placeholder={t('WEBHOOK_NEW_ORDER', 'Webhook new order')}
31
+ ref={register({
32
+ required: t(
33
+ 'VALIDATION_ERROR_REQUIRED',
34
+ 'Name is required'
35
+ ).replace('_attribute_', t('WEBHOOK_NEW_ORDER', 'Webhook new order'))
36
+ })}
37
+ autoComplete='off'
38
+ />
39
+ </InputWrapper>
40
+ <InputWrapper>
41
+ <label>{t('WEBHOOK_CANCEL_REQUEST', 'Webhook cancel request')}</label>
42
+ <Input
43
+ name='webhook_cancel_request'
44
+ defaultValue={changesState?.webhook_cancel_request ?? ''}
45
+ onChange={e => handleChangesState('webhook_cancel_request', e.target.value)}
46
+ placeholder={t('WEBHOOK_CANCEL_REQUEST', 'Webhook cancel request')}
47
+ ref={register({
48
+ required: t(
49
+ 'VALIDATION_ERROR_REQUIRED',
50
+ 'Name is required'
51
+ ).replace('_attribute_', t('WEBHOOK_CANCEL_REQUEST', 'Webhook cancel request'))
52
+ })}
53
+ autoComplete='off'
54
+ />
55
+ </InputWrapper>
56
+ <InputWrapper>
57
+ <label>{t('WEBHOOK_ORDER_STATUS_CHANGED', 'Webhook order status changed')}</label>
58
+ <Input
59
+ name='webhook_order_status_changed'
60
+ defaultValue={changesState?.webhook_order_status_changed ?? ''}
61
+ onChange={e => handleChangesState('webhook_order_status_changed', e.target.value)}
62
+ placeholder={t('WEBHOOK_ORDER_STATUS_CHANGED', 'Webhook order status changed')}
63
+ autoComplete='off'
64
+ />
65
+ </InputWrapper>
66
+ </FormContainer>
67
+ </>
68
+ )
69
+ }
@@ -0,0 +1,24 @@
1
+ import styled 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
+ div {
15
+ font-size: 14px;
16
+ }
17
+
18
+ .select {
19
+ padding-top: 4px;
20
+ padding-bottom: 4px;
21
+ border: none;
22
+ background-color: ${props => props.theme.colors.secundary};
23
+ }
24
+ `
@@ -0,0 +1,121 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import {
3
+ useLanguage,
4
+ DriversCompanyDetails as DriversCompanyDetailsController
5
+ } from 'ordering-components-admin-external'
6
+ import { useForm, FormProvider } from 'react-hook-form'
7
+ import { Alert } from '../../Shared'
8
+ import { Button } from '../../../styles'
9
+ import { GeneralForm } from './GeneralForm'
10
+ import { ScheduleForm } from './ScheduleForm'
11
+ import { WebhooksForm } from './WebhooksForm'
12
+
13
+ import {
14
+ Container,
15
+ SectionContainer,
16
+ ButtonsContainer
17
+ } from './styles'
18
+
19
+ const DriversCompanyAddFormUI = (props) => {
20
+ const {
21
+ changesState,
22
+ actionState,
23
+ cleanActionState,
24
+ handleAddDriversCompany
25
+ } = props
26
+
27
+ const [, t] = useLanguage()
28
+ const formMethods = useForm()
29
+
30
+ const [alertState, setAlertState] = useState({ open: false, content: [] })
31
+
32
+ const closeAlert = () => {
33
+ cleanActionState()
34
+ setAlertState({
35
+ open: false,
36
+ content: []
37
+ })
38
+ }
39
+
40
+ useEffect(() => {
41
+ if (!actionState.loading && actionState.error) {
42
+ setAlertState({
43
+ open: true,
44
+ content: actionState.error || [t('ERROR')]
45
+ })
46
+ }
47
+ }, [actionState])
48
+
49
+ useEffect(() => {
50
+ if (Object.keys(formMethods.errors).length > 0) {
51
+ setAlertState({
52
+ open: true,
53
+ content: Object.values(formMethods.errors).map((error) => error.message)
54
+ })
55
+ }
56
+ }, [formMethods.errors])
57
+
58
+ const onSubmit = () => {
59
+ if (!(changesState?.timezone)) {
60
+ setAlertState({
61
+ open: true,
62
+ content: t(
63
+ 'VALIDATION_ERROR_REQUIRED',
64
+ 'Name is required'
65
+ ).replace('_attribute_', t('TIMEZONE', 'Timezone'))
66
+ })
67
+ return
68
+ }
69
+ handleAddDriversCompany()
70
+ }
71
+
72
+ return (
73
+ <FormProvider {...formMethods}>
74
+ <Container onSubmit={formMethods.handleSubmit(onSubmit)}>
75
+ <SectionContainer>
76
+ <GeneralForm {...props} />
77
+ </SectionContainer>
78
+ <SectionContainer>
79
+ <ScheduleForm {...props} />
80
+ </SectionContainer>
81
+ <SectionContainer>
82
+ <WebhooksForm {...props} />
83
+ </SectionContainer>
84
+ <ButtonsContainer>
85
+ <Button
86
+ color='secundary'
87
+ onClick={() => props.onClose()}
88
+ type='button'
89
+ >
90
+ {t('CANCEL', 'Cancel')}
91
+ </Button>
92
+ <Button
93
+ borderRadius='8px'
94
+ color='primary'
95
+ type='submit'
96
+ disabled={Object.keys(changesState).length === 0}
97
+ >
98
+ {t('SAVE', 'Save')}
99
+ </Button>
100
+ </ButtonsContainer>
101
+ </Container>
102
+ <Alert
103
+ title={t('ERROR')}
104
+ content={alertState.content}
105
+ acceptText={t('ACCEPT')}
106
+ open={alertState.open}
107
+ onClose={() => closeAlert()}
108
+ onAccept={() => closeAlert()}
109
+ closeOnBackdrop={false}
110
+ />
111
+ </FormProvider>
112
+ )
113
+ }
114
+
115
+ export const DriversCompanyAddForm = (props) => {
116
+ const driversCompanyDetailsProps = {
117
+ ...props,
118
+ UIComponent: DriversCompanyAddFormUI
119
+ }
120
+ return <DriversCompanyDetailsController {...driversCompanyDetailsProps} />
121
+ }
@@ -0,0 +1,39 @@
1
+ import styled from 'styled-components'
2
+
3
+ export const Container = styled.form`
4
+ h2 {
5
+ font-weight: 600;
6
+ font-size: 16px;
7
+ line-height: 24px;
8
+ margin: 0 0 29px 0;
9
+ }
10
+ `
11
+
12
+ export const SectionContainer = styled.div`
13
+ box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.12);
14
+ border-radius: 7.6px;
15
+ padding: 25px 38px;
16
+ margin: 25px 20px 34px 20px;
17
+
18
+ > div {
19
+ max-width: 1024px;
20
+ }
21
+ `
22
+ export const ButtonsContainer = styled.div`
23
+ display: flex;
24
+ align-items: center;
25
+ justify-content: flex-end;
26
+ padding: 20px;
27
+ position: sticky;
28
+ z-index: 100;
29
+ bottom: 0;
30
+ background-color: ${props => props.theme.colors.backgroundPage};
31
+
32
+ > button {
33
+ border-radius: 8px;
34
+ height: 44px;
35
+ &:first-child {
36
+ margin: 0 10px;
37
+ }
38
+ }
39
+ `