@tap-payments/auth-jsconnect 2.0.34-test → 2.0.36-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.
- package/build/@types/app.d.ts +9 -2
- package/build/@types/app.js +7 -0
- package/build/@types/form.d.ts +4 -3
- package/build/api/entity.d.ts +2 -0
- package/build/app/rootReducer.d.ts +1 -0
- package/build/app/rootReducer.js +3 -1
- package/build/app/store.d.ts +2 -0
- package/build/assets/locales/ar.json +8 -4
- package/build/assets/locales/en.json +8 -4
- package/build/components/SocialMediaGroup/SocialMediaGroup.d.ts +2 -1
- package/build/components/SocialMediaGroup/SocialMediaGroup.js +27 -34
- package/build/constants/app.d.ts +1 -0
- package/build/constants/app.js +8 -0
- package/build/constants/assets.d.ts +9 -1
- package/build/constants/assets.js +14 -6
- package/build/features/app/auth/authStore.d.ts +20 -0
- package/build/features/app/auth/authStore.js +101 -0
- package/build/features/app/connect/connectStore.d.ts +1 -0
- package/build/features/app/connect/connectStore.js +58 -4
- package/build/features/app/entity/entityStore.d.ts +5 -0
- package/build/features/app/entity/entityStore.js +149 -14
- package/build/features/auth/Auth.d.ts +8 -0
- package/build/features/auth/Auth.js +53 -0
- package/build/features/auth/index.d.ts +1 -0
- package/build/features/auth/index.js +1 -0
- package/build/features/auth/screens/OTP/OTP.d.ts +5 -0
- package/build/features/auth/screens/OTP/OTP.js +72 -0
- package/build/features/auth/screens/OTP/OTPInput.d.ts +5 -0
- package/build/features/auth/screens/OTP/OTPInput.js +44 -0
- package/build/features/auth/screens/OTP/index.d.ts +3 -0
- package/build/features/auth/screens/OTP/index.js +2 -0
- package/build/features/auth/screens/OTP/validation.d.ts +8 -0
- package/build/features/auth/screens/OTP/validation.js +4 -0
- package/build/features/connect/screens/Merchant/Merchant.js +29 -9
- package/build/features/connect/screens/Merchant/SalesChannels.d.ts +5 -0
- package/build/features/connect/screens/Merchant/SalesChannels.js +114 -0
- package/build/features/connect/screens/Merchant/SocialMedia.js +56 -11
- package/build/features/connect/screens/Merchant/validation.d.ts +87 -0
- package/build/features/connect/screens/Merchant/validation.js +68 -2
- package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.d.ts +54 -0
- package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.js +139 -0
- package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.js +52 -2
- package/build/features/entity/screens/EntityInfoConfirm/LicenseName.d.ts +5 -0
- package/build/features/entity/screens/EntityInfoConfirm/LicenseName.js +17 -0
- package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.d.ts +5 -0
- package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.js +28 -0
- package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.d.ts +6 -0
- package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.js +38 -0
- package/build/features/entity/screens/EntityInfoConfirm/SalesChannels.d.ts +5 -0
- package/build/features/entity/screens/EntityInfoConfirm/SalesChannels.js +112 -0
- package/build/features/entity/screens/EntityInfoConfirm/validation.d.ts +107 -0
- package/build/features/entity/screens/EntityInfoConfirm/validation.js +17 -0
- package/build/features/featuresScreens.d.ts +1 -0
- package/build/features/featuresScreens.js +9 -2
- package/build/hooks/useAppDispatch.d.ts +1 -0
- package/build/index.d.ts +3 -2
- package/build/index.js +5 -2
- package/package.json +128 -128
|
@@ -51,6 +51,8 @@ import API from '../../../api';
|
|
|
51
51
|
import { FlowsTypes } from '../../../@types';
|
|
52
52
|
import { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
|
|
53
53
|
import { ENTITY_STEP_NAMES, BUSINESS_FLOW_SUCCESS } from '../../../constants';
|
|
54
|
+
import moment from 'moment';
|
|
55
|
+
import { convertNumbers2English } from '../../../utils';
|
|
54
56
|
export var verifyLeadToken = createAsyncThunk('entityVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
57
|
var payload, data, boardInfoData, board_id, board_info_id, info, hasEntityCompleted;
|
|
56
58
|
var _a;
|
|
@@ -64,22 +66,26 @@ export var verifyLeadToken = createAsyncThunk('entityVerifyLeadToken', function
|
|
|
64
66
|
return [4, API.leadService.verifyLeadToken(payload)];
|
|
65
67
|
case 1:
|
|
66
68
|
data = (_b.sent()).data;
|
|
69
|
+
return [4, thunkApi.dispatch(retrieveChannels())];
|
|
70
|
+
case 2:
|
|
71
|
+
_b.sent();
|
|
67
72
|
boardInfoData = undefined;
|
|
68
|
-
if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3,
|
|
73
|
+
if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 6];
|
|
69
74
|
board_id = data === null || data === void 0 ? void 0 : data.id;
|
|
70
75
|
board_info_id = data === null || data === void 0 ? void 0 : data.board_info_id;
|
|
71
|
-
if (!(!!board_id && !!board_info_id)) return [3,
|
|
76
|
+
if (!(!!board_id && !!board_info_id)) return [3, 4];
|
|
72
77
|
return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
|
|
73
|
-
case
|
|
78
|
+
case 3:
|
|
74
79
|
boardInfoData = _b.sent();
|
|
75
|
-
_b.label =
|
|
76
|
-
case
|
|
77
|
-
case
|
|
80
|
+
_b.label = 4;
|
|
81
|
+
case 4: return [4, thunkApi.dispatch(retrieveBoardDetails(board_id))];
|
|
82
|
+
case 5:
|
|
78
83
|
_b.sent();
|
|
79
84
|
info = boardInfoData.info;
|
|
80
85
|
hasEntityCompleted = ((_a = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'entity'; })) === null || _a === void 0 ? void 0 : _a.status) === 'completed';
|
|
86
|
+
thunkApi.dispatch(handleCurrentActiveScreen('ENTITY_INFO_STEP'));
|
|
81
87
|
if (data.step_name === ENTITY_STEP_NAMES.PHONE_AUTH) {
|
|
82
|
-
thunkApi.dispatch(handleCurrentActiveScreen('
|
|
88
|
+
thunkApi.dispatch(handleCurrentActiveScreen('ENTITY_INFO_STEP'));
|
|
83
89
|
}
|
|
84
90
|
else if (hasEntityCompleted) {
|
|
85
91
|
thunkApi.dispatch(handleNextScreenStep('ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
@@ -87,8 +93,8 @@ export var verifyLeadToken = createAsyncThunk('entityVerifyLeadToken', function
|
|
|
87
93
|
else if (data.step_name === ENTITY_STEP_NAMES.ENTITY_INFO) {
|
|
88
94
|
thunkApi.dispatch(handleNextScreenStep('ENTITY_INFO_STEP'));
|
|
89
95
|
}
|
|
90
|
-
_b.label =
|
|
91
|
-
case
|
|
96
|
+
_b.label = 6;
|
|
97
|
+
case 6: return [2, { data: data, boardResponse: { flows: BUSINESS_FLOW_SUCCESS.concat(boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) }, token: token }];
|
|
92
98
|
}
|
|
93
99
|
});
|
|
94
100
|
}); });
|
|
@@ -156,6 +162,35 @@ export var retrieveBoardDetails = createAsyncThunk('entityRetrieveEntityInfo', f
|
|
|
156
162
|
}
|
|
157
163
|
});
|
|
158
164
|
}); });
|
|
165
|
+
export var updateEntityInfo = createAsyncThunk('updateEntityInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
166
|
+
var _a, settings, entity, requestBody, data;
|
|
167
|
+
var _b, _c, _d, _e, _f;
|
|
168
|
+
return __generator(this, function (_g) {
|
|
169
|
+
switch (_g.label) {
|
|
170
|
+
case 0:
|
|
171
|
+
_a = thunkApi.getState(), settings = _a.settings, entity = _a.entity;
|
|
172
|
+
requestBody = {
|
|
173
|
+
id: (_c = (_b = entity.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.id,
|
|
174
|
+
activities: (_d = (params.activities || [])) === null || _d === void 0 ? void 0 : _d.map(function (_a) {
|
|
175
|
+
var en = _a.en;
|
|
176
|
+
return en;
|
|
177
|
+
}),
|
|
178
|
+
license_name: params.licenseName,
|
|
179
|
+
license_number: params.licenseNumber,
|
|
180
|
+
business_operation_start_at: params.operationStartDate,
|
|
181
|
+
step_name: ENTITY_STEP_NAMES.ENTITY_INFO
|
|
182
|
+
};
|
|
183
|
+
return [4, API.entityService.updateEntityInfo(requestBody)];
|
|
184
|
+
case 1:
|
|
185
|
+
data = (_g.sent()).data;
|
|
186
|
+
if (!data.errors) {
|
|
187
|
+
thunkApi.dispatch(handleNextScreenStep());
|
|
188
|
+
(_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, requestBody);
|
|
189
|
+
}
|
|
190
|
+
return [2, { data: data, formData: params }];
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}); });
|
|
159
194
|
export var updateBoardSuccess = createAsyncThunk('updateBoardEntitySuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
160
195
|
var _a, settings, entity, _b, id, infoId, payload, data;
|
|
161
196
|
var _c, _d, _e, _f;
|
|
@@ -184,6 +219,17 @@ export var updateBoardSuccess = createAsyncThunk('updateBoardEntitySuccess', fun
|
|
|
184
219
|
}
|
|
185
220
|
});
|
|
186
221
|
}); });
|
|
222
|
+
export var retrieveChannels = createAsyncThunk('retrieveChannelsEntity', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
223
|
+
var data;
|
|
224
|
+
return __generator(this, function (_a) {
|
|
225
|
+
switch (_a.label) {
|
|
226
|
+
case 0: return [4, API.dataService.getChannelsOfServices()];
|
|
227
|
+
case 1:
|
|
228
|
+
data = (_a.sent()).data;
|
|
229
|
+
return [2, data];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}); });
|
|
187
233
|
var initialState = {
|
|
188
234
|
error: null,
|
|
189
235
|
loading: false,
|
|
@@ -197,11 +243,9 @@ var initialState = {
|
|
|
197
243
|
otp: ''
|
|
198
244
|
},
|
|
199
245
|
entityData: {
|
|
200
|
-
licenseNumber: '',
|
|
201
|
-
licenseName: '',
|
|
202
246
|
activities: [],
|
|
203
247
|
salesChannels: [],
|
|
204
|
-
operationStartDate: ''
|
|
248
|
+
operationStartDate: '1998-08-22'
|
|
205
249
|
}
|
|
206
250
|
}
|
|
207
251
|
};
|
|
@@ -226,15 +270,49 @@ export var entitySlice = createSlice({
|
|
|
226
270
|
state.customLoading = true;
|
|
227
271
|
})
|
|
228
272
|
.addCase(verifyLeadToken.fulfilled, function (state, action) {
|
|
229
|
-
var _a;
|
|
273
|
+
var _a, _b, _c;
|
|
230
274
|
state.error = null;
|
|
231
275
|
state.customLoading = false;
|
|
232
|
-
var
|
|
276
|
+
var _d = action.payload, data = _d.data, token = _d.token, boardResponse = _d.boardResponse;
|
|
233
277
|
var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
234
278
|
if (description) {
|
|
235
279
|
state.error = description;
|
|
236
280
|
return;
|
|
237
281
|
}
|
|
282
|
+
var _e = state.data.verify.responseBody || {}, brand = _e.brand, entity = _e.entity;
|
|
283
|
+
var issuingDate = brand === null || brand === void 0 ? void 0 : brand.business_operation_start_at;
|
|
284
|
+
if (!!issuingDate) {
|
|
285
|
+
var formattedDate = moment(issuingDate).format('YYYY-MM-DD');
|
|
286
|
+
state.data.entityData.operationStartDate = convertNumbers2English(formattedDate);
|
|
287
|
+
}
|
|
288
|
+
var channels = (_b = state.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.channelList;
|
|
289
|
+
var selectedChannels = (!!(channels === null || channels === void 0 ? void 0 : channels[0]) && [channels === null || channels === void 0 ? void 0 : channels[0]]) || [];
|
|
290
|
+
var _f = brand || {}, website = _f.website, social = _f.social;
|
|
291
|
+
var isHasWebsite = (website === null || website === void 0 ? void 0 : website.length) > 0;
|
|
292
|
+
var isHasTwitter = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('twitter.com'); });
|
|
293
|
+
var isHasInstagram = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('instagram.com'); });
|
|
294
|
+
var websiteData = channels === null || channels === void 0 ? void 0 : channels.find(function (c) { return c.name_en.toLocaleLowerCase() === 'website'; });
|
|
295
|
+
var socialData = channels === null || channels === void 0 ? void 0 : channels.find(function (c) { return c.name_en.toLocaleLowerCase() === 'social'; });
|
|
296
|
+
if (isHasWebsite && (isHasTwitter || isHasInstagram))
|
|
297
|
+
selectedChannels = [websiteData, socialData];
|
|
298
|
+
else if (isHasTwitter || isHasInstagram)
|
|
299
|
+
selectedChannels = [socialData];
|
|
300
|
+
else if (isHasWebsite)
|
|
301
|
+
selectedChannels = [websiteData];
|
|
302
|
+
if (((_c = brand === null || brand === void 0 ? void 0 : brand.channel_services) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
303
|
+
selectedChannels = channels === null || channels === void 0 ? void 0 : channels.filter(function (channel) {
|
|
304
|
+
var _a;
|
|
305
|
+
return (_a = brand === null || brand === void 0 ? void 0 : brand.channel_services) === null || _a === void 0 ? void 0 : _a.find(function (storedChannel) { return channel.name_en.toLowerCase() === storedChannel.toLowerCase(); });
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
state.data.entityData.salesChannels = selectedChannels;
|
|
309
|
+
var activities = (entity === null || entity === void 0 ? void 0 : entity.activities) || [];
|
|
310
|
+
var selectedActivity = activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
|
|
311
|
+
var _a;
|
|
312
|
+
return (_a = brand === null || brand === void 0 ? void 0 : brand.activities) === null || _a === void 0 ? void 0 : _a.find(function (value) { var _a; return ((_a = activity.en) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === value.toLowerCase(); });
|
|
313
|
+
});
|
|
314
|
+
state.data.entityData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [activities === null || activities === void 0 ? void 0 : activities[0]];
|
|
315
|
+
state.data.entityData.responseBody = __assign(__assign({}, state.data.entityData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities, selectedActivities: (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [activities === null || activities === void 0 ? void 0 : activities[0]] });
|
|
238
316
|
state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), boardResponse), state.data.verify.responseBody), { board_id: data.id });
|
|
239
317
|
state.data.verify.token = token;
|
|
240
318
|
})
|
|
@@ -279,6 +357,27 @@ export var entitySlice = createSlice({
|
|
|
279
357
|
.addCase(verifyEntityLeadOTP.rejected, function (state, action) {
|
|
280
358
|
state.loading = false;
|
|
281
359
|
state.error = action.error.message;
|
|
360
|
+
})
|
|
361
|
+
.addCase(updateEntityInfo.pending, function (state) {
|
|
362
|
+
state.loading = true;
|
|
363
|
+
state.error = null;
|
|
364
|
+
})
|
|
365
|
+
.addCase(updateEntityInfo.fulfilled, function (state, action) {
|
|
366
|
+
var _a;
|
|
367
|
+
state.loading = false;
|
|
368
|
+
state.error = null;
|
|
369
|
+
var _b = action.payload, data = _b.data, formData = _b.formData;
|
|
370
|
+
var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
371
|
+
if (description) {
|
|
372
|
+
state.error = description;
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
state.data.entityData = formData;
|
|
376
|
+
state.data.entityData.responseBody = data;
|
|
377
|
+
})
|
|
378
|
+
.addCase(updateEntityInfo.rejected, function (state, action) {
|
|
379
|
+
state.loading = false;
|
|
380
|
+
state.error = action.error.message;
|
|
282
381
|
})
|
|
283
382
|
.addCase(retrieveBoardDetails.pending, function (state) {
|
|
284
383
|
state.error = null;
|
|
@@ -314,6 +413,42 @@ export var entitySlice = createSlice({
|
|
|
314
413
|
.addCase(updateBoardSuccess.rejected, function (state, action) {
|
|
315
414
|
state.loading = false;
|
|
316
415
|
state.error = action.error.message;
|
|
416
|
+
})
|
|
417
|
+
.addCase(retrieveChannels.pending, function (state) {
|
|
418
|
+
state.error = null;
|
|
419
|
+
state.loading = true;
|
|
420
|
+
})
|
|
421
|
+
.addCase(retrieveChannels.fulfilled, function (state, action) {
|
|
422
|
+
var _a;
|
|
423
|
+
state.error = null;
|
|
424
|
+
state.loading = false;
|
|
425
|
+
var data = action.payload || {};
|
|
426
|
+
var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
427
|
+
if (description) {
|
|
428
|
+
state.error = description;
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
var channels = data || [];
|
|
432
|
+
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { channelList: channels });
|
|
433
|
+
var brand = (state.data.verify.responseBody || {}).brand;
|
|
434
|
+
var selectedChannels = (!!(channels === null || channels === void 0 ? void 0 : channels[0]) && [channels === null || channels === void 0 ? void 0 : channels[0]]) || [];
|
|
435
|
+
var _b = brand || {}, website = _b.website, social = _b.social;
|
|
436
|
+
var isHasWebsite = (website === null || website === void 0 ? void 0 : website.length) > 0;
|
|
437
|
+
var isHasTwitter = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('twitter.com'); });
|
|
438
|
+
var isHasInstagram = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('instagram.com'); });
|
|
439
|
+
var websiteData = channels === null || channels === void 0 ? void 0 : channels.find(function (c) { return c.name_en.toLocaleLowerCase() === 'website'; });
|
|
440
|
+
var socialData = channels === null || channels === void 0 ? void 0 : channels.find(function (c) { return c.name_en.toLocaleLowerCase() === 'social'; });
|
|
441
|
+
if (isHasWebsite && (isHasTwitter || isHasInstagram))
|
|
442
|
+
selectedChannels = [websiteData, socialData];
|
|
443
|
+
else if (isHasTwitter || isHasInstagram)
|
|
444
|
+
selectedChannels = [socialData];
|
|
445
|
+
else if (isHasWebsite)
|
|
446
|
+
selectedChannels = [websiteData];
|
|
447
|
+
state.data.entityData.salesChannels = selectedChannels;
|
|
448
|
+
})
|
|
449
|
+
.addCase(retrieveChannels.rejected, function (state, action) {
|
|
450
|
+
state.error = action.error.message;
|
|
451
|
+
state.loading = false;
|
|
317
452
|
});
|
|
318
453
|
}
|
|
319
454
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LibConfig } from '../../@types';
|
|
3
|
+
export interface AuthLibProps extends LibConfig {
|
|
4
|
+
leadId: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function AuthLib(props: AuthLibProps): JSX.Element;
|
|
7
|
+
export declare function renderAuthLib(config: AuthLibProps, elementId: string): void;
|
|
8
|
+
export declare function unmountAuthLib(elementId: string): void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { memo, useEffect } from 'react';
|
|
14
|
+
import { FeatureContainer } from '../shared/Containers';
|
|
15
|
+
import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener } from '../../hooks';
|
|
16
|
+
import { settingsSelector } from '../../app/settings';
|
|
17
|
+
import AnimationFlow from '../../components/AnimationFlow';
|
|
18
|
+
import { store } from '../../app/store';
|
|
19
|
+
import { authSelector } from '../app/auth/authStore';
|
|
20
|
+
import { ReduxProvider, ThemeProvider } from '../../components/Providers';
|
|
21
|
+
import Collapse from '../../components/Collapse';
|
|
22
|
+
import { reactElement } from '../../utils';
|
|
23
|
+
import { AUTH_SCREENS_NAVIGATION } from '../../constants';
|
|
24
|
+
import { authFeatureScreens } from '../featuresScreens';
|
|
25
|
+
import Background from '../shared/Background';
|
|
26
|
+
import CustomFooter from '../shared/Footer';
|
|
27
|
+
var Auth = memo(function (props) {
|
|
28
|
+
var theme = useAppTheme().theme;
|
|
29
|
+
var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
|
|
30
|
+
var authError = useAppSelector(authSelector).error;
|
|
31
|
+
useAppConfig(__assign({ navigation: AUTH_SCREENS_NAVIGATION }, props));
|
|
32
|
+
useErrorListener(authError || error);
|
|
33
|
+
useStepStartedListener();
|
|
34
|
+
var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open;
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
if (!props.leadId)
|
|
37
|
+
throw new Error('leadId is required');
|
|
38
|
+
}, []);
|
|
39
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading, error: error, open: open, footer: _jsx(CustomFooter, {}), screenId: activeScreen.name }, { children: _jsx(FeatureContainer, { children: authFeatureScreens.map(function (_a, index) {
|
|
40
|
+
var Element = _a.element, name = _a.name;
|
|
41
|
+
var isActive = activeScreen.name === name;
|
|
42
|
+
return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));
|
|
43
|
+
}) }) })) })) })));
|
|
44
|
+
});
|
|
45
|
+
export function AuthLib(props) {
|
|
46
|
+
return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(Auth, __assign({}, props)) })));
|
|
47
|
+
}
|
|
48
|
+
export function renderAuthLib(config, elementId) {
|
|
49
|
+
reactElement(elementId).render(_jsx(AuthLib, __assign({}, config)));
|
|
50
|
+
}
|
|
51
|
+
export function unmountAuthLib(elementId) {
|
|
52
|
+
reactElement(elementId).unmount();
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Auth';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Auth';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import Box from '@mui/material/Box/Box';
|
|
14
|
+
import { styled } from '@mui/material/styles';
|
|
15
|
+
import * as React from 'react';
|
|
16
|
+
import { useTranslation } from 'react-i18next';
|
|
17
|
+
import Text from '../../../../components/Text';
|
|
18
|
+
import { clearError, authSelector, resetOTPScreen, verifyAuth } from '../../../app/auth/authStore';
|
|
19
|
+
import Button from '../../../shared/Button';
|
|
20
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
21
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
22
|
+
import { useLanguage } from '../../../../hooks';
|
|
23
|
+
import { useForm, FormProvider } from 'react-hook-form';
|
|
24
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
25
|
+
import Form from '../../../../components/Form';
|
|
26
|
+
import { maskPhone } from '../../../../utils';
|
|
27
|
+
import { OTPValidation } from './validation';
|
|
28
|
+
import OTPInput from './OTPInput';
|
|
29
|
+
var OTPTitleContainerStyled = styled(Box)(function (_a) {
|
|
30
|
+
var theme = _a.theme;
|
|
31
|
+
return ({
|
|
32
|
+
background: theme.palette.common.white,
|
|
33
|
+
border: '1px solid',
|
|
34
|
+
borderColor: theme.palette.divider,
|
|
35
|
+
direction: theme.direction,
|
|
36
|
+
borderRadius: theme.spacing(0, 0, 1.25, 1.25),
|
|
37
|
+
marginBottom: theme.spacing(5.75)
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
var OTPTitleStyled = styled(Text)(function (_a) {
|
|
41
|
+
var theme = _a.theme;
|
|
42
|
+
return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInline: theme.spacing(2.5), lineHeight: 1.75, whiteSpace: 'pre-line' }));
|
|
43
|
+
});
|
|
44
|
+
var FormStyled = styled(Form)(function () { return ({
|
|
45
|
+
display: 'flex',
|
|
46
|
+
flexDirection: 'column'
|
|
47
|
+
}); });
|
|
48
|
+
var OTP = function () {
|
|
49
|
+
var dispatch = useAppDispatch();
|
|
50
|
+
var _a = useAppSelector(authSelector), data = _a.data, loading = _a.loading, error = _a.error;
|
|
51
|
+
var methods = useForm({
|
|
52
|
+
resolver: yupResolver(OTPValidation),
|
|
53
|
+
defaultValues: { otp: '' },
|
|
54
|
+
mode: 'onChange'
|
|
55
|
+
});
|
|
56
|
+
var t = useTranslation().t;
|
|
57
|
+
var isAr = useLanguage().isAr;
|
|
58
|
+
React.useEffect(function () {
|
|
59
|
+
if (error)
|
|
60
|
+
dispatch(clearError());
|
|
61
|
+
return function () {
|
|
62
|
+
dispatch(resetOTPScreen());
|
|
63
|
+
};
|
|
64
|
+
}, [methods.formState.isValid]);
|
|
65
|
+
var onSubmit = function (formData) {
|
|
66
|
+
dispatch(verifyAuth(formData));
|
|
67
|
+
};
|
|
68
|
+
var disabled = !methods.formState.isValid || !!error;
|
|
69
|
+
var phone = data.mobileNumber || '+966 522556154';
|
|
70
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : t('ide_opt_sent_title'), !loading && _jsx("span", __assign({ dir: 'ltr' }, { children: maskPhone(phone) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disabled: disabled, disableBack: true, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('confirm') }))] })) })) }));
|
|
71
|
+
};
|
|
72
|
+
export default React.memo(OTP);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import Box from '@mui/material/Box/Box';
|
|
17
|
+
import { styled } from '@mui/material/styles';
|
|
18
|
+
import OTPField from '../../../shared/OTP';
|
|
19
|
+
import { DEFAULT_TIMER_VALUE } from '../../../../constants';
|
|
20
|
+
import { useAppDispatch } from '../../../../hooks';
|
|
21
|
+
var BoxStyled = styled(Box)(function (_a) {
|
|
22
|
+
var theme = _a.theme;
|
|
23
|
+
return ({
|
|
24
|
+
display: 'flex',
|
|
25
|
+
flexDirection: 'column',
|
|
26
|
+
fontFamily: theme.typography.fontFamily
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
var OTPInput = function (_a) {
|
|
30
|
+
var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
|
|
31
|
+
var t = useTranslation().t;
|
|
32
|
+
var dispatch = useAppDispatch();
|
|
33
|
+
var otpControl = useController({ name: 'otp', control: control });
|
|
34
|
+
var handleOnOTPChange = function (otp) {
|
|
35
|
+
otpControl.field.onChange(otp);
|
|
36
|
+
};
|
|
37
|
+
var handleOnResendOTP = function () {
|
|
38
|
+
if (otpControl.field.value)
|
|
39
|
+
setValue('otp', '', { shouldValidate: true });
|
|
40
|
+
};
|
|
41
|
+
var otpValue = otpControl.field.value;
|
|
42
|
+
return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendOTP, value: otpValue, onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
|
|
43
|
+
};
|
|
44
|
+
export default React.memo(OTPInput);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as yup from 'yup';
|
|
2
|
+
export declare const OTPValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
4
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
5
|
+
otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
6
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
7
|
+
otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
8
|
+
}>>>;
|
|
@@ -28,16 +28,18 @@ import BrandName from './BrandName';
|
|
|
28
28
|
import SocialMedia from './SocialMedia';
|
|
29
29
|
import TAC from './TAC';
|
|
30
30
|
import BrandList from './BrandList';
|
|
31
|
+
import SalesChannels from './SalesChannels';
|
|
31
32
|
var Merchant = function (_a) {
|
|
32
|
-
var _b, _c
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
33
|
+
var _b, _c;
|
|
34
|
+
var _d = React.useState(false), brandNameChecking = _d[0], setBrandNameChecking = _d[1];
|
|
35
|
+
var _e = React.useState(ValidationOptions.NEW_USER), userType = _e[0], setUserType = _e[1];
|
|
36
|
+
var _f = React.useState(false), listActive = _f[0], setListActive = _f[1];
|
|
37
|
+
var _g = useAppSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
|
|
37
38
|
var isNewUser = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.new_user;
|
|
38
39
|
var isAbsher = data.otpData.isAbsher;
|
|
39
|
-
var
|
|
40
|
-
var
|
|
40
|
+
var _h = data.brandData.responseBody || {}, brands = _h.brands, channelList = _h.channelList;
|
|
41
|
+
var brandList = brands || [];
|
|
42
|
+
var _j = data.brandData, brandName = _j.brandName, links = _j.links, selectedBrandItem = _j.selectedBrandItem, termAndConditionChecked = _j.termAndConditionChecked, responseBody = _j.responseBody, salesChannels = _j.salesChannels;
|
|
41
43
|
var methods = useForm({
|
|
42
44
|
resolver: yupResolver(MerchantValidationSchema(userType)),
|
|
43
45
|
defaultValues: {
|
|
@@ -82,6 +84,7 @@ var Merchant = function (_a) {
|
|
|
82
84
|
var sites = { website: '', twitter: '', instagram: '' };
|
|
83
85
|
methods.setValue('brandName', '', { shouldValidate: true });
|
|
84
86
|
methods.setValue('links', sites);
|
|
87
|
+
methods.setValue('salesChannels', []);
|
|
85
88
|
}, 100);
|
|
86
89
|
}
|
|
87
90
|
if (isNewUser === false && (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0 && (formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) !== 'other') {
|
|
@@ -92,18 +95,35 @@ var Merchant = function (_a) {
|
|
|
92
95
|
var website = (_e = formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.website) === null || _e === void 0 ? void 0 : _e.replaceAll(/(https|http):\/\//g, '');
|
|
93
96
|
var sites_1 = __assign(__assign({}, links), { website: website, twitter: twitter, instagram: instagram });
|
|
94
97
|
setTimeout(function () { return methods.setValue('links', sites_1, { shouldValidate: true }); }, 100);
|
|
98
|
+
var selectedChannels = (!!(channelList === null || channelList === void 0 ? void 0 : channelList[0]) && [channelList === null || channelList === void 0 ? void 0 : channelList[0]]) || [];
|
|
99
|
+
var _f = formDataSelectedBrand || {}, websiteUrl = _f.website, social = _f.social;
|
|
100
|
+
var isHasWebsite = (websiteUrl === null || websiteUrl === void 0 ? void 0 : websiteUrl.length) > 0;
|
|
101
|
+
var isHasTwitter = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('twitter.com'); });
|
|
102
|
+
var isHasInstagram = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('instagram.com'); });
|
|
103
|
+
var websiteData = channelList === null || channelList === void 0 ? void 0 : channelList.find(function (c) { return c.name_en.toLocaleLowerCase() === 'website'; });
|
|
104
|
+
var socialData = channelList === null || channelList === void 0 ? void 0 : channelList.find(function (c) { return c.name_en.toLocaleLowerCase() === 'social'; });
|
|
105
|
+
if (isHasWebsite && (isHasTwitter || isHasInstagram))
|
|
106
|
+
selectedChannels = [websiteData, socialData];
|
|
107
|
+
else if (isHasTwitter || isHasInstagram)
|
|
108
|
+
selectedChannels = [socialData];
|
|
109
|
+
else if (isHasWebsite)
|
|
110
|
+
selectedChannels = [websiteData];
|
|
111
|
+
methods.setValue('salesChannels', selectedChannels);
|
|
95
112
|
}
|
|
96
113
|
}, [formDataSelectedBrand, isNewUser]);
|
|
97
114
|
React.useEffect(function () {
|
|
98
115
|
if (!(formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) && (selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id))
|
|
99
116
|
methods.setValue('selectedBrandItem', selectedBrandItem, { shouldValidate: true });
|
|
100
117
|
}, [selectedBrandItem]);
|
|
118
|
+
React.useEffect(function () {
|
|
119
|
+
methods.setValue('salesChannels', salesChannels);
|
|
120
|
+
}, [salesChannels]);
|
|
101
121
|
var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
|
|
102
|
-
var disabled = brandErrChecks || brandNameChecking || ((
|
|
122
|
+
var disabled = brandErrChecks || brandNameChecking || ((_c = data.brandData.responseBody) === null || _c === void 0 ? void 0 : _c.response_code) === '5';
|
|
103
123
|
var isBrandListAvailable = userType !== ValidationOptions.NEW_USER && brandList.length > 0;
|
|
104
124
|
var askingForBrandInfo = userType === ValidationOptions.NEW_USER ||
|
|
105
125
|
brandList.length === 0 ||
|
|
106
126
|
userType === ValidationOptions.EXISTING_USER_WITH_OTHER_BRAND;
|
|
107
|
-
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: isBrandListAvailable, list: brandList, onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); } }), _jsx(BrandName, { show: !listActive && askingForBrandInfo, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(SocialMedia, { show: !listActive, isNewUser: isNewUser }), _jsx(TAC, { show: !listActive && askingForBrandInfo }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
|
|
127
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: isBrandListAvailable, list: brandList, onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); } }), _jsx(BrandName, { show: !listActive && askingForBrandInfo, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(SalesChannels, {}) })), _jsx(SocialMedia, { show: !listActive, isNewUser: isNewUser }), _jsx(TAC, { show: !listActive && askingForBrandInfo }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
|
|
108
128
|
};
|
|
109
129
|
export default React.memo(Merchant);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare const MandatoryStyled: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
3
|
+
export declare const CollapseStyled: import("@emotion/styled").StyledComponent<import("../../../../components/Collapse").CollapseProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
4
|
+
declare const SalesChannels: () => JSX.Element;
|
|
5
|
+
export default SalesChannels;
|