@tap-payments/auth-jsconnect 2.8.45-test → 2.8.49-development
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 +1 -0
- package/build/features/app/bank/bankStore.js +13 -6
- package/build/features/app/brand/brandStore.js +97 -69
- package/build/features/app/business/businessStore.js +7 -1
- package/build/features/app/connectExpress/connectExpressStore.js +8 -1
- package/build/features/app/entity/entityStore.d.ts +5 -1
- package/build/features/app/entity/entityStore.js +62 -43
- package/build/features/app/individual/individualStore.d.ts +1 -1
- package/build/features/app/individual/individualStore.js +27 -18
- package/build/features/app/tax/taxStore.js +1 -0
- package/build/features/auth/screens/AuthSwitch/AuthSwitch.js +13 -1
- package/build/features/auth/screens/BusinessCountry/BusinessCountry.js +7 -1
- package/build/features/bank/screens/BankDetails/BankDetails.js +7 -2
- package/build/features/brand/screens/BrandActivities/BrandActivities.js +48 -11
- package/build/features/brand/screens/BrandInfo/BrandInfo.js +22 -4
- package/build/features/brand/screens/BrandSegmentInfo/BrandSegmentInfo.js +22 -6
- package/build/features/business/screens/Activities/Activities.js +11 -2
- package/build/features/business/screens/BusinessType/BusinessType.js +9 -1
- package/build/features/business/screens/Customers/Customers.js +11 -2
- package/build/features/business/screens/IDBOD/IDBOD.js +9 -1
- package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +12 -1
- package/build/features/business/screens/Verify/Verify.js +12 -2
- package/build/features/connect/Connect.js +3 -2
- package/build/features/connect/screens/BusinessCountry/BusinessCountry.js +7 -1
- package/build/features/connect/screens/Mobile/Mobile.js +10 -7
- package/build/features/connectExpress/ConnectExpress.js +2 -1
- package/build/features/connectExpress/screens/BusinessCountry/BusinessCountry.js +7 -1
- package/build/features/connectExpress/screens/Mobile/Mobile.js +8 -1
- package/build/features/entity/screens/EntityCapital/EntityCapital.js +33 -9
- package/build/features/entity/screens/EntityName/EntityName.js +31 -14
- package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +43 -10
- package/build/features/individual/screens/IndividualList/IndividualList.js +7 -0
- package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.js +73 -18
- package/build/features/shared/Button/FlowsButtons.js +10 -1
- package/build/hooks/useFormDirtyCheck.d.ts +5 -1
- package/build/hooks/useFormDirtyCheck.js +47 -10
- package/package.json +2 -2
|
@@ -63,7 +63,7 @@ import { BusinessType, DocumentPurpose, FlowsTypes, LicenseType } from '../../..
|
|
|
63
63
|
import { handleNextScreenStep, handlePrevScreenStep, handlePublicKey, handleSetCountryByIso2, onCloseComplete } from '../../../app/settings';
|
|
64
64
|
import { ENTITY_STEP_NAMES } from '../../../constants';
|
|
65
65
|
import moment from 'moment';
|
|
66
|
-
import { convertNumbers2English, getRecentDocumentBasedOnPurpose, hasVerifiedValue, hasNoneEditableValue, sleep, formatNumberAsCurrency, removeAllCharsFromNumber, retrieveIndividualData } from '../../../utils';
|
|
66
|
+
import { convertNumbers2English, getRecentDocumentBasedOnPurpose, hasVerifiedValue, hasNoneEditableValue, sleep, formatNumberAsCurrency, removeAllCharsFromNumber, retrieveIndividualData, sendCustomEventToGTM } from '../../../utils';
|
|
67
67
|
export var verifyLeadToken = createAsyncThunk('entityVerifyLeadToken', function (_a, thunkApi) {
|
|
68
68
|
var token = _a.token, isInternally = _a.isInternally;
|
|
69
69
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -247,15 +247,16 @@ export var retrieveBoardDetails = createAsyncThunk('entityRetrieveEntityInfo', f
|
|
|
247
247
|
});
|
|
248
248
|
});
|
|
249
249
|
export var updateEntityName = createAsyncThunk('entityUpdateEntityName', function (_a, thunkApi) {
|
|
250
|
-
var formData = _a.formData, originalFormData = _a.originalFormData;
|
|
250
|
+
var formData = _a.formData, originalFormData = _a.originalFormData, isDirty = _a.isDirty;
|
|
251
251
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
252
|
-
var _b, settings, entity, _c, id, data_status, data_verification, documents, issuingDate, expiryDate, licenseType, licenseNumber, articleId, unifiedNumber, legalName, certificateId, entityType, issueDate, expDate, isFL, isLegalNameENNonEditable, isLegalNameARNonEditable, isLicenseTypeNonEditable, isEntityTypeNonEditable, isLicenseNumberNonEditable, isUnifiedNumberNonEditable, isIssuingDateNonEditable, isExpiryDateNonEditable, isDocumentsNonEditable, isAOAFileNonEditable, isEntityTypeVerified, isLicenseNonEditable, isLicenseAvailable, payload,
|
|
253
|
-
var _d, _e
|
|
254
|
-
return __generator(this, function (
|
|
255
|
-
switch (
|
|
252
|
+
var _b, settings, entity, entityRes, _c, id, data_status, data_verification, documents, issuingDate, expiryDate, licenseType, licenseNumber, articleId, unifiedNumber, legalName, certificateId, entityType, issueDate, expDate, isFL, isLegalNameENNonEditable, isLegalNameARNonEditable, isLicenseTypeNonEditable, isEntityTypeNonEditable, isLicenseNumberNonEditable, isUnifiedNumberNonEditable, isIssuingDateNonEditable, isExpiryDateNonEditable, isDocumentsNonEditable, isAOAFileNonEditable, isEntityTypeVerified, isLicenseNonEditable, isLicenseAvailable, payload, entityData, documentData, activityList, entity_1, documentResponse, document, documentBody, documentBody, entity_2, list;
|
|
253
|
+
var _d, _e;
|
|
254
|
+
return __generator(this, function (_f) {
|
|
255
|
+
switch (_f.label) {
|
|
256
256
|
case 0:
|
|
257
257
|
_b = thunkApi.getState(), settings = _b.settings, entity = _b.entity;
|
|
258
|
-
|
|
258
|
+
entityRes = (entity.data.verify.responseBody || {}).entity;
|
|
259
|
+
_c = entityRes || {}, id = _c.id, data_status = _c.data_status, data_verification = _c.data_verification, documents = _c.documents;
|
|
259
260
|
issuingDate = formData.issuingDate, expiryDate = formData.expiryDate, licenseType = formData.licenseType, licenseNumber = formData.licenseNumber, articleId = formData.articleId, unifiedNumber = formData.unifiedNumber, legalName = formData.legalName, certificateId = formData.certificateId, entityType = formData.entityType;
|
|
260
261
|
issueDate = issuingDate && new Date(issuingDate).getTime();
|
|
261
262
|
expDate = expiryDate && new Date(expiryDate).getTime();
|
|
@@ -295,22 +296,27 @@ export var updateEntityName = createAsyncThunk('entityUpdateEntityName', functio
|
|
|
295
296
|
'license.additional_info.unified_number',
|
|
296
297
|
'type'
|
|
297
298
|
] });
|
|
299
|
+
entityData = entityRes, activityList = undefined;
|
|
300
|
+
if (!isDirty) return [3, 2];
|
|
298
301
|
return [4, API.entityService.updateEntity(payload)];
|
|
299
302
|
case 1:
|
|
300
|
-
|
|
303
|
+
entity_1 = (_f.sent()).entity;
|
|
304
|
+
entityData = entity_1;
|
|
305
|
+
_f.label = 2;
|
|
306
|
+
case 2:
|
|
301
307
|
documentResponse = undefined;
|
|
302
308
|
document = getRecentDocumentBasedOnPurpose(documents, DocumentPurpose.CR);
|
|
303
|
-
if (!(!isDocumentsNonEditable && (certificateId || []).length > 0)) return [3,
|
|
304
|
-
if (!(document === null || document === void 0 ? void 0 : document.id)) return [3,
|
|
309
|
+
if (!(!isDocumentsNonEditable && (certificateId || []).length > 0)) return [3, 8];
|
|
310
|
+
if (!(document === null || document === void 0 ? void 0 : document.id)) return [3, 4];
|
|
305
311
|
documentBody = {
|
|
306
312
|
id: document.id,
|
|
307
313
|
images: certificateId
|
|
308
314
|
};
|
|
309
315
|
return [4, API.documentService.addFilesToExistingDocument(documentBody)];
|
|
310
|
-
case 2:
|
|
311
|
-
documentResponse = _g.sent();
|
|
312
|
-
return [3, 5];
|
|
313
316
|
case 3:
|
|
317
|
+
documentResponse = _f.sent();
|
|
318
|
+
return [3, 6];
|
|
319
|
+
case 4:
|
|
314
320
|
documentBody = {
|
|
315
321
|
entity_id: id || '',
|
|
316
322
|
documents: [
|
|
@@ -321,45 +327,48 @@ export var updateEntityName = createAsyncThunk('entityUpdateEntityName', functio
|
|
|
321
327
|
]
|
|
322
328
|
};
|
|
323
329
|
return [4, API.documentService.updateDocumentInfo(documentBody)];
|
|
324
|
-
case
|
|
325
|
-
documentResponse =
|
|
326
|
-
|
|
327
|
-
case
|
|
328
|
-
case
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
case 8:
|
|
334
|
-
|
|
335
|
-
|
|
330
|
+
case 5:
|
|
331
|
+
documentResponse = _f.sent();
|
|
332
|
+
_f.label = 6;
|
|
333
|
+
case 6: return [4, API.entityService.retrieveEntity(id)];
|
|
334
|
+
case 7:
|
|
335
|
+
entity_2 = (_f.sent()).entity;
|
|
336
|
+
entityData = entity_2;
|
|
337
|
+
documentData = documentResponse;
|
|
338
|
+
_f.label = 8;
|
|
339
|
+
case 8: return [4, API.dataService.getActivitiesIsIc()];
|
|
340
|
+
case 9:
|
|
341
|
+
list = (_f.sent()).list;
|
|
342
|
+
activityList = list;
|
|
336
343
|
sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep()); });
|
|
337
|
-
(
|
|
338
|
-
return [2, { data:
|
|
344
|
+
(_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, id);
|
|
345
|
+
return [2, { data: { entity: entityData, documentData: documentData, activityList: activityList }, formData: originalFormData }];
|
|
339
346
|
}
|
|
340
347
|
});
|
|
341
348
|
});
|
|
342
349
|
});
|
|
343
350
|
export var updateEntityCapital = createAsyncThunk('entityUpdateEntityCapital', function (_a, thunkApi) {
|
|
344
|
-
var formData = _a.formData, originalFormData = _a.originalFormData;
|
|
351
|
+
var formData = _a.formData, originalFormData = _a.originalFormData, isDirty = _a.isDirty;
|
|
345
352
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
346
|
-
var _b, settings, entity, _c, id, data_status, entityActivities, isCapitalPaidNonEditable, isCapitalShareCountNonEditable, isCapitalShareValueNonEditable, isActivitiesNonEditable, capitalShareCount, capitalShareValue, activities, capitalPaid, hasCapitalShares, isCapitalNonEditable, removedActivities, payload_1, activityIds, payload,
|
|
347
|
-
var _d, _e
|
|
348
|
-
return __generator(this, function (
|
|
349
|
-
switch (
|
|
353
|
+
var _b, settings, entity, entityRes, _c, id, data_status, entityActivities, isCapitalPaidNonEditable, isCapitalShareCountNonEditable, isCapitalShareValueNonEditable, isActivitiesNonEditable, capitalShareCount, capitalShareValue, activities, capitalPaid, entityData, hasCapitalShares, isCapitalNonEditable, removedActivities, payload_1, activityIds, payload, entity_3;
|
|
354
|
+
var _d, _e;
|
|
355
|
+
return __generator(this, function (_f) {
|
|
356
|
+
switch (_f.label) {
|
|
350
357
|
case 0:
|
|
351
358
|
_b = thunkApi.getState(), settings = _b.settings, entity = _b.entity;
|
|
352
|
-
|
|
359
|
+
entityRes = (entity.data.verify.responseBody || {}).entity;
|
|
360
|
+
_c = entityRes || {}, id = _c.id, data_status = _c.data_status, entityActivities = _c.activities;
|
|
353
361
|
isCapitalPaidNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.capital, 'paid');
|
|
354
362
|
isCapitalShareCountNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.capital, 'shares.count');
|
|
355
363
|
isCapitalShareValueNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.capital, 'shares.value');
|
|
356
364
|
isActivitiesNonEditable = hasNoneEditableValue(data_status, 'activities');
|
|
357
365
|
capitalShareCount = formData.capitalShareCount, capitalShareValue = formData.capitalShareValue, activities = formData.activities, capitalPaid = formData.capitalPaid;
|
|
366
|
+
entityData = entityRes;
|
|
358
367
|
hasCapitalShares = capitalShareCount || capitalShareValue;
|
|
359
368
|
isCapitalNonEditable = (isCapitalPaidNonEditable && isCapitalShareCountNonEditable && isCapitalShareValueNonEditable) || (!capitalPaid && !hasCapitalShares);
|
|
360
369
|
removedActivities = (activities === null || activities === void 0 ? void 0 : activities.length) > 0 &&
|
|
361
370
|
(entityActivities || []).filter(function (entityActivity) { return !(activities || []).some(function (activity) { return activity.id === entityActivity.id; }); });
|
|
362
|
-
if (!(!isActivitiesNonEditable && (removedActivities === null || removedActivities === void 0 ? void 0 : removedActivities.length) > 0)) return [3, 2];
|
|
371
|
+
if (!(!isActivitiesNonEditable && (removedActivities === null || removedActivities === void 0 ? void 0 : removedActivities.length) > 0 && isDirty)) return [3, 2];
|
|
363
372
|
payload_1 = {
|
|
364
373
|
id: id,
|
|
365
374
|
activities: removedActivities.map(function (a) { return ({
|
|
@@ -368,8 +377,8 @@ export var updateEntityCapital = createAsyncThunk('entityUpdateEntityCapital', f
|
|
|
368
377
|
};
|
|
369
378
|
return [4, API.entityService.removeEntityActivities(payload_1)];
|
|
370
379
|
case 1:
|
|
371
|
-
|
|
372
|
-
|
|
380
|
+
_f.sent();
|
|
381
|
+
_f.label = 2;
|
|
373
382
|
case 2:
|
|
374
383
|
activityIds = (activities || []).map(function (_a) {
|
|
375
384
|
var id = _a.id;
|
|
@@ -383,12 +392,16 @@ export var updateEntityCapital = createAsyncThunk('entityUpdateEntityCapital', f
|
|
|
383
392
|
}
|
|
384
393
|
}))
|
|
385
394
|
}));
|
|
395
|
+
if (!isDirty) return [3, 4];
|
|
386
396
|
return [4, API.entityService.updateEntity(payload)];
|
|
387
397
|
case 3:
|
|
388
|
-
|
|
398
|
+
entity_3 = (_f.sent()).entity;
|
|
399
|
+
entityData = entity_3;
|
|
400
|
+
_f.label = 4;
|
|
401
|
+
case 4:
|
|
389
402
|
thunkApi.dispatch(handleNextScreenStep());
|
|
390
|
-
(
|
|
391
|
-
return [2, { data:
|
|
403
|
+
(_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, id);
|
|
404
|
+
return [2, { data: entityData, formData: originalFormData }];
|
|
392
405
|
}
|
|
393
406
|
});
|
|
394
407
|
});
|
|
@@ -412,6 +425,12 @@ export var updateBoardSuccess = createAsyncThunk('updateBoardEntitySuccess', fun
|
|
|
412
425
|
return [4, API.boardService.updateBoardInfo(__assign({ id: board_id, infoId: infoId }, payload))];
|
|
413
426
|
case 1:
|
|
414
427
|
data = _p.sent();
|
|
428
|
+
sendCustomEventToGTM({
|
|
429
|
+
event: 'Send Event',
|
|
430
|
+
event_category: 'Board Flows - Entity',
|
|
431
|
+
event_action: 'Entity Update Success Page',
|
|
432
|
+
event_label: settings.data.businessCountry.iso2
|
|
433
|
+
});
|
|
415
434
|
if (!showBoard && mode === 'content') {
|
|
416
435
|
(_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, {});
|
|
417
436
|
(_h = (_g = settings.data.appConfig).onFlowCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, { data: data });
|
|
@@ -642,12 +661,12 @@ export var entitySlice = createSlice({
|
|
|
642
661
|
state.loading = false;
|
|
643
662
|
state.error = null;
|
|
644
663
|
var _a = action.payload, data = _a.data, formData = _a.formData;
|
|
645
|
-
var _b = data || {}, activityList = _b.activityList, rest = __rest(_b, ["activityList"]);
|
|
664
|
+
var _b = data || {}, entity = _b.entity, activityList = _b.activityList, rest = __rest(_b, ["entity", "activityList"]);
|
|
646
665
|
state.data.entityNameData = __assign(__assign({}, formData), { certificateId: undefined });
|
|
647
666
|
state.data.entityNameData.responseBody = __assign(__assign({}, state.data.entityNameData.responseBody), { rest: rest });
|
|
648
|
-
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { entity:
|
|
649
|
-
if (
|
|
650
|
-
state.data.entityCapitalData = __assign(__assign({}, state.data.entityCapitalData), { activities:
|
|
667
|
+
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { entity: entity, activityList: activityList });
|
|
668
|
+
if (entity === null || entity === void 0 ? void 0 : entity.activities)
|
|
669
|
+
state.data.entityCapitalData = __assign(__assign({}, state.data.entityCapitalData), { activities: entity === null || entity === void 0 ? void 0 : entity.activities });
|
|
651
670
|
})
|
|
652
671
|
.addCase(updateEntityName.rejected, function (state, action) {
|
|
653
672
|
state.loading = false;
|
|
@@ -211,7 +211,7 @@ export declare const updateIndividualPersonalInfo: import("@reduxjs/toolkit").As
|
|
|
211
211
|
export declare const updateIndividualInfo: import("@reduxjs/toolkit").AsyncThunk<{
|
|
212
212
|
data: any;
|
|
213
213
|
formData: IndividualExtraFormValues;
|
|
214
|
-
individualData:
|
|
214
|
+
individualData: any;
|
|
215
215
|
userList: any;
|
|
216
216
|
isKWOrSACountry: boolean;
|
|
217
217
|
}, AsyncThunkParams<IndividualExtraFormValues>, {
|
|
@@ -562,9 +562,9 @@ export var updatePhoneInfo = createAsyncThunk('individual/updatePhoneInfo', func
|
|
|
562
562
|
});
|
|
563
563
|
});
|
|
564
564
|
export var updateIndividualPersonalInfo = createAsyncThunk('individual/updateIndividualPersonalInfo', function (_a, thunkApi) {
|
|
565
|
-
var formData = _a.formData, originalFormData = _a.originalFormData;
|
|
565
|
+
var formData = _a.formData, originalFormData = _a.originalFormData, isDirty = _a.isDirty;
|
|
566
566
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
567
|
-
var _b, settings, individual, _c, recipient, user, entity, id,
|
|
567
|
+
var _b, settings, individual, _c, recipient, user, entity, id, countryCode, name, email, mobile, gender, nid, issuedCountry, expiryDate, dob, placeOfBirthCountry, placeOfBirthCity, nationality, code, _d, data_status, objects, ids, userName, identification_id_type, isGenderNonEditable, isNameENNonEditable, isNameARNonEditable, isEmailNonEditable, isMobileNumberNonEditable, isMobileCountryNonEditable, isNidNonEditable, isIssuedCountryNonEditable, isExpiryNonEditable, isIdTypeNonEditable, isNationalityNonEditable, isDOBNonEditable, isBirthCityNonEditable, isBirthCountryNonEditable, hasContact, hasPhone, hasIdentification, hasBirth, nameIsEditable, contact, requestBody, individualData, data, _e, isUser, isBuyer, isUserORBuyerType;
|
|
568
568
|
var _f, _g, _h, _j, _k;
|
|
569
569
|
return __generator(this, function (_l) {
|
|
570
570
|
switch (_l.label) {
|
|
@@ -572,11 +572,10 @@ export var updateIndividualPersonalInfo = createAsyncThunk('individual/updateInd
|
|
|
572
572
|
_b = thunkApi.getState(), settings = _b.settings, individual = _b.individual;
|
|
573
573
|
_c = individual.data.verify.responseBody || {}, recipient = _c.recipient, user = _c.user, entity = _c.entity;
|
|
574
574
|
id = (((user === null || user === void 0 ? void 0 : user.is_authorized) ? user : recipient) || {}).id;
|
|
575
|
-
_d = user || {}, objects = _d.objects, ids = _d.ids;
|
|
576
575
|
countryCode = (originalFormData || {}).countryCode;
|
|
577
576
|
name = formData.name, email = formData.email, mobile = formData.mobile, gender = formData.gender, nid = formData.nid, issuedCountry = formData.issuedCountry, expiryDate = formData.expiryDate, dob = formData.dob, placeOfBirthCountry = formData.placeOfBirthCountry, placeOfBirthCity = formData.placeOfBirthCity, nationality = formData.nationality;
|
|
578
577
|
code = entity === null || entity === void 0 ? void 0 : entity.country;
|
|
579
|
-
|
|
578
|
+
_d = user || {}, data_status = _d.data_status, objects = _d.objects, ids = _d.ids;
|
|
580
579
|
userName = getUserNameObject(name);
|
|
581
580
|
identification_id_type = nid ? (nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA) : undefined;
|
|
582
581
|
if (isOtherThanKWOrSA(settings.data.businessCountry.iso2)) {
|
|
@@ -645,28 +644,33 @@ export var updateIndividualPersonalInfo = createAsyncThunk('individual/updateInd
|
|
|
645
644
|
'date_of_birth',
|
|
646
645
|
'nationality'
|
|
647
646
|
], step_name: INDIVIDUAl_STEP_NAMES.INDIVIDUAl_PERSONAL_INFO });
|
|
647
|
+
individualData = undefined;
|
|
648
|
+
if (!isDirty) return [3, 2];
|
|
648
649
|
return [4, API.individualService.updateMultipleIndividual(requestBody)];
|
|
649
650
|
case 1:
|
|
650
651
|
data = _l.sent();
|
|
652
|
+
individualData = data;
|
|
653
|
+
_l.label = 2;
|
|
654
|
+
case 2:
|
|
651
655
|
_e = getIndividualType(objects), isUser = _e.isUser, isBuyer = _e.isBuyer;
|
|
652
656
|
isUserORBuyerType = isUser || isBuyer;
|
|
653
|
-
if (!isUserORBuyerType) return [3,
|
|
657
|
+
if (!isUserORBuyerType) return [3, 4];
|
|
654
658
|
return [4, thunkApi.dispatch(retrieveDataList(code))];
|
|
655
|
-
case 2:
|
|
656
|
-
_l.sent();
|
|
657
|
-
_l.label = 3;
|
|
658
659
|
case 3:
|
|
660
|
+
_l.sent();
|
|
661
|
+
_l.label = 4;
|
|
662
|
+
case 4:
|
|
659
663
|
sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep()); });
|
|
660
664
|
(_k = (_j = settings.data.appConfig).onStepCompleted) === null || _k === void 0 ? void 0 : _k.call(_j, settings.data.activeScreen.name, requestBody);
|
|
661
|
-
return [2, { data:
|
|
665
|
+
return [2, { data: individualData, formData: originalFormData }];
|
|
662
666
|
}
|
|
663
667
|
});
|
|
664
668
|
});
|
|
665
669
|
});
|
|
666
670
|
export var updateIndividualInfo = createAsyncThunk('updateIndividualInfo', function (_a, thunkApi) {
|
|
667
|
-
var formData = _a.formData, originalFormData = _a.originalFormData;
|
|
671
|
+
var formData = _a.formData, originalFormData = _a.originalFormData, isDirty = _a.isDirty;
|
|
668
672
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
669
|
-
var _b, settings, individual, _c, recipient, user, userList, business, id, _d, objects, ids, isKWOrSAValue, occupation, sourceIncome, monthlyIncome, isPEP, isInfluencer, shareCount, shareValue, civilID, signatureFileId, isAuthorized, isOccupationNonEditable, isSourceIncomeNonEditable, isPEPNonEditable, isInfluencerNonEditable, isMonthlyIncomeNonEditable, isAuthorizedNonEditable, isSharesAvailable, pepInfo, influencerInfo, occupationInfo, sourceIncomeInfo, monthlyIncomeInfo, isAuthorizedInfo, userPayload, shareHolderPayload, boardMemberPayload, buyerMemberPayload, _e, isUser, isShareholder, isBoardMember, isBuyer, isCustomer, isUserORBuyerType, payload, businessCountry, hasCivilIdDocument, hasSignatureDocument, isSendSignatureFile, civilIdDocument, signatureDocument, documentBody, documentBody, documentsList, documentBody,
|
|
673
|
+
var _b, settings, individual, _c, recipient, user, userList, business, id, _d, objects, ids, isKWOrSAValue, occupation, sourceIncome, monthlyIncome, isPEP, isInfluencer, shareCount, shareValue, civilID, signatureFileId, isAuthorized, isOccupationNonEditable, isSourceIncomeNonEditable, isPEPNonEditable, isInfluencerNonEditable, isMonthlyIncomeNonEditable, isAuthorizedNonEditable, isSharesAvailable, pepInfo, influencerInfo, occupationInfo, sourceIncomeInfo, monthlyIncomeInfo, isAuthorizedInfo, userPayload, shareHolderPayload, boardMemberPayload, buyerMemberPayload, _e, isUser, isShareholder, isBoardMember, isBuyer, isCustomer, isUserORBuyerType, payload, businessCountry, hasCivilIdDocument, hasSignatureDocument, isSendSignatureFile, civilIdDocument, signatureDocument, documentBody, documentBody, documentsList, documentBody, data, individualData, requestBody, user_2, userListRes;
|
|
670
674
|
var _f, _g;
|
|
671
675
|
return __generator(this, function (_h) {
|
|
672
676
|
switch (_h.label) {
|
|
@@ -762,18 +766,23 @@ export var updateIndividualInfo = createAsyncThunk('updateIndividualInfo', funct
|
|
|
762
766
|
_h.sent();
|
|
763
767
|
_h.label = 6;
|
|
764
768
|
case 6:
|
|
769
|
+
data = undefined, individualData = user || {};
|
|
765
770
|
requestBody = __assign(__assign({ ids: (ids === null || ids === void 0 ? void 0 : ids.length) ? ids : [id] }, payload), { encryption_contract: [], step_name: INDIVIDUAl_STEP_NAMES.INDIVIDUAl_INFO });
|
|
771
|
+
if (!isDirty) return [3, 8];
|
|
766
772
|
return [4, API.individualService.updateMultipleIndividual(requestBody)];
|
|
767
773
|
case 7:
|
|
768
774
|
data = _h.sent();
|
|
769
|
-
|
|
775
|
+
user_2 = (sortUserList(mapUserList(data === null || data === void 0 ? void 0 : data.individuals)) || [])[0];
|
|
776
|
+
individualData = user_2;
|
|
777
|
+
_h.label = 8;
|
|
778
|
+
case 8:
|
|
770
779
|
userListRes = userList || [];
|
|
771
|
-
if (!((user === null || user === void 0 ? void 0 : user.id) === (individualData === null || individualData === void 0 ? void 0 : individualData.id) && !(user === null || user === void 0 ? void 0 : user.is_authorized) && isAuthorized && (business === null || business === void 0 ? void 0 : business.id))) return [3,
|
|
780
|
+
if (!((user === null || user === void 0 ? void 0 : user.id) === (individualData === null || individualData === void 0 ? void 0 : individualData.id) && !(user === null || user === void 0 ? void 0 : user.is_authorized) && isAuthorized && (business === null || business === void 0 ? void 0 : business.id))) return [3, 10];
|
|
772
781
|
return [4, thunkApi.dispatch(getIndividualList(business === null || business === void 0 ? void 0 : business.id)).unwrap()];
|
|
773
|
-
case 8:
|
|
774
|
-
userListRes = _h.sent();
|
|
775
|
-
_h.label = 9;
|
|
776
782
|
case 9:
|
|
783
|
+
userListRes = _h.sent();
|
|
784
|
+
_h.label = 10;
|
|
785
|
+
case 10:
|
|
777
786
|
thunkApi.dispatch(handleNextScreenStep());
|
|
778
787
|
(_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, requestBody);
|
|
779
788
|
return [2, { data: data, formData: originalFormData, individualData: individualData, userList: userListRes, isKWOrSACountry: isKWOrSAValue }];
|
|
@@ -1263,11 +1272,11 @@ export var individualSlice = createSlice({
|
|
|
1263
1272
|
state.loading = false;
|
|
1264
1273
|
state.error = null;
|
|
1265
1274
|
var _a = action.payload, data = _a.data, formData = _a.formData, individualData = _a.individualData, userList = _a.userList, isKWOrSACountry = _a.isKWOrSACountry;
|
|
1266
|
-
state.data.individualData = formData;
|
|
1275
|
+
state.data.individualData = __assign(__assign({}, formData), { civilID: undefined, signatureFileId: undefined });
|
|
1267
1276
|
state.data.individualData.responseBody = data;
|
|
1268
1277
|
var user = (state.data.verify.responseBody || {}).user;
|
|
1269
1278
|
var isSameUser = (user === null || user === void 0 ? void 0 : user.id) === (individualData === null || individualData === void 0 ? void 0 : individualData.id);
|
|
1270
|
-
var userInfo = __assign(__assign({}, user), (isSameUser &&
|
|
1279
|
+
var userInfo = __assign(__assign({}, user), (isSameUser && individualData && __assign({}, individualData)));
|
|
1271
1280
|
if (isSameUser && !isKWOrSACountry)
|
|
1272
1281
|
userInfo = __assign(__assign({}, user), { is_authorized: individualData.is_authorized });
|
|
1273
1282
|
var list = userList || [];
|
|
@@ -439,6 +439,7 @@ export var taxSlice = createSlice({
|
|
|
439
439
|
state.error = null;
|
|
440
440
|
var _a = action.payload, data = _a.data, formData = _a.formData;
|
|
441
441
|
state.data.taxData = formData;
|
|
442
|
+
state.data.taxData = __assign(__assign({}, formData), { documentId: undefined });
|
|
442
443
|
state.data.taxData.responseBody = data;
|
|
443
444
|
})
|
|
444
445
|
.addCase(updateTaxInfo.rejected, function (state, action) {
|
|
@@ -17,7 +17,7 @@ import { handleNextScreenStep, settingsSelector } from '../../../../app/settings
|
|
|
17
17
|
import { resetStore } from '../../../app/auth/authStore';
|
|
18
18
|
import { AbsherButton, MobileButton } from '../../../shared/Button';
|
|
19
19
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
20
|
-
import { isKW, isSA } from '../../../../utils';
|
|
20
|
+
import { isKW, isSA, sendCustomEventToGTM } from '../../../../utils';
|
|
21
21
|
import { ICONS_NAMES } from '../../../../constants';
|
|
22
22
|
var AuthSwitch = function (_a) {
|
|
23
23
|
var dispatch = useAppDispatch();
|
|
@@ -35,9 +35,21 @@ var AuthSwitch = function (_a) {
|
|
|
35
35
|
dispatch(handleNextScreenStep('AUTH_EMAIL_STEP'));
|
|
36
36
|
};
|
|
37
37
|
var onOpenNID = function () {
|
|
38
|
+
sendCustomEventToGTM({
|
|
39
|
+
event: 'Send Event',
|
|
40
|
+
event_category: 'User Registration Flow',
|
|
41
|
+
event_action: 'Abser Click',
|
|
42
|
+
event_label: data.businessCountry.iso2
|
|
43
|
+
});
|
|
38
44
|
dispatch(handleNextScreenStep('AUTH_NID_STEP'));
|
|
39
45
|
};
|
|
40
46
|
var onOpenPACI = function () {
|
|
47
|
+
sendCustomEventToGTM({
|
|
48
|
+
event: 'Send Event',
|
|
49
|
+
event_category: 'User Registration Flow',
|
|
50
|
+
event_action: 'PACI Click',
|
|
51
|
+
event_label: data.businessCountry.iso2
|
|
52
|
+
});
|
|
41
53
|
dispatch(handleNextScreenStep('AUTH_CIVIL_ID_STEP'));
|
|
42
54
|
};
|
|
43
55
|
return (_jsxs(ScreenContainer, { children: [_jsx(MobileButton, __assign({ sx: { mt: 2.5 }, onClick: function () { return onOpenMobile(); } }, { children: t('mobile_button_label') })), _jsx(MobileButton, __assign({ onClick: function () { return onOpenEmail(); }, icon: ICONS_NAMES.email_icon }, { children: t('email_button_label') })), isKWCountry ? (_jsx(MobileButton, __assign({ onClick: function () { return onOpenPACI(); }, icon: ICONS_NAMES.PACI_ICON }, { children: t('paci_button_label') }))) : (isSACountry && _jsx(AbsherButton, __assign({ onClick: function () { return onOpenNID(); } }, { children: t('absher_button_label') })))] }));
|
|
@@ -52,7 +52,7 @@ import { useAppSelector, useAppDispatch, useLanguage } from '../../../../hooks';
|
|
|
52
52
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
53
53
|
import BusinessCountry from '../../../shared/BusinessCountry';
|
|
54
54
|
import Button from '../../../shared/Button';
|
|
55
|
-
import { findCountryByIso2, isSA } from '../../../../utils';
|
|
55
|
+
import { findCountryByIso2, isSA, sendCustomEventToGTM } from '../../../../utils';
|
|
56
56
|
import Collapse from '../../../../components/Collapse';
|
|
57
57
|
import { handleNextScreenStep, handleSetCountryByIso2, settingsSelector } from '../../../../app/settings';
|
|
58
58
|
import { authSelector, updateBusinessCountry, storeIsStartFromBusinessCountry, clearError, resetStore, setMobileCountryCode } from '../../../app/auth/authStore';
|
|
@@ -81,6 +81,12 @@ var BusinessCountryScreen = function (_a) {
|
|
|
81
81
|
return [2];
|
|
82
82
|
countryCode = findCountryByIso2(settingsData.countries, iso2);
|
|
83
83
|
dispatch(handleSetCountryByIso2(iso2));
|
|
84
|
+
sendCustomEventToGTM({
|
|
85
|
+
event: 'Send Event',
|
|
86
|
+
event_category: 'User Registration Flow',
|
|
87
|
+
event_action: 'Country selection page view',
|
|
88
|
+
event_label: iso2
|
|
89
|
+
});
|
|
84
90
|
if (!data.leadId) return [3, 2];
|
|
85
91
|
return [4, dispatch(updateBusinessCountry(iso2)).unwrap()];
|
|
86
92
|
case 1:
|
|
@@ -29,7 +29,7 @@ import Form from '../../../../components/Form';
|
|
|
29
29
|
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
30
30
|
import ConfirmPolicy from './ConfirmPolicy';
|
|
31
31
|
import BankStatement from './BankStatement';
|
|
32
|
-
import { deepCopy, getFileDetailsFromDocument, isKW, isStringHasOneAsterisk } from '../../../../utils';
|
|
32
|
+
import { deepCopy, getFileDetailsFromDocument, isKW, isStringHasOneAsterisk, sendCustomEventToGTM } from '../../../../utils';
|
|
33
33
|
var FormStyled = styled(Form)(function () { return ({
|
|
34
34
|
display: 'flex',
|
|
35
35
|
flexDirection: 'column',
|
|
@@ -71,6 +71,12 @@ var BankDetails = function () {
|
|
|
71
71
|
var t = useTranslation().t;
|
|
72
72
|
var isAr = useLanguage().isAr;
|
|
73
73
|
var onBack = function () {
|
|
74
|
+
sendCustomEventToGTM({
|
|
75
|
+
event: 'Send Event',
|
|
76
|
+
event_category: 'Board Flows - Wallet',
|
|
77
|
+
event_action: 'Wallet Details Back button',
|
|
78
|
+
event_label: settingsData.businessCountry.iso2
|
|
79
|
+
});
|
|
74
80
|
if ((flows === null || flows === void 0 ? void 0 : flows.length) > 0) {
|
|
75
81
|
dispatch(handlePrevScreenStep());
|
|
76
82
|
return;
|
|
@@ -107,7 +113,6 @@ var BankDetails = function () {
|
|
|
107
113
|
bankName: bank_name,
|
|
108
114
|
confirmPolicy: is_acknowledged
|
|
109
115
|
}).isDirty;
|
|
110
|
-
console.log('isDirty', isDirty);
|
|
111
116
|
var getFelids = useExcludeReadOnlyFelids(methods, readOnly).getFelids;
|
|
112
117
|
var onSubmit = function (data) {
|
|
113
118
|
var formData = __assign(__assign({}, deepCopy(getFelids(data))), { isDirty: isDirty });
|
|
@@ -15,13 +15,13 @@ import { ScreenContainer } from '../../../shared/Containers';
|
|
|
15
15
|
import { FormProvider, useForm } from 'react-hook-form';
|
|
16
16
|
import Form from '../../../../components/Form';
|
|
17
17
|
import { styled } from '@mui/material/styles';
|
|
18
|
-
import { useAppDispatch, useAppSelector, useDataNoneEditable, useFormReadOnly, useLanguage, useSetFromDefaultValues, useFormErrorAndUpdateReadOnly, useExcludeReadOnlyFelids, useDataVerified } from '../../../../hooks';
|
|
18
|
+
import { useAppDispatch, useAppSelector, useDataNoneEditable, useFormReadOnly, useLanguage, useSetFromDefaultValues, useFormErrorAndUpdateReadOnly, useExcludeReadOnlyFelids, useDataVerified, useFormDirtyCheck } from '../../../../hooks';
|
|
19
19
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
20
20
|
import { BrandActivitiesValidationSchema } from './validation';
|
|
21
21
|
import Button from '../../../shared/Button';
|
|
22
22
|
import { brandSelector, updateBrandActivities } from '../../../app/brand/brandStore';
|
|
23
|
-
import { handlePrevScreenStep } from '../../../../app/settings';
|
|
24
|
-
import { deepCopy } from '../../../../utils';
|
|
23
|
+
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
24
|
+
import { deepCopy, sendCustomEventToGTM } from '../../../../utils';
|
|
25
25
|
import { useTranslation } from 'react-i18next';
|
|
26
26
|
import ActivitiesList from './ActivitiesList';
|
|
27
27
|
import CustomerBase from './CustomerBase';
|
|
@@ -36,11 +36,12 @@ var FormStyled = styled(Form)(function () { return ({
|
|
|
36
36
|
flexDirection: 'column'
|
|
37
37
|
}); });
|
|
38
38
|
var BrandActivities = function (_a) {
|
|
39
|
-
var _b, _c, _d, _e
|
|
40
|
-
var
|
|
39
|
+
var _b, _c, _d, _e;
|
|
40
|
+
var _f = React.useState(), listActive = _f[0], setListActive = _f[1];
|
|
41
41
|
var dispatch = useAppDispatch();
|
|
42
|
-
var
|
|
43
|
-
var
|
|
42
|
+
var settingsData = useAppSelector(settingsSelector).data;
|
|
43
|
+
var _g = useAppSelector(brandSelector), data = _g.data, loading = _g.loading, error = _g.error;
|
|
44
|
+
var _h = data.brandActivities, activities = _h.activities, customerLocations = _h.customerLocations, expectedCustomer = _h.expectedCustomer, expectedSale = _h.expectedSale, termAndConditionChecked = _h.termAndConditionChecked, refundPolicy = _h.refundPolicy, transactionPolicy = _h.transactionPolicy;
|
|
44
45
|
var ListType;
|
|
45
46
|
(function (ListType) {
|
|
46
47
|
ListType["ActivitiesList"] = "ActivitiesList";
|
|
@@ -48,6 +49,14 @@ var BrandActivities = function (_a) {
|
|
|
48
49
|
ListType["ExpectedCustomerList"] = "ExpectedCustomerList";
|
|
49
50
|
ListType["ExpectedSalesList"] = "ExpectedSalesList";
|
|
50
51
|
})(ListType || (ListType = {}));
|
|
52
|
+
React.useEffect(function () {
|
|
53
|
+
sendCustomEventToGTM({
|
|
54
|
+
event: 'Send Event',
|
|
55
|
+
event_category: 'Board Flows - Brand',
|
|
56
|
+
event_action: 'Update Brand Activities Details Page',
|
|
57
|
+
event_label: settingsData.businessCountry.iso2
|
|
58
|
+
});
|
|
59
|
+
}, []);
|
|
51
60
|
var methods = useForm({
|
|
52
61
|
resolver: yupResolver(BrandActivitiesValidationSchema()),
|
|
53
62
|
defaultValues: {
|
|
@@ -62,7 +71,8 @@ var BrandActivities = function (_a) {
|
|
|
62
71
|
mode: 'onChange'
|
|
63
72
|
});
|
|
64
73
|
useSetFromDefaultValues(methods, data.brandActivities, true);
|
|
65
|
-
var
|
|
74
|
+
var _j = data.verify.responseBody || {}, activitiesDefaultValues = _j.activitiesDefaultValues, brand = _j.brand;
|
|
75
|
+
var _k = brand || {}, data_status = _k.data_status, data_verification = _k.data_verification, operations = _k.operations;
|
|
66
76
|
var originalReadOnly = useFormReadOnly(methods);
|
|
67
77
|
var noneEditable = useDataNoneEditable(data_status, [
|
|
68
78
|
'activities',
|
|
@@ -78,6 +88,32 @@ var BrandActivities = function (_a) {
|
|
|
78
88
|
'operations.sales_range'
|
|
79
89
|
]);
|
|
80
90
|
var getFelids = useExcludeReadOnlyFelids(methods, readOnly).getFelids;
|
|
91
|
+
var isDirty = useFormDirtyCheck(methods, {
|
|
92
|
+
activities: activitiesDefaultValues === null || activitiesDefaultValues === void 0 ? void 0 : activitiesDefaultValues.activities,
|
|
93
|
+
customerLocations: activitiesDefaultValues === null || activitiesDefaultValues === void 0 ? void 0 : activitiesDefaultValues.customerLocations,
|
|
94
|
+
expectedCustomer: activitiesDefaultValues === null || activitiesDefaultValues === void 0 ? void 0 : activitiesDefaultValues.expectedCustomer,
|
|
95
|
+
expectedSale: activitiesDefaultValues === null || activitiesDefaultValues === void 0 ? void 0 : activitiesDefaultValues.expectedSale,
|
|
96
|
+
termAndConditionChecked: activitiesDefaultValues === null || activitiesDefaultValues === void 0 ? void 0 : activitiesDefaultValues.termAndConditionChecked,
|
|
97
|
+
refundPolicy: activitiesDefaultValues === null || activitiesDefaultValues === void 0 ? void 0 : activitiesDefaultValues.transactionPolicy,
|
|
98
|
+
transactionPolicy: activitiesDefaultValues === null || activitiesDefaultValues === void 0 ? void 0 : activitiesDefaultValues.refundPolicy
|
|
99
|
+
}, [
|
|
100
|
+
{
|
|
101
|
+
name: 'activities',
|
|
102
|
+
keys: ['id']
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'customerLocations',
|
|
106
|
+
keys: ['id']
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: 'expectedCustomer',
|
|
110
|
+
keys: ['id']
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'expectedSale',
|
|
114
|
+
keys: ['id']
|
|
115
|
+
}
|
|
116
|
+
]).isDirty;
|
|
81
117
|
var locations = methods.watch('customerLocations');
|
|
82
118
|
var isCustomerLocationsHasVerifiedValue = React.useMemo(function () {
|
|
83
119
|
var _a, _b;
|
|
@@ -92,10 +128,11 @@ var BrandActivities = function (_a) {
|
|
|
92
128
|
return (locationIds === null || locationIds === void 0 ? void 0 : locationIds.length) === (Ids === null || Ids === void 0 ? void 0 : Ids.length) && locationIds.every(function (locationId) { return Ids.includes(locationId); });
|
|
93
129
|
}, [locations, operations]);
|
|
94
130
|
var isCustomerLocationsVerified = dataVerified['operations.customer_base_location'] && isCustomerLocationsHasVerifiedValue;
|
|
95
|
-
var isExpectedSalesRangeVerified = dataVerified['operations.sales_range'] && ((
|
|
96
|
-
var isExpectedCustomersVerified = dataVerified['operations.customer_base'] && ((
|
|
131
|
+
var isExpectedSalesRangeVerified = dataVerified['operations.sales_range'] && ((_b = operations === null || operations === void 0 ? void 0 : operations.sales) === null || _b === void 0 ? void 0 : _b.id) === ((_c = methods.watch('expectedSale')) === null || _c === void 0 ? void 0 : _c.id);
|
|
132
|
+
var isExpectedCustomersVerified = dataVerified['operations.customer_base'] && ((_d = operations === null || operations === void 0 ? void 0 : operations.customer_base) === null || _d === void 0 ? void 0 : _d.id) === ((_e = methods.watch('expectedCustomer')) === null || _e === void 0 ? void 0 : _e.id);
|
|
97
133
|
var onSubmit = function (data) {
|
|
98
|
-
|
|
134
|
+
var formData = __assign(__assign({}, deepCopy(getFelids(data))), { isDirty: isDirty });
|
|
135
|
+
dispatch(updateBrandActivities(formData));
|
|
99
136
|
};
|
|
100
137
|
var onBack = function () {
|
|
101
138
|
dispatch(handlePrevScreenStep());
|
|
@@ -14,11 +14,11 @@ import React from 'react';
|
|
|
14
14
|
import { useTranslation } from 'react-i18next';
|
|
15
15
|
import { FormProvider, useForm } from 'react-hook-form';
|
|
16
16
|
import { styled } from '@mui/material/styles';
|
|
17
|
-
import { useAppDispatch, useAppSelector, useDataNoneEditable, useFormReadOnly, useLanguage, useSetFromDefaultValues, useFormErrorAndUpdateReadOnly, useExcludeReadOnlyFelids, useDataVerified } from '../../../../hooks';
|
|
17
|
+
import { useAppDispatch, useAppSelector, useDataNoneEditable, useFormReadOnly, useLanguage, useSetFromDefaultValues, useFormErrorAndUpdateReadOnly, useExcludeReadOnlyFelids, useDataVerified, useFormDirtyCheck } from '../../../../hooks';
|
|
18
18
|
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
19
19
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
20
20
|
import Form from '../../../../components/Form';
|
|
21
|
-
import { deepCopy, mapSalesChannel } from '../../../../utils';
|
|
21
|
+
import { deepCopy, mapSalesChannel, sendCustomEventToGTM } from '../../../../utils';
|
|
22
22
|
import Button from '../../../shared/Button';
|
|
23
23
|
import { clearError, brandSelector, updateBrand, retrieveBoardStatus } from '../../../app/brand/brandStore';
|
|
24
24
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
@@ -39,7 +39,7 @@ var BrandInfo = function (_a) {
|
|
|
39
39
|
var settingsData = useAppSelector(settingsSelector).data;
|
|
40
40
|
var _d = data.brandData, brandName = _d.brandName, salesChannels = _d.salesChannels, brandLogoId = _d.brandLogoId, responseBody = _d.responseBody;
|
|
41
41
|
var _e = data.verify.responseBody || {}, brand = _e.brand, flows = _e.flows;
|
|
42
|
-
var _f = brand || {}, logo_details = _f.logo_details, data_status = _f.data_status, data_verification = _f.data_verification, name = _f.name;
|
|
42
|
+
var _f = brand || {}, logo_details = _f.logo_details, data_status = _f.data_status, data_verification = _f.data_verification, name = _f.name, channel_services = _f.channel_services;
|
|
43
43
|
var methods = useForm({
|
|
44
44
|
resolver: yupResolver(BrandValidationSchema()),
|
|
45
45
|
defaultValues: {
|
|
@@ -52,6 +52,17 @@ var BrandInfo = function (_a) {
|
|
|
52
52
|
var watch = methods.watch;
|
|
53
53
|
useSetFromDefaultValues(methods, data.brandData, true);
|
|
54
54
|
var defaultBrandLogoFile = React.useMemo(function () { return logo_details && __assign(__assign({}, logo_details), { docId: '' }); }, [logo_details]);
|
|
55
|
+
var initialSalesChannels = React.useMemo(function () { return mapSalesChannel(channel_services || []); }, [channel_services]);
|
|
56
|
+
var isDirty = useFormDirtyCheck(methods, {
|
|
57
|
+
brandName: ((name === null || name === void 0 ? void 0 : name.en) || '').trim(),
|
|
58
|
+
salesChannels: initialSalesChannels,
|
|
59
|
+
brandLogoId: defaultBrandLogoFile === null || defaultBrandLogoFile === void 0 ? void 0 : defaultBrandLogoFile.id
|
|
60
|
+
}, [
|
|
61
|
+
{
|
|
62
|
+
name: 'salesChannels',
|
|
63
|
+
keys: ['id', 'address', 'code', 'sub']
|
|
64
|
+
}
|
|
65
|
+
]).isDirty;
|
|
55
66
|
var originalReadOnly = useFormReadOnly(methods, { brandLogoId: defaultBrandLogoFile });
|
|
56
67
|
var noneEditable = useDataNoneEditable(data_status, ['name.en', 'name.ar', 'channel_services', 'logo']);
|
|
57
68
|
var readOnly = useFormErrorAndUpdateReadOnly(methods, originalReadOnly, noneEditable);
|
|
@@ -59,9 +70,16 @@ var BrandInfo = function (_a) {
|
|
|
59
70
|
var getFelids = useExcludeReadOnlyFelids(methods, readOnly).getFelids;
|
|
60
71
|
var isBrandNameVerified = dataVerified['name.en'] && dataVerified['name.ar'] && ((name === null || name === void 0 ? void 0 : name.en) === watch('brandName') || (name === null || name === void 0 ? void 0 : name.ar) === watch('brandName'));
|
|
61
72
|
var onSubmit = function (data) {
|
|
62
|
-
|
|
73
|
+
var formData = __assign(__assign({}, deepCopy(getFelids(data))), { isDirty: isDirty });
|
|
74
|
+
dispatch(updateBrand(formData));
|
|
63
75
|
};
|
|
64
76
|
var onBack = function () {
|
|
77
|
+
sendCustomEventToGTM({
|
|
78
|
+
event: 'Send Event',
|
|
79
|
+
event_category: 'Board Flows - Brand',
|
|
80
|
+
event_action: 'Brand Details Back button',
|
|
81
|
+
event_label: settingsData.businessCountry.iso2
|
|
82
|
+
});
|
|
65
83
|
if ((flows === null || flows === void 0 ? void 0 : flows.length) > 0) {
|
|
66
84
|
dispatch(handlePrevScreenStep());
|
|
67
85
|
return;
|