ordering-ui-admin-external 1.11.1 → 1.12.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 (35) hide show
  1. package/_bundles/{ordering-ui-admin.4306236a404049a30f1a.js → ordering-ui-admin.1a739d9a2d4d7fdd023f.js} +2 -2
  2. package/_bundles/{ordering-ui-admin.4306236a404049a30f1a.js.LICENSE.txt → ordering-ui-admin.1a739d9a2d4d7fdd023f.js.LICENSE.txt} +0 -0
  3. package/_modules/components/Delivery/DriversGroupDeliveryZoneInformation/index.js +8 -6
  4. package/_modules/components/Delivery/DriversGroupDetails/index.js +1 -1
  5. package/_modules/components/Delivery/DriversGroupDetails/styles.js +1 -1
  6. package/_modules/components/Delivery/DriversGroupGeneralForm/index.js +5 -2
  7. package/_modules/components/Marketing/EnterprisePromotionGeneralDetails/index.js +2 -2
  8. package/_modules/components/Shared/Confirm/index.js +6 -2
  9. package/_modules/components/SidebarMenu/index.js +17 -12
  10. package/_modules/components/Stores/BusinessDeliveryZoneDetails/index.js +3 -2
  11. package/_modules/components/Stores/BusinessWalletsList/index.js +5 -1
  12. package/_modules/components/Stores/ProductExtraOptionDetails/index.js +48 -12
  13. package/_modules/components/Stores/ProductExtraOptions/index.js +46 -8
  14. package/_modules/components/Stores/ProductExtraSuboption/index.js +34 -0
  15. package/_modules/components/Stores/ProductExtras/index.js +6 -3
  16. package/_modules/components/Stores/ProductOptionExternalId/index.js +39 -0
  17. package/_modules/components/Stores/ProductOptionExternalId/styles.js +14 -0
  18. package/package.json +2 -2
  19. package/src/components/Delivery/DriversGroupDeliveryDetails/index.js +1 -1
  20. package/src/components/Delivery/DriversGroupDeliveryZoneInformation/index.js +7 -5
  21. package/src/components/Delivery/DriversGroupDeliveryZoneList/index.js +2 -2
  22. package/src/components/Delivery/DriversGroupDetails/index.js +1 -1
  23. package/src/components/Delivery/DriversGroupDetails/styles.js +1 -0
  24. package/src/components/Delivery/DriversGroupGeneralForm/index.js +16 -13
  25. package/src/components/Marketing/EnterprisePromotionGeneralDetails/index.js +2 -2
  26. package/src/components/Shared/Confirm/index.js +11 -1
  27. package/src/components/SidebarMenu/index.js +19 -9
  28. package/src/components/Stores/BusinessDeliveryZoneDetails/index.js +3 -2
  29. package/src/components/Stores/BusinessWalletsList/index.js +6 -1
  30. package/src/components/Stores/ProductExtraOptionDetails/index.js +28 -0
  31. package/src/components/Stores/ProductExtraOptions/index.js +30 -1
  32. package/src/components/Stores/ProductExtraSuboption/index.js +32 -0
  33. package/src/components/Stores/ProductExtras/index.js +4 -1
  34. package/src/components/Stores/ProductOptionExternalId/index.js +29 -0
  35. package/src/components/Stores/ProductOptionExternalId/styles.js +22 -0
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ProductOptionExternalId = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _orderingComponentsAdminExternal = require("ordering-components-admin-external");
9
+ var _styles = require("./styles");
10
+ var _styles2 = require("../../../styles");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
16
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
17
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
+ var ProductOptionExternalId = function ProductOptionExternalId(props) {
19
+ var value = props.value,
20
+ handleChange = props.handleChange,
21
+ handleUpdate = props.handleUpdate;
22
+ var _useLanguage = (0, _orderingComponentsAdminExternal.useLanguage)(),
23
+ _useLanguage2 = _slicedToArray(_useLanguage, 2),
24
+ t = _useLanguage2[1];
25
+ return /*#__PURE__*/_react.default.createElement(_styles.Container, null, /*#__PURE__*/_react.default.createElement(_styles.FormControl, null, /*#__PURE__*/_react.default.createElement("label", {
26
+ htmlFor: "externalId"
27
+ }, t('EXTERNAL_ID', 'External Id')), /*#__PURE__*/_react.default.createElement(_styles2.Input, {
28
+ defaultValue: value || '',
29
+ placeholder: t('EXTERNAL_ID', 'External Id'),
30
+ onChange: function onChange(e) {
31
+ return handleChange(e.target.value);
32
+ }
33
+ })), /*#__PURE__*/_react.default.createElement(_styles2.Button, {
34
+ color: "primary",
35
+ borderRadius: "8px",
36
+ onClick: handleUpdate
37
+ }, t('UPDATE', 'Update')));
38
+ };
39
+ exports.ProductOptionExternalId = ProductOptionExternalId;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FormControl = exports.Container = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ var _templateObject, _templateObject2;
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
11
+ var Container = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n button {\n height: 44px;\n text-transform: lowercase;\n &:first-letter {\n text-transform: uppercase;\n }\n }\n"])));
12
+ exports.Container = Container;
13
+ var FormControl = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-bottom: 25px;\n label {\n margin-bottom: 10px;\n }\n input {\n height: 44px;\n width: 100%;\n }\n"])));
14
+ exports.FormControl = FormControl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-admin-external",
3
- "version": "1.11.1",
3
+ "version": "1.12.0",
4
4
  "description": "Ordering UI Admin Components",
