@tap-payments/auth-jsconnect 2.0.93-test → 2.0.95-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.
Files changed (31) hide show
  1. package/build/@types/app.d.ts +2 -0
  2. package/build/@types/form.d.ts +1 -0
  3. package/build/api/auth.d.ts +6 -2
  4. package/build/api/auth.js +10 -2
  5. package/build/api/index.d.ts +1 -0
  6. package/build/app/settings.d.ts +2 -0
  7. package/build/app/settings.js +8 -5
  8. package/build/constants/api.d.ts +1 -0
  9. package/build/constants/api.js +4 -2
  10. package/build/constants/dummy.d.ts +1 -0
  11. package/build/constants/dummy.js +1 -0
  12. package/build/features/app/auth/authStore.d.ts +6 -7
  13. package/build/features/app/auth/authStore.js +96 -29
  14. package/build/features/auth/Auth.d.ts +1 -1
  15. package/build/features/auth/Auth.js +5 -8
  16. package/build/features/auth/screens/NID/DOB.d.ts +7 -0
  17. package/build/features/auth/screens/NID/DOB.js +47 -0
  18. package/build/features/auth/screens/NID/IDNumber.js +17 -1
  19. package/build/features/auth/screens/NID/NID.js +18 -11
  20. package/build/features/auth/screens/NID/TAC.js +4 -2
  21. package/build/features/auth/screens/NID/validation.d.ts +16 -0
  22. package/build/features/auth/screens/NID/validation.js +10 -0
  23. package/build/features/auth/screens/OTP/OTP.js +6 -2
  24. package/build/features/business/screens/Customers/CustomerLocations.js +6 -6
  25. package/build/features/connect/screens/Merchant/BrandName.js +1 -1
  26. package/build/features/connect/screens/Merchant/SalesChannels.js +1 -1
  27. package/build/features/connect/screens/Merchant/SocialMedia.js +12 -2
  28. package/build/features/connect/screens/Merchant/validation.js +15 -6
  29. package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +2 -2
  30. package/build/features/shared/Dialog/CloseDialog.js +12 -4
  31. package/package.json +1 -1
@@ -54,6 +54,7 @@ export declare enum SocialMediaTypes {
54
54
  }
