@tap-payments/auth-jsconnect 2.1.88-test → 2.1.89-test

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.
@@ -53,10 +53,10 @@ export declare type UpdateBrandBody = {
53
53
  };
54
54
  };
55
55
  segment?: {
56
- type: {
56
+ type?: {
57
57
  id: string;
58
58
  };
59
- team: {
59
+ team?: {
60
60
  id: string;
61
61
  };
62
62
  };
@@ -48,7 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
50
  import API from '../../../api';
51
- import { FlowsTypes } from '../../../@types';
51
+ import { FieldType, FlowsTypes } from '../../../@types';
52
52
  import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
53
53
  import { BRAND_STEP_NAMES } from '../../../constants';
54
54
  import { isKW, isSA, isTwitter, isWebsite, sleep } from '../../../utils';
@@ -244,13 +244,19 @@ export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailabi
244
244
  });
245
245
  });
246
246
  export var updateBrand = createAsyncThunk('brandUpdateBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
247
- var _a, settings, brand, id, getAddress, channel_services, requestBody, brandData, activities, activityList;
248
- var _b, _c, _d, _e, _f, _g, _h;
249
- return __generator(this, function (_j) {
250
- switch (_j.label) {
247
+ var _a, settings, brand, responseBody, id, isNameEditable, isChannelServicesEditable, salesChannels, brandName, segment, teamSize, segmentId, teamSizeId, getAddress, channel_services, requestBody, brandData, activities, activityList;
248
+ var _b, _c, _d, _e, _f, _g, _h, _j;
249
+ return __generator(this, function (_k) {
250
+ switch (_k.label) {
251
251
  case 0:
252
252
  _a = thunkApi.getState(), settings = _a.settings, brand = _a.brand;
253
- id = (_c = (_b = brand.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.brand) === null || _c === void 0 ? void 0 : _c.id;
253
+ responseBody = brand.data.verify.responseBody;
254
+ id = (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.brand) === null || _b === void 0 ? void 0 : _b.id;
255
+ isNameEditable = ((_d = (_c = responseBody === null || responseBody === void 0 ? void 0 : responseBody.brand) === null || _c === void 0 ? void 0 : _c.data_status) === null || _d === void 0 ? void 0 : _d.name) === FieldType.EDITABLE;
256
+ isChannelServicesEditable = ((_f = (_e = responseBody === null || responseBody === void 0 ? void 0 : responseBody.brand) === null || _e === void 0 ? void 0 : _e.data_status) === null || _f === void 0 ? void 0 : _f.channel_services) === FieldType.EDITABLE;
257
+ salesChannels = params.salesChannels, brandName = params.brandName, segment = params.segment, teamSize = params.teamSize;
258
+ segmentId = segment && { id: segment.id };
259
+ teamSizeId = teamSize && { id: teamSize.id };
254
260
  getAddress = function (value, isTwitter, isWeb) {
255
261
  if (isTwitter)
256
262
  return '@' + value;
@@ -258,41 +264,43 @@ export var updateBrand = createAsyncThunk('brandUpdateBrand', function (params,
258
264
  return 'https://' + value;
259
265
  return value;
260
266
  };
261
- channel_services = params.salesChannels.map(function (channel) {
262
- var _a;
263
- return {
264
- id: channel.id,
265
- address: getAddress(channel.address || '', isTwitter(channel.code), isWebsite(channel.code)),
266
- sub: (_a = channel.sub) === null || _a === void 0 ? void 0 : _a.map(function (sub) {
267
- return { id: sub.id, address: getAddress(sub.address || '', isTwitter(sub.code), isWebsite(sub.code)) };
268
- })
269
- };
270
- });
267
+ channel_services = isChannelServicesEditable
268
+ ? salesChannels.map(function (channel) {
269
+ var _a;
270
+ return {
271
+ id: channel.id,
272
+ address: getAddress(channel.address || '', isTwitter(channel.code), isWebsite(channel.code)),
273
+ sub: (_a = channel.sub) === null || _a === void 0 ? void 0 : _a.map(function (sub) {
274
+ return { id: sub.id, address: getAddress(sub.address || '', isTwitter(sub.code), isWebsite(sub.code)) };
275
+ })
276
+ };
277
+ })
278
+ : undefined;
271
279
  requestBody = {
272
280
  id: id,
273
- name: { en: params === null || params === void 0 ? void 0 : params.brandName, ar: params === null || params === void 0 ? void 0 : params.brandName },
274
- segment: { type: { id: ((_d = params.segment) === null || _d === void 0 ? void 0 : _d.id) || '' }, team: { id: ((_e = params.teamSize) === null || _e === void 0 ? void 0 : _e.id) || '' } },
281
+ name: isNameEditable ? { en: brandName, ar: brandName } : undefined,
282
+ segment: { type: segmentId, team: teamSizeId },
275
283
  channel_services: channel_services
276
284
  };
277
285
  return [4, API.brandService.updateBrandInfo(requestBody)];
278
286
  case 1:
279
- brandData = (_j.sent()).data;
280
- activities = (((_f = brand.data.verify.responseBody) === null || _f === void 0 ? void 0 : _f.entity) || {}).activities;
287
+ brandData = (_k.sent()).data;
288
+ activities = (((_g = brand.data.verify.responseBody) === null || _g === void 0 ? void 0 : _g.entity) || {}).activities;
281
289
  return [4, thunkApi.dispatch(retrieveDataList())];
282
290
  case 2:
283
- _j.sent();
291
+ _k.sent();
284
292
  if (activities) {
285
293
  brandData = __assign(__assign({}, brandData), { brand_activities: activities || {} });
286
294
  }
287
295
  if (!!activities) return [3, 4];
288
296
  return [4, API.dataService.getActivities()];
289
297
  case 3:
290
- activityList = (_j.sent()).list;
298
+ activityList = (_k.sent()).list;
291
299
  brandData = __assign(__assign({}, brandData), { brand_activities: activityList || {} });
292
- _j.label = 4;
300
+ _k.label = 4;
293
301
  case 4:
294
302
  thunkApi.dispatch(handleNextScreenStep());
295
- (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, id);
303
+ (_j = (_h = settings.data.appConfig).onStepCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, settings.data.activeScreen.name, id);
296
304
  return [2, { data: __assign({}, brandData), formData: params }];
297
305
  }
298
306
  });
@@ -309,22 +317,29 @@ export var retrieveEntityList = createAsyncThunk('retrieveEntityList', function
309
317
  });
310
318
  }); });
311
319
  export var updateBrandActivities = createAsyncThunk('brandUpdateBrandActivities', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
312
- var _a, settings, brand, id, customerLocation, customerBase, sales, stepName, requestBody, brandData;
313
- var _b, _c, _d, _e, _f, _g;
314
- return __generator(this, function (_h) {
315
- switch (_h.label) {
320
+ var _a, settings, brand, brandResponse, id, isActivitiesEditable, isCustomerLocationEditable, isSalesRangeEditable, activities, customerLocations, expectedCustomer, expectedSale, customerLocation, customerBase, sales, stepName, requestBody, brandData;
321
+ var _b, _c, _d, _e, _f, _g, _h;
322
+ return __generator(this, function (_j) {
323
+ switch (_j.label) {
316
324
  case 0:
317
325
  _a = thunkApi.getState(), settings = _a.settings, brand = _a.brand;
318
- id = (_c = (_b = brand.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.brand) === null || _c === void 0 ? void 0 : _c.id;
319
- customerLocation = params.customerLocations.map(function (location) { return ({
320
- id: location === null || location === void 0 ? void 0 : location.id
321
- }); });
322
- customerBase = { id: ((_d = params.expectedCustomer) === null || _d === void 0 ? void 0 : _d.id) || '', period: 'monthly', locations: customerLocation };
323
- sales = { id: ((_e = params.expectedSale) === null || _e === void 0 ? void 0 : _e.id) || '', period: 'monthly' };
326
+ brandResponse = (brand.data.verify.responseBody || {}).brand;
327
+ id = brandResponse === null || brandResponse === void 0 ? void 0 : brandResponse.id;
328
+ isActivitiesEditable = ((_b = brandResponse === null || brandResponse === void 0 ? void 0 : brandResponse.data_status) === null || _b === void 0 ? void 0 : _b.activities) === FieldType.EDITABLE;
329
+ isCustomerLocationEditable = ((_d = (_c = brandResponse === null || brandResponse === void 0 ? void 0 : brandResponse.data_status) === null || _c === void 0 ? void 0 : _c.customer_base) === null || _d === void 0 ? void 0 : _d.location) === FieldType.EDITABLE;
330
+ isSalesRangeEditable = ((_f = (_e = brandResponse === null || brandResponse === void 0 ? void 0 : brandResponse.data_status) === null || _e === void 0 ? void 0 : _e.operations) === null || _f === void 0 ? void 0 : _f.sales_range) === FieldType.EDITABLE;
331
+ activities = params.activities, customerLocations = params.customerLocations, expectedCustomer = params.expectedCustomer, expectedSale = params.expectedSale;
332
+ customerLocation = isCustomerLocationEditable
333
+ ? customerLocations.map(function (location) { return ({
334
+ id: location === null || location === void 0 ? void 0 : location.id
335
+ }); })
336
+ : undefined;
337
+ customerBase = { id: (expectedCustomer === null || expectedCustomer === void 0 ? void 0 : expectedCustomer.id) || '', period: 'monthly', locations: customerLocation };
338
+ sales = isSalesRangeEditable ? { id: (expectedSale === null || expectedSale === void 0 ? void 0 : expectedSale.id) || '', period: 'monthly' } : undefined;
324
339
  stepName = BRAND_STEP_NAMES.BRAND_ACTIVITIES;
325
340
  requestBody = {
326
341
  id: id,
327
- activities: params.activities,
342
+ activities: isActivitiesEditable ? activities : undefined,
328
343
  operations: {
329
344
  customer_base: customerBase,
330
345
  sales: sales
@@ -334,12 +349,12 @@ export var updateBrandActivities = createAsyncThunk('brandUpdateBrandActivities'
334
349
  };
335
350
  return [4, API.brandService.updateBrandInfo(requestBody)];
336
351
  case 1:
337
- brandData = (_h.sent()).data;
352
+ brandData = (_j.sent()).data;
338
353
  return [4, thunkApi.dispatch(retrieveDataList())];
339
354
  case 2:
340
- _h.sent();
355
+ _j.sent();
341
356
  thunkApi.dispatch(handleNextScreenStep());
342
- (_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, id);
357
+ (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, id);
343
358
  return [2, { data: __assign({}, brandData), formData: params }];
344
359
  }
345
360
  });
@@ -41,6 +41,7 @@ import Tooltip from '../../../../components/Tooltip';
41
41
  import { useTranslation } from 'react-i18next';
42
42
  import { useController, useFormContext } from 'react-hook-form';
43
43
  import { useLanguage, useAppSelector } from '../../../../hooks';
44
+ import { FieldType } from '../../../../@types';
44
45
  import Collapse from '../../../../components/Collapse';
45
46
  import SimpleList from '../../../../components/SimpleList';
46
47
  import ExpandIcon from '../../../../components/ExpandIcon';
@@ -102,20 +103,21 @@ export var NameContainer = styled(Text, { shouldForwardProp: function (prop) { r
102
103
  return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25), textAlign: 'start' }));
103
104
  });
104
105
  var ActivitiesList = function (_a) {
105
- var _b, _c, _d;
106
+ var _b, _c, _d, _e;
106
107
  var show = _a.show, rest = __rest(_a, ["show"]);
107
- var _e = React.useState([]), activitiesMenuList = _e[0], setActivitiesMenuList = _e[1];
108
- var _f = React.useState(null), anchorEl = _f[0], setAnchorEl = _f[1];
108
+ var _f = React.useState([]), activitiesMenuList = _f[0], setActivitiesMenuList = _f[1];
109
+ var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
109
110
  var t = useTranslation().t;
110
111
  var isAr = useLanguage().isAr;
111
112
  var control = useFormContext().control;
112
113
  var data = useAppSelector(brandSelector).data;
113
114
  var activitiesControl = useController({ name: 'activities', control: control });
114
115
  var controlValue = activitiesControl.field.value;
115
- var _g = React.useState(false), isHovered = _g[0], setIsHovered = _g[1];
116
+ var _h = React.useState(false), isHovered = _h[0], setIsHovered = _h[1];
116
117
  var verify = data.verify;
117
- var activities = (verify.responseBody || {}).activities;
118
+ var _j = verify.responseBody || {}, activities = _j.activities, brand = _j.brand;
118
119
  var isCR = ((_d = (_c = (_b = verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.license) === null || _d === void 0 ? void 0 : _d.type) === 'commercial_registration';
120
+ var disabled = ((_e = brand === null || brand === void 0 ? void 0 : brand.data_status) === null || _e === void 0 ? void 0 : _e.activities) === FieldType.NON_EDITABLE;
119
121
  React.useEffect(function () {
120
122
  if ((activities === null || activities === void 0 ? void 0 : activities.length) > 0) {
121
123
  var list = __spreadArray([], activities, true);
@@ -154,7 +156,7 @@ var ActivitiesList = function (_a) {
154
156
  var getSelectedActivityFlag = function (item) {
155
157
  return controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.id === item.id; });
156
158
  };
157
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(LabelContainerStyled, { children: [_jsxs(InputLabelStyled, { children: [t(isCR ? 'activities' : 'category'), " ", _jsx(MandatoryStyled, { children: "*" })] }), _jsx(Tooltip, __assign({ title: t('activities_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, value: getSelectedActivities(), placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name.en', searchValuePath: ['name.ar', 'name.en'], list: activitiesMenuList, onSelectItem: onSelectItem, renderItem: function (item) {
159
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(LabelContainerStyled, { children: [_jsxs(InputLabelStyled, { children: [t(isCR ? 'activities' : 'category'), " ", _jsx(MandatoryStyled, { children: "*" })] }), _jsx(Tooltip, __assign({ title: t('activities_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, disabled: disabled, value: getSelectedActivities(), placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: disabled ? undefined : !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: disabled ? _jsx(_Fragment, {}) : _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name.en', searchValuePath: ['name.ar', 'name.en'], list: activitiesMenuList, onSelectItem: onSelectItem, renderItem: function (item) {
158
160
  var _a, _b, _c;
159
161
  return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: item.id === ((_a = getSelectedActivityFlag(item)) === null || _a === void 0 ? void 0 : _a.id) }, { children: isAr ? (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = item === null || item === void 0 ? void 0 : item.name) === null || _c === void 0 ? void 0 : _c.en })) })), getSelectedActivityFlag(item) && _jsx(CheckIconStyled, {})] }));
160
162
  } }) }))] })] }) })));
@@ -38,6 +38,7 @@ var BrandActivities = function (_a) {
38
38
  var _b = React.useState(), listActive = _b[0], setListActive = _b[1];
39
39
  var dispatch = useAppDispatch();
40
40
  var _c = useAppSelector(brandSelector), data = _c.data, loading = _c.loading, error = _c.error;
41
+ var brand = (data.verify.responseBody || {}).brand;
41
42
  var ListType;
42
43
  (function (ListType) {
43
44
  ListType["ActivitiesList"] = "ActivitiesList";
@@ -46,7 +47,7 @@ var BrandActivities = function (_a) {
46
47
  ListType["ExpectedSalesList"] = "ExpectedSalesList";
47
48
  })(ListType || (ListType = {}));
48
49
  var methods = useForm({
49
- resolver: yupResolver(BrandActivitiesValidationSchema),
50
+ resolver: yupResolver(BrandActivitiesValidationSchema(brand)),
50
51
  defaultValues: data.brandActivities,
51
52
  mode: 'onChange'
52
53
  });
@@ -35,6 +35,7 @@ import Tooltip from '../../../../components/Tooltip';
35
35
  import SimpleList from '../../../../components/SimpleList';
36
36
  import { ScreenContainer } from '../../../shared/Containers';
37
37
  import { useLanguage, useAppSelector, useAppDispatch } from '../../../../hooks';
38
+ import { FieldType } from '../../../../@types';
38
39
  import { brandSelector, clearError } from '../../../app/brand/brandStore';
39
40
  import Search from '../../../../features/shared/Search';
40
41
  import { InfoIconStyled, InfoOutlinedIconStyled, LabelContainerStyled } from './ActivitiesList';
@@ -79,18 +80,20 @@ var SimpleListStyled = styled((SimpleList))(function () { return ({
79
80
  height: 'fit-content'
80
81
  }); });
81
82
  var CustomerBase = function (_a) {
83
+ var _b, _c, _d, _e;
82
84
  var rest = __rest(_a, []);
83
- var _b = React.useState([]), customerLocationsList = _b[0], setCustomerLocationsList = _b[1];
84
- var _c = React.useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
85
+ var _f = React.useState([]), customerLocationsList = _f[0], setCustomerLocationsList = _f[1];
86
+ var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
85
87
  var t = useTranslation().t;
86
88
  var isAr = useLanguage().isAr;
87
89
  var control = useFormContext().control;
88
90
  var dispatch = useAppDispatch();
89
91
  var customerLocationsControl = useController({ name: 'customerLocations', control: control });
90
- var _d = useAppSelector(brandSelector), data = _d.data, error = _d.error;
91
- var _e = React.useState(false), isHovered = _e[0], setIsHovered = _e[1];
92
- var brandActivities = data.brandActivities;
92
+ var _h = useAppSelector(brandSelector), data = _h.data, error = _h.error;
93
+ var _j = React.useState(false), isHovered = _j[0], setIsHovered = _j[1];
94
+ var brandActivities = data.brandActivities, verify = data.verify;
93
95
  var response = brandActivities.responseBody;
96
+ var disabled = ((_e = (_d = (_c = (_b = verify.responseBody) === null || _b === void 0 ? void 0 : _b.brand) === null || _c === void 0 ? void 0 : _c.data_status) === null || _d === void 0 ? void 0 : _d.customer_base) === null || _e === void 0 ? void 0 : _e.location) === FieldType.NON_EDITABLE;
94
97
  var onOpenList = function (event) {
95
98
  var _a;
96
99
  setAnchorEl(event.currentTarget);
@@ -136,7 +139,7 @@ var CustomerBase = function (_a) {
136
139
  };
137
140
  var customerLocationsValue = customerLocationsControl.field.value;
138
141
  var customerLocationSelected = customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue[0];
139
- return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(BaseLabelStyled, { children: t('select_customer_base') }), _jsx(Tooltip, __assign({ title: t('customer_base_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(InputStyled, { readOnly: true, placeholder: t('choose_expected_sales'), value: isAr ? customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name.ar : customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name.en, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { searchKeyPath: 'name.en', list: customerLocationsList, placeholder: 'choose_customer_base', onSelectItem: onSelectItem, renderItem: function (item) {
142
+ return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(BaseLabelStyled, { children: t('select_customer_base') }), _jsx(Tooltip, __assign({ title: t('customer_base_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(InputStyled, { readOnly: true, disabled: disabled, placeholder: t('choose_expected_sales'), value: isAr ? customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name.ar : customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name.en, onClick: disabled ? undefined : !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: disabled ? _jsx(_Fragment, {}) : _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { searchKeyPath: 'name.en', list: customerLocationsList, placeholder: 'choose_customer_base', onSelectItem: onSelectItem, renderItem: function (item) {
140
143
  return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue.id) }, { children: isAr ? item.name.ar : item.name.en })) })), item.id === (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(CheckIconStyled, {}), checkRemainingCondition(item) && item.id != (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(RemainingCheck, {})] }));
141
144
  } })] }))] }) })));
