@tap-payments/auth-jsconnect 2.8.19-test → 2.8.21-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.
@@ -31,7 +31,6 @@ export declare const resendOTP: import("@reduxjs/toolkit").AsyncThunk<{
31
31
  rejectedMeta?: unknown;
32
32
  }>;
33
33
  export declare const retrieveBoardStatus: import("@reduxjs/toolkit").AsyncThunk<{
34
- data: any;
35
34
  flows: any;
36
35
  }, void, {
37
36
  state?: unknown;
@@ -119,52 +119,47 @@ export var resendOTP = createAsyncThunk('resendOTPTax', function (params, thunkA
119
119
  });
120
120
  }); });
121
121
  export var retrieveBoardStatus = createAsyncThunk('tax/retrieveBoardStatus', function (parmas, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
122
- var tax, _a, board_id, board_info_id, _b, boardInfoData, data, _c, id, type;
123
- var _d;
124
- return __generator(this, function (_e) {
125
- switch (_e.label) {
122
+ var tax, _a, board_id, board_info_id, recipient, _b, id, type, data;
123
+ return __generator(this, function (_c) {
124
+ switch (_c.label) {
126
125
  case 0:
127
126
  tax = thunkApi.getState().tax;
128
- _a = tax.data.verify.responseBody || {}, board_id = _a.board_id, board_info_id = _a.board_info_id;
127
+ _a = tax.data.verify.responseBody || {}, board_id = _a.board_id, board_info_id = _a.board_info_id, recipient = _a.recipient;
129
128
  if (!board_id || !board_info_id)
130
129
  throw new Error('Internal server error');
130
+ _b = recipient || {}, id = _b.id, type = _b.type;
131
131
  return [4, Promise.all([
132
- API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id }),
133
- API.boardService.retrieveBoardInfoStatus(board_id)
132
+ API.boardService.retrieveBoardInfoStatus(board_id),
133
+ thunkApi.dispatch(retrieveBoardDetails({ boardId: board_id, individualId: id, individualType: type })).unwrap()
134
134
  ])];
135
135
  case 1:
136
- _b = _e.sent(), boardInfoData = _b[0], data = _b[1];
137
- _c = ((_d = boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification) === null || _d === void 0 ? void 0 : _d.recipient) || {}, id = _c.id, type = _c.type;
138
- return [4, thunkApi.dispatch(retrieveBoardDetails({ boardId: board_id, individualId: id, individualType: type })).unwrap()];
139
- case 2:
140
- _e.sent();
136
+ data = (_c.sent())[0];
141
137
  thunkApi.dispatch(handlePrevScreenStep());
142
- return [2, { data: boardInfoData, flows: (data === null || data === void 0 ? void 0 : data.info) || [] }];
138
+ return [2, { flows: (data === null || data === void 0 ? void 0 : data.info) || [] }];
143
139
  }
144
140
  });
145
141
  }); });
