@tap-payments/auth-jsconnect 1.0.41 → 1.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/@types/app.d.ts +9 -33
- package/build/api/data.d.ts +1 -0
- package/build/api/data.js +5 -1
- package/build/api/entity.d.ts +3 -4
- package/build/api/index.d.ts +2 -2
- package/build/api/lead.d.ts +1 -2
- package/build/api/lead.js +3 -7
- package/build/components/AnimationFlow/BottomSheet.js +3 -23
- package/build/components/Footer/Footer.d.ts +3 -1
- package/build/components/Footer/Footer.js +11 -47
- package/build/constants/api.d.ts +2 -2
- package/build/constants/api.js +5 -5
- package/build/constants/dummy.d.ts +14 -36
- package/build/constants/dummy.js +29 -53
- package/build/features/app/business/businessStore.d.ts +9 -7
- package/build/features/app/business/businessStore.js +81 -51
- package/build/features/app/connect/connectStore.js +1 -1
- package/build/features/business/screens/Activities/Activities.js +6 -1
- package/build/features/business/screens/BusinessType/BusinessType.js +2 -3
- package/build/features/business/screens/BusinessType/CompanyLicense.d.ts +2 -2
- package/build/features/business/screens/BusinessType/CompanyLicense.js +9 -6
- package/build/features/business/screens/BusinessType/FreelanceLicense.d.ts +2 -2
- package/build/features/business/screens/BusinessType/FreelanceLicense.js +9 -9
- package/build/features/business/screens/Customers/CustomerLocations.js +14 -4
- package/build/features/business/screens/Customers/Customers.js +17 -10
- package/build/features/business/screens/Customers/ExpectedCustomers.js +14 -4
- package/build/features/business/screens/Customers/ExpectedSalesRange.js +14 -4
- package/build/features/connect/screens/Individual/Email.js +1 -1
- package/build/features/connect/screens/Merchant/BrandName.js +1 -1
- package/build/features/connect/screens/Mobile/Mobile.js +1 -2
- package/build/features/connect/screens/NID/NID.js +1 -2
- package/build/features/shared/Containers/FeatureContainer.js +1 -1
- package/build/features/shared/Containers/ScreenContainer.js +1 -1
- package/build/features/shared/Footer/Footer.js +7 -1
- package/build/hooks/useElementSizeById.d.ts +6 -0
- package/build/hooks/useElementSizeById.js +12 -0
- package/package.json +1 -1
|
@@ -173,7 +173,7 @@ export var updateLeadIdentity = createAsyncThunk('updateLeadIdentity', function
|
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
175
|
}); });
|
|
176
|
-
export var
|
|
176
|
+
export var retrieveEntityList = createAsyncThunk('retrieveEntityList', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
177
177
|
var business, leadId, data;
|
|
178
178
|
var _a;
|
|
179
179
|
return __generator(this, function (_b) {
|
|
@@ -181,22 +181,7 @@ export var retrieveCRInfos = createAsyncThunk('retrieveCRInfos', function (param
|
|
|
181
181
|
case 0:
|
|
182
182
|
business = thunkApi.getState().business;
|
|
183
183
|
leadId = (_a = business.data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.id;
|
|
184
|
-
return [4, API.leadService.
|
|
185
|
-
case 1:
|
|
186
|
-
data = (_b.sent()).data;
|
|
187
|
-
return [2, { data: data }];
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
}); });
|
|
191
|
-
export var retrieveFLInfos = createAsyncThunk('retrieveFLInfos', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
192
|
-
var business, leadId, data;
|
|
193
|
-
var _a;
|
|
194
|
-
return __generator(this, function (_b) {
|
|
195
|
-
switch (_b.label) {
|
|
196
|
-
case 0:
|
|
197
|
-
business = thunkApi.getState().business;
|
|
198
|
-
leadId = (_a = business.data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.id;
|
|
199
|
-
return [4, API.leadService.retrieveFLInfos(leadId)];
|
|
184
|
+
return [4, API.leadService.retrieveEntityList(leadId)];
|
|
200
185
|
case 1:
|
|
201
186
|
data = (_b.sent()).data;
|
|
202
187
|
return [2, { data: data }];
|
|
@@ -290,6 +275,7 @@ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', funct
|
|
|
290
275
|
case 1:
|
|
291
276
|
data = (_f.sent()).data;
|
|
292
277
|
if (!data.errors) {
|
|
278
|
+
thunkApi.dispatch(retrieveDataList());
|
|
293
279
|
thunkApi.dispatch(handleNextScreenStep());
|
|
294
280
|
(_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, requestBody);
|
|
295
281
|
}
|
|
@@ -297,28 +283,53 @@ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', funct
|
|
|
297
283
|
}
|
|
298
284
|
});
|
|
299
285
|
}); });
|
|
286
|
+
export var retrieveDataList = createAsyncThunk('retrieveDataList', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
287
|
+
var customerBases, expectedSales, expectedCustomerSales;
|
|
288
|
+
return __generator(this, function (_a) {
|
|
289
|
+
switch (_a.label) {
|
|
290
|
+
case 0: return [4, API.dataService.getCustomerBases()];
|
|
291
|
+
case 1:
|
|
292
|
+
customerBases = _a.sent();
|
|
293
|
+
return [4, API.dataService.getExpectedSales()];
|
|
294
|
+
case 2:
|
|
295
|
+
expectedSales = _a.sent();
|
|
296
|
+
return [4, API.dataService.getExpectedCutomerSales()];
|
|
297
|
+
case 3:
|
|
298
|
+
expectedCustomerSales = _a.sent();
|
|
299
|
+
return [2, {
|
|
300
|
+
customerBasesData: customerBases === null || customerBases === void 0 ? void 0 : customerBases.data,
|
|
301
|
+
expectedSalesData: expectedSales === null || expectedSales === void 0 ? void 0 : expectedSales.data,
|
|
302
|
+
expectedCustomerSalesData: expectedCustomerSales === null || expectedCustomerSales === void 0 ? void 0 : expectedCustomerSales.data
|
|
303
|
+
}];
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}); });
|
|
300
307
|
export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
301
|
-
var _a, settings, business, requestBody, headers, data;
|
|
302
|
-
var _b, _c, _d;
|
|
303
|
-
return __generator(this, function (
|
|
304
|
-
switch (
|
|
308
|
+
var _a, settings, business, customerBase, requestBody, headers, data;
|
|
309
|
+
var _b, _c, _d, _e, _f;
|
|
310
|
+
return __generator(this, function (_g) {
|
|
311
|
+
switch (_g.label) {
|
|
305
312
|
case 0:
|
|
306
313
|
_a = thunkApi.getState(), settings = _a.settings, business = _a.business;
|
|
314
|
+
customerBase = params.customerLocations.map(function (_a) {
|
|
315
|
+
var value = _a.value;
|
|
316
|
+
return value;
|
|
317
|
+
});
|
|
307
318
|
requestBody = {
|
|
308
|
-
customers_base:
|
|
309
|
-
customers_served_monthly: params.expectedCustomers,
|
|
310
|
-
yearly_sales_range: params.
|
|
319
|
+
customers_base: customerBase,
|
|
320
|
+
customers_served_monthly: ((_b = params.expectedCustomers) === null || _b === void 0 ? void 0 : _b.value) || '',
|
|
321
|
+
yearly_sales_range: ((_c = params.expectedCustomers) === null || _c === void 0 ? void 0 : _c.value) || '',
|
|
311
322
|
agree_refund: params.refundPolicy,
|
|
312
323
|
agree_chargeback: params.transactionPolicy,
|
|
313
324
|
step_name: BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS
|
|
314
325
|
};
|
|
315
|
-
headers = { entity_id: (
|
|
326
|
+
headers = { entity_id: (_d = business.data.otpData.responseBody) === null || _d === void 0 ? void 0 : _d.id };
|
|
316
327
|
return [4, API.entityService.updateEntityInfo(requestBody, { headers: headers })];
|
|
317
328
|
case 1:
|
|
318
|
-
data = (
|
|
329
|
+
data = (_g.sent()).data;
|
|
319
330
|
if (!data.errors) {
|
|
320
331
|
thunkApi.dispatch(handleNextScreenStep());
|
|
321
|
-
(
|
|
332
|
+
(_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, requestBody);
|
|
322
333
|
}
|
|
323
334
|
return [2, { data: data, formData: __assign({}, params) }];
|
|
324
335
|
}
|
|
@@ -484,43 +495,29 @@ export var businessSlice = createSlice({
|
|
|
484
495
|
state.loading = false;
|
|
485
496
|
state.error = action.error.message;
|
|
486
497
|
})
|
|
487
|
-
.addCase(
|
|
498
|
+
.addCase(retrieveEntityList.pending, function (state) {
|
|
488
499
|
state.loading = true;
|
|
489
500
|
state.error = null;
|
|
490
501
|
})
|
|
491
|
-
.addCase(
|
|
502
|
+
.addCase(retrieveEntityList.fulfilled, function (state, action) {
|
|
492
503
|
var _a;
|
|
493
504
|
state.loading = false;
|
|
494
505
|
state.error = null;
|
|
495
506
|
var data = action.payload.data;
|
|
496
507
|
var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
497
508
|
if (!description) {
|
|
498
|
-
|
|
499
|
-
|
|
509
|
+
var fl = data.fl, cr = data.cr;
|
|
510
|
+
if (Array.isArray(cr)) {
|
|
511
|
+
state.data.crInfos = cr;
|
|
500
512
|
state.data.businessTypeData.businessType = BusinessType.CR;
|
|
501
513
|
}
|
|
514
|
+
if (Array.isArray(fl)) {
|
|
515
|
+
state.data.flInfos = fl;
|
|
516
|
+
state.data.businessTypeData.businessType = BusinessType.FL;
|
|
517
|
+
}
|
|
502
518
|
}
|
|
503
519
|
})
|
|
504
|
-
.addCase(
|
|
505
|
-
state.loading = false;
|
|
506
|
-
state.error = action.error.message;
|
|
507
|
-
})
|
|
508
|
-
.addCase(retrieveFLInfos.pending, function (state) {
|
|
509
|
-
state.loading = true;
|
|
510
|
-
state.error = null;
|
|
511
|
-
})
|
|
512
|
-
.addCase(retrieveFLInfos.fulfilled, function (state, action) {
|
|
513
|
-
var _a;
|
|
514
|
-
state.loading = false;
|
|
515
|
-
state.error = null;
|
|
516
|
-
var data = action.payload.data;
|
|
517
|
-
var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
518
|
-
if (!description) {
|
|
519
|
-
state.data.flInfos = data === null || data === void 0 ? void 0 : data.licenses;
|
|
520
|
-
state.data.businessTypeData.businessType = BusinessType.FL;
|
|
521
|
-
}
|
|
522
|
-
})
|
|
523
|
-
.addCase(retrieveFLInfos.rejected, function (state, action) {
|
|
520
|
+
.addCase(retrieveEntityList.rejected, function (state, action) {
|
|
524
521
|
state.loading = false;
|
|
525
522
|
state.error = action.error.message;
|
|
526
523
|
})
|
|
@@ -608,6 +605,39 @@ export var businessSlice = createSlice({
|
|
|
608
605
|
.addCase(updateActivitiesInfo.rejected, function (state, action) {
|
|
609
606
|
state.loading = false;
|
|
610
607
|
state.error = action.error.message;
|
|
608
|
+
})
|
|
609
|
+
.addCase(retrieveDataList.pending, function (state) {
|
|
610
|
+
state.loading = true;
|
|
611
|
+
state.error = null;
|
|
612
|
+
})
|
|
613
|
+
.addCase(retrieveDataList.fulfilled, function (state, action) {
|
|
614
|
+
var _a, _b, _c;
|
|
615
|
+
state.loading = false;
|
|
616
|
+
state.error = null;
|
|
617
|
+
var _d = action.payload, customerBasesData = _d.customerBasesData, expectedSalesData = _d.expectedSalesData, expectedCustomerSalesData = _d.expectedCustomerSalesData;
|
|
618
|
+
var description = (((_a = customerBasesData === null || customerBasesData === void 0 ? void 0 : customerBasesData.errors) === null || _a === void 0 ? void 0 : _a[0]) ||
|
|
619
|
+
((_b = expectedSalesData === null || expectedSalesData === void 0 ? void 0 : expectedSalesData.errors) === null || _b === void 0 ? void 0 : _b[0]) ||
|
|
620
|
+
((_c = expectedCustomerSalesData === null || expectedCustomerSalesData === void 0 ? void 0 : expectedCustomerSalesData.errors) === null || _c === void 0 ? void 0 : _c[0]) ||
|
|
621
|
+
{}).description;
|
|
622
|
+
if (description) {
|
|
623
|
+
state.error = description;
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
var data = state.data.activitiesData.responseBody;
|
|
627
|
+
state.data.activitiesData.responseBody = __assign(__assign({}, data), { customerBases: customerBasesData || [], expectedSales: expectedSalesData.data || [], expectedCustomerSales: expectedCustomerSalesData.data || [] });
|
|
628
|
+
var selectedCustomerBase = customerBasesData === null || customerBasesData === void 0 ? void 0 : customerBasesData[0];
|
|
629
|
+
if (!!selectedCustomerBase)
|
|
630
|
+
state.data.customersData.customerLocations = [selectedCustomerBase];
|
|
631
|
+
var selectedExpectedSale = expectedSalesData === null || expectedSalesData === void 0 ? void 0 : expectedSalesData[(expectedSalesData === null || expectedSalesData === void 0 ? void 0 : expectedSalesData.length) - 1];
|
|
632
|
+
if (!!selectedExpectedSale)
|
|
633
|
+
state.data.customersData.expectedSalesRange = selectedExpectedSale;
|
|
634
|
+
var selectedExpectedCustomerSale = expectedCustomerSalesData === null || expectedCustomerSalesData === void 0 ? void 0 : expectedCustomerSalesData[(expectedCustomerSalesData === null || expectedCustomerSalesData === void 0 ? void 0 : expectedCustomerSalesData.length) - 1];
|
|
635
|
+
if (!!selectedExpectedCustomerSale)
|
|
636
|
+
state.data.customersData.expectedCustomers = selectedExpectedCustomerSale;
|
|
637
|
+
})
|
|
638
|
+
.addCase(retrieveDataList.rejected, function (state, action) {
|
|
639
|
+
state.loading = false;
|
|
640
|
+
state.error = action.error.message;
|
|
611
641
|
})
|
|
612
642
|
.addCase(updateCustomersInfo.pending, function (state) {
|
|
613
643
|
state.loading = true;
|
|
@@ -535,7 +535,7 @@ export var connectSlice = createSlice({
|
|
|
535
535
|
var firstName = (name_1 === null || name_1 === void 0 ? void 0 : name_1.first) + ' ';
|
|
536
536
|
var middleName = !!(name_1 === null || name_1 === void 0 ? void 0 : name_1.middle) ? (name_1 === null || name_1 === void 0 ? void 0 : name_1.middle) + ' ' : '';
|
|
537
537
|
var thirdName = !!(name_1 === null || name_1 === void 0 ? void 0 : name_1.third) ? (name_1 === null || name_1 === void 0 ? void 0 : name_1.third) + ' ' : '';
|
|
538
|
-
var lastName = !!(name_1 === null || name_1 === void 0 ? void 0 : name_1.last) ? name_1 === null || name_1 === void 0 ? void 0 : name_1.
|
|
538
|
+
var lastName = !!(name_1 === null || name_1 === void 0 ? void 0 : name_1.last) ? name_1 === null || name_1 === void 0 ? void 0 : name_1.last : '';
|
|
539
539
|
if (!!name_1) {
|
|
540
540
|
var capitalizedName = capitalizeTheFirstLetterOfEachWord(firstName + middleName + thirdName + lastName);
|
|
541
541
|
state.data.individualData.name = capitalizedName;
|
|
@@ -40,9 +40,10 @@ var Activities = function () {
|
|
|
40
40
|
var t = useTranslation().t;
|
|
41
41
|
var _d = useSelector(businessSelector), data = _d.data, loading = _d.loading, error = _d.error;
|
|
42
42
|
var businessTypeResponse = data.businessTypeData.responseBody;
|
|
43
|
+
var activitiesData = data.activitiesData;
|
|
43
44
|
var methods = useForm({
|
|
44
45
|
resolver: yupResolver(ActivitiesValidationSchema),
|
|
45
|
-
defaultValues:
|
|
46
|
+
defaultValues: activitiesData,
|
|
46
47
|
mode: 'onChange'
|
|
47
48
|
});
|
|
48
49
|
var onSubmit = function (data) {
|
|
@@ -55,6 +56,10 @@ var Activities = function () {
|
|
|
55
56
|
var onBack = function () {
|
|
56
57
|
dispatch(handlePrevScreenStep());
|
|
57
58
|
};
|
|
59
|
+
React.useEffect(function () {
|
|
60
|
+
var salesChannels = activitiesData.salesChannels;
|
|
61
|
+
methods.setValue('salesChannels', salesChannels);
|
|
62
|
+
}, [activitiesData.salesChannels]);
|
|
58
63
|
React.useEffect(function () {
|
|
59
64
|
if (error)
|
|
60
65
|
dispatch(clearError());
|
|
@@ -21,7 +21,7 @@ import Form from '../../../../components/Form';
|
|
|
21
21
|
import Collapse from '../../../../components/Collapse';
|
|
22
22
|
import { useLanguage } from '../../../../hooks';
|
|
23
23
|
import ScreenContainer from '../../../shared/Containers/ScreenContainer';
|
|
24
|
-
import { businessSelector, clearError,
|
|
24
|
+
import { businessSelector, clearError, retrieveEntityList, updateLeadBusinessType } from '../../../app/business/businessStore';
|
|
25
25
|
import { BusinessType as BusinessTypeEnum } from '../../../../@types';
|
|
26
26
|
import Button from '../../../shared/Button';
|
|
27
27
|
import { CRValidationSchema, FLValidationSchema } from './validation';
|
|
@@ -42,8 +42,7 @@ var BusinessType = function (_a) {
|
|
|
42
42
|
mode: 'onChange'
|
|
43
43
|
});
|
|
44
44
|
React.useEffect(function () {
|
|
45
|
-
dispatch(
|
|
46
|
-
dispatch(retrieveCRInfos());
|
|
45
|
+
dispatch(retrieveEntityList());
|
|
47
46
|
}, []);
|
|
48
47
|
React.useEffect(function () {
|
|
49
48
|
var businessType = businessTypeData.businessType;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { License } from '../../../../@types';
|
|
3
3
|
interface CompanyLicenseProps {
|
|
4
4
|
show: boolean;
|
|
5
|
-
list: Array<
|
|
5
|
+
list: Array<License>;
|
|
6
6
|
onSelectLicense?: (number: string) => void;
|
|
7
7
|
onListOpen?: () => void;
|
|
8
8
|
onListClose?: () => void;
|
|
@@ -43,7 +43,7 @@ import SimpleList from '../../../../components/SimpleList';
|
|
|
43
43
|
import Text from '../../../../components/Text';
|
|
44
44
|
import ExpandIcon from '../../../../components/ExpandIcon';
|
|
45
45
|
import Collapse from '../../../../components/Collapse';
|
|
46
|
-
import {
|
|
46
|
+
import { OTHER_LICENSE } from '../../../../constants';
|
|
47
47
|
import CRNumber from './CRNumber';
|
|
48
48
|
var InputStyled = styled(Input)(function (_a) {
|
|
49
49
|
var theme = _a.theme;
|
|
@@ -88,19 +88,22 @@ var CompanyLicense = function (_a) {
|
|
|
88
88
|
setSelectedLicense(first);
|
|
89
89
|
setValue('crNumber', getLicenseNumber(first), { shouldValidate: true });
|
|
90
90
|
if (!hasOther)
|
|
91
|
-
array = __spreadArray(__spreadArray([], array, true), [
|
|
91
|
+
array = __spreadArray(__spreadArray([], array, true), [OTHER_LICENSE], false);
|
|
92
92
|
setLicenseList(array);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}, [show, list]);
|
|
96
96
|
var getLicenseNumber = function (item) {
|
|
97
|
-
|
|
97
|
+
var _a;
|
|
98
|
+
return ((_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.number) || '';
|
|
98
99
|
};
|
|
99
100
|
var getLicenseName = function (item) {
|
|
100
|
-
|
|
101
|
+
var _a, _b;
|
|
102
|
+
return (isAr ? (_a = item === null || item === void 0 ? void 0 : item.legal_name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.legal_name) === null || _b === void 0 ? void 0 : _b.en) || '';
|
|
101
103
|
};
|
|
102
104
|
var isOtherLicense = function (item) {
|
|
103
|
-
|
|
105
|
+
var _a;
|
|
106
|
+
return ((_a = item === null || item === void 0 ? void 0 : item.legal_name) === null || _a === void 0 ? void 0 : _a.en) === 'other';
|
|
104
107
|
};
|
|
105
108
|
var onSelectItem = function (license) {
|
|
106
109
|
setSelectedLicense(license);
|
|
@@ -112,7 +115,7 @@ var CompanyLicense = function (_a) {
|
|
|
112
115
|
};
|
|
113
116
|
var hasList = (licenseList === null || licenseList === void 0 ? void 0 : licenseList.length) > 0;
|
|
114
117
|
var showCRNumber = !anchorEl;
|
|
115
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: hasList }, { children: [_jsx(InputStyled, { label: t('enter_commercial_register_no'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_cr'), value: t(getLicenseName(selectedLicense)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: '
|
|
118
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: hasList }, { children: [_jsx(InputStyled, { label: t('enter_commercial_register_no'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_cr'), value: t(getLicenseName(selectedLicense)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
116
119
|
return (_jsxs(_Fragment, { children: [_jsx(LicenseContainer, { children: _jsx(LicenseNameText, __assign({ isSelected: getLicenseNumber(item) === getLicenseNumber(selectedLicense) }, { children: isOtherLicense(item)
|
|
117
120
|
? t(getLicenseNumber(item))
|
|
118
121
|
: isAr
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { License } from '../../../../@types';
|
|
3
3
|
interface FreelanceLicenseProps {
|
|
4
4
|
show: boolean;
|
|
5
|
-
list: Array<
|
|
5
|
+
list: Array<License>;
|
|
6
6
|
onSelectLicense?: (number: string) => void;
|
|
7
7
|
onListOpen?: () => void;
|
|
8
8
|
onListClose?: () => void;
|
|
@@ -42,7 +42,7 @@ import ScreenContainer from '../../../shared/Containers/ScreenContainer';
|
|
|
42
42
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
43
43
|
import ExpandIcon from '../../../../components/ExpandIcon';
|
|
44
44
|
import Input from '../../../shared/Input';
|
|
45
|
-
import {
|
|
45
|
+
import { OTHER_LICENSE } from '../../../../constants';
|
|
46
46
|
import SimpleList from '../../../../components/SimpleList';
|
|
47
47
|
import FLNumber from './FLNumber';
|
|
48
48
|
var InputStyled = styled(Input)(function (_a) {
|
|
@@ -88,22 +88,22 @@ var FreelanceLicense = function (_a) {
|
|
|
88
88
|
setSelectedLicense(first);
|
|
89
89
|
setValue('flNumber', getLicenseNumber(first), { shouldValidate: true });
|
|
90
90
|
if (!hasOther)
|
|
91
|
-
array = __spreadArray(__spreadArray([], array, true), [
|
|
91
|
+
array = __spreadArray(__spreadArray([], array, true), [OTHER_LICENSE], false);
|
|
92
92
|
setLicenseList(array);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}, [show, list]);
|
|
96
96
|
var getLicenseNumber = function (item) {
|
|
97
|
-
|
|
97
|
+
var _a;
|
|
98
|
+
return ((_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.number) || '';
|
|
98
99
|
};
|
|
99
100
|
var isOtherLicense = function (item) {
|
|
100
|
-
|
|
101
|
+
var _a;
|
|
102
|
+
return ((_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.number) === 'other';
|
|
101
103
|
};
|
|
102
104
|
var getLicenseName = function (item) {
|
|
103
|
-
var _a, _b
|
|
104
|
-
return ((
|
|
105
|
-
? (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.license_specialities) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.speciality) === null || _c === void 0 ? void 0 : _c.name
|
|
106
|
-
: (_f = (_e = (_d = item === null || item === void 0 ? void 0 : item.license_specialities) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.speciality) === null || _f === void 0 ? void 0 : _f.name_en) || '');
|
|
105
|
+
var _a, _b;
|
|
106
|
+
return (isAr ? (_a = item === null || item === void 0 ? void 0 : item.legal_name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.legal_name) === null || _b === void 0 ? void 0 : _b.en) || '';
|
|
107
107
|
};
|
|
108
108
|
var onSelectItem = function (license) {
|
|
109
109
|
setSelectedLicense(license);
|
|
@@ -115,7 +115,7 @@ var FreelanceLicense = function (_a) {
|
|
|
115
115
|
};
|
|
116
116
|
var hasList = (licenseList === null || licenseList === void 0 ? void 0 : licenseList.length) > 0;
|
|
117
117
|
var showFLNumber = !anchorEl;
|
|
118
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: hasList }, { children: [_jsx(InputStyled, { label: t('enter_freelance_license'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_fl'), value: t(getLicenseName(selectedLicense)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: '
|
|
118
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: hasList }, { children: [_jsx(InputStyled, { label: t('enter_freelance_license'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_fl'), value: t(getLicenseName(selectedLicense)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
119
119
|
return (_jsxs(_Fragment, { children: [_jsx(LicenseContainer, { children: _jsx(LicenseNameText, __assign({ isSelected: getLicenseNumber(item) === getLicenseNumber(selectedLicense) }, { children: isOtherLicense(item)
|
|
120
120
|
? t(getLicenseNumber(item))
|
|
121
121
|
: isAr
|
|
@@ -22,6 +22,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
import * as React from 'react';
|
|
25
|
+
import { useSelector } from 'react-redux';
|
|
25
26
|
import Box from '@mui/material/Box';
|
|
26
27
|
import { useTranslation } from 'react-i18next';
|
|
27
28
|
import { useController, useFormContext } from 'react-hook-form';
|
|
@@ -34,7 +35,7 @@ import Input from '../../../../components/Input';
|
|
|
34
35
|
import SimpleList from '../../../../components/SimpleList';
|
|
35
36
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
36
37
|
import { useLanguage } from '../../../../hooks';
|
|
37
|
-
import {
|
|
38
|
+
import { businessSelector } from '../../../app/business/businessStore';
|
|
38
39
|
export var InputLabelStyled = styled(Text)(function (_a) {
|
|
39
40
|
var theme = _a.theme;
|
|
40
41
|
return (__assign({ margin: theme.spacing(2.5, 2.5, 1.5, 2.5), color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
|
|
@@ -73,12 +74,15 @@ var SimpleListStyled = styled((SimpleList))(function () { return ({
|
|
|
73
74
|
}); });
|
|
74
75
|
var customerLocations = function (_a) {
|
|
75
76
|
var rest = __rest(_a, []);
|
|
76
|
-
var
|
|
77
|
-
var
|
|
77
|
+
var _b = React.useState([]), customerLocationsList = _b[0], setCustomerLocationsList = _b[1];
|
|
78
|
+
var _c = React.useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
|
|
78
79
|
var t = useTranslation().t;
|
|
79
80
|
var isAr = useLanguage().isAr;
|
|
80
81
|
var control = useFormContext().control;
|
|
81
82
|
var customerLocationsControl = useController({ name: 'customerLocations', control: control });
|
|
83
|
+
var data = useSelector(businessSelector).data;
|
|
84
|
+
var activitiesData = data.activitiesData;
|
|
85
|
+
var response = activitiesData.responseBody;
|
|
82
86
|
var onOpenList = function (event) {
|
|
83
87
|
var _a;
|
|
84
88
|
setAnchorEl(event.currentTarget);
|
|
@@ -89,6 +93,12 @@ var customerLocations = function (_a) {
|
|
|
89
93
|
setAnchorEl(null);
|
|
90
94
|
(_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
91
95
|
};
|
|
96
|
+
React.useEffect(function () {
|
|
97
|
+
var _a;
|
|
98
|
+
if (((_a = response === null || response === void 0 ? void 0 : response.customerBases) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
99
|
+
setCustomerLocationsList(response === null || response === void 0 ? void 0 : response.customerBases);
|
|
100
|
+
}
|
|
101
|
+
}, [response === null || response === void 0 ? void 0 : response.customerBases]);
|
|
92
102
|
var checkRemainingCondition = function (item) {
|
|
93
103
|
return !!customerLocationsValue.find(function (location) {
|
|
94
104
|
return location.id === item.id;
|
|
@@ -102,7 +112,7 @@ var customerLocations = function (_a) {
|
|
|
102
112
|
var customerLocationsValue = customerLocationsControl.field.value;
|
|
103
113
|
var customerLocationSelected = customerLocationsValue[customerLocationsValue.length - 1];
|
|
104
114
|
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('select_customer_base') }), _jsx(InputStyled, { readOnly: true, value: isAr ? customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.nameAR : customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: customerLocationsList, placeholder: 'choose_customer_base', onSelectItem: onSelectItem, renderItem: function (item) {
|
|
105
|
-
return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue.id) }, { children: isAr ? item.
|
|
115
|
+
return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue.id) }, { children: isAr ? item.titleAr : item.title })) })), item.id === (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(CheckIconStyled, {}), checkRemainingCondition(item) && item.id != (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(RemainingCheck, {})] }));
|
|
106
116
|
} }) }))] }) })));
|
|
107
117
|
};
|
|
108
118
|
export default React.memo(customerLocations);
|
|
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import Box from '@mui/material/Box/Box';
|
|
14
|
+
import { useSelector } from 'react-redux';
|
|
14
15
|
import { styled } from '@mui/material/styles';
|
|
15
16
|
import * as React from 'react';
|
|
16
17
|
import { useTranslation } from 'react-i18next';
|
|
@@ -25,12 +26,11 @@ import { useLanguage } from '../../../../hooks';
|
|
|
25
26
|
import CustomerLocations from './CustomerLocations';
|
|
26
27
|
import ExpectedCustomers from './ExpectedCustomers';
|
|
27
28
|
import ExpectedSales from './ExpectedSalesRange';
|
|
28
|
-
import { CUSTOMER_LOCATIONS, EXPECTED_CUSTOMERS, EXPECTED_SALES_RANGE } from '../../../../constants';
|
|
29
29
|
import RefundPolicy from './RefundPolicy';
|
|
30
30
|
import TransactionPolicy from './TransactionPolicy';
|
|
31
31
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
32
32
|
import Collapse from '../../../../components/Collapse';
|
|
33
|
-
import { updateCustomersInfo } from '../../../app/business/businessStore';
|
|
33
|
+
import { businessSelector, clearError, updateCustomersInfo } from '../../../app/business/businessStore';
|
|
34
34
|
var FormStyled = styled(Form)(function () { return ({
|
|
35
35
|
display: 'flex',
|
|
36
36
|
flexDirection: 'column'
|
|
@@ -44,15 +44,11 @@ var ListType;
|
|
|
44
44
|
var Customers = function (_a) {
|
|
45
45
|
var _b = React.useState(), listActive = _b[0], setListActive = _b[1];
|
|
46
46
|
var dispatch = useAppDispatch();
|
|
47
|
+
var _c = useSelector(businessSelector), data = _c.data, loading = _c.loading, error = _c.error;
|
|
48
|
+
var customerData = data.customersData;
|
|
47
49
|
var methods = useForm({
|
|
48
50
|
resolver: yupResolver(CustomerInfoValidation),
|
|
49
|
-
defaultValues:
|
|
50
|
-
customerLocations: CUSTOMER_LOCATIONS,
|
|
51
|
-
expectedCustomers: EXPECTED_CUSTOMERS[EXPECTED_CUSTOMERS.length - 1],
|
|
52
|
-
expectedSalesRange: EXPECTED_SALES_RANGE[EXPECTED_SALES_RANGE.length - 1],
|
|
53
|
-
refundPolicy: false,
|
|
54
|
-
transactionPolicy: false
|
|
55
|
-
},
|
|
51
|
+
defaultValues: data.customersData,
|
|
56
52
|
mode: 'onChange'
|
|
57
53
|
});
|
|
58
54
|
var onSubmit = function (data) {
|
|
@@ -67,6 +63,16 @@ var Customers = function (_a) {
|
|
|
67
63
|
var handleMenuClick = function (flag) {
|
|
68
64
|
setListActive(flag);
|
|
69
65
|
};
|
|
66
|
+
React.useEffect(function () {
|
|
67
|
+
if (error)
|
|
68
|
+
dispatch(clearError());
|
|
69
|
+
}, [methods.formState.isValid]);
|
|
70
|
+
React.useEffect(function () {
|
|
71
|
+
var customerLocations = customerData.customerLocations, expectedCustomers = customerData.expectedCustomers, expectedSalesRange = customerData.expectedSalesRange;
|
|
72
|
+
methods.setValue('customerLocations', customerLocations);
|
|
73
|
+
methods.setValue('expectedCustomers', expectedCustomers);
|
|
74
|
+
methods.setValue('expectedSalesRange', expectedSalesRange);
|
|
75
|
+
}, [customerData.customerLocations, customerData.expectedCustomers, customerData.expectedSalesRange]);
|
|
70
76
|
var isCustomerLocationsListActive = listActive === ListType.CustomerLocationsList;
|
|
71
77
|
var isExpectedCustomersListActive = listActive === ListType.ExpectedCustomersList;
|
|
72
78
|
var isExpectedSalesListActive = listActive === ListType.ExpectedSalesList;
|
|
@@ -74,6 +80,7 @@ var Customers = function (_a) {
|
|
|
74
80
|
var whenNotSelectExpectedCustomers = !isCustomerLocationsListActive && !isExpectedSalesListActive;
|
|
75
81
|
var whenNotSelectExpectedSales = !isCustomerLocationsListActive && !isExpectedCustomersListActive;
|
|
76
82
|
var isAnyListSelected = !isExpectedCustomersListActive && !isCustomerLocationsListActive && !isExpectedSalesListActive;
|
|
77
|
-
|
|
83
|
+
var disabled = !methods.formState.isValid || !!error;
|
|
84
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(CustomerLocations, { show: whenNotSelectCustomersLocation, onListOpen: function () { return handleMenuClick(ListType.CustomerLocationsList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(ExpectedCustomers, { show: whenNotSelectExpectedCustomers, onListOpen: function () { return handleMenuClick(ListType.ExpectedCustomersList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(ExpectedSales, { show: whenNotSelectExpectedSales, onListOpen: function () { return handleMenuClick(ListType.ExpectedSalesList); }, onListClose: function () { return handleMenuClick(); } }), _jsxs(Collapse, __assign({ in: isAnyListSelected }, { children: [_jsx(RefundPolicy, {}), _jsx(TransactionPolicy, {}), _jsx(Box, __assign({ sx: { mt: 2 } }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disabled: disabled, loading: loading, error: t(error || '') }, { children: t('next') })) }))] }))] })) })) }));
|
|
78
85
|
};
|
|
79
86
|
export default React.memo(Customers);
|
|
@@ -22,17 +22,18 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
import * as React from 'react';
|
|
25
|
+
import { useSelector } from 'react-redux';
|
|
25
26
|
import Box from '@mui/material/Box';
|
|
26
27
|
import { styled } from '@mui/material/styles';
|
|
27
28
|
import { useTranslation } from 'react-i18next';
|
|
28
29
|
import { useController, useFormContext } from 'react-hook-form';
|
|
29
30
|
import { useLanguage } from '../../../../hooks';
|
|
30
31
|
import SimpleList from '../../../../components/SimpleList';
|
|
31
|
-
import { EXPECTED_CUSTOMERS } from '../../../../constants';
|
|
32
32
|
import Collapse from '../../../../components/Collapse';
|
|
33
33
|
import ExpandIcon from '../../../../components/ExpandIcon';
|
|
34
34
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
35
35
|
import { CheckIconStyled, InputLabelStyled, InputStyled, NameContainer } from './CustomerLocations';
|
|
36
|
+
import { businessSelector } from '../../../app/business/businessStore';
|
|
36
37
|
var ListItemContainer = styled(Box)(function (_a) {
|
|
37
38
|
var theme = _a.theme;
|
|
38
39
|
return ({
|
|
@@ -45,12 +46,15 @@ var SimpleListStyled = styled((SimpleList))(function () { return ({
|
|
|
45
46
|
}); });
|
|
46
47
|
var ExpectedCustomers = function (_a) {
|
|
47
48
|
var rest = __rest(_a, []);
|
|
48
|
-
var
|
|
49
|
-
var
|
|
49
|
+
var _b = React.useState([]), expectedCustomersList = _b[0], setExpectedCustomersList = _b[1];
|
|
50
|
+
var _c = React.useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
|
|
50
51
|
var t = useTranslation().t;
|
|
51
52
|
var isAr = useLanguage().isAr;
|
|
52
53
|
var control = useFormContext().control;
|
|
53
54
|
var expectedCustomersControl = useController({ name: 'expectedCustomers', control: control });
|
|
55
|
+
var data = useSelector(businessSelector).data;
|
|
56
|
+
var activitiesData = data.activitiesData;
|
|
57
|
+
var response = activitiesData.responseBody;
|
|
54
58
|
var onOpenList = function (event) {
|
|
55
59
|
var _a;
|
|
56
60
|
setAnchorEl(event.currentTarget);
|
|
@@ -61,6 +65,12 @@ var ExpectedCustomers = function (_a) {
|
|
|
61
65
|
setAnchorEl(null);
|
|
62
66
|
(_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
63
67
|
};
|
|
68
|
+
React.useEffect(function () {
|
|
69
|
+
var _a;
|
|
70
|
+
if (((_a = response === null || response === void 0 ? void 0 : response.expectedCustomerSales) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
71
|
+
setExpectedCustomersList(response === null || response === void 0 ? void 0 : response.expectedCustomerSales);
|
|
72
|
+
}
|
|
73
|
+
}, [response === null || response === void 0 ? void 0 : response.expectedCustomerSales]);
|
|
64
74
|
var onSelectItem = function (expectedCustomers) {
|
|
65
75
|
onCloseList();
|
|
66
76
|
expectedCustomersControl.field.onChange(expectedCustomers);
|
|
@@ -68,7 +78,7 @@ var ExpectedCustomers = function (_a) {
|
|
|
68
78
|
var expectedCustomersValue = expectedCustomersControl.field.value;
|
|
69
79
|
var expectedCustomersSelected = expectedCustomersValue;
|
|
70
80
|
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_customers_to_serve') }), _jsx(InputStyled, { readOnly: true, value: isAr ? expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.nameAR : expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.name, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: expectedCustomersList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
71
|
-
return (_jsxs(_Fragment, { children: [_jsx(ListItemContainer, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (expectedCustomersValue === null || expectedCustomersValue === void 0 ? void 0 : expectedCustomersValue.id) }, { children: isAr ? item.
|
|
81
|
+
return (_jsxs(_Fragment, { children: [_jsx(ListItemContainer, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (expectedCustomersValue === null || expectedCustomersValue === void 0 ? void 0 : expectedCustomersValue.id) }, { children: isAr ? item.titleAr : item.title })) }), item.id === (expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.id) && _jsx(CheckIconStyled, {})] }));
|
|
72
82
|
} }) }))] }) })));
|
|
73
83
|
};
|
|
74
84
|
export default ExpectedCustomers;
|
|
@@ -27,12 +27,13 @@ import { styled } from '@mui/material/styles';
|
|
|
27
27
|
import { useTranslation } from 'react-i18next';
|
|
28
28
|
import { useController, useFormContext } from 'react-hook-form';
|
|
29
29
|
import { useLanguage } from '../../../../hooks';
|
|
30
|
-
import { EXPECTED_SALES_RANGE } from '../../../../constants';
|
|
31
30
|
import SimpleList from '../../../../components/SimpleList';
|
|
32
31
|
import Collapse from '../../../../components/Collapse';
|
|
33
32
|
import ExpandIcon from '../../../../components/ExpandIcon';
|
|
34
33
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
35
34
|
import { InputLabelStyled, CheckIconStyled, InputStyled, NameContainer } from './CustomerLocations';
|
|
35
|
+
import { useSelector } from 'react-redux';
|
|
36
|
+
import { businessSelector } from '../../../../features/app/business/businessStore';
|
|
36
37
|
var ListItemContainer = styled(Box)(function () { return ({
|
|
37
38
|
display: 'flex'
|
|
38
39
|
}); });
|
|
@@ -41,12 +42,15 @@ var SimpleListStyled = styled((SimpleList))(function () { return ({
|
|
|
41
42
|
}); });
|
|
42
43
|
var ExpectedSalesRange = function (_a) {
|
|
43
44
|
var rest = __rest(_a, []);
|
|
44
|
-
var
|
|
45
|
-
var
|
|
45
|
+
var _b = React.useState([]), expectedSalesRangeList = _b[0], setExpectedSalesRangeList = _b[1];
|
|
46
|
+
var _c = React.useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
|
|
46
47
|
var t = useTranslation().t;
|
|
47
48
|
var isAr = useLanguage().isAr;
|
|
48
49
|
var control = useFormContext().control;
|
|
49
50
|
var expectedSalesRangeControl = useController({ name: 'expectedSalesRange', control: control });
|
|
51
|
+
var data = useSelector(businessSelector).data;
|
|
52
|
+
var activitiesData = data.activitiesData;
|
|
53
|
+
var response = activitiesData.responseBody;
|
|
50
54
|
var onOpenList = function (event) {
|
|
51
55
|
var _a;
|
|
52
56
|
setAnchorEl(event.currentTarget);
|
|
@@ -57,6 +61,12 @@ var ExpectedSalesRange = function (_a) {
|
|
|
57
61
|
setAnchorEl(null);
|
|
58
62
|
(_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
59
63
|
};
|
|
64
|
+
React.useEffect(function () {
|
|
65
|
+
var _a;
|
|
66
|
+
if (((_a = response === null || response === void 0 ? void 0 : response.expectedSales) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
67
|
+
setExpectedSalesRangeList(response === null || response === void 0 ? void 0 : response.expectedSales);
|
|
68
|
+
}
|
|
69
|
+
}, [response === null || response === void 0 ? void 0 : response.expectedSales]);
|
|
60
70
|
var checkRemainingCondition = function (item) {
|
|
61
71
|
return !!expectedSalesRangeValue.find(function (expectedSale) {
|
|
62
72
|
return expectedSale.id === item.id;
|
|
@@ -69,7 +79,7 @@ var ExpectedSalesRange = function (_a) {
|
|
|
69
79
|
var expectedSalesRangeValue = expectedSalesRangeControl.field.value || expectedSalesRangeList;
|
|
70
80
|
var expectedSalesRangeSelected = expectedSalesRangeValue;
|
|
71
81
|
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_sales_yearly') }), _jsx(InputStyled, { readOnly: true, value: isAr ? expectedSalesRangeSelected === null || expectedSalesRangeSelected === void 0 ? void 0 : expectedSalesRangeSelected.nameAR : expectedSalesRangeSelected === null || expectedSalesRangeSelected === void 0 ? void 0 : expectedSalesRangeSelected.name, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, placeholder: t('choose_expected_sales'), endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: expectedSalesRangeList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
72
|
-
return (_jsxs(_Fragment, { children: [_jsx(ListItemContainer, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id) }, { children: isAr ? item.
|
|
82
|
+
return (_jsxs(_Fragment, { children: [_jsx(ListItemContainer, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id) }, { children: isAr ? item.titleAr : item.title })) }), item.id === (expectedSalesRangeSelected === null || expectedSalesRangeSelected === void 0 ? void 0 : expectedSalesRangeSelected.id) && _jsx(CheckIconStyled, {})] }));
|
|
73
83
|
} }) }))] }) })));
|
|
74
84
|
};
|
|
75
85
|
export default ExpectedSalesRange;
|
|
@@ -54,6 +54,6 @@ var Email = function (_a) {
|
|
|
54
54
|
var clearNumber = function () {
|
|
55
55
|
emailControl.field.onChange('');
|
|
56
56
|
};
|
|
57
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(InputStyled, { label: t('signup_email_lable'), value: emailValue, onChange: handleEmailChange, type: 'email', placeholder: t('signup_email_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: !error && emailValue ? _jsx(CheckIcon, {}) : emailValue && _jsx(ClearIcon, { onClick: clearNumber }) }) }) })));
|
|
57
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(InputStyled, { label: t('signup_email_lable'), value: emailValue, onEnterPressed: function (e) { return e.preventDefault(); }, onChange: handleEmailChange, type: 'email', placeholder: t('signup_email_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: !error && emailValue ? _jsx(CheckIcon, {}) : emailValue && _jsx(ClearIcon, { onClick: clearNumber }) }) }) })));
|
|
58
58
|
};
|
|
59
59
|
export default React.memo(Email);
|