@tap-payments/auth-jsconnect 2.0.45 → 2.0.46

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 (203) hide show
  1. package/build/@types/app.d.ts +47 -2
  2. package/build/@types/app.js +22 -0
  3. package/build/@types/form.d.ts +19 -1
  4. package/build/@types/index.d.ts +1 -0
  5. package/build/@types/index.js +1 -0
  6. package/build/@types/user.d.ts +141 -0
  7. package/build/@types/user.js +1 -0
  8. package/build/api/board.d.ts +16 -0
  9. package/build/api/board.js +10 -1
  10. package/build/api/country.d.ts +4 -0
  11. package/build/api/country.js +9 -1
  12. package/build/api/entity.d.ts +3 -3
  13. package/build/api/index.d.ts +8 -3
  14. package/build/api/individual.d.ts +54 -4
  15. package/build/api/individual.js +9 -1
  16. package/build/api/user.d.ts +6 -0
  17. package/build/api/user.js +9 -1
  18. package/build/app/settings.js +11 -8
  19. package/build/assets/locales/ar.json +28 -2
  20. package/build/assets/locales/en.json +28 -1
  21. package/build/components/SimpleList/SimpleList.d.ts +2 -0
  22. package/build/constants/api.d.ts +1 -0
  23. package/build/constants/api.js +3 -1
  24. package/build/constants/app.d.ts +1 -0
  25. package/build/constants/app.js +20 -7
  26. package/build/constants/assets.d.ts +4 -0
  27. package/build/constants/assets.js +4 -0
  28. package/build/features/app/bank/bankStore.d.ts +1 -0
  29. package/build/features/app/bank/bankStore.js +19 -13
  30. package/build/features/app/brand/brandStore.d.ts +2 -0
  31. package/build/features/app/brand/brandStore.js +69 -49
  32. package/build/features/app/business/businessStore.js +3 -3
  33. package/build/features/app/connect/connectStore.js +6 -6
  34. package/build/features/app/connectExpress/connectExpressStore.js +15 -9
  35. package/build/features/app/entity/entityStore.d.ts +2 -0
  36. package/build/features/app/entity/entityStore.js +5 -3
  37. package/build/features/app/individual/individualStore.d.ts +93 -4
  38. package/build/features/app/individual/individualStore.js +613 -129
  39. package/build/features/app/password/passwordStore.js +2 -2
  40. package/build/features/app/tax/taxStore.js +30 -29
  41. package/build/features/bank/Bank.js +2 -2
  42. package/build/features/bank/screens/BankDetails/BankDetails.js +8 -7
  43. package/build/features/bank/screens/BankDetails/BankName.js +13 -10
  44. package/build/features/bank/screens/BankDetails/BankStatement.js +8 -2
  45. package/build/features/bank/screens/BankDetails/Beneficiary.js +12 -13
  46. package/build/features/bank/screens/BankDetails/IBAN.js +14 -10
  47. package/build/features/bank/screens/BankDetails/validation.d.ts +14 -14
  48. package/build/features/bank/screens/BankDetails/validation.js +34 -15
  49. package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  50. package/build/features/brand/Brand.js +2 -2
  51. package/build/features/brand/screens/BrandActivities/ActivitiesList.d.ts +3 -3
  52. package/build/features/brand/screens/BrandActivities/ActivitiesList.js +8 -6
  53. package/build/features/brand/screens/BrandActivities/BrandActivities.js +12 -2
  54. package/build/features/brand/screens/BrandActivities/CustomerBase.d.ts +2 -2
  55. package/build/features/brand/screens/BrandActivities/CustomerBase.js +9 -6
  56. package/build/features/brand/screens/BrandActivities/ExpectedSalesRange.js +10 -7
  57. package/build/features/brand/screens/BrandActivities/validation.d.ts +7 -7
  58. package/build/features/brand/screens/BrandActivities/validation.js +26 -15
  59. package/build/features/brand/screens/BrandInfo/BrandInfo.js +11 -4
  60. package/build/features/brand/screens/BrandInfo/BrandName.js +13 -12
  61. package/build/features/brand/screens/BrandInfo/SalesChannels.js +21 -9
  62. package/build/features/brand/screens/BrandInfo/validation.d.ts +7 -7
  63. package/build/features/brand/screens/BrandInfo/validation.js +46 -36
  64. package/build/features/brand/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  65. package/build/features/business/Business.js +2 -2
  66. package/build/features/business/screens/Activities/ActivitiesList.d.ts +3 -3
  67. package/build/features/business/screens/BusinessType/LicenseCertificate.js +2 -1
  68. package/build/features/business/screens/BusinessType/LicenseType.d.ts +2 -2
  69. package/build/features/business/screens/Customers/CustomerLocations.d.ts +2 -2
  70. package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  71. package/build/features/connect/Connect.js +2 -2
  72. package/build/features/connect/screens/Merchant/BrandList.js +4 -4
  73. package/build/features/connect/screens/Merchant/BrandName.js +6 -5
  74. package/build/features/connect/screens/Merchant/validation.js +2 -2
  75. package/build/features/connectExpress/ConnectExpress.js +2 -2
  76. package/build/features/connectExpress/screens/CollectBusinessInfo/BrandName.js +1 -3
  77. package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseType.d.ts +2 -2
  78. package/build/features/connectExpress/screens/CollectBusinessInfo/validation.js +5 -5
  79. package/build/features/connectExpress/screens/CreateAccountLoader/CreateAccountLoader.js +23 -3
  80. package/build/features/connectExpress/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +3 -3
  81. package/build/features/entity/Entity.js +2 -2
  82. package/build/features/entity/screens/EntityCapital/ActivityList.d.ts +3 -3
  83. package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +3 -3
  84. package/build/features/entity/screens/EntityName/LicenseCertificate.js +9 -3
  85. package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  86. package/build/features/featuresScreens.js +10 -0
  87. package/build/features/individual/Individual.js +2 -2
  88. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.d.ts +13 -0
  89. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +48 -25
  90. package/build/features/individual/screens/AdditionalIndividualInfo/CivilIDFile.js +6 -1
  91. package/build/features/individual/screens/AdditionalIndividualInfo/InfluencerSwitch.js +9 -2
  92. package/build/features/individual/screens/AdditionalIndividualInfo/MonthlyIncome.js +11 -17
  93. package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +12 -16
  94. package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.d.ts +2 -2
  95. package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.js +9 -2
  96. package/build/features/individual/screens/AdditionalIndividualInfo/ShareCount.d.ts +6 -0
  97. package/build/features/individual/screens/AdditionalIndividualInfo/ShareCount.js +35 -0
  98. package/build/features/individual/screens/AdditionalIndividualInfo/ShareValue.d.ts +6 -0
  99. package/build/features/individual/screens/AdditionalIndividualInfo/ShareValue.js +41 -0
  100. package/build/features/individual/screens/AdditionalIndividualInfo/SignatureFile.js +8 -2
  101. package/build/features/individual/screens/AdditionalIndividualInfo/SourceOfIncome.js +9 -6
  102. package/build/features/individual/screens/AdditionalIndividualInfo/validation.d.ts +25 -23
  103. package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +19 -25
  104. package/build/features/individual/screens/IndividualList/CollectPhoneEmail.d.ts +10 -0
  105. package/build/features/individual/screens/IndividualList/CollectPhoneEmail.js +31 -0
  106. package/build/features/individual/screens/IndividualList/Email.d.ts +6 -0
  107. package/build/features/individual/screens/IndividualList/Email.js +48 -0
  108. package/build/features/individual/screens/IndividualList/IndividualList.d.ts +31 -0
  109. package/build/features/individual/screens/IndividualList/IndividualList.js +58 -0
  110. package/build/features/individual/screens/IndividualList/MobileNumber.d.ts +12 -0
  111. package/build/features/individual/screens/IndividualList/MobileNumber.js +143 -0
  112. package/build/features/individual/screens/IndividualList/UserList.d.ts +5 -0
  113. package/build/features/individual/screens/IndividualList/UserList.js +186 -0
  114. package/build/features/individual/screens/IndividualList/index.d.ts +3 -0
  115. package/build/features/individual/screens/IndividualList/index.js +2 -0
  116. package/build/features/individual/screens/IndividualList/validation.d.ts +12 -0
  117. package/build/features/individual/screens/IndividualList/validation.js +39 -0
  118. package/build/features/individual/screens/IndividualPersonalInfo/BirthCity.d.ts +8 -0
  119. package/build/features/individual/screens/IndividualPersonalInfo/BirthCity.js +109 -0
  120. package/build/features/individual/screens/{AdditionalIndividualInfo/EmployerLocation.d.ts → IndividualPersonalInfo/BirthCountry.d.ts} +2 -2
  121. package/build/features/individual/screens/{AdditionalIndividualInfo/EmployerLocation.js → IndividualPersonalInfo/BirthCountry.js} +14 -24
  122. package/build/features/individual/screens/IndividualPersonalInfo/DOB.d.ts +7 -0
  123. package/build/features/individual/screens/IndividualPersonalInfo/DOB.js +46 -0
  124. package/build/features/individual/screens/IndividualPersonalInfo/Email.d.ts +6 -0
  125. package/build/features/individual/screens/IndividualPersonalInfo/Email.js +50 -0
  126. package/build/features/individual/screens/IndividualPersonalInfo/ExpiryDate.d.ts +7 -0
  127. package/build/features/individual/screens/IndividualPersonalInfo/ExpiryDate.js +50 -0
  128. package/build/features/individual/screens/IndividualPersonalInfo/Gender.d.ts +34 -0
  129. package/build/features/individual/screens/IndividualPersonalInfo/Gender.js +81 -0
  130. package/build/features/individual/screens/IndividualPersonalInfo/ID.d.ts +6 -0
  131. package/build/features/individual/screens/IndividualPersonalInfo/ID.js +48 -0
  132. package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.d.ts +21 -0
  133. package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.js +139 -0
  134. package/build/features/individual/screens/IndividualPersonalInfo/IssuedCountry.d.ts +10 -0
  135. package/build/features/individual/screens/IndividualPersonalInfo/IssuedCountry.js +88 -0
  136. package/build/features/individual/screens/IndividualPersonalInfo/MobileNumber.d.ts +10 -0
  137. package/build/features/individual/screens/IndividualPersonalInfo/MobileNumber.js +145 -0
  138. package/build/features/individual/screens/IndividualPersonalInfo/Name.d.ts +6 -0
  139. package/build/features/individual/screens/IndividualPersonalInfo/Name.js +52 -0
  140. package/build/features/individual/screens/IndividualPersonalInfo/Nationality.d.ts +10 -0
  141. package/build/features/individual/screens/IndividualPersonalInfo/Nationality.js +88 -0
  142. package/build/features/individual/screens/IndividualPersonalInfo/index.d.ts +3 -0
  143. package/build/features/individual/screens/IndividualPersonalInfo/index.js +2 -0
  144. package/build/features/individual/screens/IndividualPersonalInfo/validation.d.ts +38 -0
  145. package/build/features/individual/screens/IndividualPersonalInfo/validation.js +68 -0
  146. package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  147. package/build/features/individual/screens/Verify/Verify.js +10 -17
  148. package/build/features/password/Password.js +2 -2
  149. package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  150. package/build/features/shared/Address/Address.d.ts +6 -1
  151. package/build/features/shared/Address/Address.js +40 -30
  152. package/build/features/shared/Address/CountryList.d.ts +1 -1
  153. package/build/features/shared/Address/InputSelect.d.ts +1 -1
  154. package/build/features/shared/Address/InputText.d.ts +2 -1
  155. package/build/features/shared/Address/InputText.js +2 -2
  156. package/build/features/shared/Button/Button.js +11 -0
  157. package/build/features/shared/Button/FlowsButtons.d.ts +1 -0
  158. package/build/features/shared/Button/FlowsButtons.js +5 -5
  159. package/build/features/shared/Button/ListButton.d.ts +18 -0
  160. package/build/features/shared/Button/ListButton.js +125 -0
  161. package/build/features/shared/Button/index.d.ts +2 -1
  162. package/build/features/shared/Button/index.js +2 -1
  163. package/build/features/shared/CreateAccountLoading/CreateAccountLoading.d.ts +2 -1
  164. package/build/features/shared/CreateAccountLoading/CreateAccountLoading.js +2 -2
  165. package/build/features/shared/SalesChannels/SalesChannel.d.ts +2 -1
  166. package/build/features/shared/SalesChannels/SalesChannel.js +2 -2
  167. package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.d.ts +2 -1
  168. package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.js +8 -6
  169. package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +6 -1
  170. package/build/features/shared/UploadMultipleFile/UploadMultipleFile.js +33 -11
  171. package/build/features/signIn/SignIn.js +2 -2
  172. package/build/features/tax/Tax.js +2 -2
  173. package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  174. package/build/features/tax/screens/TaxDetails/TaxDetails.js +2 -1
  175. package/build/features/tax/screens/TaxDetails/TaxDocument.js +8 -2
  176. package/build/features/tax/screens/TaxDetails/VATId.js +8 -3
  177. package/build/features/tax/screens/TaxDetails/validation.d.ts +4 -4
  178. package/build/features/tax/screens/TaxDetails/validation.js +10 -5
  179. package/build/utils/array.d.ts +1 -0
  180. package/build/utils/array.js +10 -2
  181. package/build/utils/common.d.ts +1 -0
  182. package/build/utils/common.js +6 -0
  183. package/build/utils/date.d.ts +1 -0
  184. package/build/utils/date.js +7 -1
  185. package/build/utils/error.d.ts +1 -0
  186. package/build/utils/error.js +3 -0
  187. package/build/utils/html.d.ts +1 -1
  188. package/build/utils/html.js +4 -1
  189. package/build/utils/index.d.ts +1 -0
  190. package/build/utils/index.js +1 -0
  191. package/build/utils/string.d.ts +15 -2
  192. package/build/utils/string.js +37 -3
  193. package/build/utils/validation.d.ts +1 -0
  194. package/build/utils/validation.js +3 -0
  195. package/package.json +129 -129
  196. package/build/features/individual/screens/AdditionalIndividualInfo/EmployerName.d.ts +0 -6
  197. package/build/features/individual/screens/AdditionalIndividualInfo/EmployerName.js +0 -46
  198. package/build/features/individual/screens/ShowIndividualInfo/ShowOwnerInfo.d.ts +0 -19
  199. package/build/features/individual/screens/ShowIndividualInfo/ShowOwnerInfo.js +0 -52
  200. package/build/features/individual/screens/ShowIndividualInfo/index.d.ts +0 -3
  201. package/build/features/individual/screens/ShowIndividualInfo/index.js +0 -2
  202. package/build/features/individual/screens/ShowIndividualInfo/info.d.ts +0 -7
  203. package/build/features/individual/screens/ShowIndividualInfo/info.js +0 -28
