@tap-payments/auth-jsconnect 2.0.92-test → 2.0.94-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 +2 -0
- package/build/@types/form.d.ts +1 -0
- package/build/app/settings.d.ts +2 -0
- package/build/app/settings.js +8 -5
- package/build/components/AnimationFlow/AnimationFlow.d.ts +2 -1
- package/build/components/AnimationFlow/AnimationFlow.js +4 -4
- package/build/components/AnimationFlow/BottomSheet.d.ts +2 -1
- package/build/components/AnimationFlow/BottomSheet.js +2 -2
- package/build/components/AnimationFlow/Dialog.d.ts +2 -1
- package/build/components/AnimationFlow/Dialog.js +3 -2
- package/build/constants/dummy.d.ts +1 -0
- package/build/constants/dummy.js +1 -0
- package/build/features/app/auth/authStore.d.ts +3 -8
- package/build/features/app/auth/authStore.js +9 -7
- package/build/features/auth/Auth.d.ts +1 -1
- package/build/features/auth/Auth.js +7 -10
- package/build/features/auth/screens/NID/DOB.d.ts +7 -0
- package/build/features/auth/screens/NID/DOB.js +47 -0
- package/build/features/auth/screens/NID/IDNumber.js +17 -1
- package/build/features/auth/screens/NID/NID.js +17 -9
- package/build/features/auth/screens/NID/TAC.js +4 -2
- package/build/features/auth/screens/NID/validation.d.ts +16 -0
- package/build/features/auth/screens/NID/validation.js +10 -0
- package/build/features/auth/screens/OTP/OTP.js +6 -2
- package/build/features/business/screens/Customers/CustomerLocations.js +6 -6
- package/build/features/connect/screens/Merchant/BrandName.js +1 -1
- package/build/features/connect/screens/Merchant/SalesChannels.js +1 -1
- package/build/features/connect/screens/Merchant/SocialMedia.js +12 -2
- package/build/features/connect/screens/Merchant/validation.js +15 -6
- package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +2 -2
- package/build/features/shared/Dialog/CloseDialog.js +12 -4
- package/package.json +1 -1
package/build/@types/app.d.ts
CHANGED
|
@@ -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;
|
package/build/@types/form.d.ts
CHANGED
package/build/app/settings.d.ts
CHANGED
|
@@ -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
|
}
|
package/build/app/settings.js
CHANGED
|
@@ -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;
|
|
@@ -12,5 +12,6 @@ export interface AnimationFlowProps {
|
|
|
12
12
|
animationType?: 'slide' | 'fade' | 'collapse';
|
|
13
13
|
onClose?: () => void;
|
|
14
14
|
onConfirm?: () => void;
|
|
15
|
+
pointerEvents?: 'auto' | 'none';
|
|
15
16
|
}
|
|
16
|
-
export default function AnimationFlow({ open, children, breakpoint, type, footer, loading, error, isTapOrigin, screenId, animationType, onClose, onConfirm }: AnimationFlowProps): JSX.Element;
|
|
17
|
+
export default function AnimationFlow({ open, children, breakpoint, type, footer, loading, error, isTapOrigin, screenId, animationType, onClose, onConfirm, pointerEvents }: AnimationFlowProps): JSX.Element;
|
|
@@ -16,7 +16,7 @@ import BottomSheet from './BottomSheet';
|
|
|
16
16
|
import Loader from './Loader';
|
|
17
17
|
import Error from './Error';
|
|
18
18
|
export default function AnimationFlow(_a) {
|
|
19
|
-
var open = _a.open, children = _a.children, breakpoint = _a.breakpoint, type = _a.type, footer = _a.footer, loading = _a.loading, error = _a.error, isTapOrigin = _a.isTapOrigin, screenId = _a.screenId, animationType = _a.animationType, onClose = _a.onClose, onConfirm = _a.onConfirm;
|
|
19
|
+
var open = _a.open, children = _a.children, breakpoint = _a.breakpoint, type = _a.type, footer = _a.footer, loading = _a.loading, error = _a.error, isTapOrigin = _a.isTapOrigin, screenId = _a.screenId, animationType = _a.animationType, onClose = _a.onClose, onConfirm = _a.onConfirm, _b = _a.pointerEvents, pointerEvents = _b === void 0 ? 'auto' : _b;
|
|
20
20
|
var small = useScreen(breakpoint).small;
|
|
21
21
|
if (loading) {
|
|
22
22
|
return _jsx(Loader, {});
|
|
@@ -25,10 +25,10 @@ export default function AnimationFlow(_a) {
|
|
|
25
25
|
return _jsx(Error, { error: error });
|
|
26
26
|
}
|
|
27
27
|
if (type === 'PUPOP') {
|
|
28
|
-
return (_jsx(Dialog, __assign({ onClose: onClose, onConfirm: onConfirm, footer: footer, open: open, isTapOrigin: isTapOrigin, animationType: animationType }, { children: children })));
|
|
28
|
+
return (_jsx(Dialog, __assign({ pointerEvents: pointerEvents, onClose: onClose, onConfirm: onConfirm, footer: footer, open: open, isTapOrigin: isTapOrigin, animationType: animationType }, { children: children })));
|
|
29
29
|
}
|
|
30
30
|
if (type === 'BOTTOMSHEET') {
|
|
31
|
-
return _jsx(BottomSheet, __assign({ open: open }, { children: children }));
|
|
31
|
+
return (_jsx(BottomSheet, __assign({ pointerEvents: pointerEvents, open: open }, { children: children })));
|
|
32
32
|
}
|
|
33
|
-
return small ? (_jsx(BottomSheet, __assign({ open: open, screenId: screenId }, { children: children }))) : (_jsx(Dialog, __assign({ onClose: onClose, onConfirm: onConfirm, open: open, footer: footer, isTapOrigin: isTapOrigin, animationType: animationType }, { children: children })));
|
|
33
|
+
return small ? (_jsx(BottomSheet, __assign({ pointerEvents: pointerEvents, open: open, screenId: screenId }, { children: children }))) : (_jsx(Dialog, __assign({ pointerEvents: pointerEvents, onClose: onClose, onConfirm: onConfirm, open: open, footer: footer, isTapOrigin: isTapOrigin, animationType: animationType }, { children: children })));
|
|
34
34
|
}
|
|
@@ -5,6 +5,7 @@ export interface BottomSheetProps extends MainBottomSheetProps {
|
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
open: boolean;
|
|
7
7
|
screenId?: string;
|
|
8
|
+
pointerEvents?: 'none' | 'auto';
|
|
8
9
|
}
|
|
9
|
-
declare const _default: React.MemoExoticComponent<({ open, children, screenId, ...rest }: BottomSheetProps) => JSX.Element>;
|
|
10
|
+
declare const _default: React.MemoExoticComponent<({ open, children, screenId, pointerEvents, ...rest }: BottomSheetProps) => JSX.Element>;
|
|
10
11
|
export default _default;
|
|
@@ -60,7 +60,7 @@ var BottomSheetStyled = styled(BottomSheet)(function (_a) {
|
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
var BottomSheetComponent = function (_a) {
|
|
63
|
-
var open = _a.open, children = _a.children, screenId = _a.screenId, rest = __rest(_a, ["open", "children", "screenId"]);
|
|
63
|
+
var open = _a.open, children = _a.children, screenId = _a.screenId, _b = _a.pointerEvents, pointerEvents = _b === void 0 ? 'auto' : _b, rest = __rest(_a, ["open", "children", "screenId", "pointerEvents"]);
|
|
64
64
|
var sheetRef = React.useRef(null);
|
|
65
65
|
var getMinHeight = function (maxHeight) {
|
|
66
66
|
var el = document.getElementById('main-feature-container');
|
|
@@ -78,7 +78,7 @@ var BottomSheetComponent = function (_a) {
|
|
|
78
78
|
}, 500);
|
|
79
79
|
}
|
|
80
80
|
}, [screenId]);
|
|
81
|
-
return (_jsx(BottomSheetStyled, __assign({ ref: sheetRef, open: open, snapPoints: function (_a) {
|
|
81
|
+
return (_jsx(BottomSheetStyled, __assign({ sx: { pointerEvents: pointerEvents }, ref: sheetRef, open: open, snapPoints: function (_a) {
|
|
82
82
|
var maxHeight = _a.maxHeight;
|
|
83
83
|
return [getMinHeight(maxHeight), maxHeight * 0.95];
|
|
84
84
|
} }, rest, { children: children })));
|
|
@@ -9,6 +9,7 @@ export interface DialogProps extends MUIDialogProps {
|
|
|
9
9
|
animationType?: 'slide' | 'fade' | 'collapse';
|
|
10
10
|
onClose?: () => void;
|
|
11
11
|
onConfirm?: () => void;
|
|
12
|
+
pointerEvents?: 'none' | 'auto';
|
|
12
13
|
}
|
|
13
|
-
declare const _default: React.MemoExoticComponent<({ open, children, footer, transitionDuration, isTapOrigin, animationType, onClose, onConfirm, ...rest }: DialogProps) => JSX.Element>;
|
|
14
|
+
declare const _default: React.MemoExoticComponent<({ open, children, footer, transitionDuration, isTapOrigin, animationType, onClose, onConfirm, pointerEvents, ...rest }: DialogProps) => JSX.Element>;
|
|
14
15
|
export default _default;
|
|
@@ -93,7 +93,7 @@ var LogoIconStyled = styled(Icon)(function (_a) {
|
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
var Dialog = function (_a) {
|
|
96
|
-
var open = _a.open, children = _a.children, footer = _a.footer, transitionDuration = _a.transitionDuration, isTapOrigin = _a.isTapOrigin, _b = _a.animationType, animationType = _b === void 0 ? 'slide' : _b, onClose = _a.onClose, onConfirm = _a.onConfirm, rest = __rest(_a, ["open", "children", "footer", "transitionDuration", "isTapOrigin", "animationType", "onClose", "onConfirm"]);
|
|
96
|
+
var open = _a.open, children = _a.children, footer = _a.footer, transitionDuration = _a.transitionDuration, isTapOrigin = _a.isTapOrigin, _b = _a.animationType, animationType = _b === void 0 ? 'slide' : _b, onClose = _a.onClose, onConfirm = _a.onConfirm, _c = _a.pointerEvents, pointerEvents = _c === void 0 ? 'auto' : _c, rest = __rest(_a, ["open", "children", "footer", "transitionDuration", "isTapOrigin", "animationType", "onClose", "onConfirm", "pointerEvents"]);
|
|
97
97
|
var isAr = useLanguage().isAr;
|
|
98
98
|
var animation = {};
|
|
99
99
|
if (animationType === 'slide') {
|
|
@@ -104,7 +104,8 @@ var Dialog = function (_a) {
|
|
|
104
104
|
}, sx: {
|
|
105
105
|
'& .MuiDialog-paper': {
|
|
106
106
|
overflowY: 'visible'
|
|
107
|
-
}
|
|
107
|
+
},
|
|
108
|
+
pointerEvents: pointerEvents
|
|
108
109
|
}, hideBackdrop: true, PaperComponent: PaperStyled, open: open, transitionDuration: transitionDuration || 500, keepMounted: true, "aria-describedby": 'dialog-slide-description' }, rest, animation, { children: [_jsx(DialogContainer, __assign({ isTapOrigin: isTapOrigin, onClose: onClose, onConfirm: onConfirm }, { children: _jsxs(DialogContentStyled, { children: [_jsxs(Collapse, __assign({ in: !isTapOrigin }, { children: [_jsx(LogoBadge, { src: ICONS_NAMES.LOGO_ICON }), _jsx(LogoIconBoxStyled, { children: _jsx(LogoIconStyled, { src: isAr ? ICONS_NAMES.TAP_AR : ICONS_NAMES.TAP_EN, alt: 'tap logo' }) })] })), children] }) })), footer] })));
|
|
109
110
|
};
|
|
110
111
|
export default React.memo(Dialog);
|
package/build/constants/dummy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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;
|
|
@@ -11,7 +11,6 @@ export interface AuthData extends ResponseData {
|
|
|
11
11
|
leadId: string;
|
|
12
12
|
postUrl: string;
|
|
13
13
|
otp: string;
|
|
14
|
-
mobileNumber: string;
|
|
15
14
|
nid: string;
|
|
16
15
|
termAndConditionChecked: boolean;
|
|
17
16
|
dob: string;
|
|
@@ -31,17 +30,13 @@ export declare const authSlice: import("@reduxjs/toolkit").Slice<AuthState, {
|
|
|
31
30
|
storePostUrl: (state: AuthState, action: ActionState<{
|
|
32
31
|
postUrl: string;
|
|
33
32
|
}>) => void;
|
|
34
|
-
|
|
35
|
-
termAndConditionChecked: boolean;
|
|
36
|
-
}>) => void;
|
|
33
|
+
storeData: (state: AuthState, action: ActionState<IDFormValues>) => void;
|
|
37
34
|
}, "auth/store">;
|
|
38
35
|
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
36
|
leadId: string;
|
|
40
37
|
}, string>, storePostUrl: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
41
38
|
postUrl: string;
|
|
42
|
-
}, string>,
|
|
43
|
-
termAndConditionChecked: boolean;
|
|
44
|
-
}, string>;
|
|
39
|
+
}, string>, storeData: import("@reduxjs/toolkit").ActionCreatorWithPayload<IDFormValues, string>;
|
|
45
40
|
declare const _default: import("redux").Reducer<AuthState, import("redux").AnyAction>;
|
|
46
41
|
export default _default;
|
|
47
42
|
export declare const authSelector: (state: RootState) => AuthState;
|
|
@@ -38,6 +38,7 @@ var _a;
|
|
|
38
38
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
39
39
|
import { handleOpen } from '../../../app/settings';
|
|
40
40
|
import API from '../../../api';
|
|
41
|
+
import { getEighteenYearsAgo } from '../../../utils';
|
|
41
42
|
export var retrieveLead = createAsyncThunk('retrieveLeadAuthKit', function (leadId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
43
|
var data;
|
|
43
44
|
return __generator(this, function (_a) {
|
|
@@ -106,10 +107,9 @@ var initialState = {
|
|
|
106
107
|
leadId: '',
|
|
107
108
|
postUrl: '',
|
|
108
109
|
otp: '',
|
|
109
|
-
mobileNumber: '',
|
|
110
110
|
nid: '',
|
|
111
111
|
termAndConditionChecked: false,
|
|
112
|
-
dob:
|
|
112
|
+
dob: getEighteenYearsAgo(),
|
|
113
113
|
type: '',
|
|
114
114
|
countryISOCode: ''
|
|
115
115
|
}
|
|
@@ -135,9 +135,11 @@ export var authSlice = createSlice({
|
|
|
135
135
|
var postUrl = action.payload.postUrl;
|
|
136
136
|
state.data.postUrl = postUrl;
|
|
137
137
|
},
|
|
138
|
-
|
|
139
|
-
var
|
|
138
|
+
storeData: function (state, action) {
|
|
139
|
+
var _a = action.payload, termAndConditionChecked = _a.termAndConditionChecked, nid = _a.nid, dob = _a.dob;
|
|
140
140
|
state.data.termAndConditionChecked = termAndConditionChecked;
|
|
141
|
+
state.data.nid = nid;
|
|
142
|
+
state.data.dob = dob;
|
|
141
143
|
}
|
|
142
144
|
},
|
|
143
145
|
extraReducers: function (builder) {
|
|
@@ -147,7 +149,7 @@ export var authSlice = createSlice({
|
|
|
147
149
|
state.error = null;
|
|
148
150
|
})
|
|
149
151
|
.addCase(retrieveLead.fulfilled, function (state, action) {
|
|
150
|
-
var _a
|
|
152
|
+
var _a;
|
|
151
153
|
state.customLoading = false;
|
|
152
154
|
state.error = null;
|
|
153
155
|
var data = action.payload;
|
|
@@ -156,11 +158,11 @@ export var authSlice = createSlice({
|
|
|
156
158
|
state.error = description;
|
|
157
159
|
return;
|
|
158
160
|
}
|
|
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
161
|
state.data.nid = data === null || data === void 0 ? void 0 : data.identification_id;
|
|
161
162
|
state.data.dob = data === null || data === void 0 ? void 0 : data.date_of_birth;
|
|
162
163
|
state.data.type = data === null || data === void 0 ? void 0 : data.identification_id_type;
|
|
163
164
|
state.data.countryISOCode = data === null || data === void 0 ? void 0 : data.country_code;
|
|
165
|
+
state.data.responseBody = data;
|
|
164
166
|
})
|
|
165
167
|
.addCase(retrieveLead.rejected, function (state, action) {
|
|
166
168
|
state.loading = false;
|
|
@@ -191,6 +193,6 @@ export var authSlice = createSlice({
|
|
|
191
193
|
});
|
|
192
194
|
}
|
|
193
195
|
});
|
|
194
|
-
export var clearError = (_a = authSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, storeLeadId = _a.storeLeadId, storePostUrl = _a.storePostUrl,
|
|
196
|
+
export var clearError = (_a = authSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, storeLeadId = _a.storeLeadId, storePostUrl = _a.storePostUrl, storeData = _a.storeData;
|
|
195
197
|
export default authSlice.reducer;
|
|
196
198
|
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;
|
|
@@ -39,31 +39,28 @@ var Auth = memo(function (_a) {
|
|
|
39
39
|
var theme = useAppTheme().theme;
|
|
40
40
|
var dispatch = useAppDispatch();
|
|
41
41
|
var _b = useAppSelector(settingsSelector), data = _b.data, error = _b.error, settingLoading = _b.loading;
|
|
42
|
-
var _c = useAppSelector(authSelector), authError = _c.error, customLoading = _c.customLoading;
|
|
42
|
+
var _c = useAppSelector(authSelector), authError = _c.error, customLoading = _c.customLoading, loading = _c.loading;
|
|
43
43
|
useAppConfig(__assign({ navigation: AUTH_SCREENS_NAVIGATION, disableCountries: true, disableLocale: true }, props));
|
|
44
44
|
useErrorListener(authError || error);
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
};
|
|
66
|
-
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ open: open, isTapOrigin: isTapOrigin, loading: settingLoading || customLoading }, { children: _jsx(AnimationFlow, __assign({ onClose: onClose, onConfirm: handleDialogClose, isTapOrigin: isTapOrigin, loading: settingLoading || customLoading, error: error, open: open, footer: _jsx(_Fragment, {}), screenId: activeScreen.name, animationType: 'collapse' }, { children: _jsx(FeatureContainer, { children: authFeatureScreens.map(function (_a, index) {
|
|
63
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ open: open, isTapOrigin: isTapOrigin, loading: settingLoading || customLoading }, { children: _jsx(AnimationFlow, __assign({ pointerEvents: loading ? 'none' : 'auto', onClose: onClose, onConfirm: handleDialogClose, isTapOrigin: isTapOrigin, loading: settingLoading || customLoading, error: error, open: open, footer: _jsx(_Fragment, {}), screenId: activeScreen.name, animationType: 'collapse' }, { children: _jsx(FeatureContainer, { children: authFeatureScreens.map(function (_a, index) {
|
|
67
64
|
var Element = _a.element, name = _a.name;
|
|
68
65
|
var isActive = activeScreen.name === name;
|
|
69
66
|
return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));
|
|
@@ -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
|
-
|
|
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
20
|
import { handleNextScreenStep, settingsSelector } from '../../../../app/settings';
|
|
21
|
-
import { clearError, authSelector,
|
|
21
|
+
import { clearError, authSelector, storeData } 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 =
|
|
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:
|
|
41
|
-
|
|
45
|
+
nid: nid,
|
|
46
|
+
dob: dob,
|
|
47
|
+
termAndConditionChecked: termAndConditionChecked
|
|
42
48
|
},
|
|
43
49
|
mode: 'onChange'
|
|
44
50
|
});
|
|
@@ -46,15 +52,17 @@ var NID = function (_a) {
|
|
|
46
52
|
handleClearError();
|
|
47
53
|
}, [methods.formState.isValid]);
|
|
48
54
|
var onSubmit = function (data) {
|
|
49
|
-
|
|
50
|
-
dispatch(storeTerms({ termAndConditionChecked: termAndConditionChecked }));
|
|
55
|
+
dispatch(storeData(data));
|
|
51
56
|
dispatch(handleNextScreenStep());
|
|
52
57
|
};
|
|
58
|
+
var handleCollapseOpenClose = function (flag) {
|
|
59
|
+
setCollapse(flag);
|
|
60
|
+
};
|
|
53
61
|
var handleClearError = function () {
|
|
54
62
|
if (error)
|
|
55
63
|
dispatch(clearError());
|
|
56
64
|
};
|
|
57
65
|
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') }))] })) })) }));
|
|
66
|
+
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
67
|
};
|
|
60
68
|
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 (
|
|
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,
|
|
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.
|
|
114
|
-
if (customerLocations.
|
|
115
|
-
customerLocationsControl.field.onChange(checked.concat(customerLocationsList.filter(function (location) { return location.
|
|
116
|
-
else if (customerLocations.
|
|
117
|
-
customerLocationsControl.field.onChange(checked.concat(customerLocationsList.filter(function (location) { return location.
|
|
118
|
-
else if (customerLocations.
|
|
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.
|
|
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.
|
|
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(
|
|
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(
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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().
|
|
87
|
-
occupation.name.ar.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-
|
|
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
|
}
|