5
5
  "main": "./_modules/index.js",
6
6
  "exports": {
@@ -83,7 +83,7 @@
83
83
  "lodash": "^4.17.20",
84
84
  "moment": "^2.29.1",
85
85
  "moment-range": "^4.0.2",
86
- "ordering-components-admin-external": "1.11.1",
86
+ "ordering-components-admin-external": "1.12.0",
87
87
  "polished": "^3.6.7",
88
88
  "prop-types": "^15.7.2",
89
89
  "react-big-calendar": "^1.4.2",
@@ -8,7 +8,7 @@ import { Button } from '../../../styles'
8
8
  import { Alert } from '../../Shared'
9
9
 
10
10
  import {
11
- Container,
11
+ Container
12
12
  } from './styles'
13
13
 
14
14
  const DriverGroupDeliveryDetailsUI = (props) => {
@@ -213,17 +213,19 @@ export const DriverGroupDeliveryZoneInformation = (props) => {
213
213
  name='distance'
214
214
  maxLength={2}
215
215
  value={formState.changes?.data?.distance ?? zone?.data?.distance ?? ''}
216
- onInput={(e) => {
217
- e.target.value = e.target.value.match('^[1-9]{1,2}$')
218
- }}
219
216
  onChange={e => handleChangeInput(e, configState?.configs?.distance_unit?.value)}
220
217
  ref={register({
221
218
  required: t('DISTANCE_FROM_STORE', 'Distance from store')
222
219
  })}
220
+ onKeyPress={(e) => {
221
+ if (!/^[0-9]$/.test(e.key)) {
222
+ e.preventDefault()
223
+ }
224
+ }}
223
225
  />
224
226
  </FormControl>
225
227
  </Row>}
226
- {zoneType !== 4 && isShowMap && (
228
+ {zoneType !== 4 && zoneType !== 5 && isShowMap && (
227
229
  configState?.configs?.google_maps_api_key?.value ? (
228
230
  <WrapperMap>
229
231
  <button
@@ -254,7 +256,7 @@ export const DriverGroupDeliveryZoneInformation = (props) => {
254
256
  <ErrorText>{t('REQUIRED_GOOGLE_MAP_API_KEY', 'Google Maps api key is required')}</ErrorText>
255
257
  )
256
258
  )}
257
- {!zone && (
259
+ {!zone && zoneType !== 5 && (
258
260
  <KmlButtonWrapper>
259
261
  <Button
260
262
  color='primary'
@@ -65,7 +65,7 @@ export const DriverGroupDeliveryZoneList = (props) => {
65
65
  </InfoBlock>
66
66
  </DeliveryZonesTableWrapper>
67
67
  ))
68
- ) :
68
+ ) : (
69
69
  <DeliveryZonesTable>
70
70
  <thead>
71
71
  <tr>
@@ -106,7 +106,7 @@ export const DriverGroupDeliveryZoneList = (props) => {
106
106
  </ZoneTbody>
107
107
  ))}
108
108
  </DeliveryZonesTable>
109
- }
109
+ )}
110
110
  <AddDeliveryZoneButton
111
111
  onClick={(e) => handleOpenZone(e, null)}
112
112
  >
@@ -73,7 +73,7 @@ const DriversGroupDetailsUI = (props) => {
73
73
  { key: 'logs', value: t('LOGS', 'Logs') }
74
74
  ]
75
75
  setDriversGroupMenus(_driversGroupMenus)
76
- }, [useAdvanced])
76
+ }, [useAdvanced, driversGroupState?.driversGroup])
77
77
 