146
142
  export var retrieveBoardDetails = createAsyncThunk('tax/retrieveBrandInfo', function (_a) {
147
143
  var boardId = _a.boardId, id = _a.individualId, type = _a.individualType;
148
144
  return __awaiter(void 0, void 0, void 0, function () {
149
- var data, individualData, serviceCallBack, data_state;
150
- var _b, _c, _d, _e;
151
- return __generator(this, function (_f) {
152
- switch (_f.label) {
145
+ var data, individualData, boardData, serviceCallBack, _b, boardRes, individualRes;
146
+ var _c, _d, _e, _f;
147
+ return __generator(this, function (_g) {
148
+ switch (_g.label) {
153
149
  case 0: return [4, API.boardService.retrieveBoardDetails(boardId)];
154
150
  case 1:
155
- data = _f.sent();
151
+ data = _g.sent();
156
152
  individualData = data === null || data === void 0 ? void 0 : data.user;
157
- if (!(((_b = data === null || data === void 0 ? void 0 : data.user) === null || _b === void 0 ? void 0 : _b.id) !== id)) return [3, 3];
153
+ boardData = data;
154
+ if (!(((_c = data === null || data === void 0 ? void 0 : data.user) === null || _c === void 0 ? void 0 : _c.id) !== id)) return [3, 3];
158
155
  serviceCallBack = function () { return API.individualService.retrieveIndividual(id, type); };
159
156
  return [4, retrieveIndividualData(type, data, serviceCallBack)];
160
157
  case 2:
161
- individualData = _f.sent();
162
- _f.label = 3;
163
- case 3:
164
- data_state = (((individualData === null || individualData === void 0 ? void 0 : individualData.is_authorized) ? data === null || data === void 0 ? void 0 : data.individuals : individualData) || {}).data_state;
165
- return [2, __assign(__assign(__assign(__assign({}, data), { user: data === null || data === void 0 ? void 0 : data.user, brand: data === null || data === void 0 ? void 0 : data.brand, bank_account: data === null || data === void 0 ? void 0 : data.bank_account, entity: data === null || data === void 0 ? void 0 : data.entity, merchant: data === null || data === void 0 ? void 0 : data.merchant, name: (_c = data === null || data === void 0 ? void 0 : data.user) === null || _c === void 0 ? void 0 : _c.names, vatID: (_d = data === null || data === void 0 ? void 0 : data.entity) === null || _d === void 0 ? void 0 : _d.vat_id, individuals: data === null || data === void 0 ? void 0 : data.individuals, contact: (_e = data === null || data === void 0 ? void 0 : data.user) === null || _e === void 0 ? void 0 : _e.contact }), (individualData && { user: individualData })), (data_state && {
166
- individuals: __assign(__assign({}, data === null || data === void 0 ? void 0 : data.individuals), { data_state: data_state })
167
- }))];
158
+ _b = _g.sent(), boardRes = _b.boardRes, individualRes = _b.individualRes;
159
+ individualData = individualRes;
160
+ boardData = boardRes;
161
+ _g.label = 3;
162
+ case 3: return [2, __assign(__assign({}, boardData), { brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand, bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account, entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity, merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant, name: (_d = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _d === void 0 ? void 0 : _d.names, vatID: (_e = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _e === void 0 ? void 0 : _e.vat_id, individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals, contact: (_f = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _f === void 0 ? void 0 : _f.contact, user: individualData })];
168
163
  }
169
164
  });
170
165
  });
@@ -443,8 +438,8 @@ export var taxSlice = createSlice({
443
438
  .addCase(retrieveBoardStatus.fulfilled, function (state, action) {
444
439
  state.error = null;
445
440
  state.loading = false;
446
- var _a = action.payload, flows = _a.flows, data = _a.data;
447
- state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows, notification: data === null || data === void 0 ? void 0 : data.notification });
441
+ var flows = action.payload.flows;
442
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows });
448
443
  })
449
444
  .addCase(retrieveBoardStatus.rejected, function (state, action) {
450
445
  state.error = action.error.message;
@@ -16,11 +16,12 @@ import Box from '@mui/material/Box';
16
16
  import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
17
17
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
18
18
  import Text from '../../../../components/Text';
19
- import Button from '../../../../components/Button';
20
19
  import Collapse from '../../../../components/Collapse';
21
20
  import Warning from '../../../../components/Warning';
21
+ import Button from '../../../../components/Button';
22
+ import Loader from '../../../../components/Loader';
22
23
  import { ScreenContainer } from '../../../shared/Containers';
23
- import { individualSelector } from '../../../app/individual/individualStore';
24
+ import { individualSelector, retrieveBoardStatus } from '../../../app/individual/individualStore';
24
25
  import UserList from './UserList';
25
26
  var BoxStyled = styled(Box)(function (_a) {
26
27
  var theme = _a.theme;
@@ -49,12 +50,17 @@ export var SubTitleStyled = styled(Text)(function (_a) {
49
50
  var IndividualList = function () {
50
51
  var dispatch = useAppDispatch();
51
52
  var t = useTranslation().t;
52
- var error = useAppSelector(individualSelector).error;
53
+ var _a = useAppSelector(individualSelector), error = _a.error, data = _a.data, loading = _a.loading;
53
54
  var settingsData = useAppSelector(settingsSelector).data;
55
+ var flows = (data.verify.responseBody || {}).flows;
54
56
  var onBack = function () {
55
- dispatch(handlePrevScreenStep());
57
+ if ((flows === null || flows === void 0 ? void 0 : flows.length) > 0) {
58
+ dispatch(handlePrevScreenStep());
59
+ return;
60
+ }
61
+ dispatch(retrieveBoardStatus());
56
62
  };
57
63
  var hideBack = settingsData.appConfig.mode === 'content';
58
- return (_jsxs(ScreenContainer, { children: [_jsxs(BoxStyled, { children: [_jsxs(ContentStyled, { children: [_jsx(TitleStyled, { children: t('company_individuals') }), _jsx(SubTitleStyled, { children: t('company_individuals_add_or_request_details') })] }), _jsx(UserList, {})] }), _jsx(Collapse, __assign({ in: !!error, timeout: 400 }, { children: _jsx(Warning, __assign({ warningType: 'error' }, { children: t(error || '') })) })), !hideBack && (_jsx(Button, __assign({ sx: { mb: 1.5, mt: 1.5 }, onClick: function () { return onBack(); }, variant: 'text' }, { children: t('back') })))] }));
64
+ return (_jsxs(ScreenContainer, { children: [_jsxs(BoxStyled, { children: [_jsxs(ContentStyled, { children: [_jsx(TitleStyled, { children: t('company_individuals') }), _jsx(SubTitleStyled, { children: t('company_individuals_add_or_request_details') })] }), _jsx(UserList, {})] }), _jsx(Collapse, __assign({ in: !!error, timeout: 400 }, { children: _jsx(Warning, __assign({ warningType: 'error' }, { children: t(error || '') })) })), !hideBack && (_jsx(Button, __assign({ sx: { mb: 1.5, mt: 1.5 }, onClick: function () { return onBack(); }, variant: 'text' }, { children: loading ? _jsx(Loader, { innerColor: 'black', outerColor: 'black', size: 15, toggleAnimation: !!loading }) : t('back') })))] }));
59
65
  };
60
66
  export default IndividualList;
@@ -85,12 +85,12 @@ var UserList = function (_a) {
85
85
  var dispatch = useAppDispatch();
86
86
  var _j = React.useState(false), emailChecking = _j[0], setEmailChecking = _j[1];
87
87
  var theme = useTheme();
88
- var _k = useAppSelector(individualSelector), data = _k.data, loading = _k.loading, error = _k.error;
88
+ var _k = useAppSelector(individualSelector), data = _k.data, addOrRequestDetailLoading = _k.addOrRequestDetailLoading, error = _k.error;
89
89
  var settingsData = useAppSelector(settingsSelector).data;
90
90
  var _l = data.individualCollectData, email = _l.email, mobile = _l.mobile, responseBody = _l.responseBody;
91
91
  var is_available = (responseBody || {}).is_available;
92
92
  var verify = data.verify;
93
- var _m = verify.responseBody || {}, userList = _m.userList, notification = _m.notification, userRes = _m.user;
93
+ var _m = verify.responseBody || {}, userList = _m.userList, recipient = _m.recipient, userRes = _m.user;
94
94
  var methods = useForm({
95
95
  resolver: yupResolver(IndividualCollectInfoValidationSchema(activeUser)),
96
96
  defaultValues: {
@@ -159,10 +159,10 @@ var UserList = function (_a) {
159
159
  return (activeUser === null || activeUser === void 0 ? void 0 : activeUser.id) === user.id;
160
160
  };
161
161
  var isSameUserRequestedBefore = function (user) {
162
- var _a, _b;
162
+ var _a;
163
163
  if (!(userRes === null || userRes === void 0 ? void 0 : userRes.is_authorized) && !isKWOrSA(settingsData.businessCountry.iso2))
164
164
  return false;
165
- return (_a = user === null || user === void 0 ? void 0 : user.ids) === null || _a === void 0 ? void 0 : _a.includes((_b = notification === null || notification === void 0 ? void 0 : notification.recipient) === null || _b === void 0 ? void 0 : _b.id);
165
+ return (_a = user === null || user === void 0 ? void 0 : user.ids) === null || _a === void 0 ? void 0 : _a.includes(recipient === null || recipient === void 0 ? void 0 : recipient.id);
166
166
  };
167
167
  var getUserStatus = function (user) {
168
168
  return user === null || user === void 0 ? void 0 : user.individual_data_state;
@@ -196,7 +196,7 @@ var UserList = function (_a) {
196
196
  status: getUserStatus(user),
197
197
  title: t('add_details'),
198
198
  onClick: onAddDetails,
199
- loading: isActiveUser(user) && loading && type === IndividualRequestType.ADD
199
+ loading: isActiveUser(user) && !!addOrRequestDetailLoading && type === IndividualRequestType.ADD
200
200
  }, requestEmail: {
201
201
  children: getCollectForm(user),
202
202
  title: t('request_details_by_email'),
@@ -204,7 +204,7 @@ var UserList = function (_a) {
204
204
  disabled: showCollectForm ? disabled : false,
205
205
  onClick: onRequestEmail,
206
206
  show: !isSameUserRequestedBefore(user),
207
- loading: isActiveUser(user) && loading && type === IndividualRequestType.REQUEST_EMAIL
207
+ loading: isActiveUser(user) && !!addOrRequestDetailLoading && type === IndividualRequestType.REQUEST_EMAIL
208
208
  } }) }))] }), index));
209
209
  }) }));
210
210
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.8.19-test",
3
+ "version": "2.8.21-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",