142
145
  };
@@ -9,13 +9,14 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import * as React from 'react';
14
14
  import Box from '@mui/material/Box';
15
15
  import { styled } from '@mui/material/styles';
16
16
  import { useTranslation } from 'react-i18next';
17
17
  import { useController, useFormContext } from 'react-hook-form';
18
18
  import { useLanguage, useAppSelector, useAppDispatch } from '../../../../hooks';
19
+ import { FieldType } from '../../../../@types';
19
20
  import SimpleList from '../../../../components/SimpleList';
20
21
  import Collapse from '../../../../components/Collapse';
21
22
  import ExpandIcon from '../../../../components/ExpandIcon';
@@ -46,21 +47,23 @@ var SimpleListStyled = styled((SimpleList))(function () { return ({
46
47
  height: 'fit-content'
47
48
  }); });
48
49
  var ExpectedSalesRange = function (_a) {
50
+ var _b, _c, _d, _e;
49
51
  var show = _a.show, onListClose = _a.onListClose, onListOpen = _a.onListOpen;
50
- var _b = React.useState([]), expectedSalesRangeList = _b[0], setExpectedSalesRangeList = _b[1];
51
- var _c = React.useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
52
- var _d = React.useState(''), subIndex = _d[0], setSubIndex = _d[1];
52
+ var _f = React.useState([]), expectedSalesRangeList = _f[0], setExpectedSalesRangeList = _f[1];
53
+ var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
54
+ var _h = React.useState(''), subIndex = _h[0], setSubIndex = _h[1];
53
55
  var t = useTranslation().t;
54
56
  var isAr = useLanguage().isAr;
55
57
  var control = useFormContext().control;
56
58
  var dispatch = useAppDispatch();
57
59
  var expectedSaleControl = useController({ name: 'expectedSale', control: control });
58
- var _e = useAppSelector(brandSelector), data = _e.data, error = _e.error;
60
+ var _j = useAppSelector(brandSelector), data = _j.data, error = _j.error;
59
61
  var settingsData = useAppSelector(settingsSelector).data;
60
- var brandActivities = data.brandActivities;
62
+ var brandActivities = data.brandActivities, verify = data.verify;
61
63
  var expectedSales = (brandActivities.responseBody || {}).expectedSales;
62
64
  var expectedSalesRangeValue = expectedSaleControl.field.value;
63
65
  var countryCode = settingsData.businessCountry;
66
+ var disabled = ((_e = (_d = (_c = (_b = verify.responseBody) === null || _b === void 0 ? void 0 : _b.brand) === null || _c === void 0 ? void 0 : _c.data_status) === null || _d === void 0 ? void 0 : _d.operations) === null || _e === void 0 ? void 0 : _e.sales_range) === FieldType.NON_EDITABLE;
64
67
  var handleOpenMainMenu = function (event) {
65
68
  setAnchorEl(event.currentTarget);
66
69
  onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
@@ -112,7 +115,7 @@ var ExpectedSalesRange = function (_a) {
112
115
  }, [anchorEl, expectedSalesRangeValue]);
113
116
  return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_sales_monthly', {
114
117
  currency: t(findCurrencyByIso2(countryCode.iso2))
115
- }) }), _jsx(InputStyled, { readOnly: true, value: (isAr ? expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.name.ar : expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.name.en) || '', onClick: !!anchorEl ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_expected_sales'), endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: expectedSalesRangeList, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (item) {
118
+ }) }), _jsx(InputStyled, { readOnly: true, disabled: disabled, value: (isAr ? expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.name.ar : expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.name.en) || '', onClick: disabled ? undefined : !!anchorEl ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_expected_sales'), endAdornment: disabled ? _jsx(_Fragment, {}) : _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: expectedSalesRangeList, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (item) {
116
119
  var isOnlyOneItem = !item.sub || item.sub.length === 1;
117
120
  if (isOnlyOneItem)
118
121
  onSelectItem(item);
@@ -1,6 +1,6 @@
1
1
  import * as yup from 'yup';
2
- export declare const BrandActivitiesValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
- activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
2
+ export declare const BrandActivitiesValidationSchema: (brand: any) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ activities: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
4
4
  ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
5
5
  en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
6
6
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
@@ -16,14 +16,14 @@ export declare const BrandActivitiesValidationSchema: yup.ObjectSchema<import("y
16
16
  ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
17
17
  en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
18
18
  }>>[] | undefined>;
19
- customerLocations: import("yup/lib/array").RequiredArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined>;
19
+ customerLocations: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | import("yup/lib/array").RequiredArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined>;
20
20
  expectedCustomers: any;
21
21
  expectedSalesRange: any;
22
22
  termAndConditionChecked: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
23
23
  refundPolicy: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
24
24
  transactionPolicy: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
25
25
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
26
- activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
26
+ activities: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
27
27
  ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
28
28
  en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
29
29
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
@@ -39,14 +39,14 @@ export declare const BrandActivitiesValidationSchema: yup.ObjectSchema<import("y
39
39
  ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
40
40
  en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
41
41
  }>>[] | undefined>;
42
- customerLocations: import("yup/lib/array").RequiredArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined>;
42
+ customerLocations: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | import("yup/lib/array").RequiredArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined>;
43
43
  expectedCustomers: any;
44
44
  expectedSalesRange: any;
45
45
  termAndConditionChecked: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
46
46
  refundPolicy: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
47
47
  transactionPolicy: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
48
48
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
49
- activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
49
+ activities: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
50
50
  ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
51
51
  en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
52
52
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
@@ -62,7 +62,7 @@ export declare const BrandActivitiesValidationSchema: yup.ObjectSchema<import("y
62
62
  ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
63
63
  en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
64
64
  }>>[] | undefined>;
65
- customerLocations: import("yup/lib/array").RequiredArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined>;
65
+ customerLocations: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | import("yup/lib/array").RequiredArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined>;
66
66
  expectedCustomers: any;
67
67
  expectedSalesRange: any;
68
68
  termAndConditionChecked: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
@@ -1,21 +1,32 @@
1
1
  import * as yup from 'yup';
2
+ import { FieldType } from '../../../../@types';
2
3
  var objectElements = {
3
4
  id: yup.number(),
4
5
  name_ar: yup.string(),
5
6
  name_en: yup.string()
6
7
  };
7
- export var BrandActivitiesValidationSchema = yup.object().shape({
8
- activities: yup
9
- .array()
10
- .min(1, 'activities_list_alert')
11
- .of(yup.object().shape({
12
- ar: yup.string(),
13
- en: yup.string()
14
- })),
15
- customerLocations: yup.array().required('please_choose_base'),
16
- expectedCustomers: yup.object().shape(objectElements).required('select_expected_customers_serve'),
17
- expectedSalesRange: yup.object().shape(objectElements).required('select_expected_sales'),
18
- termAndConditionChecked: yup.boolean().isTrue('check_terms_cond').required('check_terms_cond'),
19
- refundPolicy: yup.boolean().required().isTrue('refund_policy_error'),
20
- transactionPolicy: yup.boolean().required().isTrue('transaction_policy_error')
21
- });
8
+ export var BrandActivitiesValidationSchema = function (brand) {
9
+ var _a, _b, _c;
10
+ var _d = brand || {}, activities = _d.activities, operations = _d.operations, data_status = _d.data_status;
11
+ var _e = operations || {}, customer_base = _e.customer_base, sales = _e.sales;
12
+ var isActivitiesOptional = !((activities === null || activities === void 0 ? void 0 : activities.length) > 0) && (data_status === null || data_status === void 0 ? void 0 : data_status.activities) === FieldType.NON_EDITABLE;
13
+ var isCustomerLocationsOptional = !(((_a = customer_base === null || customer_base === void 0 ? void 0 : customer_base.locations) === null || _a === void 0 ? void 0 : _a.length) > 0) && ((_b = data_status === null || data_status === void 0 ? void 0 : data_status.customer_base) === null || _b === void 0 ? void 0 : _b.location) === FieldType.NON_EDITABLE;
14
+ var isExpectedSalesRangeOptional = !(sales === null || sales === void 0 ? void 0 : sales.id) && ((_c = data_status === null || data_status === void 0 ? void 0 : data_status.operations) === null || _c === void 0 ? void 0 : _c.sales_range) === FieldType.NON_EDITABLE;
15
+ return yup.object().shape({
16
+ activities: isActivitiesOptional
17
+ ? yup.array().optional()
18
+ : yup
19
+ .array()
20
+ .min(1, 'activities_list_alert')
21
+ .of(yup.object().shape({
22
+ ar: yup.string(),
23
+ en: yup.string()
24
+ })),
25
+ customerLocations: isCustomerLocationsOptional ? yup.array().optional() : yup.array().required('please_choose_base'),
26
+ expectedCustomers: yup.object().shape(objectElements).required('select_expected_customers_serve'),
27
+ expectedSalesRange: isExpectedSalesRangeOptional ? yup.object().optional() : yup.object().shape(objectElements).required('select_expected_sales'),
28
+ termAndConditionChecked: yup.boolean().isTrue('check_terms_cond').required('check_terms_cond'),
29
+ refundPolicy: yup.boolean().required().isTrue('refund_policy_error'),
30
+ transactionPolicy: yup.boolean().required().isTrue('transaction_policy_error')
31
+ });
32
+ };
@@ -37,7 +37,7 @@ var BrandInfo = function (_a) {
37
37
  var _d = useAppSelector(brandSelector), data = _d.data, loading = _d.loading, error = _d.error;
38
38
  var responseBody = data.brandData.responseBody;
39
39
  var methods = useForm({
40
- resolver: yupResolver(BrandValidationSchema),
40
+ resolver: yupResolver(BrandValidationSchema((responseBody === null || responseBody === void 0 ? void 0 : responseBody.brand) || {})),
41
41
  defaultValues: data.brandData,
42
42
  mode: 'onChange'
43
43
  });
@@ -47,24 +47,25 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
49
49
  import * as React from 'react';
50
+ import { debounce } from 'lodash-es';
51
+ import axios from 'axios';
50
52
  import { useTranslation } from 'react-i18next';
51
53
  import { useController, useFormContext } from 'react-hook-form';
52
54
  import Box from '@mui/material/Box';
53
- import axios from 'axios';
54
55
  import { styled, alpha } from '@mui/material/styles';
55
56
  import InfoIcon from '@mui/icons-material/Info';
56
57
  import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
57
- import { ScreenContainer } from '../../../shared/Containers';
58
58
  import CircularProgress from '@mui/material/CircularProgress';
59
+ import { FieldType } from '../../../../@types';
60
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
61
+ import Tooltip from '../../../../components/Tooltip';
62
+ import Collapse from '../../../../components/Collapse';
59
63
  import Text from '../../../../components/Text';
60
64
  import Input from '../../../shared/Input';
61
65
  import ClearIcon from '../../../shared/ClearIcon';
62
- import Tooltip from '../../../../components/Tooltip';
63
- import Collapse from '../../../../components/Collapse';
66
+ import { ScreenContainer } from '../../../shared/Containers';
64
67
  import CheckIcon from '../../../shared/CheckIcon';
65
68
  import { checkBrandNameAvailability, brandSelector } from '../../../app/brand/brandStore';
66
- import { useAppDispatch, useAppSelector } from '../../../../hooks';
67
- import { debounce } from 'lodash-es';
68
69
  var LabelContainerStyled = styled(Box)(function (_a) {
69
70
  var theme = _a.theme;
70
71
  return ({
@@ -97,16 +98,18 @@ var InfoIconStyled = styled(InfoIcon)(function (_a) {
97
98
  });
98
99
  var cancelToken = null;
99
100
  var BrandName = function (_a) {
100
- var _b;
101
+ var _b, _c;
101
102
  var show = _a.show, brandNameChecking = _a.brandNameChecking, fetchingBrandName = _a.fetchingBrandName;
102
103
  var dispatch = useAppDispatch();
103
- var _c = React.useState(false), isHovered = _c[0], setIsHovered = _c[1];
104
+ var _d = React.useState(false), isHovered = _d[0], setIsHovered = _d[1];
104
105
  var t = useTranslation().t;
105
106
  var data = useAppSelector(brandSelector).data;
106
107
  var control = useFormContext().control;
107
108
  var brandControl = useController({ control: control, name: 'brandName' });
108
109
  var brandNameValue = brandControl.field.value;
109
110
  var error = (_b = brandControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
111
+ var brand = (data.verify.responseBody || {}).brand;
112
+ var isNonEditable = ((_c = brand === null || brand === void 0 ? void 0 : brand.data_status) === null || _c === void 0 ? void 0 : _c.name) === FieldType.NON_EDITABLE;
110
113
  var checkBrand = debounce(function (value) { return __awaiter(void 0, void 0, void 0, function () {
111
114
  var onSuccess;
112
115
  return __generator(this, function (_a) {
@@ -135,6 +138,6 @@ var BrandName = function (_a) {
135
138
  var clearBrandName = function () {
136
139
  brandControl.field.onChange('');
137
140
  };
138
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('signup_brand_name_label') }), _jsx(Tooltip, __assign({ title: t('brand_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { onChange: handleBrandNameChange, value: brandNameValue || '', placeholder: t('signup_brand_name_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: brandNameChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && brandNameValue ? (_jsx(CheckIcon, {})) : (brandNameValue && _jsx(ClearIcon, { onClick: clearBrandName })) })] })) })));
141
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('signup_brand_name_label') }), _jsx(Tooltip, __assign({ title: t('brand_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { onChange: handleBrandNameChange, value: brandNameValue || '', disabled: isNonEditable, placeholder: t('signup_brand_name_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: brandNameChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && brandNameValue ? (_jsx(CheckIcon, {})) : (brandNameValue && _jsx(ClearIcon, { onClick: clearBrandName })) })] })) })));
139
142
  };