78
78
  const onDeleteGroup = () => {
79
79
  setConfirm({
@@ -28,6 +28,7 @@ export const Header = styled.div`
28
28
  font-size: 20px;
29
29
  font-weight: 700;
30
30
  margin: 0px;
31
+ flex: 1;
31
32
  }
32
33
 
33
34
  label {
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useEffect } from 'react'
2
- import { useLanguage, useConfig } from 'ordering-components-admin-external'
2
+ import { useLanguage, useConfig, useSession } from 'ordering-components-admin-external'
3
3
  import { useForm } from 'react-hook-form'
4
4
  import { Input, Checkbox, Button, SecondSelect as DefaultSelect } from '../../../styles'
5
5
  import { Alert } from '../../Shared'
@@ -31,6 +31,7 @@ export const DriversGroupGeneralForm = (props) => {
31
31
  const { handleSubmit, register, errors } = useForm()
32
32
  const [alertState, setAlertState] = useState({ open: false, content: [] })
33
33
  const [configState] = useConfig()
34
+ const [{ user }] = useSession()
34
35
 
35
36
  const autoAssignType = configState?.configs?.autoassign_type?.value
36
37
 
@@ -75,7 +76,7 @@ export const DriversGroupGeneralForm = (props) => {
75
76
  }
76
77
  handleUpdateDriversGroup(changesState)
77
78
  } else {
78
- if (!changesState?.administrator_id) {
79
+ if (user?.level !== 5 && !changesState?.administrator_id) {
79
80
  setAlertState({
80
81
  open: true,
81
82
  content: [t('VALIDATION_ERROR_REQUIRED', 'The manager is required.').replace('_attribute_', t('DRIVER_MANAGER', 'Driver manager'))]
@@ -142,17 +143,19 @@ export const DriversGroupGeneralForm = (props) => {
142
143
  autoComplete='off'
143
144
  />
144
145
  </InputWrapper>
145
- <InputWrapper>
146
- <label>{t('DRIVER_MANAGER', 'Driver manager')}</label>
147
- <DefaultSelect
148
- isSecondIcon
149
- placeholder={t('SELECT_MANAGER', 'Select driver manager')}
150
- options={driversManagersOptions}
151
- defaultValue={changesState?.administrator_id ?? driversGroupState.driversGroup?.administrator_id}
152
- optionInnerMaxHeight='60vh'
153
- onChange={val => handleChangesState({ administrator_id: val })}
154
- />
155
- </InputWrapper>
146
+ {user?.level !== 5 && (
147
+ <InputWrapper>
148
+ <label>{t('DRIVER_MANAGER', 'Driver manager')}</label>
149
+ <DefaultSelect
150
+ isSecondIcon
151
+ placeholder={t('SELECT_MANAGER', 'Select driver manager')}
152
+ options={driversManagersOptions}
153
+ defaultValue={changesState?.administrator_id ?? driversGroupState.driversGroup?.administrator_id}
154
+ optionInnerMaxHeight='60vh'
155
+ onChange={val => handleChangesState({ administrator_id: val })}
156
+ />
157
+ </InputWrapper>
158
+ )}
156
159
  <InputWrapper>
157
160
  <label>{t('TYPE', 'Type')}</label>
158
161
  <DefaultSelect
@@ -125,8 +125,8 @@ export const EnterprisePromotionGeneralDetails = (props) => {
125
125
 
126
126
  const handleChangeDates = (item) => {
127
127
  handleChangeItem({
128
- start: moment(item.selection.startDate).format('YYYY-MM-DD'),
129
- end: item.selection.endDate ? moment(item.selection.endDate).format('YYYY-MM-DD') : null
128
+ start: moment(item.selection.startDate).format('YYYY-MM-DD 00:00:00'),
129
+ end: item.selection.endDate ? moment(item.selection.endDate).format('YYYY-MM-DD 23:59:59') : null
130
130
  })
131
131
  setDateRange([item.selection])
132
132
  }
@@ -45,7 +45,17 @@ const ConfirmUI = (props) => {
45
45
  {content && typeof content === 'object' && Array.isArray(content) && (
46
46
  <ul>
47
47
  {content.map((item, i) => (
48
- <li key={i}>{t(item.toUpperCase(), errors[item])}</li>
48
+ <React.Fragment key={i}>
49
+ {Array.isArray(item) ? (
50
+ item.map((err, index) => (
51
+ typeof err === 'string' && (
52
+ <li key={index}>{t(err.toUpperCase(), errors[err] || err)}</li>
53
+ )
54
+ ))
55
+ ) : (
56
+ typeof item === 'string' && <li>{t(item.toUpperCase(), errors[item] || item)}</li>
57
+ )}
58
+ </React.Fragment>
49
59
  ))}
50
60
  </ul>
51
61
  )}
@@ -19,7 +19,6 @@ import {
19
19
  Cart3,
20
20
  Cash,
21
21
  BagCheck,
22
- CloudDownload,
23
22
  X as CloseIcon
24
23
  } from 'react-bootstrap-icons'
25
24
  import { useTheme } from 'styled-components'
@@ -73,18 +72,27 @@ const SidebarMenuUI = (props) => {
73
72
  {
74
73
  id: 2,
75
74
  title: t('DELIVERY_DASHBOARD', 'Deliveries dashboard'),
76
- pageName: 'deliveries'
75
+ pageName: 'deliveries',
76
+ url: '/deliveries'
77
77
  },
78
78
  {
79
79
  id: 3,
80
80
  title: t('DRIVERS_DASHBOARD', 'Drivers Dashboard'),
81
- pageName: 'drivers'
81
+ pageName: 'drivers',
82
+ url: '/drivers'
83
+ },
84
+ {
85
+ id: 4,
86
+ title: t('APPOINTMENTS', 'Appointments'),
87
+ pageName: 'appointments',
88
+ url: '/appointments'
89
+ },
90
+ {
91
+ id: 5,
92
+ title: t('GIFT_CARD_MANAGER', 'Gift card manager'),
93
+ pageName: 'giftCards',
94
+ url: '/gift-cards'
82
95
  }
83
- // {
84
- // id: 4,
85
- // title: t('APPOINTMENTS', 'Appointments'),
86
- // pageName: 'appointments'
87
- // }
88
96
  ]
89
97
 
90
98
  const loyaltySubMenus = [
@@ -669,7 +677,8 @@ const SidebarMenuUI = (props) => {
669
677
  eventKey='8'
670
678
  active={
671
679
  location.pathname === '/marketing/promotions-enterprise' ||
672
- location.pathname === '/marketing/campaign'
680
+ location.pathname === '/marketing/campaign' ||
681
+ location.pathname === '/marketing/ad-banners'
673
682
  }
674
683
  >
675
684
  <GraphUp />
@@ -794,6 +803,7 @@ const SidebarMenuUI = (props) => {
794
803
  active={
795
804
  location.pathname === '/settings/basic' ||
796
805
  location.pathname === '/settings/operation' ||
806
+ location.pathname === '/settings/plugin' ||
797
807
  location.pathname === '/settings/pages' ||
798
808
  location.pathname === '/settings/integrations' ||
799
809
  location.pathname === '/settings/places' ||
@@ -30,7 +30,8 @@ const BusinessDeliveryZoneDetailsUI = (props) => {
30
30
  handleAddBusinessDeliveryZone,
31
31
  handleDeleteBusinessDeliveryZone,
32
32
  kmlData,
33
- handleUploadKmlFiles
33
+ handleUploadKmlFiles,
34
+ handleSuccessUpdate
34
35
  } = props
35
36
 
36
37
  const theme = useTheme()
@@ -106,7 +107,7 @@ const BusinessDeliveryZoneDetailsUI = (props) => {
106
107
  <BusinessDeliveryZoneShare
107
108
  business={business}
108
109
  zone={zoneState.zone}
109
- handleUpdateBusinessDeliveryZone={handleUpdateBusinessDeliveryZone}
110
+ handleSuccessUpdate={handleSuccessUpdate}
110
111
  />
111
112
  )}
112
113
  </Container>
@@ -37,6 +37,11 @@ const BusinessWalletsListUI = (props) => {
37
37
  wallet_credit_point_enabled: isWalletPointsEnabled && loyaltyPlanState.created
38
38
  }
39
39
 
40
+ const walletsLangs = {
41
+ wallet_cash_enabled: t('WALLET_CASH_ENABLED', 'Wallet cash enabled'),
42
+ wallet_credit_point_enabled: t('WALLET_CREDIT_POINT_ENABLED', 'Wallet credit point enabled')
43
+ }
44
+
40
45
  const handleOpenWallet = (config) => {
41
46
  setIsOpenWalletDetails(true)
42
47
  handleClosePaymethodDetails()
@@ -83,7 +88,7 @@ const BusinessWalletsListUI = (props) => {
83
88
  active={config.id === currentConfig?.id}
84
89
  onClick={() => handleOpenWallet(config)}
85
90
  >
86
- <WalletName>{config.name}</WalletName>
91
+ <WalletName>{walletsLangs[config.key]}</WalletName>
87
92
  <ChevronRight />
88
93
  </WalletOption>
89
94
  ))}
@@ -21,6 +21,7 @@ import {
21
21
  import { useForm, Controller } from 'react-hook-form'
22
22
  import { ProductExtraSuboption } from '../ProductExtraSuboption'
23
23
  import { ProductExtraOptionForm } from '../ProductExtraOptionForm'
24
+ import { ProductOptionExternalId } from '../ProductOptionExternalId'
24
25
 
25
26
  import {
26
27
  MainContainer,
@@ -87,6 +88,7 @@ const ProductExtraOptionDetailsUI = (props) => {
87
88
  const [selectedSubOptionId, setSelectedSubOptionId] = useState(null)
88
89
  const { handleSubmit, register, errors, control, setValue } = useForm()
89
90
  const [cropState, setCropState] = useState({ name: null, data: null, open: false })
91
+ const [externalId, setExternalId] = useState()
90
92
 
91
93
  const handleClickSubOptionImage = (id) => {
92
94
  document.getElementById(id).click()
@@ -149,6 +151,11 @@ const ProductExtraOptionDetailsUI = (props) => {
149
151
  }
150
152
  }
151
153
 
154
+ const handleUpdateExternalId = () => {
155
+ handleUpdateOption({ external_id: externalId })
156
+ setOpenModal({ ...openModal, externalId: false })
157
+ }
158
+
152
159
  useEffect(() => {
153
160
  if (Object.keys(errors).length > 0) {
154
161
  setAlertState({
@@ -158,6 +165,10 @@ const ProductExtraOptionDetailsUI = (props) => {
158
165
  }
159
166
  }, [errors])
160
167
 
168
+ useEffect(() => {
169
+ setExternalId(optionState?.option?.external_id)
170
+ }, [optionState?.option?.external_id])
171
+
161
172
  return (
162
173
  <MainContainer>
163
174
  <Header>
@@ -174,6 +185,11 @@ const ProductExtraOptionDetailsUI = (props) => {
174
185
  >
175
186
  {t('CUSTOM_FIELDS', 'Custom Fields')}
176
187
  </Dropdown.Item>
188
+ <Dropdown.Item
189
+ onClick={() => setOpenModal({ ...openModal, externalId: true })}
190
+ >
191
+ {t('EXTERNAL_ID', 'External ID')}
192
+ </Dropdown.Item>
177
193
  <Dropdown.Item
178
194
  onClick={() => handleDeleteOption()}
179
195
  >
@@ -446,6 +462,18 @@ const ProductExtraOptionDetailsUI = (props) => {
446
462
  />
447
463
  </Modal>
448
464
  )}
465
+ <Modal
466
+ width='70%'
467
+ title={t('PRODUCT_SUBOPTION', 'Product suboption')}
468
+ open={openModal?.externalId}
469
+ onClose={() => setOpenModal({ ...openModal, externalId: false })}
470
+ >
471
+ <ProductOptionExternalId
472
+ value={externalId}
473
+ handleChange={setExternalId}
474
+ handleUpdate={handleUpdateExternalId}
475
+ />
476
+ </Modal>
449
477
  <Modal
450
478
  width='700px'
451
479
  height='80vh'
@@ -13,6 +13,7 @@ import { Alert, Confirm, Modal, ImageCrop } from '../../Shared'
13
13
  import { IconButton } from '../../../styles'
14
14
  import { ProductExtraMetaFields } from '../ProductExtraMetaFields'
15
15
  import { ProductExtraOptionDetails } from '../ProductExtraOptionDetails'
16
+ import { ProductOptionExternalId } from '../ProductOptionExternalId'
16
17
 
17
18
  import {
18
19
  MainContainer,
@@ -59,7 +60,8 @@ const ProductExtraOptionsUI = (props) => {
59
60
  handleDragStart,
60
61
  hanldeDragOver,
61
62
  handleDrop,
62
- handleDragEnd
63
+ handleDragEnd,
64
+ handleUpdateExtraState
63
65
  } = props
64
66
 
65
67
  const theme = useTheme()
@@ -76,6 +78,7 @@ const ProductExtraOptionsUI = (props) => {
76
78
  const [confirm, setConfirm] = useState({ open: false, content: null, handleOnAccept: null })
77
79
  const [isMaxError, setIsMaxError] = useState(false)
78
80
  const [cropState, setCropState] = useState({ name: null, data: null, open: false })
81
+ const [externalId, setExternalId] = useState()
79
82
 
80
83
  const closeAlert = () => {
81
84
  setAlertState({
@@ -182,6 +185,11 @@ const ProductExtraOptionsUI = (props) => {
182
185
  setTimer(_timer)
183
186
  }
184
187
 
188
+ const handleUpdateExternalId = () => {
189
+ handleUpdateExtraState(extraState.extra?.id, { external_id: externalId })
190
+ setOpenModal({ ...openModal, externalId: false })
191
+ }
192
+
185
193
  useEffect(() => {
186
194
  if (!addChangesState?.name && addChangesState?.min === 1 && addChangesState?.max === 1) {
187
195
  setValue('name', addChangesState?.name || '')
@@ -194,6 +202,10 @@ const ProductExtraOptionsUI = (props) => {
194
202
  setExtraName(extraState.extra?.name)
195
203
  }, [extraState.extra?.name])
196
204
 
205
+ useEffect(() => {
206
+ setExternalId(extraState?.extra?.external_id)
207
+ }, [extraState?.extra?.external_id])
208
+
197
209
  return (
198
210
  <MainContainer id='extra_options'>
199
211
  <OptionsContainer>
@@ -217,6 +229,11 @@ const ProductExtraOptionsUI = (props) => {
217
229
  >
218
230
  {t('CUSTOM_FIELDS', 'Custom Fields')}
219
231
  </Dropdown.Item>
232
+ <Dropdown.Item
233
+ onClick={() => setOpenModal({ ...openModal, externalId: true })}
234
+ >
235
+ {t('EXTERNAL_ID', 'External ID')}
236
+ </Dropdown.Item>
220
237
  <Dropdown.Item
221
238
  onClick={() => handleDeleteExtraClick()}
222
239
  >
@@ -418,6 +435,18 @@ const ProductExtraOptionsUI = (props) => {
418
435
  extraId={extraState.extra.id}
419
436
  />
420
437
  </Modal>
438
+ <Modal
439
+ width='70%'
440
+ title={t('PRODUCT_EXTRA', 'Product extra')}
441
+ open={openModal?.externalId}
442
+ onClose={() => setOpenModal({ ...openModal, externalId: false })}
443
+ >
444
+ <ProductOptionExternalId
445
+ value={externalId}
446
+ handleChange={setExternalId}
447
+ handleUpdate={handleUpdateExternalId}
448
+ />
449
+ </Modal>
421
450
  <Modal
422
451
  width='700px'
423
452
  height='80vh'
@@ -21,6 +21,7 @@ import {
21
21
  ActionSelectorWrapper,
22
22
  DragImageWrapper
23
23
  } from './styles'
24
+ import { ProductOptionExternalId } from '../ProductOptionExternalId'
24
25
 
25
26
  export const ProductExtraSuboption = (props) => {
26
27
  const {
@@ -54,6 +55,8 @@ export const ProductExtraSuboption = (props) => {
54
55
  const [confirm, setConfirm] = useState({ open: false, content: null, handleOnAccept: null })
55
56
  const [cropState, setCropState] = useState({ name: null, data: null, open: false })
56
57
  const [formState, setFormState] = useState({ })
58
+ const [externalIdOpen, setExternalIdOpen] = useState(false)
59
+ const [externalId, setExternalId] = useState()
57
60
 
58
61
  const handleClickSubOptionImage = (id) => {
59
62
  document.getElementById(id).click()
@@ -119,6 +122,14 @@ export const ProductExtraSuboption = (props) => {
119
122
  })
120
123
  }
121
124
 
125
+ const handleUpdateExternalId = () => {
126
+ handleUpdateSubOption({
127
+ id: subOption.id,
128
+ external_id: externalId
129
+ })
130
+ setExternalIdOpen(false)
131
+ }
132
+
122
133
  useEffect(() => {
123
134
  if (Object.keys(errors).length > 0) {
124
135
  setAlertState({
@@ -137,6 +148,10 @@ export const ProductExtraSuboption = (props) => {
137
148
  setTimer(_timer)
138
149
  }, [formState])
139
150
 
151
+ useEffect(() => {
152
+ setExternalId(subOption?.external_id)
153
+ }, [subOption?.external_id])
154
+
140
155
  return (
141
156
  <SubOptionContainer
142
157
  onSubmit={handleSubmit(onSubmit)}
@@ -311,6 +326,11 @@ export const ProductExtraSuboption = (props) => {
311
326
  >
312
327
  {t('CUSTOM_FIELDS', 'Custom fields')}
313
328
  </Dropdown.Item>
329
+ <Dropdown.Item
330
+ onClick={() => setExternalIdOpen(true)}
331
+ >
332
+ {t('EXTERNAL_ID', 'External ID')}
333
+ </Dropdown.Item>
314
334
  <Dropdown.Item onClick={() => handleDeteteClick(subOption.id)}>{t('DELETE', 'Delete')}</Dropdown.Item>
315
335
  </DropdownButton>
316
336
  </ActionSelectorWrapper>
@@ -352,6 +372,18 @@ export const ProductExtraSuboption = (props) => {
352
372
  handleChangePhoto={handleChangePhoto}
353
373
  />
354
374
  </Modal>
375
+ <Modal
376
+ width='70%'
377
+ title={t('MODIFIER_OPTION', 'Modifier option')}
378
+ open={externalIdOpen}
379
+ onClose={() => setExternalIdOpen(false)}
380
+ >
381
+ <ProductOptionExternalId
382
+ value={externalId}
383
+ handleChange={setExternalId}
384
+ handleUpdate={handleUpdateExternalId}
385
+ />
386
+ </Modal>
355
387
  </SubOptionContainer>
356
388
  )
357
389
  }
@@ -39,7 +39,8 @@ const ProductExtrasUI = (props) => {
39
39
  handleDragStart,
40
40
  hanldeDragOver,
41
41
  handleDrop,
42
- handleDragEnd
42
+ handleDragEnd,
43
+ handleUpdateExtraState
43
44
  } = props
44
45
  const theme = useTheme()
45
46
  const [, t] = useLanguage()
@@ -195,6 +196,7 @@ const ProductExtrasUI = (props) => {
195
196
  extra={currentExtra}
196
197
  handleChangeExtraName={handleChangeExtraInput}
197
198
  handleUpdateBusinessState={handleUpdateBusinessState}
199
+ handleUpdateExtraState={handleUpdateExtraState}
198
200
  />
199
201
  )}
200
202
  </>
@@ -214,6 +216,7 @@ const ProductExtrasUI = (props) => {
214
216
  extra={currentExtra}
215
217
  handleChangeExtraName={handleChangeExtraInput}
216
218
  handleUpdateBusinessState={handleUpdateBusinessState}
219
+ handleUpdateExtraState={handleUpdateExtraState}
217
220
  />
218
221
  </Modal>
219
222
  )}
@@ -0,0 +1,29 @@
1
+ import React from 'react'
2
+ import { useLanguage } from 'ordering-components-admin-external'
3
+ import { Container, FormControl } from './styles'
4
+ import { Button, Input } from '../../../styles'
5
+
6
+ export const ProductOptionExternalId = (props) => {
7
+ const { value, handleChange, handleUpdate } = props
8
+ const [, t] = useLanguage()
9
+
10
+ return (
11
+ <Container>
12
+ <FormControl>
13
+ <label htmlFor='externalId'>{t('EXTERNAL_ID', 'External Id')}</label>
14
+ <Input
15
+ defaultValue={value || ''}
16
+ placeholder={t('EXTERNAL_ID', 'External Id')}
17
+ onChange={(e) => handleChange(e.target.value)}
18
+ />
19
+ </FormControl>
20
+ <Button
21
+ color='primary'
22
+ borderRadius='8px'
23
+ onClick={handleUpdate}
24
+ >
25
+ {t('UPDATE', 'Update')}
26
+ </Button>
27
+ </Container>
28
+ )
29
+ }
@@ -0,0 +1,22 @@
1
+ import styled from 'styled-components'
2
+
3
+ export const Container = styled.div`
4
+ button {
5
+ height: 44px;
6
+ text-transform: lowercase;
7
+ &:first-letter {
8
+ text-transform: uppercase;
9
+ }
10
+ }
11
+ `
12
+
13
+ export const FormControl = styled.div`
14
+ margin-bottom: 25px;
15
+ label {
16
+ margin-bottom: 10px;
17
+ }
18
+ input {
19
+ height: 44px;
20
+ width: 100%;
21
+ }
22
+ `