@tap-payments/auth-jsconnect 1.1.0-test → 1.1.1-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.
@@ -49,7 +49,7 @@ export declare type BankFormValues = {
49
49
  iban: string;
50
50
  beneficiaryName: string;
51
51
  bankName: string;
52
- bankStatementId: string;
52
+ bankStatementId?: string;
53
53
  uploading?: boolean;
54
54
  confirmPolicy: boolean;
55
55
  };
@@ -27,6 +27,7 @@ declare type BrandContent = {
27
27
  about?: BrandTitle;
28
28
  };
29
29
  declare type BrandInfo = {
30
+ id?: string;
30
31
  name?: BrandTitle;
31
32
  sector?: Array<string>;
32
33
  website?: string;
@@ -33,6 +33,6 @@ var UploadInput = function (_a) {
33
33
  if (event.target.files)
34
34
  onChange === null || onChange === void 0 ? void 0 : onChange(event.target.files[0]);
35
35
  };
36
- return (_jsxs(UploadBoxStyled, __assign({ onClick: openDeviceMedia }, { children: [_jsx(Text, __assign({ sx: { fontSize: '12px' } }, { children: title })), _jsx(UploadInputStyled, { onChange: onFileChange, id: 'upload-file-input', inputRef: fileRef, type: 'file', inputProps: { accept: '.png,.jpg,.pdf,.jpeg' }, required: true })] })));
36
+ return (_jsxs(UploadBoxStyled, __assign({ onClick: openDeviceMedia }, { children: [_jsx(Text, __assign({ sx: { fontSize: '12px' } }, { children: title })), _jsx(UploadInputStyled, { onChange: onFileChange, id: 'upload-file-input', inputRef: fileRef, type: 'file', inputProps: { accept: '.png,.jpg,.pdf,.jpeg' } })] })));
37
37
  };
38
38
  export default UploadInput;
@@ -271,7 +271,6 @@ var initialState = {
271
271
  iban: '',
272
272
  beneficiaryName: '',
273
273
  bankName: '',
274
- bankStatementId: '',
275
274
  confirmPolicy: false,
276
275
  uploading: false
277
276
  }
@@ -309,10 +309,10 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
309
309
  });
310
310
  }); });
311
311
  export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