55
55
  export interface CustomerLocation {
56
56
  id: string;
57
+ code: string;
57
58
  name: {
58
59
  ar: string;
59
60
  en: string;
@@ -98,6 +99,7 @@ export interface Activity {
98
99
  }
99
100
  export interface SubSaleChannel {
100
101
  id: string;
102
+ code: string;
101
103
  name?: {
102
104
  ar: string;
103
105
  en: string;
@@ -18,6 +18,7 @@ export declare type NIDFormValues = {
18
18
  };
19
19
  export declare type IDFormValues = {
20
20
  nid: string;
21
+ dob: string;
21
22
  termAndConditionChecked: boolean;
22
23
  };
23
24
  export declare type CivilFormValues = {
@@ -62,9 +62,12 @@ export declare type CreatePasswordBody = {
62
62
  encryption_contract: Array<string>;
63
63
  };
64
64
  export declare type VerifyAuthKitOTPBody = {
65
- lead_id: string;
66
- verify_token?: string;
65
+ auth_token?: string;
67
66
  data: string;
67
+ auth_type: number;
68
+ service_name: string;
69
+ sign_in: boolean;
70
+ device_token: string;
68
71
  post_url: string;
69
72
  scopes?: Array<string>;
70
73
  terms: Array<string>;
@@ -77,5 +80,6 @@ declare const authService: {
77
80
  verifyAuthKitOTP: (data: VerifyAuthKitOTPBody) => Promise<any>;
78
81
  getVerifyAuth: (token: string, config?: AxiosRequestConfig) => Promise<any>;
79
82
  getTokenVerify: (token: string, config?: AxiosRequestConfig) => Promise<any>;
83
+ createAuthKitNID: (data: CreateAuthBody) => Promise<any>;
80
84
  };
81
85
  export { authService };
package/build/api/auth.js CHANGED
@@ -32,17 +32,25 @@ var getTokenVerify = function (token, config) {
32
32
  };
33
33
  var verifyAuthKitOTP = function (data) {
34
34
  return httpClient({
35
- method: 'post',
35
+ method: 'put',
36
36
  url: "".concat(ENDPOINT_PATHS.VERIFY_AUTH_OTP),
37
37
  data: data
38
38
  });
39
39
  };
40
+ var createAuthKitNID = function (data) {
41
+ return httpClient({
42
+ method: 'post',
43
+ url: "".concat(ENDPOINT_PATHS.CREATE_AUTH_NID),
44
+ data: data
45
+ });
46
+ };
40
47
  var authService = {
41
48
  createAuth: createAuth,
42
49
  verifyAuth: verifyAuth,
43
50
  createPassword: createPassword,
44
51
  verifyAuthKitOTP: verifyAuthKitOTP,
45
52
  getVerifyAuth: getVerifyAuth,
46
- getTokenVerify: getTokenVerify
53
+ getTokenVerify: getTokenVerify,
54
+ createAuthKitNID: createAuthKitNID
47
55
  };
48
56
  export { authService };
@@ -27,6 +27,7 @@ declare const API: {
27
27
  verifyAuthKitOTP: (data: VerifyAuthKitOTPBody) => Promise<any>;
28
28
  getVerifyAuth: (token: string, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<any>;
29
29
  getTokenVerify: (token: string, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<any>;
30
+ createAuthKitNID: (data: CreateAuthBody) => Promise<any>;
30
31
  };
31
32
  leadService: {
32
33
  createLead: (data: CreateLeadBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -5,6 +5,7 @@ export declare const fetchAppSettingsSync: import("@reduxjs/toolkit").AsyncThunk
5
5
  businessCountry: CountryCode;
6
6
  locale: any;
7
7
  deviceInfo: DeviceInfo;
8
+ isValidOperator: boolean;
8
9
  }, {
9
10
  disableCountries?: boolean | undefined;
10
11
  disableLocale?: boolean | undefined;
@@ -20,6 +21,7 @@ export interface SettingsData {
20
21
  isTapOrigin: boolean;
21
22
  businessCountry: CountryCode;
22
23
  countries: Array<CountryCode>;
24
+ isValidOperator: boolean;
23
25
  }
24
26
  export interface SettingsState extends SharedState<SettingsData> {
25
27
  }
@@ -53,7 +53,7 @@ import i18n from '../i18n';
53
53
  import { updateLocale } from '../utils/locale';
54
54
  import API, { setAxiosGlobalHeaders } from '../api';
55
55
  export var fetchAppSettingsSync = createAsyncThunk('fetchAppSettingsSync', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
56
- var settings, _a, appConfig, language, _b, client, device, os, disableCountries, disableLocale, _c, visitorId, _d, ip, latitude, longitude, locale, list, operatorData, deviceInfo, countries, businessCountry;
56
+ var settings, _a, appConfig, language, _b, client, device, os, disableCountries, disableLocale, _c, visitorId, _d, ip, latitude, longitude, locale, list, operatorData, deviceInfo, operatorStatus, isValidOperator, countries, businessCountry;
57
57
  return __generator(this, function (_e) {
58
58
  switch (_e.label) {
59
59
  case 0:
@@ -110,10 +110,11 @@ export var fetchAppSettingsSync = createAsyncThunk('fetchAppSettingsSync', funct
110
110
  setAxiosGlobalHeaders(__assign(__assign({}, getRequestHeaders(deviceInfo)), { authorization: encryptString(appConfig.publicKey), mdn: encryptString(window.location.origin) }));
111
111
  return [4, API.operatorService.validateOperator(operatorData)];
112
112
  case 2:
113
- _e.sent();
113
+ operatorStatus = _e.sent();
114
+ isValidOperator = operatorStatus === 'valid';
114
115
  countries = sortCountries(list);
115
116
  businessCountry = findCountryByIso2(countries, appConfig.businessCountryCode) || defaultCountry;
116
- return [2, { countries: countries, businessCountry: businessCountry, locale: locale, deviceInfo: deviceInfo }];
117
+ return [2, { countries: countries, businessCountry: businessCountry, locale: locale, deviceInfo: deviceInfo, isValidOperator: isValidOperator }];
117
118
  }
118
119
  });
119
120
  }); });
@@ -130,7 +131,8 @@ var initialState = {
130
131
  deviceInfo: DefaultDeviceInfo,
131
132
  appConfig: {},
132
133
  businessCountry: defaultCountry,
133
- countries: []
134
+ countries: [],
135
+ isValidOperator: false
134
136
  }
135
137
  };
136
138
  export var settingsSlice = createSlice({
@@ -233,10 +235,11 @@ export var settingsSlice = createSlice({
233
235
  state.error = null;
234
236
  });
235
237
  builder.addCase(fetchAppSettingsSync.fulfilled, function (state, action) {
236
- var _a = action.payload, businessCountry = _a.businessCountry, countries = _a.countries, locale = _a.locale, deviceInfo = _a.deviceInfo;
238
+ var _a = action.payload, businessCountry = _a.businessCountry, countries = _a.countries, locale = _a.locale, deviceInfo = _a.deviceInfo, isValidOperator = _a.isValidOperator;
237
239
  state.data.countries = countries;
238
240
  state.data.businessCountry = businessCountry;
239
241
  state.data.deviceInfo = deviceInfo;
242
+ state.data.isValidOperator = isValidOperator;
240
243
  if (locale)
241
244
  updateLocale(locale, businessCountry.iso2);
242
245
  state.loading = false;
@@ -36,4 +36,5 @@ export declare const ENDPOINT_PATHS: {
36
36
  VERIFY_AUTH_OTP: string;
37
37
  RETRIEVE_ACTIVITIES_LIST_PATH: string;
38
38
  DOCUMENT: string;
39
+ CREATE_AUTH_NID: string;
39
40
  };
@@ -34,7 +34,8 @@ var TOKEN_VERIFY_PATH = '/token/verify';
34
34
  var RETRIEVE_USER_INFO_PATH = '/user';
35
35
  var BOARD_PATH = '/board';
36
36
  var CONNECT_PATH = '/connect';
37
- var VERIFY_AUTH_OTP_PATH = "".concat(CONNECT_PATH, "/lead/verify");
37
+ var CREATE_AUTH_NID_PATH = "".concat(CONNECT_PATH, "/auth");
38
+ var VERIFY_AUTH_OTP_PATH = "".concat(CONNECT_PATH, "/auth");
38
39
  var DOCUMENT_PATH = '/document';
39
40
  export var ENDPOINT_PATHS = {
40
41
  SANDBOX_BASE_URL: SANDBOX_BASE_URL,
@@ -73,5 +74,6 @@ export var ENDPOINT_PATHS = {
73
74
  BRAND_SALES_CHANNELS: BRAND_SALES_CHANNELS,
74
75
  VERIFY_AUTH_OTP: VERIFY_AUTH_OTP_PATH,
75
76
  RETRIEVE_ACTIVITIES_LIST_PATH: RETRIEVE_ACTIVITIES_LIST_PATH,
76
- DOCUMENT: DOCUMENT_PATH
77
+ DOCUMENT: DOCUMENT_PATH,
78
+ CREATE_AUTH_NID: CREATE_AUTH_NID_PATH
77
79
  };
@@ -1,5 +1,6 @@
1
1
  export declare const OTHER_BRAND: {
2
2
  id: string;
3
+ code: string;
3
4
  name: {
4
5
  ar: string;
5
6
  en: string;
@@ -1,5 +1,6 @@
1
1
  export var OTHER_BRAND = {
2
2
  id: 'other',
3
+ code: 'other',
3
4
  name: {
4
5
  ar: 'other',
5
6
  en: 'other'
@@ -1,19 +1,23 @@
1
1
  import { RootState } from '../../../app/store';
2
- import { ResponseData, OTPFormValues, SharedState, ActionState } from '../../../@types';
2
+ import { ResponseData, OTPFormValues, SharedState, ActionState, IDFormValues } from '../../../@types';
3
3
  export declare const retrieveLead: import("@reduxjs/toolkit").AsyncThunk<any, string, {}>;
4
4
  export declare const verifyAuthOTP: import("@reduxjs/toolkit").AsyncThunk<{
5
5
  response: any;
6
6
  formData: OTPFormValues;
7
7
  }, OTPFormValues, {}>;
8
+ export declare const createAuth: import("@reduxjs/toolkit").AsyncThunk<{
9
+ data: any;
10
+ formData: IDFormValues;
11
+ }, IDFormValues, {}>;
8
12
  export declare const resendOTP: import("@reduxjs/toolkit").AsyncThunk<any, void, {}>;
9
13
  export interface AuthData extends ResponseData {
10
14
  verifyToken: string | undefined;
11
15
  leadId: string;
12
16
  postUrl: string;
13
17
  otp: string;
14
- mobileNumber: string;
15
18
  nid: string;
16
19
  termAndConditionChecked: boolean;
20
+ device_token?: string;
17
21
  dob: string;
18
22
  type: string;
19
23
  countryISOCode: string;
@@ -31,16 +35,11 @@ export declare const authSlice: import("@reduxjs/toolkit").Slice<AuthState, {
31
35
  storePostUrl: (state: AuthState, action: ActionState<{
32
36
  postUrl: string;
33
37
  }>) => void;
34
- storeTerms: (state: AuthState, action: ActionState<{
35
- termAndConditionChecked: boolean;
36
- }>) => void;
37
38
  }, "auth/store">;
38
39
  export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, storeLeadId: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
39
40
  leadId: string;
40
41
  }, string>, storePostUrl: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
41
42
  postUrl: string;
42
- }, string>, storeTerms: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
43
- termAndConditionChecked: boolean;
44
43
  }, string>;
45
44
  declare const _default: import("redux").Reducer<AuthState, import("redux").AnyAction>;
46
45
  export default _default;
@@ -36,8 +36,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  var _a;
38
38
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
39
- import { handleOpen } from '../../../app/settings';
39
+ import { handleNextScreenStep, handleOpen } from '../../../app/settings';
40
40
  import API from '../../../api';
41
+ import { getEighteenYearsAgo } from '../../../utils';
42
+ import { IDENTIFICATION_TYPE } from '../../../constants';
41
43
  export var retrieveLead = createAsyncThunk('retrieveLeadAuthKit', function (leadId) { return __awaiter(void 0, void 0, void 0, function () {
42
44
  var data;
43
45
  return __generator(this, function (_a) {
@@ -50,18 +52,22 @@ export var retrieveLead = createAsyncThunk('retrieveLeadAuthKit', function (lead
50
52
  });
51
53
  }); });
52
54
  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, verifyToken, payload, data;
55
+ var _a, settings, auth, _b, postUrl, verifyToken, device_token, payload, data;
54
56
  var _c, _d, _e, _f;
55
57
  return __generator(this, function (_g) {
56
58
  switch (_g.label) {
57
59
  case 0:
58
60
  _a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
59
- _b = auth.data, leadId = _b.leadId, postUrl = _b.postUrl, verifyToken = _b.verifyToken;
61
+ _b = auth.data, postUrl = _b.postUrl, verifyToken = _b.verifyToken, device_token = _b.device_token;
60
62
  payload = {
61
- lead_id: leadId,
62
- verify_token: verifyToken,
63
+ auth_token: verifyToken,
63
64
  data: params.otp,
64
65
  post_url: postUrl,
66
+ auth_type: 2,
67
+ device_token: device_token || '',
68
+ service_name: 'absher',
69
+ sign_in: false,
70
+ scopes: settings.data.appConfig.scope || [],
65
71
  terms: auth.data.termAndConditionChecked ? ['general'] : [],
66
72
  encryption_contract: ['data']
67
73
  };
@@ -75,24 +81,72 @@ export var verifyAuthOTP = createAsyncThunk('verifyAuthOTPKit', function (params
75
81
  }
76
82
  });
77
83
  }); });
78
- export var resendOTP = createAsyncThunk('authResendOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
79
- var auth, _a, nid, dob, type, countryISOCode, leadId, requestBody, data;
80
- return __generator(this, function (_b) {
81
- switch (_b.label) {
84
+ export var createAuth = createAsyncThunk('authCreateAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
85
+ var _a, auth, settings, _b, type, countryISOCode, nid, dob, identification_id_type, requestBody, data;
86
+ return __generator(this, function (_c) {
87
+ switch (_c.label) {
82
88
  case 0:
83
- auth = thunkApi.getState().auth;
84
- _a = auth.data || {}, nid = _a.nid, dob = _a.dob, type = _a.type, countryISOCode = _a.countryISOCode, leadId = _a.leadId;
89
+ _a = thunkApi.getState(), auth = _a.auth, settings = _a.settings;
90
+ _b = auth.data, type = _b.type, countryISOCode = _b.countryISOCode;
91
+ nid = params.nid, dob = params.dob;
92
+ identification_id_type = type
93
+ ? type
94
+ : params.nid.startsWith('1')
95
+ ? IDENTIFICATION_TYPE.NID
96
+ : IDENTIFICATION_TYPE.IQAMA;
85
97
  requestBody = {
86
- id: leadId,
87
- identification_id: nid,
88
- identification_id_type: type,
89
- date_of_birth: dob,
90
- country_code: countryISOCode,
91
- encryption_contract: ['country_code', 'identification_id', 'identification_id_type', 'date_of_birth']
98
+ lang: settings.data.language,
99
+ user_credentail: {
100
+ identification_id: nid,
101
+ identification_id_type: identification_id_type,
102
+ date_of_birth: dob,
103
+ country_code: countryISOCode || settings.data.businessCountry.iso2
104
+ },
105
+ sign_in: false,
106
+ is_lead: false,
107
+ encryption_contract: [
108
+ 'user_credentail.country_code',
109
+ 'user_credentail.identification_id',
110
+ 'user_credentail.identification_id_type',
111
+ 'user_credentail.date_of_birth'
112
+ ]
92
113
  };
93
- return [4, API.leadService.updateLead(requestBody)];
114
+ return [4, API.authService.createAuthKitNID(requestBody)];
94
115
  case 1:
95
- data = _b.sent();
116
+ data = _c.sent();
117
+ thunkApi.dispatch(handleNextScreenStep());
118
+ return [2, { data: data, formData: params }];
119
+ }
120
+ });
121
+ }); });
122
+ export var resendOTP = createAsyncThunk('authResendOTP', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
123
+ var _a, auth, settings, _b, nid, dob, type, countryISOCode, identification_id_type, requestBody, data;
124
+ return __generator(this, function (_c) {
125
+ switch (_c.label) {
126
+ case 0:
127
+ _a = thunkApi.getState(), auth = _a.auth, settings = _a.settings;
128
+ _b = auth.data, nid = _b.nid, dob = _b.dob, type = _b.type, countryISOCode = _b.countryISOCode;
129
+ identification_id_type = type ? type : nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
130
+ requestBody = {
131
+ lang: settings.data.language,
132
+ user_credentail: {
133
+ identification_id: nid,
134
+ identification_id_type: identification_id_type,
135
+ date_of_birth: dob,
136
+ country_code: countryISOCode || settings.data.businessCountry.iso2
137
+ },
138
+ sign_in: false,
139
+ is_lead: false,
140
+ encryption_contract: [
141
+ 'user_credentail.country_code',
142
+ 'user_credentail.identification_id',
143
+ 'user_credentail.identification_id_type',
144
+ 'user_credentail.date_of_birth'
145
+ ]
146
+ };
147
+ return [4, API.authService.createAuthKitNID(requestBody)];
148
+ case 1:
149
+ data = _c.sent();
96
150
  return [2, data];
97
151
  }
98
152
  });
@@ -106,10 +160,9 @@ var initialState = {
106
160
  leadId: '',
107
161
  postUrl: '',
108
162
  otp: '',
109
- mobileNumber: '',
110
163
  nid: '',
111
164
  termAndConditionChecked: false,
112
- dob: '',
165
+ dob: getEighteenYearsAgo(),
113
166
  type: '',
114
167
  countryISOCode: ''
115
168
  }
@@ -134,10 +187,6 @@ export var authSlice = createSlice({
134
187
  storePostUrl: function (state, action) {
135
188
  var postUrl = action.payload.postUrl;
136
189
  state.data.postUrl = postUrl;
137
- },
138
- storeTerms: function (state, action) {
139
- var termAndConditionChecked = action.payload.termAndConditionChecked;
140
- state.data.termAndConditionChecked = termAndConditionChecked;
141
190
  }
142
191
  },
143
192
  extraReducers: function (builder) {
@@ -147,7 +196,7 @@ export var authSlice = createSlice({
147
196
  state.error = null;
148
197
  })
149
198
  .addCase(retrieveLead.fulfilled, function (state, action) {
150
- var _a, _b, _c;
199
+ var _a;
151
200
  state.customLoading = false;
152
201
  state.error = null;
153
202
  var data = action.payload;
@@ -156,15 +205,33 @@ export var authSlice = createSlice({
156
205
  state.error = description;
157
206
  return;
158
207
  }
159
- 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) || '';
160
208
  state.data.nid = data === null || data === void 0 ? void 0 : data.identification_id;
161
209
  state.data.dob = data === null || data === void 0 ? void 0 : data.date_of_birth;
162
210
  state.data.type = data === null || data === void 0 ? void 0 : data.identification_id_type;
163
211
  state.data.countryISOCode = data === null || data === void 0 ? void 0 : data.country_code;
212
+ state.data.responseBody = data;
164
213
  })
165
214
  .addCase(retrieveLead.rejected, function (state, action) {
166
215
  state.loading = false;
167
216
  state.error = action.error.message;
217
+ })
218
+ .addCase(createAuth.pending, function (state) {
219
+ state.loading = true;
220
+ state.error = null;
221
+ })
222
+ .addCase(createAuth.fulfilled, function (state, action) {
223
+ state.loading = false;
224
+ state.error = null;
225
+ var _a = action.payload, data = _a.data, formData = _a.formData;
226
+ state.data.verifyToken = data === null || data === void 0 ? void 0 : data.auth_token;
227
+ state.data.dob = formData.dob;
228
+ state.data.nid = formData.nid;
229
+ state.data.termAndConditionChecked = formData.termAndConditionChecked;
230
+ state.data.device_token = data === null || data === void 0 ? void 0 : data.device_token;
231
+ })
232
+ .addCase(createAuth.rejected, function (state, action) {
233
+ state.loading = false;
234
+ state.error = action.error.message;
168
235
  })
169
236
  .addCase(verifyAuthOTP.pending, function (state) {
170
237
  state.loading = true;
@@ -184,13 +251,13 @@ export var authSlice = createSlice({
184
251
  .addCase(resendOTP.fulfilled, function (state, action) {
185
252
  state.error = null;
186
253
  var data = action.payload;
187
- state.data.verifyToken = data === null || data === void 0 ? void 0 : data.verify_token;
254
+ state.data.verifyToken = data === null || data === void 0 ? void 0 : data.auth_token;
188
255
  })
189
256
  .addCase(resendOTP.rejected, function (state, action) {
190
257
  state.error = action.error.message;
191
258
  });
192
259
  }
193
260
  });
194
- export var clearError = (_a = authSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, storeLeadId = _a.storeLeadId, storePostUrl = _a.storePostUrl, storeTerms = _a.storeTerms;
261
+ export var clearError = (_a = authSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, storeLeadId = _a.storeLeadId, storePostUrl = _a.storePostUrl;
195
262
  export default authSlice.reducer;
196
263
  export var authSelector = function (state) { return state.auth; };
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { LibConfig } from '../../@types';
3
3
  export interface AuthLibProps extends LibConfig {
4
- leadId: string;
5
4
  postURL: string;
5
+ leadId?: string;
6
6
  onClose?: () => void;
7
7
  }
8
8
  export declare function AuthLib(props: AuthLibProps): JSX.Element;
@@ -45,21 +45,18 @@ var Auth = memo(function (_a) {
45
45
  useStepStartedListener();
46
46
  var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open;
47
47
  useEffect(function () {
48
- if (!props.leadId)
49
- throw new Error('leadId is required');
50
48
  var _a = props || {}, leadId = _a.leadId, postURL = _a.postURL;
51
49
  var data = {
52
- leadId: leadId,
53
50
  postUrl: postURL
54
51
  };
55
- dispatch(storeLeadId(data));
56
52
  dispatch(storePostUrl(data));
53
+ if (leadId)
54
+ dispatch(storeLeadId({ leadId: leadId }));
57
55
  }, []);
58
56
  useEffect(function () {
59
- var leadId = (props || {}).leadId;
60
- if (!settingLoading && activeScreen.name === 'AUTH_NID_STEP')
61
- dispatch(retrieveLead(leadId));
62
- }, [settingLoading]);
57
+ if (data.isValidOperator && props.leadId)
58
+ dispatch(retrieveLead(props.leadId));
59
+ }, [data.isValidOperator]);
63
60
  var handleDialogClose = function () {
64
61
  dispatch(handleOpen(false));
65
62
  };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ interface DOBProps {
3
+ show: boolean;
4
+ onDateClicked?: (flag: boolean) => void;
5
+ }
6
+ declare const DOB: ({ show, onDateClicked }: DOBProps) => JSX.Element;
7
+ export default DOB;
@@ -0,0 +1,47 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useTranslation } from 'react-i18next';
14
+ import { useController, useFormContext } from 'react-hook-form';
15
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
16
+ import { ScreenContainer } from '../../../shared/Containers';
17
+ import DatePicker from '../../../../components/DatePicker';
18
+ import { alpha, styled } from '@mui/material/styles';
19
+ import { clearError, authSelector } from '../../../app/auth/authStore';
20
+ import Text from '../../../../components/Text';
21
+ import Collapse from '../../../../components/Collapse';
22
+ var InputLabelStyled = styled(Text)(function (_a) {
23
+ var theme = _a.theme;
24
+ return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
25
+ });
26
+ var DOB = function (_a) {
27
+ var show = _a.show, onDateClicked = _a.onDateClicked;
28
+ var t = useTranslation().t;
29
+ var control = useFormContext().control;
30
+ var dispatch = useAppDispatch();
31
+ var dobControl = useController({ control: control, name: 'dob' });
32
+ var error = useAppSelector(authSelector).error;
33
+ var handleBirthDateChange = function (data) {
34
+ dobControl.field.onChange(data);
35
+ handleClearError();
36
+ };
37
+ var handleClearError = function () {
38
+ if (error)
39
+ dispatch(clearError());
40
+ };
41
+ var dateValue = dobControl.field.value;
42
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, __assign({ sx: { p: function (_a) {
43
+ var spacing = _a.spacing;
44
+ return spacing(2.5, 2.5, 1.5, 2.5);
45
+ } } }, { children: t('enter_birth_date') })), _jsx(DatePicker, { defaultValue: dateValue ? new Date(dateValue) : new Date(), dir: 'ltr', locale: 'en', onDateChange: handleBirthDateChange, onClick: function () { return onDateClicked === null || onDateClicked === void 0 ? void 0 : onDateClicked(true); }, onDatePicked: function () { return onDateClicked === null || onDateClicked === void 0 ? void 0 : onDateClicked(false); } })] }) })));
46
+ };
47
+ export default DOB;
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import * as React from 'react';
14
+ import { useAppSelector } from '../../../../hooks';
14
15
  import Box from '@mui/material/Box';
15
16
  import { useTranslation } from 'react-i18next';
16
17
  import { useController, useFormContext } from 'react-hook-form';
@@ -20,6 +21,9 @@ import Input from '../../../shared/Input';
20
21
  import CheckIcon from '../../../shared/CheckIcon';
21
22
  import ScreenContainer from '../../../shared/Containers/ScreenContainer';
22
23
  import { ID_NUMBER_LENGTH } from '../../../../constants';
24
+ import { authSelector } from '../../../app/auth/authStore';
25
+ import ClearIcon from '../../../shared/ClearIcon';
26
+ import { removeAllCharsFromNumber } from '../../../../utils';
23
27
  var LabelContainerStyled = styled(Box)(function (_a) {
24
28
  var theme = _a.theme;
25
29
  return ({
@@ -37,12 +41,24 @@ var IDNumber = React.forwardRef(function (_a, ref) {
37
41
  var t = useTranslation().t;
38
42
  var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
39
43
  var nidControl = useController({ control: control, name: 'nid' });
44
+ var data = useAppSelector(authSelector).data;
45
+ var responseBody = data.responseBody;
46
+ var defaultNid = responseBody === null || responseBody === void 0 ? void 0 : responseBody.identification_id;
40
47
  React.useEffect(function () {
41
48
  if (nidControl.field.value)
42
49
  setValue('nid', nidControl.field.value, { shouldValidate: true });
43
50
  }, []);
51
+ var handleIdChange = function (_a) {
52
+ var target = _a.target;
53
+ var value = removeAllCharsFromNumber(target.value);
54
+ nidControl.field.onChange(value);
55
+ };
56
+ var clearIdNumber = function () {
57
+ nidControl.field.onChange('');
58
+ };
44
59
  var nidValue = nidControl.field.value;
45
60
  var error = (_b = nidControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
46
- return (_jsxs(ScreenContainer, __assign({ ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('enter_national_id') }) }), _jsx(Input, { dir: 'ltr', type: 'tel', readOnly: true, inputProps: { maxLength: ID_NUMBER_LENGTH }, value: nidValue, endAdornment: !error && nidValue ? _jsx(CheckIcon, {}) : _jsx(_Fragment, {}), placeholder: t('national_id_placeholder'), warningType: 'alert', warningMessage: error && t(error, { number: '1' }), required: true })] })));
61
+ var readOnly = !!defaultNid;
62
+ return (_jsxs(ScreenContainer, __assign({ ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('enter_national_id') }) }), _jsx(Input, { dir: 'ltr', type: 'tel', readOnly: readOnly, inputProps: { maxLength: ID_NUMBER_LENGTH }, value: nidValue, onChange: handleIdChange, endAdornment: !error && nidValue ? _jsx(CheckIcon, {}) : readOnly ? _jsx(_Fragment, {}) : nidValue && _jsx(ClearIcon, { onClick: clearIdNumber }), placeholder: t('national_id_placeholder'), warningType: 'alert', warningMessage: error && t(error, { number: '1' }), required: true })] })));
47
63
  });
48
64
  export default React.memo(IDNumber);
@@ -15,15 +15,17 @@ import { useTranslation } from 'react-i18next';
15
15
  import { styled } from '@mui/material/styles';
16
16
  import { useForm, FormProvider } from 'react-hook-form';
17
17
  import { yupResolver } from '@hookform/resolvers/yup';
18
- import { NIDValidationSchema } from './validation';
18
+ import { NIDValidationSchema, NIDDOBValidationSchema } from './validation';
19
19
  import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
20
- import { handleNextScreenStep, settingsSelector } from '../../../../app/settings';
21
- import { clearError, authSelector, storeTerms } from '../../../app/auth/authStore';
20
+ import { settingsSelector } from '../../../../app/settings';
21
+ import { clearError, authSelector, createAuth } from '../../../app/auth/authStore';
22
22
  import Form from '../../../../components/Form';
23
23
  import Button from '../../../shared/Button';
24
24
  import { ScreenContainer } from '../../../shared/Containers';
25
+ import Collapse from '../../../../components/Collapse';
25
26
  import IDNumber from './IDNumber';
26
27
  import TAC from './TAC';
28
+ import DOB from './DOB';
27
29
  var FormStyled = styled(Form)(function () { return ({
28
30
  display: 'flex',
29
31
  flexDirection: 'column'
@@ -32,13 +34,17 @@ var NID = function (_a) {
32
34
  var isAr = useLanguage().isAr;
33
35
  var dispatch = useAppDispatch();
34
36
  var t = useTranslation().t;
35
- var _b = useAppSelector(authSelector), data = _b.data, loading = _b.loading, error = _b.error;
37
+ var _b = React.useState(false), collapse = _b[0], setCollapse = _b[1];
38
+ var _c = useAppSelector(authSelector), data = _c.data, loading = _c.loading, error = _c.error;
36
39
  var settingsStore = useAppSelector(settingsSelector);
40
+ var nid = data.nid, dob = data.dob, termAndConditionChecked = data.termAndConditionChecked, responseBody = data.responseBody;
41
+ var defaultDob = responseBody === null || responseBody === void 0 ? void 0 : responseBody.date_of_birth;
37
42
  var methods = useForm({
38
- resolver: yupResolver(NIDValidationSchema),
43
+ resolver: yupResolver(!defaultDob ? NIDDOBValidationSchema : NIDValidationSchema),
39
44
  defaultValues: {
40
- nid: data.nid,
41
- termAndConditionChecked: data.termAndConditionChecked
45
+ nid: nid,
46
+ dob: dob,
47
+ termAndConditionChecked: termAndConditionChecked
42
48
  },
43
49
  mode: 'onChange'
44
50
  });
@@ -46,15 +52,16 @@ var NID = function (_a) {
46
52
  handleClearError();
47
53
  }, [methods.formState.isValid]);
48
54
  var onSubmit = function (data) {
49
- var termAndConditionChecked = data.termAndConditionChecked;
50
- dispatch(storeTerms({ termAndConditionChecked: termAndConditionChecked }));
51
- dispatch(handleNextScreenStep());
55
+ dispatch(createAuth(data));
56
+ };
57
+ var handleCollapseOpenClose = function (flag) {
58
+ setCollapse(flag);
52
59
  };
53
60
  var handleClearError = function () {
54
61
  if (error)
55
62
  dispatch(clearError());
56
63
  };
57
64
  var disabled = !methods.formState.isValid || !!error;
58
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(IDNumber, {}), _jsx(TAC, {}), _jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
65
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(IDNumber, {}) })), _jsx(DOB, { show: !defaultDob, onDateClicked: handleCollapseOpenClose }), _jsxs(Collapse, __assign({ in: !collapse }, { children: [_jsx(TAC, {}), _jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') }))] }))] })) })) }));
59
66
  };
60
67
  export default React.memo(NID);
@@ -25,6 +25,7 @@ import Collapse from '../../../../components/Collapse';
25
25
  import { EXTERNAL_LINKS, TAP_WEBSITE } from '../../../../constants';
26
26
  import { settingsSelector } from '../../../../app/settings';
27
27
  import { useAppSelector } from '../../../../hooks';
28
+ import { authSelector } from '../../../../features/app/auth/authStore';
28
29
  var TACContainerStyled = styled(Box)(function (_a) {
29
30
  var theme = _a.theme;
30
31
  return ({
@@ -66,15 +67,16 @@ var CollapseStyled = styled(Collapse)(function () { return ({
66
67
  width: '100%'
67
68
  }); });
68
69
  var TAC = function () {
69
- var _a;
70
+ var _a, _b;
70
71
  var t = useTranslation().t;
71
72
  var isAr = useLanguage().isAr;
72
73
  var control = useFormContext().control;
73
74
  var settingsData = useAppSelector(settingsSelector).data;
75
+ var data = useAppSelector(authSelector).data;
74
76
  var tacControl = useController({ control: control, name: 'termAndConditionChecked' });
75
77
  var tacChecked = tacControl.field.value;
76
78
  var warningMessage = (_a = tacControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
77
- var countryCode = settingsData.businessCountry.iso2.toLowerCase();
79
+ var countryCode = ((_b = data.countryISOCode) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || settingsData.businessCountry.iso2.toLowerCase();
78
80
  var handleTACCheckedChange = function (event, checked) {
79
81
  tacControl.field.onChange(checked);
80
82
  };
@@ -1,11 +1,27 @@
1
1
  import * as yup from 'yup';
2
2
  export declare const NIDValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
3
  nid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
+ dob: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
4
5
  termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
5
6
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
6
7
  nid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ dob: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
7
9
  termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
8
10
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
9
11
  nid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
12
+ dob: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
13
+ termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
14
+ }>>>;
15
+ export declare const NIDDOBValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
16
+ nid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
17
+ dob: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
18
+ termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
19
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
20
+ nid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
21
+ dob: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
22
+ termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
23
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
24
+ nid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
25
+ dob: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
10
26
  termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
11
27
  }>>>;
@@ -5,5 +5,15 @@ export var NIDValidationSchema = yup.object().shape({
5
5
  .matches(/^(1|2)([0-9]{1,})$/g, 'signup_invalid_national_id_format')
6
6
  .min(10, 'signup_invalid_national_id')
7
7
  .required('signup_invalid_national_id'),
8
+ dob: yup.string().optional(),
9
+ termAndConditionChecked: yup.boolean().required().isTrue('check_terms_cond')
10
+ });
11
+ export var NIDDOBValidationSchema = yup.object().shape({
12
+ nid: yup
13
+ .string()
14
+ .matches(/^(1|2)([0-9]{1,})$/g, 'signup_invalid_national_id_format')
15
+ .min(10, 'signup_invalid_national_id')
16
+ .required('signup_invalid_national_id'),
17
+ dob: yup.string().min(5).required('enter_valid_birth_date'),
8
18
  termAndConditionChecked: yup.boolean().required().isTrue('check_terms_cond')
9
19
  });
@@ -22,6 +22,7 @@ import { useAppDispatch, useAppSelector } from '../../../../hooks';
22
22
  import { useLanguage } from '../../../../hooks';
23
23
  import { useForm, FormProvider } from 'react-hook-form';
24
24
  import { yupResolver } from '@hookform/resolvers/yup';
25
+ import { handlePrevScreenStep } from '../../../../app/settings';
25
26
  import Form from '../../../../components/Form';
26
27
  import { maskPhone } from '../../../../utils';
27
28
  import { OTPValidation } from './validation';
@@ -56,7 +57,7 @@ var OTP = function () {
56
57
  var t = useTranslation().t;
57
58
  var isAr = useLanguage().isAr;
58
59
  React.useEffect(function () {
59
- if (!!data.mobileNumber && error)
60
+ if (error)
60
61
  dispatch(clearError());
61
62
  return function () {
62
63
  dispatch(resetOTPScreen());
@@ -65,8 +66,11 @@ var OTP = function () {
65
66
  var onSubmit = function (formData) {
66
67
  dispatch(verifyAuthOTP(formData));
67
68
  };
69
+ var onBack = function () {
70
+ dispatch(handlePrevScreenStep());
71
+ };
68
72
  var disabled = !methods.formState.isValid || !!error;
69
73
  var phone = data.nid;
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') }))] })) })) }));
74
+ 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, isAr: isAr, loading: loading, error: t(error || ''), onBackClicked: function () { return onBack(); } }, { children: t('confirm') }))] })) })) }));
71
75
  };
72
76
  export default React.memo(OTP);
@@ -110,12 +110,12 @@ var customerLocations = function (_a) {
110
110
  };
111
111
  var onSelectItem = function (customerLocations) {
112
112
  onCloseList();
113
- var checked = customerLocationsList.filter(function (location) { return location.id === customerLocations.id; });
114
- if (customerLocations.id === 'regional')
115
- customerLocationsControl.field.onChange(checked.concat(customerLocationsList.filter(function (location) { return location.id === 'local'; })));
116
- else if (customerLocations.id === 'global')
117
- customerLocationsControl.field.onChange(checked.concat(customerLocationsList.filter(function (location) { return location.id != customerLocations.id; })));
118
- else if (customerLocations.id === 'local')
113
+ var checked = customerLocationsList.filter(function (location) { return (location === null || location === void 0 ? void 0 : location.code) === customerLocations.code; });
114
+ if (customerLocations.code === 'regional')
115
+ customerLocationsControl.field.onChange(checked.concat(customerLocationsList.filter(function (location) { return (location === null || location === void 0 ? void 0 : location.code) === 'local'; })));
116
+ else if (customerLocations.code === 'global')
117
+ customerLocationsControl.field.onChange(checked.concat(customerLocationsList.filter(function (location) { return (location === null || location === void 0 ? void 0 : location.code) != customerLocations.code; })));
118
+ else if (customerLocations.code === 'local')
119
119
  customerLocationsControl.field.onChange(checked);
120
120
  if (error)
121
121
  dispatch(clearError());
@@ -129,7 +129,7 @@ var BrandName = function (_a) {
129
129
  var brandValue = value.replaceAll(' ', '-').toLowerCase();
130
130
  var address = (brandValue[brandValue.length - 1] === '-' ? brandValue.slice(0, -1) : brandValue) + '.com';
131
131
  var updatedSalesChannels = salesChannels.map(function (channel) {
132
- if (channel.id.toLowerCase() === 'website') {
132
+ if (channel.code.toLowerCase() === 'website') {
133
133
  return __assign(__assign({}, channel), { address: address });
134
134
  }
135
135
  return channel;
@@ -95,7 +95,7 @@ var SalesChannels = function (_a) {
95
95
  else {
96
96
  var brandName = getValues('brandName');
97
97
  var newChannel = __assign({}, channel);
98
- if (newChannel.id === 'website' && brandName) {
98
+ if (newChannel.code === 'website' && brandName) {
99
99
  var brandValue = brandName.replaceAll(' ', '-').toLowerCase();
100
100
  var address = (brandValue[brandValue.length - 1] === '-' ? brandValue.slice(0, -1) : brandValue) + '.com';
101
101
  newChannel.address = address;
@@ -31,6 +31,7 @@ import Collapse from '../../../../components/Collapse';
31
31
  import SocialMediaGroup from '../../../../components/SocialMediaGroup';
32
32
  import ToggleButton from '../../../../components/ToggleButton';
33
33
  import Icon from '../../../../components/Icon';
34
+ import { useLanguage } from '../../../../hooks';
34
35
  var SocialMediaGroupStyled = styled(SocialMediaGroup)(function (_a) {
35
36
  var theme = _a.theme, defaultValue = _a.defaultValue;
36
37
  return ({
@@ -80,6 +81,7 @@ var SocialMedia = function (_a) {
80
81
  var show = _a.show;
81
82
  var _c = React.useState(''), activeSocialId = _c[0], setActiveSocialId = _c[1];
82
83
  var t = useTranslation().t;
84
+ var isAr = useLanguage().isAr;
83
85
  var _d = useFormContext(), setValue = _d.setValue, watch = _d.watch, getFieldState = _d.getFieldState;
84
86
  var selectedChannels = watch('salesChannels');
85
87
  var salesChannelsState = getFieldState('salesChannels');
@@ -93,6 +95,7 @@ var SocialMedia = function (_a) {
93
95
  var _a;
94
96
  if (channel.id === id) {
95
97
  return {
98
+ code: channel.code,
96
99
  address: value,
97
100
  logo: channel.logo,
98
101
  id: channel.id,
@@ -104,6 +107,7 @@ var SocialMedia = function (_a) {
104
107
  var updatedSub = channel.sub.map(function (subChannel) {
105
108
  if (subChannel.id === id) {
106
109
  return {
110
+ code: subChannel.code,
107
111
  address: value,
108
112
  logo: subChannel.logo,
109
113
  id: subChannel.id,
@@ -140,6 +144,12 @@ var SocialMedia = function (_a) {
140
144
  React.useEffect(function () {
141
145
  setDefaultActiveSocialId();
142
146
  }, [setDefaultActiveSocialId]);
147
+ var getPlaceHolder = function (item) {
148
+ var _a, _b;
149
+ if (isAr)
150
+ return ((_a = item.name) === null || _a === void 0 ? void 0 : _a.ar) || '';
151
+ return ((_b = item.name) === null || _b === void 0 ? void 0 : _b.en) || '';
152
+ };
143
153
  var hasError = React.useMemo(function () {
144
154
  return ['enter_at_least_one', 'invalid_url'].some(function (error) { var _a, _b; return (_b = (_a = salesChannelsState.error) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.includes(error); });
145
155
  }, [salesChannelsState]);
@@ -160,10 +170,10 @@ var SocialMedia = function (_a) {
160
170
  var isSubActive = activeSocialId === sub.id;
161
171
  return (_jsx(Collapse, __assign({ in: isSubActive, timeout: 300 }, { children: _jsx(InputStyled, { onChange: function (e) {
162
172
  onChangeInput(e.target.value, sub.id);
163
- }, value: sub.address || '', startAdornment: _jsx(TextStyled, {}), placeholder: t("".concat(sub.id)) }) }), "sub_".concat(subIndex)));
173
+ }, value: sub.address || '', startAdornment: _jsx(TextStyled, {}), placeholder: t(getPlaceHolder(sub)) }) }), "sub_".concat(subIndex)));
164
174
  })) : (_jsx(Collapse, __assign({ in: isActive, timeout: 300 }, { children: _jsx(InputStyled, { onChange: function (e) {
165
175
  onChangeInput(e.target.value, channel.id);
166
- }, value: channel.address || '', startAdornment: _jsx(TextStyled, {}), placeholder: t("".concat(channel.id)) }) }), index));
176
+ }, value: channel.address || '', startAdornment: _jsx(TextStyled, {}), placeholder: t(getPlaceHolder(channel)) }) }), index));
167
177
  }), _jsx(Collapse, __assign({ in: hasError }, { children: _jsx(Warning, __assign({ warningType: 'alert' }, { children: t(linksErrorMsg) })) }))] })) })) }));
168
178
  };
169
179
  export default React.memo(SocialMedia);
@@ -1,3 +1,12 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
1
10
  import { REGEX_WEBSITE, REGEX_BRAND_NAME } from '../../../../constants';
2
11
  import * as yup from 'yup';
3
12
  export var MerchantValidationSchema = function (isNewBrand) {
@@ -28,12 +37,12 @@ export var MerchantValidationSchema = function (isNewBrand) {
28
37
  var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
29
38
  if (length === 0)
30
39
  return true;
31
- var channels = (value || []);
40
+ var channels = __spreadArray([], (value || []), true);
32
41
  var dic = {};
33
42
  channels.forEach(function (channel) {
34
43
  var _a, _b, _c;
35
44
  if ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) {
36
- var key_1 = (_b = channel.id) === null || _b === void 0 ? void 0 : _b.toLowerCase();
45
+ var key_1 = (_b = channel.code) === null || _b === void 0 ? void 0 : _b.toLowerCase();
37
46
  if (key_1)
38
47
  dic[key_1] = [];
39
48
  channel.sub.forEach(function (sub) {
@@ -41,7 +50,7 @@ export var MerchantValidationSchema = function (isNewBrand) {
41
50
  });
42
51
  }
43
52
  else {
44
- var key = (_c = channel.id) === null || _c === void 0 ? void 0 : _c.toLowerCase();
53
+ var key = (_c = channel.code) === null || _c === void 0 ? void 0 : _c.toLowerCase();
45
54
  if (key)
46
55
  dic[key] = [channel.address || ''];
47
56
  }
@@ -74,12 +83,12 @@ export var MerchantValidationSchema = function (isNewBrand) {
74
83
  var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
75
84
  if (length === 0)
76
85
  return true;
77
- var channels = (value || []);
86
+ var channels = __spreadArray([], (value || []), true);
78
87
  var dic = {};
79
88
  channels.forEach(function (channel) {
80
89
  var _a, _b, _c;
81
90
  if ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) {
82
- var key_2 = (_b = channel.id) === null || _b === void 0 ? void 0 : _b.toLowerCase();
91
+ var key_2 = (_b = channel.code) === null || _b === void 0 ? void 0 : _b.toLowerCase();
83
92
  if (key_2)
84
93
  dic[key_2] = [];
85
94
  channel.sub.forEach(function (sub) {
@@ -87,7 +96,7 @@ export var MerchantValidationSchema = function (isNewBrand) {
87
96
  });
88
97
  }
89
98
  else {
90
- var key = (_c = channel.id) === null || _c === void 0 ? void 0 : _c.toLowerCase();
99
+ var key = (_c = channel.code) === null || _c === void 0 ? void 0 : _c.toLowerCase();
91
100
  if (key)
92
101
  dic[key] = [channel.address || ''];
93
102
  }
@@ -83,8 +83,8 @@ var Occupation = function (_a) {
83
83
  };
84
84
  var handleSearch = function (value) {
85
85
  var filteredList = occupationsList === null || occupationsList === void 0 ? void 0 : occupationsList.filter(function (occupation) {
86
- return occupation.name.en.toLowerCase().startsWith(value.toLowerCase()) ||
87
- occupation.name.ar.toLowerCase().startsWith(value.toLowerCase());
86
+ return occupation.name.en.toLowerCase().includes(value.toLowerCase()) ||
87
+ occupation.name.ar.toLowerCase().includes(value.toLowerCase());
88
88
  });
89
89
  setOccupationList(filteredList);
90
90
  };
@@ -22,11 +22,14 @@ var ConfirmCloseBox = styled(Box)(function (_a) {
22
22
  borderRadius: theme.spacing(1),
23
23
  height: theme.spacing(5.5),
24
24
  display: 'flex',
25
- justifyContent: 'space-evenly',
25
+ justifyContent: 'space-between',
26
+ flexDirection: 'row',
26
27
  alignItems: 'center',
27
28
  zIndex: 20,
28
29
  width: '100%',
29
- bottom: theme.spacing(2.625)
30
+ bottom: theme.spacing(2.625),
31
+ paddingInlineStart: theme.spacing(2.25),
32
+ paddingInlineEnd: theme.spacing(2.25)
30
33
  });
31
34
  });
32
35
  var DisableBoxStyled = styled(Box)(function (_a) {
@@ -46,7 +49,8 @@ var YesTextStyled = styled(Text)(function (_a) {
46
49
  var theme = _a.theme;
47
50
  return ({
48
51
  color: theme.palette.primary.main,
49
- cursor: 'pointer'
52
+ cursor: 'pointer',
53
+ paddingInlineEnd: theme.spacing(2.5)
50
54
  });
51
55
  });
52
56
  var NoTextStyled = styled(Text)(function (_a) {
@@ -56,8 +60,12 @@ var NoTextStyled = styled(Text)(function (_a) {
56
60
  cursor: 'pointer'
57
61
  });
58
62
  });
63
+ var ConfirmEnd = styled(Box)(function () { return ({
64
+ display: 'flex',
65
+ flexDirection: 'row'
66
+ }); });
59
67
  export default function CloseDialog(_a) {
60
68
  var message = _a.message, confirmTitle = _a.confirmTitle, closeTitle = _a.closeTitle, open = _a.open, onConfirm = _a.onConfirm, onCancel = _a.onCancel;
61
69
  var theme = useTheme();
62
- return (_jsxs(Collapse, __assign({ in: open }, { children: [_jsx(Box, __assign({ sx: { direction: theme.direction } }, { children: _jsxs(ConfirmCloseBox, { children: [_jsxs(Text, { children: [" ", message] }), _jsx(YesTextStyled, __assign({ onClick: onConfirm }, { children: confirmTitle })), _jsx(NoTextStyled, __assign({ onClick: onCancel }, { children: closeTitle }))] }) })), _jsx(DisableBoxStyled, { id: 'disable-container' })] })));
70
+ return (_jsxs(Collapse, __assign({ in: open }, { children: [_jsx(Box, __assign({ sx: { direction: theme.direction } }, { children: _jsxs(ConfirmCloseBox, { children: [_jsxs(Text, { children: [" ", message] }), _jsxs(ConfirmEnd, { children: [_jsx(YesTextStyled, __assign({ onClick: onConfirm }, { children: confirmTitle })), _jsx(NoTextStyled, __assign({ onClick: onCancel }, { children: closeTitle }))] })] }) })), _jsx(DisableBoxStyled, { id: 'disable-container' })] })));
63
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.0.93-test",
3
+ "version": "2.0.95-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",