@@ -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,8 @@ 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;
42
+ var _d = data.brandActivities, activities = _d.activities, customerLocations = _d.customerLocations, expectedCustomer = _d.expectedCustomer, expectedSale = _d.expectedSale, termAndConditionChecked = _d.termAndConditionChecked, refundPolicy = _d.refundPolicy, transactionPolicy = _d.transactionPolicy;
41
43
  var ListType;
42
44
  (function (ListType) {
43
45
  ListType["ActivitiesList"] = "ActivitiesList";
@@ -46,8 +48,16 @@ var BrandActivities = function (_a) {
46
48
  ListType["ExpectedSalesList"] = "ExpectedSalesList";
47
49
  })(ListType || (ListType = {}));
48
50
  var methods = useForm({
49
- resolver: yupResolver(BrandActivitiesValidationSchema),
50
- defaultValues: data.brandActivities,
51
+ resolver: yupResolver(BrandActivitiesValidationSchema(brand)),
52
+ defaultValues: {
53
+ activities: activities,
54
+ customerLocations: customerLocations,
55
+ expectedCustomer: expectedCustomer,
56
+ expectedSale: expectedSale,
57
+ termAndConditionChecked: termAndConditionChecked,
58
+ refundPolicy: refundPolicy,
59
+ transactionPolicy: transactionPolicy
60
+ },
51
61
  mode: 'onChange'
52
62
  });
53
63
  useSetFromDefaultValues(methods, data.brandActivities, true);
@@ -48,7 +48,7 @@ export declare const NameContainer: import("@emotion/styled").StyledComponent<im
48
48
  export declare const CheckIconStyled: import("@emotion/styled").StyledComponent<{
49
49
  children?: React.ReactNode;
50
50
  classes?: Partial<import("@mui/material").SvgIconClasses> | undefined;
51
- color?: "inherit" | "disabled" | "error" | "success" | "info" | "primary" | "secondary" | "action" | "warning" | undefined;
51
+ color?: "inherit" | "disabled" | "error" | "info" | "success" | "primary" | "secondary" | "action" | "warning" | undefined;
52
52
  fontSize?: "small" | "inherit" | "medium" | "large" | undefined;
53
53
  htmlColor?: string | undefined;
54
54
  inheritViewBox?: boolean | undefined;
@@ -62,7 +62,7 @@ export declare const CheckIconStyled: import("@emotion/styled").StyledComponent<
62
62
  export declare const RemainingCheck: import("@emotion/styled").StyledComponent<{
63
63
  children?: React.ReactNode;
64
64
  classes?: Partial<import("@mui/material").SvgIconClasses> | undefined;
65
- color?: "inherit" | "disabled" | "error" | "success" | "info" | "primary" | "secondary" | "action" | "warning" | undefined;
65
+ color?: "inherit" | "disabled" | "error" | "info" | "success" | "primary" | "secondary" | "action" | "warning" | undefined;
66
66
  fontSize?: "small" | "inherit" | "medium" | "large" | undefined;
67
67
  htmlColor?: string | undefined;
68
68
  inheritViewBox?: boolean | undefined;
@@ -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
+ };
@@ -35,13 +35,20 @@ var BrandInfo = function (_a) {
35
35
  var _c = React.useState(false), brandNameChecking = _c[0], setBrandNameChecking = _c[1];
36
36
  var dispatch = useAppDispatch();
37
37
  var _d = useAppSelector(brandSelector), data = _d.data, loading = _d.loading, error = _d.error;
38
- var responseBody = data.brandData.responseBody;
38
+ var _e = data.brandData, brandName = _e.brandName, segment = _e.segment, teamSize = _e.teamSize, salesChannels = _e.salesChannels, termAndConditionChecked = _e.termAndConditionChecked, selectedBrandItem = _e.selectedBrandItem, responseBody = _e.responseBody;
39
39
  var methods = useForm({
40
- resolver: yupResolver(BrandValidationSchema),
41
- defaultValues: data.brandData,
40
+ resolver: yupResolver(BrandValidationSchema((responseBody === null || responseBody === void 0 ? void 0 : responseBody.brand) || {})),
41
+ defaultValues: {
42
+ brandName: brandName,
43
+ segment: segment,
44
+ teamSize: teamSize,
45
+ salesChannels: salesChannels,
46
+ termAndConditionChecked: termAndConditionChecked,
47
+ selectedBrandItem: selectedBrandItem
48
+ },
42
49
  mode: 'onChange'
43
50
  });
44
- useSetFromDefaultValues(methods, data.brandData);
51
+ useSetFromDefaultValues(methods, data.brandData, true);
45
52
  var onSubmit = function (data) {
46
53
  dispatch(updateBrand(data));
47
54
  };
@@ -47,25 +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';
64
- import { removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
66
+ import { ScreenContainer } from '../../../shared/Containers';
65
67
  import CheckIcon from '../../../shared/CheckIcon';
66
68
  import { checkBrandNameAvailability, brandSelector } from '../../../app/brand/brandStore';
67
- import { useAppDispatch, useAppSelector } from '../../../../hooks';
68
- import { debounce } from 'lodash-es';
69
69
  var LabelContainerStyled = styled(Box)(function (_a) {
70
70
  var theme = _a.theme;
71
71
  return ({
@@ -98,16 +98,18 @@ var InfoIconStyled = styled(InfoIcon)(function (_a) {
98
98
  });
99
99
  var cancelToken = null;
100
100
  var BrandName = function (_a) {
101
- var _b;
101
+ var _b, _c;
102
102
  var show = _a.show, brandNameChecking = _a.brandNameChecking, fetchingBrandName = _a.fetchingBrandName;
103
103
  var dispatch = useAppDispatch();
104
- var _c = React.useState(false), isHovered = _c[0], setIsHovered = _c[1];
104
+ var _d = React.useState(false), isHovered = _d[0], setIsHovered = _d[1];
105
105
  var t = useTranslation().t;
106
106
  var data = useAppSelector(brandSelector).data;
107
107
  var control = useFormContext().control;
108
108
  var brandControl = useController({ control: control, name: 'brandName' });
109
109
  var brandNameValue = brandControl.field.value;
110
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;
111
113
  var checkBrand = debounce(function (value) { return __awaiter(void 0, void 0, void 0, function () {
112
114
  var onSuccess;
113
115
  return __generator(this, function (_a) {
@@ -122,8 +124,7 @@ var BrandName = function (_a) {
122
124
  }); }, 500);
123
125
  var handleBrandNameChange = function (_a) {
124
126
  var target = _a.target;
125
- var value = removeAllOtherThanCharsNumbersAndSpace(target.value);
126
- brandControl.field.onChange(value);
127
+ brandControl.field.onChange(target.value);
127
128
  };
128
129
  React.useEffect(function () {
129
130
  var _a, _b, _c;
@@ -137,6 +138,6 @@ var BrandName = function (_a) {
137
138
  var clearBrandName = function () {
138
139
  brandControl.field.onChange('');
139
140
  };
140
- 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 })) })] })) })));
141
142
  };
142
143
  export default React.memo(BrandName);
@@ -1,20 +1,32 @@
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 control = useFormContext().control;
10
+ var _b, _c;
11
+ var _d = useFormContext(), control = _d.control, setValue = _d.setValue, getValues = _d.getValues;
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;
14
- var responseBody = data.verify.responseBody;
15
- var _e = responseBody || {}, channelList = _e.channel_list, defaultSalesChannels = _e.salesChannels;
13
+ var _e = useController({ control: control, name: 'salesChannels' }), fieldState = _e.fieldState, field = _e.field;
14
+ var _f = useAppSelector(brandSelector), data = _f.data, error = _f.error;
15
+ var verify = data.verify, brandData = data.brandData;
16
+ var selectedBrandItem = brandData.selectedBrandItem, defaultSalesChannels = brandData.salesChannels;
17
+ var _g = verify.responseBody || {}, channelList = _g.channel_list, brand = _g.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;
19
+ var selectedBrandControl = getValues('selectedBrandItem');
20
+ React.useEffect(function () {
21
+ if (selectedBrandItem.id) {
22
+ setValue('selectedBrandItem', selectedBrandItem);
23
+ var sales = mapSalesChannel(selectedBrandItem.channel_services || []);
24
+ field.onChange(sales);
25
+ }
26
+ }, [selectedBrandItem]);
16
27
  React.useEffect(function () {
17
- if ((defaultSalesChannels === null || defaultSalesChannels === void 0 ? void 0 : defaultSalesChannels.length) > 0) {
28
+ var _a;
29
+ if ((defaultSalesChannels === null || defaultSalesChannels === void 0 ? void 0 : defaultSalesChannels.length) > 0 && ((_a = field === null || field === void 0 ? void 0 : field.value) === null || _a === void 0 ? void 0 : _a.length) === 0) {
18
30
  var sales = mapSalesChannel(defaultSalesChannels);
19
31
  field.onChange(sales);
20
32
  }
@@ -25,6 +37,6 @@ var SalesChannels = function (_a) {
25
37
  dispatch(clearError());
26
38
  field.onChange(channels);
27
39
  };
28
- return _jsx(SalesChannel, { error: (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message, list: channelList, onChange: onChange, defaultValue: selectedSalesChannels });
40
+ return (_jsx(SalesChannel, { disabled: isNonEditable, error: (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message, list: channelList, selectFirstIconListener: selectedBrandControl === null || selectedBrandControl === void 0 ? void 0 : selectedBrandControl.id, onChange: onChange, defaultValue: selectedSalesChannels }));
29
41
  };
30
42
  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,7 +7,8 @@ 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 { REGEX_WEBSITE, REGEX_BRAND_NAME, LINKEDIN_URL, SOCIAL_USERNAME, DIGITS_ONLY, REGEX_ALPHANUMERIC } from '../../../../constants';
10
+ import { FieldType } from '../../../../@types';
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) {
13
14
  if (channels === void 0) { 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 && (value === null || value === void 0 ? void 0 : value.match(REGEX_BRAND_NAME)))
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
+ };