312
- var _a, settings, connect, instagram, twitter, _b, mobileData, nidData, otpData, brandData, isAbsher, responseBody, isExistingUser, payload, data;
313
- var _c, _d, _e, _f, _g, _h, _j, _k, _l;
314
- return __generator(this, function (_m) {
315
- switch (_m.label) {
312
+ var _a, settings, connect, instagram, twitter, _b, mobileData, nidData, otpData, brandData, isAbsher, responseBody, isExistingUser, isOther, brand, payload, data;
313
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
314
+ return __generator(this, function (_p) {
315
+ switch (_p.label) {
316
316
  case 0:
317
317
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
318
318
  instagram = !!((_c = params.links) === null || _c === void 0 ? void 0 : _c.instagram) ? "".concat(INSTAGRAM_URL, "/").concat((_d = params.links) === null || _d === void 0 ? void 0 : _d.instagram) : '';
@@ -321,17 +321,19 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
321
321
  isAbsher = otpData.isAbsher;
322
322
  responseBody = (isAbsher ? nidData : mobileData).responseBody;
323
323
  isExistingUser = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user) === false;
324
+ isOther = ((_g = params.selectedBrandItem) === null || _g === void 0 ? void 0 : _g.id) === 'other';
325
+ brand = __assign({ name: {
326
+ en: params.brandName,
327
+ ar: params.brandName,
328
+ zh: params.brandName
329
+ }, website: (_h = params.links) === null || _h === void 0 ? void 0 : _h.website, social: [twitter, instagram] }, (isExistingUser &&
330
+ !isOther && {
331
+ id: (_j = params.selectedBrandItem) === null || _j === void 0 ? void 0 : _j.id,
332
+ name: undefined
333
+ }));
324
334
  payload = {
325
- brand: {
326
- name: {
327
- en: params.brandName,
328
- ar: params.brandName,
329
- zh: params.brandName
330
- },
331
- website: (_g = params.links) === null || _g === void 0 ? void 0 : _g.website,
332
- social: [twitter, instagram]
333
- },
334
- id: (isExistingUser ? (_h = brandData.responseBody) === null || _h === void 0 ? void 0 : _h.lead_id : (_j = otpData.responseBody) === null || _j === void 0 ? void 0 : _j.lead_id) || '',
335
+ brand: brand,
336
+ id: (isExistingUser ? (_k = brandData.responseBody) === null || _k === void 0 ? void 0 : _k.lead_id : (_l = otpData.responseBody) === null || _l === void 0 ? void 0 : _l.lead_id) || '',
335
337
  terms_conditions_accepted: params.termAndConditionChecked,
336
338
  step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_MERCHANT,
337
339
  encryption_contract: [
@@ -345,10 +347,10 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
345
347
  };
346
348
  return [4, API.leadService.updateLead(payload)];
347
349
  case 1:
348
- data = (_m.sent()).data;
350
+ data = (_p.sent()).data;
349
351
  if (!data.errors) {
350
352
  thunkApi.dispatch(handleNextScreenStep());
351
- (_l = (_k = settings.data.appConfig).onStepCompleted) === null || _l === void 0 ? void 0 : _l.call(_k, settings.data.activeScreen.name, params);
353
+ (_o = (_m = settings.data.appConfig).onStepCompleted) === null || _o === void 0 ? void 0 : _o.call(_m, settings.data.activeScreen.name, params);
352
354
  }
353
355
  return [2, { response: data, formData: params }];
354
356
  }
@@ -51,10 +51,8 @@ var BrandList = function (_a) {
51
51
  var _b = React.useState(null), anchorEl = _b[0], setAnchorEl = _b[1];
52
52
  var t = useTranslation().t;
53
53
  var isAr = useLanguage().isAr;
54
- var _c = useFormContext(), setValue = _c.setValue, control = _c.control;
55
- var linksControl = useController({ control: control, name: 'links' });
54
+ var control = useFormContext().control;
56
55
  var selectedBrandControl = useController({ control: control, name: 'selectedBrandItem' });
57
- var links = linksControl.field.value;
58
56
  var selectedBrand = selectedBrandControl.field.value;
59
57
  var onOpenBrandList = function (event) {
60
58
  var _a;
@@ -79,8 +77,6 @@ var BrandList = function (_a) {
79
77
  var onSelectItem = function (brand) {
80
78
  selectedBrandControl.field.onChange(brand);
81
79
  onCloseBrandList();
82
- var website = brand.website;
83
- setValue('links', __assign(__assign({}, links), { website: website }), { shouldValidate: true });
84
80
  };
85
81
  return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('select_brand_label'), readOnly: true, onClick: !!anchorEl ? onCloseBrandList : onOpenBrandList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_brand'), value: t(getBrandName(selectedBrand)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'id', list: list, onSelectItem: onSelectItem, renderItem: function (item) {
86
82
  return (_jsxs(_Fragment, { children: [_jsx(BrandContainer, { children: _jsx(BrandNameText, __assign({ isSelected: getBrandId(item) === getBrandId(selectedBrand) }, { children: isOtherLicense(item) ? t(getBrandName(item)) : getBrandName(item) })) }), getBrandId(item) === getBrandId(selectedBrand) && _jsx(CheckIcon, {})] }));
@@ -18,6 +18,7 @@ import { yupResolver } from '@hookform/resolvers/yup';
18
18
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
19
19
  import { handlePrevScreenStep } from '../../../../app/settings';
20
20
  import Form from '../../../../components/Form';
21
+ import { INSTAGRAM_URL, TWITTER_URL } from '../../../../constants';
21
22
  import { ScreenContainer } from '../../../shared/Containers';
22
23
  import Button from '../../../shared/Button';
23
24
  import { clearError, connectSelector, updateLeadBrand } from '../../../app/connect/connectStore';
@@ -50,6 +51,7 @@ var Merchant = function (_a) {
50
51
  var t = useTranslation().t;
51
52
  var isAr = useLanguage().isAr;
52
53
  var dispatch = useAppDispatch();
54
+ var formDataSelectedBrand = methods.getValues('selectedBrandItem');
53
55
  var onSubmit = function (formData) {
54
56
  dispatch(updateLeadBrand(formData));
55
57
  };
@@ -69,11 +71,11 @@ var Merchant = function (_a) {
69
71
  methods.setError('brandName', { message: 'Profile Name already exists' });
70
72
  }, [responseBody]);
71
73
  React.useEffect(function () {
72
- var _a, _b;
74
+ var _a, _b, _c, _d;
73
75
  if (isNewUser === true) {
74
76
  setUserType(ValidationOptions.NEW_USER);
75
77
  }
76
- if (isNewUser === false && (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0 && methods.getValues('selectedBrandItem').id === 'other') {
78
+ if (isNewUser === false && (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0 && (formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) === 'other') {
77
79
  setUserType(ValidationOptions.EXISTING_USER_WITH_OTHER_BRAND);
78
80
  methods.clearErrors();
79
81
  setTimeout(function () {
@@ -82,17 +84,17 @@ var Merchant = function (_a) {
82
84
  methods.setValue('links', sites);
83
85
  }, 100);
84
86
  }
85
- if (isNewUser === false && (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0 && methods.getValues('selectedBrandItem').id !== 'other') {
87
+ if (isNewUser === false && (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0 && (formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) !== 'other') {
86
88
  setUserType(ValidationOptions.EXISTING_USER_WITH_EXIST_BRAND);
87
89
  methods.clearErrors();
88
- var twitter = ((_a = selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.social) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.includes('twitter.com'); })) || '';
89
- var instagram = ((_b = selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.social) === null || _b === void 0 ? void 0 : _b.find(function (item) { return item.includes('instagram.com'); })) || '';
90
- var sites_1 = __assign(__assign({}, links), { website: selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.website, twitter: twitter, instagram: instagram });
90
+ var twitter = ((_b = (_a = formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.social) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.includes('twitter.com'); })) === null || _b === void 0 ? void 0 : _b.replaceAll("".concat(TWITTER_URL, "/"), '')) || '';
91
+ var instagram = ((_d = (_c = formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.social) === null || _c === void 0 ? void 0 : _c.find(function (item) { return item.includes('instagram.com'); })) === null || _d === void 0 ? void 0 : _d.replaceAll("".concat(INSTAGRAM_URL, "/"), '')) || '';
92
+ var sites_1 = __assign(__assign({}, links), { website: formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.website, twitter: twitter, instagram: instagram });
91
93
  setTimeout(function () { return methods.setValue('links', sites_1, { shouldValidate: true }); }, 100);
92
94
  }
93
- }, [methods.getValues('selectedBrandItem'), isNewUser]);
95
+ }, [formDataSelectedBrand, isNewUser]);
94
96
  React.useEffect(function () {
95
- if (selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id)
97
+ if (!(formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) && (selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id))
96
98
  methods.setValue('selectedBrandItem', selectedBrandItem, { shouldValidate: true });
97
99
  }, [selectedBrandItem]);
98
100
  var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
@@ -37,7 +37,7 @@ var IconStyled = styled(Icon, { shouldForwardProp: function (prop) { return prop
37
37
  width: theme.spacing(3),
38
38
  height: theme.spacing(3),
39
39
  transform: isAr ? 'scaleX(-1)' : 'scaleX(1)',
40
- marginInlineEnd: theme.spacing(0.5)
40
+ marginInlineEnd: theme.spacing(-0.375)
41
41
  });
42
42
  });
43
43
  var BackIconStyled = styled(Icon, { shouldForwardProp: function (prop) { return prop !== 'isAr'; } })(function (_a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.1.0-test",
3
+ "version": "1.1.1-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",