140
143
  export default React.memo(BrandName);
@@ -1,18 +1,21 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import { useController, useFormContext } from 'react-hook-form';
4
+ import { FieldType } from '../../../../@types';
4
5
  import { useAppSelector, useAppDispatch } from '../../../../hooks';
5
- import { brandSelector, clearError } from '../../../app/brand/brandStore';
6
6
  import { mapSalesChannel } from '../../../../utils';
7
+ import { brandSelector, clearError } from '../../../app/brand/brandStore';
7
8
  import SalesChannel from '../../../shared/SalesChannels';
8
9
  var SalesChannels = function (_a) {
9
- var _b;
10
+ var _b, _c;
10
11
  var control = useFormContext().control;
11
12
  var dispatch = useAppDispatch();
12
- var _c = useController({ control: control, name: 'salesChannels' }), fieldState = _c.fieldState, field = _c.field;
13
- var _d = useAppSelector(brandSelector), data = _d.data, error = _d.error;
13
+ var _d = useController({ control: control, name: 'salesChannels' }), fieldState = _d.fieldState, field = _d.field;
14
+ var _e = useAppSelector(brandSelector), data = _e.data, error = _e.error;
14
15
  var responseBody = data.verify.responseBody;
15
- var _e = responseBody || {}, channelList = _e.channel_list, defaultSalesChannels = _e.salesChannels;
16
+ var _f = responseBody || {}, channelList = _f.channel_list, defaultSalesChannels = _f.salesChannels;
17
+ var brand = (data.verify.responseBody || {}).brand;
18
+ var isNonEditable = ((_b = brand === null || brand === void 0 ? void 0 : brand.data_status) === null || _b === void 0 ? void 0 : _b.name) === FieldType.NON_EDITABLE;
16
19
  React.useEffect(function () {
17
20
  if ((defaultSalesChannels === null || defaultSalesChannels === void 0 ? void 0 : defaultSalesChannels.length) > 0) {
18
21
  var sales = mapSalesChannel(defaultSalesChannels);
@@ -25,6 +28,6 @@ var SalesChannels = function (_a) {
25
28
  dispatch(clearError());
26
29
  field.onChange(channels);
27
30
  };
28
- return _jsx(SalesChannel, { error: (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message, list: channelList, onChange: onChange, defaultValue: selectedSalesChannels });
31
+ return (_jsx(SalesChannel, { disabled: isNonEditable, error: (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message, list: channelList, onChange: onChange, defaultValue: selectedSalesChannels }));
29
32
  };
30
33
  export default SalesChannels;
@@ -1,9 +1,9 @@
1
1
  import * as yup from 'yup';
2
- export declare const BrandValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
- brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
2
+ export declare const BrandValidationSchema: (brand: any) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
4
4
  segment: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
5
5
  teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
6
- salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
6
+ salesChannels: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
7
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
8
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
9
9
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
@@ -13,10 +13,10 @@ export declare const BrandValidationSchema: yup.ObjectSchema<import("yup/lib/obj
13
13
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
14
14
  }>>[] | undefined>;
15
15
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
16
- brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
16
+ brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
17
17
  segment: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
18
18
  teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
19
- salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
19
+ salesChannels: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
20
20
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
21
21
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
22
22
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
@@ -26,10 +26,10 @@ export declare const BrandValidationSchema: yup.ObjectSchema<import("yup/lib/obj
26
26
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
27
27
  }>>[] | undefined>;
28
28
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
29
- brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
29
+ brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
30
30
  segment: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
31
31
  teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
32
- salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
32
+ salesChannels: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
33
33
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
34
34
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
35
35
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
@@ -7,6 +7,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
7
7
  }
8
8
  return to.concat(ar || Array.prototype.slice.call(from));
9
9
  };
10
+ import { FieldType } from '../../../../@types';
10
11
  import { REGEX_WEBSITE, LINKEDIN_URL, SOCIAL_USERNAME, DIGITS_ONLY, REGEX_ALPHANUMERIC } from '../../../../constants';
11
12
  import * as yup from 'yup';
12
13
  var validationSalesChannels = function (channels) {
@@ -69,38 +70,47 @@ var validationSalesChannels = function (channels) {
69
70
  }
70
71
  return true;
71
72
  };
72
- export var BrandValidationSchema = yup.object().shape({
73
- brandName: yup
74
- .string()
75
- .test({
76
- test: function (value) {
77
- if ((value === null || value === void 0 ? void 0 : value.length) === 0)
78
- return true;
79
- if (value && value.length >= 3)
80
- return true;
81
- return this.createError({ message: 'enter_brand_name_english_chars_numbers_space' });
82
- }
83
- })
84
- .required('enter_brand_name_english_chars_numbers_space'),
85
- segment: yup.object().required('alert_choose_segment'),
86
- teamSize: yup.object().required('alert_choose_teamSize'),
87
- salesChannels: yup
88
- .array()
89
- .min(1, 'choose_atleast_one_channel')
90
- .of(yup.object().shape({
91
- id: yup.string().required('choose_atleast_one_channel')
92
- }))
93
- .test({
94
- test: function (value) {
95
- var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
96
- if (length === 0)
97
- return true;
98
- var channels = __spreadArray([], (value || []), true);
99
- var result = validationSalesChannels(channels);
100
- if (result === true)
101
- return true;
102
- return this.createError({ message: result });
103
- }
104
- })
105
- .required('choose_atleast_one_channel')
106
- });
73
+ export var BrandValidationSchema = function (brand) {
74
+ var _a = brand || {}, name = _a.name, channel_services = _a.channel_services, data_status = _a.data_status;
75
+ var isNameOptional = !name && (data_status === null || data_status === void 0 ? void 0 : data_status.name) === FieldType.NON_EDITABLE;
76
+ var isSalesChannelsOptional = !channel_services && (data_status === null || data_status === void 0 ? void 0 : data_status.channel_services) === FieldType.NON_EDITABLE;
77
+ return yup.object().shape({
78
+ brandName: isNameOptional
79
+ ? yup.string().optional()
80
+ : yup
81
+ .string()
82
+ .test({
83
+ test: function (value) {
84
+ if ((value === null || value === void 0 ? void 0 : value.length) === 0)
85
+ return true;
86
+ if (value && value.length >= 3)
87
+ return true;
88
+ return this.createError({ message: 'enter_brand_name_english_chars_numbers_space' });
89
+ }
90
+ })
91
+ .required('enter_brand_name_english_chars_numbers_space'),
92
+ segment: yup.object().required('alert_choose_segment'),
93
+ teamSize: yup.object().required('alert_choose_teamSize'),
94
+ salesChannels: isSalesChannelsOptional
95
+ ? yup.array().optional()
96
+ : yup
97
+ .array()
98
+ .min(1, 'choose_atleast_one_channel')
99
+ .of(yup.object().shape({
100
+ id: yup.string().required('choose_atleast_one_channel')
101
+ }))
102
+ .test({
103
+ test: function (value) {
104
+ var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
105
+ if (length === 0)
106
+ return true;
107
+ var channels = __spreadArray([], (value || []), true);
108
+ var result = validationSalesChannels(channels);
109
+ if (result === true)
110
+ return true;
111
+ return this.createError({ message: result });
112
+ }
113
+ })
114
+ .required('choose_atleast_one_channel')
115
+ });
116
+ };
@@ -6,6 +6,7 @@ interface SalesChannelProps {
6
6
  onChange: (channel: SaleChannel[]) => void;
7
7
  defaultValue?: SaleChannel[];
8
8
  selectFirstIconListener?: string | number | boolean;
9
+ disabled?: boolean;
9
10
  }
10
- declare const _default: React.MemoExoticComponent<({ list, onChange, error, defaultValue, selectFirstIconListener }: SalesChannelProps) => JSX.Element>;
11
+ declare const _default: React.MemoExoticComponent<({ list, onChange, error, disabled, defaultValue, selectFirstIconListener }: SalesChannelProps) => JSX.Element>;
11
12
  export default _default;
@@ -74,7 +74,7 @@ var CollapseStyled = styled(Collapse)(function (_a) {
74
74
  });
75
75
  });
76
76
  var SalesChannel = function (_a) {
77
- var _b = _a.list, list = _b === void 0 ? [] : _b, onChange = _a.onChange, error = _a.error, _c = _a.defaultValue, defaultValue = _c === void 0 ? [] : _c, _d = _a.selectFirstIconListener, selectFirstIconListener = _d === void 0 ? '' : _d;
77
+ var _b = _a.list, list = _b === void 0 ? [] : _b, onChange = _a.onChange, error = _a.error, disabled = _a.disabled, _c = _a.defaultValue, defaultValue = _c === void 0 ? [] : _c, _d = _a.selectFirstIconListener, selectFirstIconListener = _d === void 0 ? '' : _d;
78
78
  var _e = React.useState(''), activeSaleIconId = _e[0], setActiveSaleIconId = _e[1];
79
79
  var _f = React.useState([]), selectedSalas = _f[0], setSelectedSales = _f[1];
80
80
  var t = useTranslation().t;
@@ -143,7 +143,7 @@ var SalesChannel = function (_a) {
143
143
  }, [selectFirstIconListener]);
144
144
  return (_jsxs(_Fragment, { children: [_jsxs(Box, __assign({ sx: { mb: 3 } }, { children: [_jsxs(InputLabelStyled, { children: [t('channel_of_service'), " ", _jsx(MandatoryStyled, { children: "*" })] }), list.map(function (channel, index) {
145
145
  var _a, _b;
146
- return (_jsxs(ContainerStyled, { children: [_jsx(CheckBoxStyled, { id: channel.id, disableRipple: true, disableFocusRipple: true, focusRipple: false, checked: isChecked(channel.id), onChange: function () { return onSelectSalesChannel(channel); } }), _jsxs(TextStyled, { children: [isAr ? (_a = channel === null || channel === void 0 ? void 0 : channel.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = channel === null || channel === void 0 ? void 0 : channel.name) === null || _b === void 0 ? void 0 : _b.en, " "] })] }, "".concat(channel.id, "-indx").concat(index)));
146
+ return (_jsxs(ContainerStyled, { children: [_jsx(CheckBoxStyled, { id: channel.id, disableRipple: true, disabled: disabled, disableFocusRipple: true, focusRipple: false, checked: isChecked(channel.id), onChange: function () { return onSelectSalesChannel(channel); } }), _jsxs(TextStyled, { children: [isAr ? (_a = channel === null || channel === void 0 ? void 0 : channel.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = channel === null || channel === void 0 ? void 0 : channel.name) === null || _b === void 0 ? void 0 : _b.en, " "] })] }, "".concat(channel.id, "-indx").concat(index)));
147
147
  }), _jsx(CollapseStyled, __assign({ in: error === 'choose_atleast_one_channel' }, { children: _jsx(Warning, __assign({ warningType: 'alert' }, { children: t(error) })) }))] }), 'salesChannels'), _jsx(SaleChannelIconsInput, { error: error, selectedIconId: activeSaleIconId, onSelectIcon: onChangeActiveSaleIcon, onChangeValue: onValueChange, selectedChannels: selectedSalas }, 'saleChannelIconsInput')] }));
148
148
  };
149
149
  export default React.memo(SalesChannel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.1.88-test",
3
+ "version": "2.1.89-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",