@tap-payments/auth-jsconnect 2.0.83-test → 2.0.84-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 +1 -2
- package/build/api/auth.d.ts +1 -0
- package/build/api/index.d.ts +3 -3
- package/build/constants/dummy.d.ts +0 -1
- package/build/constants/dummy.js +1 -2
- package/build/features/app/auth/authStore.d.ts +5 -0
- package/build/features/app/auth/authStore.js +59 -3
- package/build/features/app/connect/connectStore.d.ts +8 -2
- package/build/features/app/connect/connectStore.js +77 -52
- package/build/features/auth/screens/OTP/OTP.js +1 -1
- package/build/features/auth/screens/OTP/OTPInput.js +8 -1
- package/build/features/connect/screens/Merchant/BrandList.js +13 -7
- package/build/features/connect/screens/Merchant/BrandName.js +2 -6
- package/build/features/connect/screens/Merchant/Merchant.js +24 -6
- package/build/features/connect/screens/Merchant/validation.d.ts +1 -12
- package/build/features/connect/screens/Merchant/validation.js +57 -21
- package/package.json +1 -1
package/build/@types/app.d.ts
CHANGED
package/build/api/auth.d.ts
CHANGED
package/build/api/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axiosInstance, { setAxiosGlobalHeaders, removeAxiosGlobalHeaders, getAxiosHeaders } from './axios';
|
|
2
2
|
import { ValidateOperatorBody } from './operator';
|
|
3
|
-
import { CreateAuthBody, VerifyAuthBody, CreatePasswordBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody } from './auth';
|
|
3
|
+
import { CreateAuthBody, VerifyAuthBody, CreatePasswordBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, VerifyAuthKitOTPBody } from './auth';
|
|
4
4
|
import { UpdateLeadBody, LeadVerifyBody, CreateLeadBody, LeadOTPVerifyBody, LeadIdentityUpdateBody } from './lead';
|
|
5
5
|
import { CheckEmailBody, CheckBrandBody } from './availabilityServices';
|
|
6
6
|
import { EntityInfoBody, EntityBankUpdateBody, UploadFileBody, DocumentUpdateBody, DocumentInfo } from './entity';
|
|
@@ -22,7 +22,7 @@ declare const API: {
|
|
|
22
22
|
createAuth: (data: CreateAuthBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
23
23
|
verifyAuth: (data: VerifyAuthBody | VerifyOperationAuthBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
24
24
|
createPassword: (data: CreatePasswordBody) => Promise<any>;
|
|
25
|
-
verifyAuthKitOTP: (data:
|
|
25
|
+
verifyAuthKitOTP: (data: VerifyAuthKitOTPBody) => Promise<any>;
|
|
26
26
|
getVerifyAuth: (token: string, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<any>;
|
|
27
27
|
getTokenVerify: (token: string, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<any>;
|
|
28
28
|
};
|
|
@@ -100,6 +100,6 @@ declare const API: {
|
|
|
100
100
|
updateBrandSales: ({ id, ...data }: import("./individual").UpdateSalesChannels) => void;
|
|
101
101
|
};
|
|
102
102
|
};
|
|
103
|
-
export type { ValidateOperatorBody, CreateAuthBody, VerifyAuthBody, CreateLeadBody, UpdateLeadBody, LeadVerifyBody, LeadOTPVerifyBody, CheckEmailBody, CheckBrandBody, LeadIdentityUpdateBody, EntityInfoBody, CreateAccountBody, EntityBankUpdateBody, CreatePasswordBody, BrandListBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, UpdateBoardBody, UpdateBrandBody, DataElementBody, UploadFileBody, DocumentUpdateBody, DocumentInfo };
|
|
103
|
+
export type { ValidateOperatorBody, CreateAuthBody, VerifyAuthBody, CreateLeadBody, UpdateLeadBody, LeadVerifyBody, LeadOTPVerifyBody, CheckEmailBody, CheckBrandBody, LeadIdentityUpdateBody, EntityInfoBody, CreateAccountBody, EntityBankUpdateBody, CreatePasswordBody, BrandListBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, UpdateBoardBody, UpdateBrandBody, DataElementBody, UploadFileBody, DocumentUpdateBody, DocumentInfo, VerifyAuthKitOTPBody };
|
|
104
104
|
export { setAxiosGlobalHeaders, removeAxiosGlobalHeaders, axiosInstance, getAxiosHeaders };
|
|
105
105
|
export default API;
|
package/build/constants/dummy.js
CHANGED
|
@@ -5,13 +5,18 @@ export declare const verifyAuthOTP: import("@reduxjs/toolkit").AsyncThunk<{
|
|
|
5
5
|
response: any;
|
|
6
6
|
formData: OTPFormValues;
|
|
7
7
|
}, OTPFormValues, {}>;
|
|
8
|
+
export declare const resendOTP: import("@reduxjs/toolkit").AsyncThunk<any, void, {}>;
|
|
8
9
|
export interface AuthData extends ResponseData {
|
|
10
|
+
verifyToken: string | undefined;
|
|
9
11
|
leadId: string;
|
|
10
12
|
postUrl: string;
|
|
11
13
|
otp: string;
|
|
12
14
|
mobileNumber: string;
|
|
13
15
|
nid: string;
|
|
14
16
|
termAndConditionChecked: boolean;
|
|
17
|
+
dob: string;
|
|
18
|
+
type: string;
|
|
19
|
+
businessCountryCode: string;
|
|
15
20
|
}
|
|
16
21
|
export interface AuthState extends SharedState<AuthData> {
|
|
17
22
|
customLoading?: boolean;
|
|
@@ -50,15 +50,16 @@ export var retrieveLead = createAsyncThunk('retrieveLeadAuthKit', function (lead
|
|
|
50
50
|
});
|
|
51
51
|
}); });
|
|
52
52
|
export var verifyAuthOTP = createAsyncThunk('verifyAuthOTPKit', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
53
|
-
var _a, settings, auth, _b, leadId, postUrl, payload, data;
|
|
53
|
+
var _a, settings, auth, _b, leadId, postUrl, verifyToken, payload, data;
|
|
54
54
|
var _c, _d, _e, _f;
|
|
55
55
|
return __generator(this, function (_g) {
|
|
56
56
|
switch (_g.label) {
|
|
57
57
|
case 0:
|
|
58
58
|
_a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
|
|
59
|
-
_b = auth.data, leadId = _b.leadId, postUrl = _b.postUrl;
|
|
59
|
+
_b = auth.data, leadId = _b.leadId, postUrl = _b.postUrl, verifyToken = _b.verifyToken;
|
|
60
60
|
payload = {
|
|
61
61
|
lead_id: leadId,
|
|
62
|
+
verify_token: verifyToken,
|
|
62
63
|
data: params.otp,
|
|
63
64
|
post_url: postUrl,
|
|
64
65
|
scopes: settings.data.appConfig.scope || [],
|
|
@@ -75,17 +76,52 @@ export var verifyAuthOTP = createAsyncThunk('verifyAuthOTPKit', function (params
|
|
|
75
76
|
}
|
|
76
77
|
});
|
|
77
78
|
}); });
|
|
79
|
+
export var resendOTP = createAsyncThunk('authResendOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
+
var _a, settings, auth, _b, nid, dob, type, requestBody, data;
|
|
81
|
+
return __generator(this, function (_c) {
|
|
82
|
+
switch (_c.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
_a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
|
|
85
|
+
_b = auth.data || {}, nid = _b.nid, dob = _b.dob, type = _b.type;
|
|
86
|
+
requestBody = {
|
|
87
|
+
lang: settings.data.language,
|
|
88
|
+
user_credentail: {
|
|
89
|
+
identification_id: nid,
|
|
90
|
+
identification_id_type: type,
|
|
91
|
+
date_of_birth: dob,
|
|
92
|
+
country_code: settings.data.businessCountry.iso2
|
|
93
|
+
},
|
|
94
|
+
sign_in: false,
|
|
95
|
+
is_lead: true,
|
|
96
|
+
encryption_contract: [
|
|
97
|
+
'user_credentail.country_code',
|
|
98
|
+
'user_credentail.identification_id',
|
|
99
|
+
'user_credentail.identification_id_type',
|
|
100
|
+
'user_credentail.date_of_birth'
|
|
101
|
+
]
|
|
102
|
+
};
|
|
103
|
+
return [4, API.authService.createAuth(requestBody)];
|
|
104
|
+
case 1:
|
|
105
|
+
data = (_c.sent()).data;
|
|
106
|
+
return [2, data];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}); });
|
|
78
110
|
var initialState = {
|
|
79
111
|
error: null,
|
|
80
112
|
loading: false,
|
|
81
113
|
customLoading: false,
|
|
82
114
|
data: {
|
|
115
|
+
verifyToken: undefined,
|
|
83
116
|
leadId: '',
|
|
84
117
|
postUrl: '',
|
|
85
118
|
otp: '',
|
|
86
119
|
mobileNumber: '',
|
|
87
120
|
nid: '',
|
|
88
|
-
termAndConditionChecked: false
|
|
121
|
+
termAndConditionChecked: false,
|
|
122
|
+
dob: '',
|
|
123
|
+
type: '',
|
|
124
|
+
businessCountryCode: ''
|
|
89
125
|
}
|
|
90
126
|
};
|
|
91
127
|
export var authSlice = createSlice({
|
|
@@ -132,6 +168,9 @@ export var authSlice = createSlice({
|
|
|
132
168
|
}
|
|
133
169
|
state.data.mobileNumber = ((_c = (_b = data === null || data === void 0 ? void 0 : data.contact) === null || _b === void 0 ? void 0 : _b.phone) === null || _c === void 0 ? void 0 : _c.number) || '';
|
|
134
170
|
state.data.nid = data === null || data === void 0 ? void 0 : data.identification_id;
|
|
171
|
+
state.data.dob = data === null || data === void 0 ? void 0 : data.date_of_birth;
|
|
172
|
+
state.data.type = data === null || data === void 0 ? void 0 : data.identification_id_type;
|
|
173
|
+
state.data.businessCountryCode = data === null || data === void 0 ? void 0 : data.country_code;
|
|
135
174
|
})
|
|
136
175
|
.addCase(retrieveLead.rejected, function (state, action) {
|
|
137
176
|
state.loading = false;
|
|
@@ -148,6 +187,23 @@ export var authSlice = createSlice({
|
|
|
148
187
|
.addCase(verifyAuthOTP.rejected, function (state, action) {
|
|
149
188
|
state.loading = false;
|
|
150
189
|
state.error = action.error.message;
|
|
190
|
+
})
|
|
191
|
+
.addCase(resendOTP.pending, function (state) {
|
|
192
|
+
state.error = null;
|
|
193
|
+
})
|
|
194
|
+
.addCase(resendOTP.fulfilled, function (state, action) {
|
|
195
|
+
var _a;
|
|
196
|
+
state.error = null;
|
|
197
|
+
var data = action.payload;
|
|
198
|
+
var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
199
|
+
if (description) {
|
|
200
|
+
state.error = description;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
state.data.verifyToken = data === null || data === void 0 ? void 0 : data.auth_token;
|
|
204
|
+
})
|
|
205
|
+
.addCase(resendOTP.rejected, function (state, action) {
|
|
206
|
+
state.error = action.error.message;
|
|
151
207
|
});
|
|
152
208
|
}
|
|
153
209
|
});
|
|
@@ -23,6 +23,7 @@ export declare const verifyAuth: import("@reduxjs/toolkit").AsyncThunk<{
|
|
|
23
23
|
authResponse: any;
|
|
24
24
|
leadResponse: any;
|
|
25
25
|
isNewUser: any;
|
|
26
|
+
countryCode: CountryCode | undefined;
|
|
26
27
|
}, OTPFormValues, {}>;
|
|
27
28
|
interface verifyPACIParams {
|
|
28
29
|
onSuccess?: () => void | Promise<void>;
|
|
@@ -31,6 +32,7 @@ export declare const verifyPACI: import("@reduxjs/toolkit").AsyncThunk<{
|
|
|
31
32
|
authResponse: any;
|
|
32
33
|
leadResponse: any;
|
|
33
34
|
isNewUser: any;
|
|
35
|
+
countryCode: CountryCode | undefined;
|
|
34
36
|
}, verifyPACIParams, {}>;
|
|
35
37
|
export declare const updateLeadIndividual: import("@reduxjs/toolkit").AsyncThunk<{
|
|
36
38
|
leadResponse: any;
|
|
@@ -38,8 +40,12 @@ export declare const updateLeadIndividual: import("@reduxjs/toolkit").AsyncThunk
|
|
|
38
40
|
}, IndividualFormValues, {}>;
|
|
39
41
|
export declare const updateLeadBrand: import("@reduxjs/toolkit").AsyncThunk<{
|
|
40
42
|
response: any;
|
|
41
|
-
formData: BrandFormValues
|
|
42
|
-
|
|
43
|
+
formData: BrandFormValues & {
|
|
44
|
+
isNewBrand: boolean;
|
|
45
|
+
};
|
|
46
|
+
}, BrandFormValues & {
|
|
47
|
+
isNewBrand: boolean;
|
|
48
|
+
}, {}>;
|
|
43
49
|
export declare const checkEmailAvailability: import("@reduxjs/toolkit").AsyncThunk<{
|
|
44
50
|
response: any;
|
|
45
51
|
formData: string;
|
|
@@ -63,7 +63,7 @@ import { FlowsTypes } from '../../../@types';
|
|
|
63
63
|
import API from '../../../api';
|
|
64
64
|
import { CONNECT_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_BRAND } from '../../../constants';
|
|
65
65
|
import { defaultCountry } from '../../../constants';
|
|
66
|
-
import { getIndividualName, capitalizeTheFirstLetterOfEachWord, getEighteenYearsAgo, sleep } from '../../../utils';
|
|
66
|
+
import { getIndividualName, capitalizeTheFirstLetterOfEachWord, getEighteenYearsAgo, sleep, findCountryByIddPrefix } from '../../../utils';
|
|
67
67
|
export var createMobileAuth = createAsyncThunk('createMobileAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
68
|
var settings, requestBody, data;
|
|
69
69
|
var _a, _b;
|
|
@@ -217,7 +217,7 @@ export var resendOTPNID = createAsyncThunk('resendOTPNID', function (params, thu
|
|
|
217
217
|
});
|
|
218
218
|
}); });
|
|
219
219
|
export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
220
|
-
var _a, connect, settings, isAbsher, _b, mobileData, nidData, responseBody, payload, data, lead_id, individual_id, leadBody, leadResponse, _c, isNewUser,
|
|
220
|
+
var _a, connect, settings, isAbsher, _b, mobileData, nidData, responseBody, payload, data, lead_id, individual_id, leadBody, leadResponse, _c, isNewUser, brands, err_1, channels, phone, countryCode;
|
|
221
221
|
var _d, _e, _f, _g;
|
|
222
222
|
return __generator(this, function (_h) {
|
|
223
223
|
switch (_h.label) {
|
|
@@ -268,8 +268,8 @@ export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkAp
|
|
|
268
268
|
_h.trys.push([6, 8, , 9]);
|
|
269
269
|
return [4, API.brandService.getBrandList({ individual_id: leadResponse.individual_id })];
|
|
270
270
|
case 7:
|
|
271
|
-
|
|
272
|
-
leadResponse.brand_list =
|
|
271
|
+
brands = (_h.sent()).brands;
|
|
272
|
+
leadResponse.brand_list = brands;
|
|
273
273
|
return [3, 9];
|
|
274
274
|
case 8:
|
|
275
275
|
err_1 = _h.sent();
|
|
@@ -280,17 +280,19 @@ export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkAp
|
|
|
280
280
|
leadResponse.channel_list = channels;
|
|
281
281
|
_h.label = 11;
|
|
282
282
|
case 11:
|
|
283
|
+
phone = ((leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.contact) || {}).phone;
|
|
284
|
+
countryCode = findCountryByIddPrefix(settings.data.countries, phone === null || phone === void 0 ? void 0 : phone.country_code);
|
|
283
285
|
if (isNewUser)
|
|
284
286
|
thunkApi.dispatch(handleNextScreenStep('CONNECT_INDIVIDUAL_STEP'));
|
|
285
287
|
if (!isNewUser)
|
|
286
288
|
thunkApi.dispatch(handleNextScreenStep('CONNECT_MERCHANT_INFO_STEP'));
|
|
287
289
|
(_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, { otp: params.otp });
|
|
288
|
-
return [2, { authResponse: data, leadResponse: leadResponse, isNewUser: isNewUser }];
|
|
290
|
+
return [2, { authResponse: data, leadResponse: leadResponse, isNewUser: isNewUser, countryCode: countryCode }];
|
|
289
291
|
}
|
|
290
292
|
});
|
|
291
293
|
}); });
|
|
292
294
|
export var verifyPACI = createAsyncThunk('verifyPACI', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
293
|
-
var _a, settings, connect, responseBody, expiry, interval, maxCalls, count, authResponse, isSuccess, lead_id, individual_id, leadBody, leadResponse, _b, isNewUser,
|
|
295
|
+
var _a, settings, connect, responseBody, expiry, interval, maxCalls, count, authResponse, isSuccess, lead_id, individual_id, leadBody, leadResponse, _b, isNewUser, brands, err_2, channels, phone, countryCode;
|
|
294
296
|
var _c, _d, _e, _f, _g;
|
|
295
297
|
return __generator(this, function (_h) {
|
|
296
298
|
switch (_h.label) {
|
|
@@ -340,8 +342,8 @@ export var verifyPACI = createAsyncThunk('verifyPACI', function (params, thunkAp
|
|
|
340
342
|
_h.trys.push([8, 10, , 11]);
|
|
341
343
|
return [4, API.brandService.getBrandList({ individual_id: leadResponse.individual_id })];
|
|
342
344
|
case 9:
|
|
343
|
-
|
|
344
|
-
leadResponse.brand_list =
|
|
345
|
+
brands = (_h.sent()).brands;
|
|
346
|
+
leadResponse.brand_list = brands;
|
|
345
347
|
return [3, 11];
|
|
346
348
|
case 10:
|
|
347
349
|
err_2 = _h.sent();
|
|
@@ -352,12 +354,14 @@ export var verifyPACI = createAsyncThunk('verifyPACI', function (params, thunkAp
|
|
|
352
354
|
leadResponse.channel_list = channels;
|
|
353
355
|
_h.label = 13;
|
|
354
356
|
case 13:
|
|
357
|
+
phone = ((leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.contact) || {}).phone;
|
|
358
|
+
countryCode = findCountryByIddPrefix(settings.data.countries, phone === null || phone === void 0 ? void 0 : phone.country_code);
|
|
355
359
|
if (isNewUser)
|
|
356
360
|
thunkApi.dispatch(handleNextScreenStep('CONNECT_INDIVIDUAL_STEP'));
|
|
357
361
|
if (!isNewUser)
|
|
358
362
|
thunkApi.dispatch(handleNextScreenStep('CONNECT_MERCHANT_INFO_STEP'));
|
|
359
363
|
(_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, {});
|
|
360
|
-
return [2, { authResponse: authResponse, leadResponse: leadResponse, isNewUser: isNewUser }];
|
|
364
|
+
return [2, { authResponse: authResponse, leadResponse: leadResponse, isNewUser: isNewUser, countryCode: countryCode }];
|
|
361
365
|
case 14: return [4, sleep(interval * 1000)];
|
|
362
366
|
case 15:
|
|
363
367
|
_h.sent();
|
|
@@ -411,49 +415,64 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
|
|
|
411
415
|
});
|
|
412
416
|
}); });
|
|
413
417
|
export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
414
|
-
var _a, settings, connect, responseBody, brandNameBody, payload, lead,
|
|
415
|
-
var _b, _c, _d;
|
|
416
|
-
return __generator(this, function (
|
|
417
|
-
switch (
|
|
418
|
+
var _a, settings, connect, responseBody, isNewBrand, brandName, salesChannels, selectedBrandItem, channel_services, brandReqBody_1, brand_1, brandNameBody, payload, lead, brandReqBody, brand;
|
|
419
|
+
var _b, _c, _d, _e, _f;
|
|
420
|
+
return __generator(this, function (_g) {
|
|
421
|
+
switch (_g.label) {
|
|
418
422
|
case 0:
|
|
419
423
|
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
420
424
|
responseBody = connect.data.otpData.responseBody;
|
|
425
|
+
isNewBrand = params.isNewBrand, brandName = params.brandName, salesChannels = params.salesChannels, selectedBrandItem = params.selectedBrandItem;
|
|
426
|
+
channel_services = salesChannels.map(function (channel) {
|
|
427
|
+
var _a;
|
|
428
|
+
return {
|
|
429
|
+
id: channel.id,
|
|
430
|
+
address: channel.address,
|
|
431
|
+
sub: (_a = channel.sub) === null || _a === void 0 ? void 0 : _a.map(function (sub) { return ({ id: sub.id, address: sub.address }); })
|
|
432
|
+
};
|
|
433
|
+
});
|
|
434
|
+
if (!!isNewBrand) return [3, 2];
|
|
435
|
+
brandReqBody_1 = {
|
|
436
|
+
id: (selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id) || '',
|
|
437
|
+
channel_services: channel_services,
|
|
438
|
+
step_name: CONNECT_STEP_NAMES.UPDATE_BRAND_INFO
|
|
439
|
+
};
|
|
440
|
+
return [4, API.brandService.updateBrandInfo(brandReqBody_1)];
|
|
441
|
+
case 1:
|
|
442
|
+
brand_1 = _g.sent();
|
|
443
|
+
thunkApi.dispatch(updateLeadSuccess());
|
|
444
|
+
thunkApi.dispatch(handleNextScreenStep());
|
|
445
|
+
(_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, params);
|
|
446
|
+
return [2, { response: brand_1, formData: params }];
|
|
447
|
+
case 2:
|
|
421
448
|
brandNameBody = {
|
|
422
449
|
name: {
|
|
423
|
-
en:
|
|
424
|
-
ar:
|
|
425
|
-
zh:
|
|
450
|
+
en: brandName,
|
|
451
|
+
ar: brandName,
|
|
452
|
+
zh: brandName
|
|
426
453
|
}
|
|
427
454
|
};
|
|
428
455
|
payload = {
|
|
429
456
|
brand: brandNameBody,
|
|
430
457
|
id: (responseBody === null || responseBody === void 0 ? void 0 : responseBody.lead_id) || '',
|
|
431
|
-
terms_conditions_accepted: params.termAndConditionChecked,
|
|
432
458
|
step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_BRAND,
|
|
433
459
|
encryption_contract: ['brand.name.en', 'brand.name.ar', 'brand.name.zh']
|
|
434
460
|
};
|
|
435
461
|
return [4, API.leadService.updateLead(payload)];
|
|
436
|
-
case
|
|
437
|
-
lead =
|
|
438
|
-
channel_services = params.salesChannels.map(function (channel) {
|
|
439
|
-
var _a;
|
|
440
|
-
return {
|
|
441
|
-
id: channel.id,
|
|
442
|
-
address: channel.address,
|
|
443
|
-
sub: (_a = channel.sub) === null || _a === void 0 ? void 0 : _a.map(function (sub) { return ({ id: sub.id, address: sub.address }); })
|
|
444
|
-
};
|
|
445
|
-
});
|
|
462
|
+
case 3:
|
|
463
|
+
lead = _g.sent();
|
|
446
464
|
brandReqBody = {
|
|
447
|
-
id: ((
|
|
465
|
+
id: ((_d = lead.brand) === null || _d === void 0 ? void 0 : _d.id) || '',
|
|
448
466
|
channel_services: channel_services,
|
|
467
|
+
term: ['agree'],
|
|
449
468
|
step_name: CONNECT_STEP_NAMES.UPDATE_BRAND_INFO
|
|
450
469
|
};
|
|
451
470
|
return [4, API.brandService.updateBrandInfo(brandReqBody)];
|
|
452
|
-
case
|
|
453
|
-
brand =
|
|
471
|
+
case 4:
|
|
472
|
+
brand = _g.sent();
|
|
454
473
|
thunkApi.dispatch(updateLeadSuccess());
|
|
455
474
|
thunkApi.dispatch(handleNextScreenStep());
|
|
456
|
-
(
|
|
475
|
+
(_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
|
|
457
476
|
return [2, { response: brand, formData: params }];
|
|
458
477
|
}
|
|
459
478
|
});
|
|
@@ -506,27 +525,24 @@ export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailabi
|
|
|
506
525
|
});
|
|
507
526
|
});
|
|
508
527
|
export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
509
|
-
var _a, settings, connect,
|
|
510
|
-
var _c, _d, _e
|
|
511
|
-
return __generator(this, function (
|
|
512
|
-
switch (
|
|
528
|
+
var _a, settings, connect, lead_id, payload, data;
|
|
529
|
+
var _b, _c, _d, _e;
|
|
530
|
+
return __generator(this, function (_f) {
|
|
531
|
+
switch (_f.label) {
|
|
513
532
|
case 0:
|
|
514
533
|
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
515
|
-
|
|
516
|
-
responseBody = otpData.responseBody;
|
|
517
|
-
isExistingUser = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.is_new_individual) === false;
|
|
518
|
-
leadId = isExistingUser ? (_c = brandData.responseBody) === null || _c === void 0 ? void 0 : _c.lead_id : (_d = otpData.responseBody) === null || _d === void 0 ? void 0 : _d.lead_id;
|
|
534
|
+
lead_id = (connect.data.otpData.responseBody || {}).lead_id;
|
|
519
535
|
payload = {
|
|
520
536
|
lang: settings.data.language,
|
|
521
537
|
step_name: CONNECT_STEP_NAMES.CONNECT_SUCCESS,
|
|
522
|
-
id:
|
|
538
|
+
id: lead_id || '',
|
|
523
539
|
encryption_contract: []
|
|
524
540
|
};
|
|
525
541
|
return [4, API.leadService.updateLead(payload)];
|
|
526
542
|
case 1:
|
|
527
|
-
data =
|
|
528
|
-
(
|
|
529
|
-
(
|
|
543
|
+
data = _f.sent();
|
|
544
|
+
(_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, params);
|
|
545
|
+
(_e = (_d = settings.data.appConfig).onFlowCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, { data: data });
|
|
530
546
|
return [2, { response: data, formData: params }];
|
|
531
547
|
}
|
|
532
548
|
});
|
|
@@ -672,8 +688,8 @@ export var connectSlice = createSlice({
|
|
|
672
688
|
var _a;
|
|
673
689
|
state.loading = false;
|
|
674
690
|
state.error = null;
|
|
675
|
-
var _b = action.payload, authResponse = _b.authResponse, leadResponse = _b.leadResponse, isNewUser = _b.isNewUser;
|
|
676
|
-
var name = leadResponse.name, contact = leadResponse.contact, brand = leadResponse.brand, brand_list = leadResponse.brand_list, channel_list = leadResponse.channel_list;
|
|
691
|
+
var _b = action.payload, authResponse = _b.authResponse, leadResponse = _b.leadResponse, isNewUser = _b.isNewUser, countryCode = _b.countryCode;
|
|
692
|
+
var name = leadResponse.name, contact = leadResponse.contact, brand = leadResponse.brand, brand_list = leadResponse.brand_list, channel_list = leadResponse.channel_list, is_new_individual = leadResponse.is_new_individual, id = leadResponse.id;
|
|
677
693
|
var _c = contact || {}, email = _c.email, phone = _c.phone;
|
|
678
694
|
var firstName = (name === null || name === void 0 ? void 0 : name.first) + ' ';
|
|
679
695
|
var middleName = !!(name === null || name === void 0 ? void 0 : name.middle) ? (name === null || name === void 0 ? void 0 : name.middle) + ' ' : '';
|
|
@@ -687,16 +703,18 @@ export var connectSlice = createSlice({
|
|
|
687
703
|
state.data.individualData.email = email;
|
|
688
704
|
if (phone === null || phone === void 0 ? void 0 : phone.number)
|
|
689
705
|
state.data.individualData.mobile = phone.number;
|
|
706
|
+
if (!!countryCode)
|
|
707
|
+
state.data.individualData.countryCode = countryCode;
|
|
690
708
|
if ((_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en)
|
|
691
709
|
state.data.brandData.brandName = brand.name.en;
|
|
692
710
|
if (!isNewUser) {
|
|
693
711
|
state.data.brandData.responseBody = {
|
|
694
|
-
brand_list: (brand_list === null || brand_list === void 0 ? void 0 : brand_list.length) ?
|
|
712
|
+
brand_list: (brand_list === null || brand_list === void 0 ? void 0 : brand_list.length) ? brand_list.concat(OTHER_BRAND) : [],
|
|
695
713
|
channel_list: channel_list
|
|
696
714
|
};
|
|
697
715
|
state.data.brandData.selectedBrandItem = (brand_list === null || brand_list === void 0 ? void 0 : brand_list[0]) || {};
|
|
698
716
|
}
|
|
699
|
-
state.data.otpData.responseBody = authResponse;
|
|
717
|
+
state.data.otpData.responseBody = __assign(__assign({}, authResponse), { is_new_individual: is_new_individual, lead_id: id });
|
|
700
718
|
})
|
|
701
719
|
.addCase(verifyPACI.rejected, function (state, action) {
|
|
702
720
|
state.loading = false;
|
|
@@ -709,8 +727,8 @@ export var connectSlice = createSlice({
|
|
|
709
727
|
var _a;
|
|
710
728
|
state.loading = false;
|
|
711
729
|
state.error = null;
|
|
712
|
-
var _b = action.payload, authResponse = _b.authResponse, leadResponse = _b.leadResponse, isNewUser = _b.isNewUser;
|
|
713
|
-
var name = leadResponse.name, contact = leadResponse.contact, brand = leadResponse.brand, brand_list = leadResponse.brand_list, channel_list = leadResponse.channel_list;
|
|
730
|
+
var _b = action.payload, authResponse = _b.authResponse, leadResponse = _b.leadResponse, isNewUser = _b.isNewUser, countryCode = _b.countryCode;
|
|
731
|
+
var name = leadResponse.name, contact = leadResponse.contact, brand = leadResponse.brand, brand_list = leadResponse.brand_list, channel_list = leadResponse.channel_list, is_new_individual = leadResponse.is_new_individual, id = leadResponse.id;
|
|
714
732
|
var _c = contact || {}, email = _c.email, phone = _c.phone;
|
|
715
733
|
var firstName = (name === null || name === void 0 ? void 0 : name.first) + ' ';
|
|
716
734
|
var middleName = !!(name === null || name === void 0 ? void 0 : name.middle) ? (name === null || name === void 0 ? void 0 : name.middle) + ' ' : '';
|
|
@@ -724,16 +742,18 @@ export var connectSlice = createSlice({
|
|
|
724
742
|
state.data.individualData.email = email;
|
|
725
743
|
if (phone === null || phone === void 0 ? void 0 : phone.number)
|
|
726
744
|
state.data.individualData.mobile = phone.number;
|
|
745
|
+
if (!!countryCode)
|
|
746
|
+
state.data.individualData.countryCode = countryCode;
|
|
727
747
|
if ((_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en)
|
|
728
748
|
state.data.brandData.brandName = brand.name.en;
|
|
729
749
|
if (!isNewUser) {
|
|
730
750
|
state.data.brandData.responseBody = {
|
|
731
|
-
brand_list: (brand_list === null || brand_list === void 0 ? void 0 : brand_list.length) ?
|
|
751
|
+
brand_list: (brand_list === null || brand_list === void 0 ? void 0 : brand_list.length) ? brand_list.concat(OTHER_BRAND) : [],
|
|
732
752
|
channel_list: channel_list
|
|
733
753
|
};
|
|
734
754
|
state.data.brandData.selectedBrandItem = (brand_list === null || brand_list === void 0 ? void 0 : brand_list[0]) || {};
|
|
735
755
|
}
|
|
736
|
-
state.data.otpData.responseBody = authResponse;
|
|
756
|
+
state.data.otpData.responseBody = __assign(__assign({}, authResponse), { is_new_individual: is_new_individual, lead_id: id });
|
|
737
757
|
})
|
|
738
758
|
.addCase(verifyAuth.pending, function (state) {
|
|
739
759
|
state.loading = true;
|
|
@@ -789,8 +809,13 @@ export var connectSlice = createSlice({
|
|
|
789
809
|
var _a = action.payload, formData = _a.formData, leadResponse = _a.leadResponse;
|
|
790
810
|
var brand = leadResponse.brand, brand_list = leadResponse.brand_list, channel_list = leadResponse.channel_list, rest = __rest(leadResponse, ["brand", "brand_list", "channel_list"]);
|
|
791
811
|
if (brand) {
|
|
792
|
-
var channel_services = brand.channel_services;
|
|
812
|
+
var channel_services = brand.channel_services, terms = brand.terms;
|
|
793
813
|
state.data.brandData.salesChannels = channel_services || [];
|
|
814
|
+
var termAndCondition = (terms || []).find(function (_a) {
|
|
815
|
+
var term = _a.term, agree = _a.agree;
|
|
816
|
+
return term === 'agree' && agree === true;
|
|
817
|
+
});
|
|
818
|
+
state.data.brandData.termAndConditionChecked = !!termAndCondition;
|
|
794
819
|
}
|
|
795
820
|
if (brand_list) {
|
|
796
821
|
state.data.brandData.responseBody = { brand_list: brand_list.concat(OTHER_BRAND) };
|
|
@@ -66,7 +66,7 @@ var OTP = function () {
|
|
|
66
66
|
dispatch(verifyAuthOTP(formData));
|
|
67
67
|
};
|
|
68
68
|
var disabled = !methods.formState.isValid || !!error;
|
|
69
|
-
var phone = data.
|
|
69
|
+
var phone = data.nid;
|
|
70
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('opt_nid_sent_title', { provider: 'ABSHER' }), !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
71
|
};
|
|
72
72
|
export default React.memo(OTP);
|
|
@@ -16,8 +16,9 @@ import { useTranslation } from 'react-i18next';
|
|
|
16
16
|
import Box from '@mui/material/Box/Box';
|
|
17
17
|
import { styled } from '@mui/material/styles';
|
|
18
18
|
import OTPField from '../../../shared/OTP';
|
|
19
|
+
import { authSelector, clearError, resendOTP } from '../../../app/auth/authStore';
|
|
19
20
|
import { DEFAULT_TIMER_VALUE } from '../../../../constants';
|
|
20
|
-
import { useAppDispatch } from '../../../../hooks';
|
|
21
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
21
22
|
var BoxStyled = styled(Box)(function (_a) {
|
|
22
23
|
var theme = _a.theme;
|
|
23
24
|
return ({
|
|
@@ -31,12 +32,18 @@ var OTPInput = function (_a) {
|
|
|
31
32
|
var t = useTranslation().t;
|
|
32
33
|
var dispatch = useAppDispatch();
|
|
33
34
|
var otpControl = useController({ name: 'otp', control: control });
|
|
35
|
+
var error = useAppSelector(authSelector).error;
|
|
34
36
|
var handleOnOTPChange = function (otp) {
|
|
37
|
+
if (!!error)
|
|
38
|
+
dispatch(clearError());
|
|
35
39
|
otpControl.field.onChange(otp);
|
|
36
40
|
};
|
|
37
41
|
var handleOnResendOTP = function () {
|
|
42
|
+
if (!!error)
|
|
43
|
+
dispatch(clearError());
|
|
38
44
|
if (otpControl.field.value)
|
|
39
45
|
setValue('otp', '', { shouldValidate: true });
|
|
46
|
+
dispatch(resendOTP());
|
|
40
47
|
};
|
|
41
48
|
var otpValue = otpControl.field.value;
|
|
42
49
|
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()); } }) })));
|
|
@@ -51,7 +51,7 @@ var BrandList = function (_a) {
|
|
|
51
51
|
var _b = React.useState(null), anchorEl = _b[0], setAnchorEl = _b[1];
|
|
52
52
|
var t = useTranslation().t;
|
|
53
53
|
var isAr = useLanguage().isAr;
|
|
54
|
-
var
|
|
54
|
+
var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
|
|
55
55
|
var selectedBrandControl = useController({ control: control, name: 'selectedBrandItem' });
|
|
56
56
|
var selectedBrand = selectedBrandControl.field.value;
|
|
57
57
|
var onOpenBrandList = function (event) {
|
|
@@ -64,22 +64,28 @@ var BrandList = function (_a) {
|
|
|
64
64
|
setAnchorEl(null);
|
|
65
65
|
(_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
66
66
|
};
|
|
67
|
-
var getBrandName = function (
|
|
68
|
-
var _a
|
|
69
|
-
return (isAr ?
|
|
67
|
+
var getBrandName = function (_a) {
|
|
68
|
+
var name = _a.name;
|
|
69
|
+
return (isAr ? name === null || name === void 0 ? void 0 : name.ar : name === null || name === void 0 ? void 0 : name.en) || '';
|
|
70
70
|
};
|
|
71
71
|
var getBrandId = function (item) {
|
|
72
72
|
return item.id || '';
|
|
73
73
|
};
|
|
74
|
-
var
|
|
75
|
-
return item
|
|
74
|
+
var isOtherBrand = function (item) {
|
|
75
|
+
return getBrandId(item) === 'other';
|
|
76
76
|
};
|
|
77
77
|
var onSelectItem = function (brand) {
|
|
78
78
|
selectedBrandControl.field.onChange(brand);
|
|
79
|
+
if (!isOtherBrand(brand))
|
|
80
|
+
setValue('salesChannels', brand.channel_services || []);
|
|
81
|
+
if (isOtherBrand(brand)) {
|
|
82
|
+
setValue('salesChannels', []);
|
|
83
|
+
setValue('brandName', 'other');
|
|
84
|
+
}
|
|
79
85
|
onCloseBrandList();
|
|
80
86
|
};
|
|
81
87
|
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('select_brand_label'), readOnly: true, onClick: !!anchorEl ? onCloseBrandList : onOpenBrandList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_brand'), value: t(getBrandName(selectedBrand)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'id', list: list, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
82
|
-
return (_jsxs(_Fragment, { children: [_jsx(BrandContainer, { children: _jsx(BrandNameText, __assign({ isSelected: getBrandId(item) === getBrandId(selectedBrand) }, { children:
|
|
88
|
+
return (_jsxs(_Fragment, { children: [_jsx(BrandContainer, { children: _jsx(BrandNameText, __assign({ isSelected: getBrandId(item) === getBrandId(selectedBrand) }, { children: isOtherBrand(item) ? t(getBrandName(item)) : getBrandName(item) })) }), getBrandId(item) === getBrandId(selectedBrand) && _jsx(CheckIcon, {})] }));
|
|
83
89
|
} }) }))] }) })));
|
|
84
90
|
};
|
|
85
91
|
export default React.memo(BrandList);
|
|
@@ -107,7 +107,6 @@ var BrandName = function (_a) {
|
|
|
107
107
|
var _d = useFormContext(), control = _d.control, watch = _d.watch, setValue = _d.setValue;
|
|
108
108
|
var brandControl = useController({ control: control, name: 'brandName' });
|
|
109
109
|
var salesChannels = watch('salesChannels');
|
|
110
|
-
var selectedBrandItem = watch('selectedBrandItem');
|
|
111
110
|
var brandNameValue = brandControl.field.value;
|
|
112
111
|
var error = (_b = brandControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
113
112
|
var checkBrand = debounce(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -125,6 +124,8 @@ var BrandName = function (_a) {
|
|
|
125
124
|
var updateSalesChannelsWebsiteUrl = function (value) {
|
|
126
125
|
if (!value)
|
|
127
126
|
return;
|
|
127
|
+
if (!salesChannels.length)
|
|
128
|
+
return;
|
|
128
129
|
var brandValue = value.replaceAll(' ', '-').toLowerCase();
|
|
129
130
|
var address = (brandValue[brandValue.length - 1] === '-' ? brandValue.slice(0, -1) : brandValue) + '.com';
|
|
130
131
|
var updatedSalesChannels = salesChannels.map(function (channel) {
|
|
@@ -142,11 +143,6 @@ var BrandName = function (_a) {
|
|
|
142
143
|
brandControl.field.onChange(value);
|
|
143
144
|
updateSalesChannelsWebsiteUrl(value);
|
|
144
145
|
};
|
|
145
|
-
var updateBrandNameIncaseOfOther = React.useCallback(function () { return function (value) {
|
|
146
|
-
if ((selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id) === 'other') {
|
|
147
|
-
brandControl.field.onChange(value);
|
|
148
|
-
}
|
|
149
|
-
}; }, [brandControl.field, selectedBrandItem]);
|
|
150
146
|
React.useEffect(function () {
|
|
151
147
|
var _a, _b, _c;
|
|
152
148
|
var isValid = brandNameValue && !error && brandNameValue.length > 2;
|
|
@@ -27,18 +27,21 @@ import { MerchantValidationSchema } from './validation';
|
|
|
27
27
|
import BrandName from './BrandName';
|
|
28
28
|
import SocialMedia from './SocialMedia';
|
|
29
29
|
import TAC from './TAC';
|
|
30
|
+
import BrandList from './BrandList';
|
|
30
31
|
import SalesChannels from './SalesChannels';
|
|
31
32
|
var Merchant = function (_a) {
|
|
32
33
|
var _b, _c;
|
|
33
34
|
var _d = React.useState(false), brandNameChecking = _d[0], setBrandNameChecking = _d[1];
|
|
34
|
-
var _e =
|
|
35
|
+
var _e = React.useState(false), isBrandListOpen = _e[0], setIsBrandListOpen = _e[1];
|
|
36
|
+
var _f = React.useState(false), isRequiredNewBrand = _f[0], setIsRequiredNewBrand = _f[1];
|
|
37
|
+
var _g = useAppSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
|
|
35
38
|
var settingsData = useAppSelector(settingsSelector).data;
|
|
36
39
|
var isNewIndividual = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.is_new_individual;
|
|
37
40
|
var isAbsher = data.otpData.isAbsher;
|
|
38
|
-
var
|
|
41
|
+
var _h = data.brandData, brandName = _h.brandName, selectedBrandItem = _h.selectedBrandItem, termAndConditionChecked = _h.termAndConditionChecked, responseBody = _h.responseBody, salesChannels = _h.salesChannels;
|
|
39
42
|
var brandList = (responseBody || {}).brand_list;
|
|
40
43
|
var methods = useForm({
|
|
41
|
-
resolver: yupResolver(MerchantValidationSchema()),
|
|
44
|
+
resolver: yupResolver(MerchantValidationSchema(isRequiredNewBrand)),
|
|
42
45
|
defaultValues: {
|
|
43
46
|
brandName: brandName,
|
|
44
47
|
selectedBrandItem: selectedBrandItem,
|
|
@@ -50,8 +53,9 @@ var Merchant = function (_a) {
|
|
|
50
53
|
var t = useTranslation().t;
|
|
51
54
|
var isAr = useLanguage().isAr;
|
|
52
55
|
var dispatch = useAppDispatch();
|
|
56
|
+
var brandListItem = methods.watch('selectedBrandItem');
|
|
53
57
|
var onSubmit = function (formData) {
|
|
54
|
-
dispatch(updateLeadBrand(formData));
|
|
58
|
+
dispatch(updateLeadBrand(__assign(__assign({}, formData), { isNewBrand: isRequiredNewBrand })));
|
|
55
59
|
};
|
|
56
60
|
var onBack = function () {
|
|
57
61
|
var _a;
|
|
@@ -70,14 +74,28 @@ var Merchant = function (_a) {
|
|
|
70
74
|
if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.response_code) === '5')
|
|
71
75
|
methods.setError('brandName', { message: 'Profile Name already exists' });
|
|
72
76
|
}, [responseBody]);
|
|
77
|
+
React.useEffect(function () {
|
|
78
|
+
if (selectedBrandItem.id) {
|
|
79
|
+
methods.setValue('selectedBrandItem', selectedBrandItem, { shouldValidate: true });
|
|
80
|
+
methods.setValue('salesChannels', selectedBrandItem.channel_services || [], { shouldValidate: true });
|
|
81
|
+
}
|
|
82
|
+
}, [selectedBrandItem]);
|
|
73
83
|
React.useEffect(function () {
|
|
74
84
|
if (salesChannels.length > 0)
|
|
75
85
|
methods.setValue('salesChannels', salesChannels);
|
|
76
86
|
}, [salesChannels]);
|
|
87
|
+
React.useEffect(function () {
|
|
88
|
+
if (termAndConditionChecked === true)
|
|
89
|
+
methods.setValue('termAndConditionChecked', termAndConditionChecked, { shouldValidate: true });
|
|
90
|
+
}, [termAndConditionChecked]);
|
|
77
91
|
var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
|
|
78
92
|
var disabled = brandErrChecks || brandNameChecking || ((_c = data.brandData.responseBody) === null || _c === void 0 ? void 0 : _c.response_code) === '5';
|
|
79
93
|
var hasBrandList = (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0;
|
|
80
|
-
var isOtherBrand = (
|
|
81
|
-
|
|
94
|
+
var isOtherBrand = (brandListItem === null || brandListItem === void 0 ? void 0 : brandListItem.id) === 'other' && hasBrandList;
|
|
95
|
+
var isNewBrand = (brandList === null || brandList === void 0 ? void 0 : brandList.length) === 0 || BrandList === undefined;
|
|
96
|
+
React.useEffect(function () {
|
|
97
|
+
setIsRequiredNewBrand(isOtherBrand || isNewBrand);
|
|
98
|
+
}, [isOtherBrand, isNewBrand]);
|
|
99
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: !(isOtherBrand || isNewBrand), list: brandList, onListOpen: function () { return setIsBrandListOpen(true); }, onListClose: function () { return setIsBrandListOpen(false); } }), _jsx(BrandName, { show: (isNewBrand || isOtherBrand) && !isBrandListOpen, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(Collapse, __assign({ in: !isBrandListOpen }, { children: _jsx(SalesChannels, {}) })), _jsx(SocialMedia, { show: !isBrandListOpen }), _jsx(TAC, { show: (isNewBrand || isOtherBrand) && !isBrandListOpen }), _jsx(Collapse, __assign({ in: !isBrandListOpen, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
|
|
82
100
|
};
|
|
83
101
|
export default React.memo(Merchant);
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
export declare
|
|
3
|
-
NEW_USER = "NEW_USER",
|
|
4
|
-
EXISTING_USER_WITH_EXIST_BRAND = "EXISTING_USER_WITH_EXIST_BRAND",
|
|
5
|
-
EXISTING_USER_WITH_OTHER_BRAND = "EXISTING_USER_WITH_OTHER_BRAND"
|
|
6
|
-
}
|
|
7
|
-
export declare const MerchantValidationSchema: () => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
8
|
-
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
9
|
-
termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
|
|
2
|
+
export declare const MerchantValidationSchema: (isNewBrand?: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
10
3
|
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
11
4
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
12
5
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
@@ -17,8 +10,6 @@ export declare const MerchantValidationSchema: () => yup.ObjectSchema<import("yu
|
|
|
17
10
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
18
11
|
}>>[] | undefined>;
|
|
19
12
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
20
|
-
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
21
|
-
termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
|
|
22
13
|
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
23
14
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
24
15
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
@@ -29,8 +20,6 @@ export declare const MerchantValidationSchema: () => yup.ObjectSchema<import("yu
|
|
|
29
20
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
30
21
|
}>>[] | undefined>;
|
|
31
22
|
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
32
|
-
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
33
|
-
termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
|
|
34
23
|
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
35
24
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
36
25
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
@@ -1,27 +1,63 @@
|
|
|
1
1
|
import { REGEX_WEBSITE, REGEX_BRAND_NAME } from '../../../../constants';
|
|
2
2
|
import * as yup from 'yup';
|
|
3
|
-
export var
|
|
4
|
-
(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
16
|
-
if (length === 0)
|
|
3
|
+
export var MerchantValidationSchema = function (isNewBrand) {
|
|
4
|
+
if (isNewBrand === void 0) { isNewBrand = true; }
|
|
5
|
+
if (isNewBrand)
|
|
6
|
+
return yup.object().shape({
|
|
7
|
+
brandName: yup
|
|
8
|
+
.string()
|
|
9
|
+
.test({
|
|
10
|
+
test: function (value) {
|
|
11
|
+
if (length === 0)
|
|
12
|
+
return true;
|
|
13
|
+
if (length < 3 || !(value === null || value === void 0 ? void 0 : value.match(REGEX_BRAND_NAME)))
|
|
14
|
+
return this.createError({ message: 'enter_brand_name_english_chars_numbers_spac' });
|
|
17
15
|
return true;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
.required('enter_brand_name_english_chars_numbers_spac'),
|
|
19
|
+
termAndConditionChecked: yup.boolean().isTrue('check_terms_cond').required('check_terms_cond'),
|
|
20
|
+
salesChannels: yup
|
|
21
|
+
.array()
|
|
22
|
+
.min(1, 'choose_atleast_one_channel')
|
|
23
|
+
.of(yup.object().shape({
|
|
24
|
+
id: yup.string().required('choose_atleast_one_channel')
|
|
25
|
+
}))
|
|
26
|
+
.test({
|
|
27
|
+
test: function (value) {
|
|
28
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
29
|
+
if (length === 0)
|
|
30
|
+
return true;
|
|
31
|
+
var channels = (value || []);
|
|
32
|
+
var dic = {};
|
|
33
|
+
channels.forEach(function (channel) {
|
|
34
|
+
var _a, _b, _c;
|
|
35
|
+
if ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) {
|
|
36
|
+
channel.sub.forEach(function (sub) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
var key = (_b = (_a = sub.name) === null || _a === void 0 ? void 0 : _a.en) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
39
|
+
if (key)
|
|
40
|
+
dic[key] = sub.address || '';
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
var key = (_c = (_b = channel.name) === null || _b === void 0 ? void 0 : _b.en) === null || _c === void 0 ? void 0 : _c.toLowerCase();
|
|
45
|
+
if (key)
|
|
46
|
+
dic[key] = channel.address || '';
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
var requiredOneItemAtLest = Object.values(dic).every(function (item) { return item === ''; });
|
|
50
|
+
if (requiredOneItemAtLest)
|
|
51
|
+
return this.createError({ message: 'enter_at_least_one' });
|
|
52
|
+
var isValidURL = !!dic['website'] ? REGEX_WEBSITE.test(dic['website']) : true;
|
|
53
|
+
if (!isValidURL)
|
|
54
|
+
return this.createError({ message: 'ide_not_valid_url' });
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
.required('choose_atleast_one_channel')
|
|
59
|
+
});
|
|
60
|
+
return yup.object().shape({
|
|
25
61
|
salesChannels: yup
|
|
26
62
|
.array()
|
|
27
63
|
.min(1, 'choose_atleast_one_channel')
|