@tap-payments/auth-jsconnect 2.4.4 → 2.4.5
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/features/app/connect/connectStore.d.ts +3 -17
- package/build/features/app/connect/connectStore.js +39 -115
- package/build/features/app/individual/individualStore.js +1 -1
- package/build/features/connect/screens/BrandSegment/BrandSegment.js +3 -25
- package/build/features/connect/screens/BrandSegment/TeamSize.js +1 -1
- package/build/features/connect/screens/BrandSegment/validation.d.ts +0 -9
- package/build/features/connect/screens/BrandSegment/validation.js +0 -3
- package/package.json +1 -1
- package/build/features/connect/screens/BrandSegment/SegmentLocations.d.ts +0 -7
- package/build/features/connect/screens/BrandSegment/SegmentLocations.js +0 -66
- package/build/features/connect/screens/BrandSegment/SegmentProfits.d.ts +0 -7
- package/build/features/connect/screens/BrandSegment/SegmentProfits.js +0 -66
- package/build/features/connect/screens/BrandSegment/SegmentTechs.d.ts +0 -7
- package/build/features/connect/screens/BrandSegment/SegmentTechs.js +0 -66
|
@@ -135,20 +135,6 @@ export declare const retrieveLead: import("@reduxjs/toolkit").AsyncThunk<{
|
|
|
135
135
|
fulfilledMeta?: unknown;
|
|
136
136
|
rejectedMeta?: unknown;
|
|
137
137
|
}>;
|
|
138
|
-
export declare const retrieveSegmentDataList: import("@reduxjs/toolkit").AsyncThunk<{
|
|
139
|
-
segmentLocation: any;
|
|
140
|
-
segmentProfit: any;
|
|
141
|
-
segmentTech: any;
|
|
142
|
-
}, void, {
|
|
143
|
-
state?: unknown;
|
|
144
|
-
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
145
|
-
extra?: unknown;
|
|
146
|
-
rejectValue?: unknown;
|
|
147
|
-
serializedErrorType?: unknown;
|
|
148
|
-
pendingMeta?: unknown;
|
|
149
|
-
fulfilledMeta?: unknown;
|
|
150
|
-
rejectedMeta?: unknown;
|
|
151
|
-
}>;
|
|
152
138
|
export declare const updateLeadBrand: import("@reduxjs/toolkit").AsyncThunk<{
|
|
153
139
|
response: any;
|
|
154
140
|
formData: BrandFormValues & {
|
|
@@ -168,8 +154,8 @@ export declare const updateLeadBrand: import("@reduxjs/toolkit").AsyncThunk<{
|
|
|
168
154
|
}>;
|
|
169
155
|
export declare const updateLeadBrandSegment: import("@reduxjs/toolkit").AsyncThunk<{
|
|
170
156
|
response: any;
|
|
171
|
-
formData: BrandSegmentFormValues
|
|
172
|
-
}, BrandSegmentFormValues, {
|
|
157
|
+
formData: Pick<BrandSegmentFormValues, "teamSize">;
|
|
158
|
+
}, Pick<BrandSegmentFormValues, "teamSize">, {
|
|
173
159
|
state?: unknown;
|
|
174
160
|
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
175
161
|
extra?: unknown;
|
|
@@ -240,7 +226,7 @@ export interface ConnectData {
|
|
|
240
226
|
};
|
|
241
227
|
individualData: IndividualFormValues & ResponseData;
|
|
242
228
|
brandData: BrandFormValues & ResponseData;
|
|
243
|
-
brandSegmentData: BrandSegmentFormValues & ResponseData;
|
|
229
|
+
brandSegmentData: Pick<BrandSegmentFormValues, 'teamSize'> & ResponseData;
|
|
244
230
|
flowName: FlowsTypes;
|
|
245
231
|
isStartFromBusinessCountry?: boolean;
|
|
246
232
|
}
|
|
@@ -462,35 +462,11 @@ export var retrieveLead = createAsyncThunk('connect/retrieveLead', function (par
|
|
|
462
462
|
}
|
|
463
463
|
});
|
|
464
464
|
}); });
|
|
465
|
-
export var retrieveSegmentDataList = createAsyncThunk('connectRetrieveSegmentDataList', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
466
|
-
var dataBody, _a, segmentLocation, segmentProfit, segmentTech;
|
|
467
|
-
return __generator(this, function (_b) {
|
|
468
|
-
switch (_b.label) {
|
|
469
|
-
case 0:
|
|
470
|
-
dataBody = {
|
|
471
|
-
page: 0,
|
|
472
|
-
limit: 50
|
|
473
|
-
};
|
|
474
|
-
return [4, Promise.all([
|
|
475
|
-
API.dataService.getSegmentLocation(dataBody),
|
|
476
|
-
API.dataService.getSegmentProfit(dataBody),
|
|
477
|
-
API.dataService.getSegmentTech(dataBody)
|
|
478
|
-
])];
|
|
479
|
-
case 1:
|
|
480
|
-
_a = _b.sent(), segmentLocation = _a[0].list, segmentProfit = _a[1].list, segmentTech = _a[2].list;
|
|
481
|
-
return [2, {
|
|
482
|
-
segmentLocation: segmentLocation,
|
|
483
|
-
segmentProfit: segmentProfit,
|
|
484
|
-
segmentTech: segmentTech
|
|
485
|
-
}];
|
|
486
|
-
}
|
|
487
|
-
});
|
|
488
|
-
}); });
|
|
489
465
|
export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
490
|
-
var _a, settings, connect, responseBody, leadBrandId, isNewBrand, brandName, salesChannels, selectedBrandItem, brandLogoId, termAndConditionChecked, getAddress, channel_services, payload_1, brandReqBody_1, brand_1,
|
|
491
|
-
var
|
|
492
|
-
return __generator(this, function (
|
|
493
|
-
switch (
|
|
466
|
+
var _a, settings, connect, responseBody, leadBrandId, isNewBrand, brandName, salesChannels, selectedBrandItem, brandLogoId, termAndConditionChecked, getAddress, channel_services, payload_1, brandReqBody_1, brand_1, teamSize, err_5, brandNameBody, payload, lead, brandReqBody, brand, teamSize, err_6;
|
|
467
|
+
var _b, _c, _d, _e, _f;
|
|
468
|
+
return __generator(this, function (_g) {
|
|
469
|
+
switch (_g.label) {
|
|
494
470
|
case 0:
|
|
495
471
|
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
496
472
|
responseBody = connect.data.otpData.responseBody;
|
|
@@ -513,7 +489,7 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
|
|
|
513
489
|
})
|
|
514
490
|
};
|
|
515
491
|
});
|
|
516
|
-
if (!!isNewBrand) return [3,
|
|
492
|
+
if (!!isNewBrand) return [3, 8];
|
|
517
493
|
if (!(leadBrandId !== (selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id))) return [3, 2];
|
|
518
494
|
payload_1 = {
|
|
519
495
|
brand: {
|
|
@@ -525,8 +501,8 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
|
|
|
525
501
|
};
|
|
526
502
|
return [4, API.leadService.updateLead(payload_1)];
|
|
527
503
|
case 1:
|
|
528
|
-
|
|
529
|
-
|
|
504
|
+
_g.sent();
|
|
505
|
+
_g.label = 2;
|
|
530
506
|
case 2:
|
|
531
507
|
brandReqBody_1 = {
|
|
532
508
|
id: (selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id) || '',
|
|
@@ -536,35 +512,23 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
|
|
|
536
512
|
};
|
|
537
513
|
return [4, API.brandService.updateBrandInfo(brandReqBody_1)];
|
|
538
514
|
case 3:
|
|
539
|
-
brand_1 =
|
|
540
|
-
|
|
515
|
+
brand_1 = _g.sent();
|
|
516
|
+
_g.label = 4;
|
|
541
517
|
case 4:
|
|
542
|
-
|
|
543
|
-
return [4,
|
|
518
|
+
_g.trys.push([4, 6, , 7]);
|
|
519
|
+
return [4, API.dataService.getTeamSize({ page: 0 })];
|
|
544
520
|
case 5:
|
|
545
|
-
|
|
546
|
-
brand_1.
|
|
547
|
-
brand_1.segment_profit_list = segmentProfit;
|
|
548
|
-
brand_1.segment_tech_list = segmentTech;
|
|
521
|
+
teamSize = _g.sent();
|
|
522
|
+
brand_1.team_size_list = teamSize.list;
|
|
549
523
|
return [3, 7];
|
|
550
524
|
case 6:
|
|
551
|
-
err_5 =
|
|
525
|
+
err_5 = _g.sent();
|
|
552
526
|
return [3, 7];
|
|
553
527
|
case 7:
|
|
554
|
-
_j.trys.push([7, 9, , 10]);
|
|
555
|
-
return [4, API.dataService.getTeamSize({ page: 0 })];
|
|
556
|
-
case 8:
|
|
557
|
-
teamSize = _j.sent();
|
|
558
|
-
brand_1.team_size_list = teamSize.list;
|
|
559
|
-
return [3, 10];
|
|
560
|
-
case 9:
|
|
561
|
-
err_6 = _j.sent();
|
|
562
|
-
return [3, 10];
|
|
563
|
-
case 10:
|
|
564
528
|
sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep()); });
|
|
565
|
-
(
|
|
529
|
+
(_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, params);
|
|
566
530
|
return [2, { response: brand_1, formData: params }];
|
|
567
|
-
case
|
|
531
|
+
case 8:
|
|
568
532
|
brandNameBody = {
|
|
569
533
|
id: '',
|
|
570
534
|
name: {
|
|
@@ -580,53 +544,41 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
|
|
|
580
544
|
encryption_contract: ['brand.name.en', 'brand.name.ar', 'brand.name.zh']
|
|
581
545
|
};
|
|
582
546
|
return [4, API.leadService.updateLead(payload)];
|
|
583
|
-
case
|
|
584
|
-
lead =
|
|
547
|
+
case 9:
|
|
548
|
+
lead = _g.sent();
|
|
585
549
|
if (!lead.brand) {
|
|
586
550
|
console.error('Internal server error: brand is not created');
|
|
587
551
|
throw new Error('Internal server error');
|
|
588
552
|
}
|
|
589
553
|
brandReqBody = {
|
|
590
|
-
id: ((
|
|
554
|
+
id: ((_d = lead.brand) === null || _d === void 0 ? void 0 : _d.id) || '',
|
|
591
555
|
channel_services: channel_services,
|
|
592
556
|
term: ['general'],
|
|
593
557
|
step_name: CONNECT_STEP_NAMES.UPDATE_BRAND_INFO
|
|
594
558
|
};
|
|
595
559
|
return [4, API.brandService.updateBrandInfo(brandReqBody)];
|
|
596
|
-
case
|
|
597
|
-
brand =
|
|
598
|
-
|
|
599
|
-
case
|
|
600
|
-
|
|
601
|
-
return [4, thunkApi.dispatch(retrieveSegmentDataList()).unwrap()];
|
|
602
|
-
case 15:
|
|
603
|
-
_c = _j.sent(), segmentLocation = _c.segmentLocation, segmentProfit = _c.segmentProfit, segmentTech = _c.segmentTech;
|
|
604
|
-
brand.segment_location_list = segmentLocation;
|
|
605
|
-
brand.segment_profit_list = segmentProfit;
|
|
606
|
-
brand.segment_tech_list = segmentTech;
|
|
607
|
-
return [3, 17];
|
|
608
|
-
case 16:
|
|
609
|
-
err_7 = _j.sent();
|
|
610
|
-
return [3, 17];
|
|
611
|
-
case 17:
|
|
612
|
-
_j.trys.push([17, 19, , 20]);
|
|
560
|
+
case 10:
|
|
561
|
+
brand = _g.sent();
|
|
562
|
+
_g.label = 11;
|
|
563
|
+
case 11:
|
|
564
|
+
_g.trys.push([11, 13, , 14]);
|
|
613
565
|
return [4, API.dataService.getTeamSize({ page: 0 })];
|
|
614
|
-
case
|
|
615
|
-
teamSize =
|
|
566
|
+
case 12:
|
|
567
|
+
teamSize = _g.sent();
|
|
616
568
|
brand.team_size_list = teamSize.list;
|
|
617
|
-
return [3,
|
|
618
|
-
case
|
|
619
|
-
|
|
620
|
-
return [3,
|
|
621
|
-
case
|
|
569
|
+
return [3, 14];
|
|
570
|
+
case 13:
|
|
571
|
+
err_6 = _g.sent();
|
|
572
|
+
return [3, 14];
|
|
573
|
+
case 14:
|
|
622
574
|
sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep()); });
|
|
623
|
-
(
|
|
575
|
+
(_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
|
|
624
576
|
return [2, { response: brand, formData: params }];
|
|
625
577
|
}
|
|
626
578
|
});
|
|
627
579
|
}); });
|
|
628
580
|
export var updateLeadBrandSegment = createAsyncThunk('updateLeadBrandSegment', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
629
|
-
var _a, settings, connect, responseBody, leadBrandId,
|
|
581
|
+
var _a, settings, connect, responseBody, leadBrandId, teamSize, brandReqBody, brand;
|
|
630
582
|
var _b, _c, _d;
|
|
631
583
|
return __generator(this, function (_e) {
|
|
632
584
|
switch (_e.label) {
|
|
@@ -634,11 +586,13 @@ export var updateLeadBrandSegment = createAsyncThunk('updateLeadBrandSegment', f
|
|
|
634
586
|
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
635
587
|
responseBody = connect.data.brandData.responseBody;
|
|
636
588
|
leadBrandId = (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.brand) === null || _b === void 0 ? void 0 : _b.id;
|
|
637
|
-
|
|
589
|
+
teamSize = params.teamSize;
|
|
638
590
|
brandReqBody = {
|
|
639
591
|
id: leadBrandId || '',
|
|
640
592
|
step_name: CONNECT_STEP_NAMES.UPDATE_BRAND_SEGMENT_INFO,
|
|
641
|
-
segment:
|
|
593
|
+
segment: {
|
|
594
|
+
team: { id: (teamSize === null || teamSize === void 0 ? void 0 : teamSize.id) || '' }
|
|
595
|
+
}
|
|
642
596
|
};
|
|
643
597
|
return [4, API.brandService.updateBrandInfo(brandReqBody)];
|
|
644
598
|
case 1:
|
|
@@ -764,9 +718,6 @@ var initialState = {
|
|
|
764
718
|
}
|
|
765
719
|
},
|
|
766
720
|
brandSegmentData: {
|
|
767
|
-
segmentLocation: undefined,
|
|
768
|
-
segmentProfit: undefined,
|
|
769
|
-
segmentTech: undefined,
|
|
770
721
|
teamSize: undefined
|
|
771
722
|
}
|
|
772
723
|
}
|
|
@@ -1004,47 +955,20 @@ export var connectSlice = createSlice({
|
|
|
1004
955
|
.addCase(updateLeadIndividual.rejected, function (state, action) {
|
|
1005
956
|
state.loading = false;
|
|
1006
957
|
state.error = action.error.message;
|
|
1007
|
-
})
|
|
1008
|
-
.addCase(retrieveSegmentDataList.pending, function (state) {
|
|
1009
|
-
state.loading = true;
|
|
1010
|
-
state.error = null;
|
|
1011
|
-
})
|
|
1012
|
-
.addCase(retrieveSegmentDataList.fulfilled, function (state) {
|
|
1013
|
-
state.loading = false;
|
|
1014
|
-
state.error = null;
|
|
1015
|
-
})
|
|
1016
|
-
.addCase(retrieveSegmentDataList.rejected, function (state, action) {
|
|
1017
|
-
state.loading = false;
|
|
1018
|
-
state.error = action.error.message;
|
|
1019
958
|
})
|
|
1020
959
|
.addCase(updateLeadBrand.fulfilled, function (state, action) {
|
|
1021
960
|
state.loading = false;
|
|
1022
961
|
state.error = null;
|
|
1023
962
|
var _a = action.payload, formData = _a.formData, response = _a.response;
|
|
1024
|
-
var _b = response || {},
|
|
1025
|
-
var selectedSegmentLocation = segment_location_list === null || segment_location_list === void 0 ? void 0 : segment_location_list.find(function (location) {
|
|
1026
|
-
var _a, _b;
|
|
1027
|
-
return location.id === ((_b = (_a = brand === null || brand === void 0 ? void 0 : brand.segment) === null || _a === void 0 ? void 0 : _a.location_type) === null || _b === void 0 ? void 0 : _b.id);
|
|
1028
|
-
});
|
|
1029
|
-
var selectedSegmentProfit = segment_profit_list === null || segment_profit_list === void 0 ? void 0 : segment_profit_list.find(function (profit) {
|
|
1030
|
-
var _a, _b;
|
|
1031
|
-
return profit.id === ((_b = (_a = brand === null || brand === void 0 ? void 0 : brand.segment) === null || _a === void 0 ? void 0 : _a.profit_type) === null || _b === void 0 ? void 0 : _b.id);
|
|
1032
|
-
});
|
|
1033
|
-
var selectedSegmentTech = segment_tech_list === null || segment_tech_list === void 0 ? void 0 : segment_tech_list.find(function (tech) {
|
|
1034
|
-
var _a, _b;
|
|
1035
|
-
return tech.id === ((_b = (_a = brand === null || brand === void 0 ? void 0 : brand.segment) === null || _a === void 0 ? void 0 : _a.tech_type) === null || _b === void 0 ? void 0 : _b.id);
|
|
1036
|
-
});
|
|
963
|
+
var _b = response || {}, team_size_list = _b.team_size_list, brand = _b.brand;
|
|
1037
964
|
var selectedTeamSize = team_size_list === null || team_size_list === void 0 ? void 0 : team_size_list.find(function (_a) {
|
|
1038
965
|
var _b, _c;
|
|
1039
966
|
var id = _a.id;
|
|
1040
967
|
return ((_c = (_b = brand === null || brand === void 0 ? void 0 : brand.segment) === null || _b === void 0 ? void 0 : _b.team) === null || _c === void 0 ? void 0 : _c.id) === id;
|
|
1041
968
|
});
|
|
1042
|
-
state.data.brandSegmentData.segmentLocation = selectedSegmentLocation || (segment_location_list === null || segment_location_list === void 0 ? void 0 : segment_location_list[0]);
|
|
1043
|
-
state.data.brandSegmentData.segmentProfit = selectedSegmentProfit || (segment_profit_list === null || segment_profit_list === void 0 ? void 0 : segment_profit_list[0]);
|
|
1044
|
-
state.data.brandSegmentData.segmentTech = selectedSegmentTech || (segment_tech_list === null || segment_tech_list === void 0 ? void 0 : segment_tech_list[1]);
|
|
1045
969
|
state.data.brandSegmentData.teamSize = selectedTeamSize;
|
|
1046
970
|
state.data.brandData = __assign(__assign({}, formData), { responseBody: __assign(__assign({}, state.data.brandData.responseBody), { brand: brand }) });
|
|
1047
|
-
state.data.brandSegmentData.responseBody = {
|
|
971
|
+
state.data.brandSegmentData.responseBody = { team_size_list: team_size_list };
|
|
1048
972
|
})
|
|
1049
973
|
.addCase(updateLeadBrand.pending, function (state) {
|
|
1050
974
|
state.loading = true;
|
|
@@ -1171,7 +1171,7 @@ export var individualSlice = createSlice({
|
|
|
1171
1171
|
var occupationList = (occupationData === null || occupationData === void 0 ? void 0 : occupationData.list) || [];
|
|
1172
1172
|
state.data.individualData.responseBody = __assign(__assign({}, data), { sourceIncomeList: sourceIncomeList, monthlyIncomeList: monthlyIncomeList, occupationList: occupationList });
|
|
1173
1173
|
var _d = ((_b = state.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.user) || {}, source_income = _d.source_income, monthly_income = _d.monthly_income, occupation = _d.occupation;
|
|
1174
|
-
var selectedSourceIncome =
|
|
1174
|
+
var selectedSourceIncome = sourceIncomeList === null || sourceIncomeList === void 0 ? void 0 : sourceIncomeList.find(function (source) { var _a; return (source === null || source === void 0 ? void 0 : source.id) === ((_a = source_income === null || source_income === void 0 ? void 0 : source_income[0]) === null || _a === void 0 ? void 0 : _a.id); });
|
|
1175
1175
|
if (!!selectedSourceIncome)
|
|
1176
1176
|
state.data.individualData.sourceIncome = selectedSourceIncome;
|
|
1177
1177
|
var selectedMonthlyIncome = monthlyIncomeList === null || monthlyIncomeList === void 0 ? void 0 : monthlyIncomeList.find(function (income) {
|
|
@@ -24,23 +24,11 @@ import Button from '../../../shared/Button';
|
|
|
24
24
|
import { clearError, connectSelector, updateLeadBrandSegment } from '../../../app/connect/connectStore';
|
|
25
25
|
import { useLanguage } from '../../../../hooks';
|
|
26
26
|
import { BrandSegmentValidationSchema } from './validation';
|
|
27
|
-
import SegmentLocations from './SegmentLocations';
|
|
28
|
-
import SegmentProfits from './SegmentProfits';
|
|
29
|
-
import SegmentTechs from './SegmentTechs';
|
|
30
27
|
import TeamSize from './TeamSize';
|
|
31
|
-
var ListType;
|
|
32
|
-
(function (ListType) {
|
|
33
|
-
ListType["SegmentLocationList"] = "SegmentLocationList";
|
|
34
|
-
ListType["SegmentProfitList"] = "SegmentProfitList";
|
|
35
|
-
ListType["SegmentTechList"] = "SegmentTechList";
|
|
36
|
-
ListType["TeamSizeList"] = "TeamSizeList";
|
|
37
|
-
ListType["BrandList"] = "BrandList";
|
|
38
|
-
ListType["BusinessList"] = "BusinessList";
|
|
39
|
-
})(ListType || (ListType = {}));
|
|
40
28
|
var BrandSegment = function (_a) {
|
|
41
29
|
var _b = useAppSelector(connectSelector), data = _b.data, loading = _b.loading, error = _b.error;
|
|
42
|
-
var _c =
|
|
43
|
-
var
|
|
30
|
+
var _c = React.useState(false), listActive = _c[0], setListActive = _c[1];
|
|
31
|
+
var teamSize = data.brandSegmentData.teamSize;
|
|
44
32
|
React.useEffect(function () {
|
|
45
33
|
sendCustomEventToGTM({
|
|
46
34
|
event: 'Send Event',
|
|
@@ -51,9 +39,6 @@ var BrandSegment = function (_a) {
|
|
|
51
39
|
var methods = useForm({
|
|
52
40
|
resolver: yupResolver(BrandSegmentValidationSchema()),
|
|
53
41
|
defaultValues: {
|
|
54
|
-
segmentLocation: segmentLocation,
|
|
55
|
-
segmentProfit: segmentProfit,
|
|
56
|
-
segmentTech: segmentTech,
|
|
57
42
|
teamSize: teamSize
|
|
58
43
|
},
|
|
59
44
|
mode: 'onChange'
|
|
@@ -72,13 +57,6 @@ var BrandSegment = function (_a) {
|
|
|
72
57
|
dispatch(clearError());
|
|
73
58
|
}, [methods.formState.isValid]);
|
|
74
59
|
var disabled = !methods.formState.isValid || !!error;
|
|
75
|
-
|
|
76
|
-
setListActive(flag);
|
|
77
|
-
};
|
|
78
|
-
var isSegmentLocationListActive = listActive === ListType.SegmentLocationList;
|
|
79
|
-
var isSegmentProfitListActive = listActive === ListType.SegmentProfitList;
|
|
80
|
-
var isSegmentTechListActive = listActive === ListType.SegmentTechList;
|
|
81
|
-
var isTeamSizeListActive = listActive === ListType.TeamSizeList;
|
|
82
|
-
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(SegmentLocations, { show: !isTeamSizeListActive && !isSegmentProfitListActive && !isSegmentTechListActive, onListOpen: function () { return handleMenuClick(ListType.SegmentLocationList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(SegmentProfits, { show: !isTeamSizeListActive && !isSegmentLocationListActive && !isSegmentTechListActive, onListOpen: function () { return handleMenuClick(ListType.SegmentProfitList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(SegmentTechs, { show: !isTeamSizeListActive && !isSegmentLocationListActive && !isSegmentProfitListActive, onListOpen: function () { return handleMenuClick(ListType.SegmentTechList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(TeamSize, { show: !isSegmentLocationListActive && !isSegmentProfitListActive && !isSegmentTechListActive, onListOpen: function () { return handleMenuClick(ListType.TeamSizeList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
|
|
60
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(TeamSize, { show: true, onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); } }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
|
|
83
61
|
};
|
|
84
62
|
export default React.memo(BrandSegment);
|
|
@@ -58,7 +58,7 @@ var TeamSize = function (_a) {
|
|
|
58
58
|
onCloseList();
|
|
59
59
|
teamSizeControl.field.onChange(teamSize);
|
|
60
60
|
};
|
|
61
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb:
|
|
61
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 2.6 } }, { children: [_jsx(InputSelect, { required: true, label: t('team_size_title'), onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_team_size'), value: (isAr ? (_d = teamSize === null || teamSize === void 0 ? void 0 : teamSize.name) === null || _d === void 0 ? void 0 : _d.ar : (_e = teamSize === null || teamSize === void 0 ? void 0 : teamSize.name) === null || _e === void 0 ? void 0 : _e.en) || '', warningMessage: error && t(error) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.en', searchValuePath: ['name.en', 'name.ar'], list: teamSizeList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
62
62
|
var _a, _b;
|
|
63
63
|
return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(IncomeText, __assign({ isSelected: item.id === (teamSize === null || teamSize === void 0 ? void 0 : teamSize.id) }, { children: isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en })) })), item.id === (teamSize === null || teamSize === void 0 ? void 0 : teamSize.id) && _jsx(CheckIcon, {})] }));
|
|
64
64
|
} }) }))] })) })));
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
2
|
export declare const BrandSegmentValidationSchema: () => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
-
segmentLocation: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
4
|
-
segmentProfit: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
5
|
-
segmentTech: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
6
3
|
teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
7
4
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
8
|
-
segmentLocation: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
9
|
-
segmentProfit: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
10
|
-
segmentTech: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
11
5
|
teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
12
6
|
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
13
|
-
segmentLocation: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
14
|
-
segmentProfit: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
15
|
-
segmentTech: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
16
7
|
teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
17
8
|
}>>>;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
2
|
export var BrandSegmentValidationSchema = function () {
|
|
3
3
|
return yup.object().shape({
|
|
4
|
-
segmentLocation: yup.object().required('alert_choose_segment_location'),
|
|
5
|
-
segmentProfit: yup.object().required('alert_choose_segment_profit'),
|
|
6
|
-
segmentTech: yup.object().required('alert_choose_segment_tech'),
|
|
7
4
|
teamSize: yup.object().required('alert_choose_teamSize')
|
|
8
5
|
});
|
|
9
6
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
interface SegmentLocationsProps {
|
|
2
|
-
show: boolean;
|
|
3
|
-
onListOpen?: () => void;
|
|
4
|
-
onListClose?: () => void;
|
|
5
|
-
}
|
|
6
|
-
declare const SegmentLocations: ({ show, onListOpen, onListClose }: SegmentLocationsProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export default SegmentLocations;
|
|
@@ -1,66 +0,0 @@
|
|
|
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, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { useTranslation } from 'react-i18next';
|
|
15
|
-
import { useController, useFormContext } from 'react-hook-form';
|
|
16
|
-
import Box from '@mui/material/Box';
|
|
17
|
-
import { styled } from '@mui/material/styles';
|
|
18
|
-
import { useAppSelector, useLanguage } from '../../../../hooks';
|
|
19
|
-
import SimpleList from '../../../../components/SimpleList';
|
|
20
|
-
import Text from '../../../../components/Text';
|
|
21
|
-
import Collapse from '../../../../components/Collapse';
|
|
22
|
-
import { EndAdornmentExpanded } from '../../../shared/EndAdornment';
|
|
23
|
-
import { ScreenContainer } from '../../../shared/Containers';
|
|
24
|
-
import InputSelect from '../../../shared/InputSelect';
|
|
25
|
-
import CheckIcon from '../../../shared/CheckIcon';
|
|
26
|
-
import { connectSelector } from '../../../app/connect/connectStore';
|
|
27
|
-
var IncomeText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
|
|
28
|
-
var theme = _a.theme, isSelected = _a.isSelected;
|
|
29
|
-
return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25), textAlign: 'start' }));
|
|
30
|
-
});
|
|
31
|
-
var SegmentLocations = function (_a) {
|
|
32
|
-
var _b, _c, _d, _e;
|
|
33
|
-
var show = _a.show, onListOpen = _a.onListOpen, onListClose = _a.onListClose;
|
|
34
|
-
var _f = React.useState([]), segmentList = _f[0], setSegmentList = _f[1];
|
|
35
|
-
var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
|
|
36
|
-
var t = useTranslation().t;
|
|
37
|
-
var isAr = useLanguage().isAr;
|
|
38
|
-
var data = useAppSelector(connectSelector).data;
|
|
39
|
-
var control = useFormContext().control;
|
|
40
|
-
var segmentLocationList = ((_b = data.brandSegmentData.responseBody) === null || _b === void 0 ? void 0 : _b.segment_location_list) || [];
|
|
41
|
-
var segmentControl = useController({ control: control, name: 'segmentLocation' });
|
|
42
|
-
var segment = segmentControl.field.value;
|
|
43
|
-
var error = (_c = segmentControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message;
|
|
44
|
-
React.useEffect(function () {
|
|
45
|
-
if ((segmentLocationList === null || segmentLocationList === void 0 ? void 0 : segmentLocationList.length) > 0) {
|
|
46
|
-
setSegmentList(segmentLocationList);
|
|
47
|
-
}
|
|
48
|
-
}, [segmentLocationList]);
|
|
49
|
-
var onOpenList = function (event) {
|
|
50
|
-
setAnchorEl(event.currentTarget);
|
|
51
|
-
onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
|
|
52
|
-
};
|
|
53
|
-
var onCloseList = function () {
|
|
54
|
-
setAnchorEl(null);
|
|
55
|
-
onListClose === null || onListClose === void 0 ? void 0 : onListClose();
|
|
56
|
-
};
|
|
57
|
-
var onSelectItem = function (segment) {
|
|
58
|
-
onCloseList();
|
|
59
|
-
segmentControl.field.onChange(segment);
|
|
60
|
-
};
|
|
61
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsx(InputSelect, { required: true, label: t('segment_location_title'), onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(EndAdornmentExpanded, { anchorEl: anchorEl }), placeholder: t('choose_any_segment'), value: (isAr ? (_d = segment === null || segment === void 0 ? void 0 : segment.name) === null || _d === void 0 ? void 0 : _d.ar : (_e = segment === null || segment === void 0 ? void 0 : segment.name) === null || _e === void 0 ? void 0 : _e.en) || '', warningMessage: error && t(error) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.en', searchValuePath: ['name.ar', 'name.en'], list: segmentList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
62
|
-
var _a, _b;
|
|
63
|
-
return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(IncomeText, __assign({ isSelected: item.id === (segment === null || segment === void 0 ? void 0 : segment.id) }, { children: isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en })) })), item.id === (segment === null || segment === void 0 ? void 0 : segment.id) && _jsx(CheckIcon, {})] }));
|
|
64
|
-
} }) }))] })) })));
|
|
65
|
-
};
|
|
66
|
-
export default SegmentLocations;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
interface SegmentProfitsProps {
|
|
2
|
-
show: boolean;
|
|
3
|
-
onListOpen?: () => void;
|
|
4
|
-
onListClose?: () => void;
|
|
5
|
-
}
|
|
6
|
-
declare const SegmentProfits: ({ show, onListOpen, onListClose }: SegmentProfitsProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export default SegmentProfits;
|
|
@@ -1,66 +0,0 @@
|
|
|
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, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { useTranslation } from 'react-i18next';
|
|
15
|
-
import { useController, useFormContext } from 'react-hook-form';
|
|
16
|
-
import Box from '@mui/material/Box';
|
|
17
|
-
import { styled } from '@mui/material/styles';
|
|
18
|
-
import { useAppSelector, useLanguage } from '../../../../hooks';
|
|
19
|
-
import SimpleList from '../../../../components/SimpleList';
|
|
20
|
-
import Text from '../../../../components/Text';
|
|
21
|
-
import Collapse from '../../../../components/Collapse';
|
|
22
|
-
import { EndAdornmentExpanded } from '../../../shared/EndAdornment';
|
|
23
|
-
import { ScreenContainer } from '../../../shared/Containers';
|
|
24
|
-
import InputSelect from '../../../shared/InputSelect';
|
|
25
|
-
import CheckIcon from '../../../shared/CheckIcon';
|
|
26
|
-
import { connectSelector } from '../../../app/connect/connectStore';
|
|
27
|
-
var IncomeText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
|
|
28
|
-
var theme = _a.theme, isSelected = _a.isSelected;
|
|
29
|
-
return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25), textAlign: 'start' }));
|
|
30
|
-
});
|
|
31
|
-
var SegmentProfits = function (_a) {
|
|
32
|
-
var _b, _c, _d, _e;
|
|
33
|
-
var show = _a.show, onListOpen = _a.onListOpen, onListClose = _a.onListClose;
|
|
34
|
-
var _f = React.useState([]), segmentList = _f[0], setSegmentList = _f[1];
|
|
35
|
-
var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
|
|
36
|
-
var t = useTranslation().t;
|
|
37
|
-
var isAr = useLanguage().isAr;
|
|
38
|
-
var data = useAppSelector(connectSelector).data;
|
|
39
|
-
var control = useFormContext().control;
|
|
40
|
-
var segmentProfitList = ((_b = data.brandSegmentData.responseBody) === null || _b === void 0 ? void 0 : _b.segment_profit_list) || [];
|
|
41
|
-
var segmentControl = useController({ control: control, name: 'segmentProfit' });
|
|
42
|
-
var segment = segmentControl.field.value;
|
|
43
|
-
var error = (_c = segmentControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message;
|
|
44
|
-
React.useEffect(function () {
|
|
45
|
-
if ((segmentProfitList === null || segmentProfitList === void 0 ? void 0 : segmentProfitList.length) > 0) {
|
|
46
|
-
setSegmentList(segmentProfitList);
|
|
47
|
-
}
|
|
48
|
-
}, [segmentProfitList]);
|
|
49
|
-
var onOpenList = function (event) {
|
|
50
|
-
setAnchorEl(event.currentTarget);
|
|
51
|
-
onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
|
|
52
|
-
};
|
|
53
|
-
var onCloseList = function () {
|
|
54
|
-
setAnchorEl(null);
|
|
55
|
-
onListClose === null || onListClose === void 0 ? void 0 : onListClose();
|
|
56
|
-
};
|
|
57
|
-
var onSelectItem = function (segment) {
|
|
58
|
-
onCloseList();
|
|
59
|
-
segmentControl.field.onChange(segment);
|
|
60
|
-
};
|
|
61
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsx(InputSelect, { required: true, label: t('segment_profit_title'), onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(EndAdornmentExpanded, { anchorEl: anchorEl }), placeholder: t('choose_any_segment'), value: (isAr ? (_d = segment === null || segment === void 0 ? void 0 : segment.name) === null || _d === void 0 ? void 0 : _d.ar : (_e = segment === null || segment === void 0 ? void 0 : segment.name) === null || _e === void 0 ? void 0 : _e.en) || '', warningMessage: error && t(error) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.en', searchValuePath: ['name.ar', 'name.en'], list: segmentList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
62
|
-
var _a, _b;
|
|
63
|
-
return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(IncomeText, __assign({ isSelected: item.id === (segment === null || segment === void 0 ? void 0 : segment.id) }, { children: isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en })) })), item.id === (segment === null || segment === void 0 ? void 0 : segment.id) && _jsx(CheckIcon, {})] }));
|
|
64
|
-
} }) }))] })) })));
|
|
65
|
-
};
|
|
66
|
-
export default SegmentProfits;
|
|
@@ -1,66 +0,0 @@
|
|
|
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, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { useTranslation } from 'react-i18next';
|
|
15
|
-
import { useController, useFormContext } from 'react-hook-form';
|
|
16
|
-
import Box from '@mui/material/Box';
|
|
17
|
-
import { styled } from '@mui/material/styles';
|
|
18
|
-
import { useAppSelector, useLanguage } from '../../../../hooks';
|
|
19
|
-
import SimpleList from '../../../../components/SimpleList';
|
|
20
|
-
import Text from '../../../../components/Text';
|
|
21
|
-
import Collapse from '../../../../components/Collapse';
|
|
22
|
-
import { EndAdornmentExpanded } from '../../../shared/EndAdornment';
|
|
23
|
-
import { ScreenContainer } from '../../../shared/Containers';
|
|
24
|
-
import InputSelect from '../../../shared/InputSelect';
|
|
25
|
-
import CheckIcon from '../../../shared/CheckIcon';
|
|
26
|
-
import { connectSelector } from '../../../app/connect/connectStore';
|
|
27
|
-
var IncomeText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
|
|
28
|
-
var theme = _a.theme, isSelected = _a.isSelected;
|
|
29
|
-
return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25), textAlign: 'start' }));
|
|
30
|
-
});
|
|
31
|
-
var SegmentTechs = function (_a) {
|
|
32
|
-
var _b, _c, _d, _e;
|
|
33
|
-
var show = _a.show, onListOpen = _a.onListOpen, onListClose = _a.onListClose;
|
|
34
|
-
var _f = React.useState([]), segmentList = _f[0], setSegmentList = _f[1];
|
|
35
|
-
var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
|
|
36
|
-
var t = useTranslation().t;
|
|
37
|
-
var isAr = useLanguage().isAr;
|
|
38
|
-
var data = useAppSelector(connectSelector).data;
|
|
39
|
-
var control = useFormContext().control;
|
|
40
|
-
var segmentTechList = ((_b = data.brandSegmentData.responseBody) === null || _b === void 0 ? void 0 : _b.segment_tech_list) || [];
|
|
41
|
-
var segmentControl = useController({ control: control, name: 'segmentTech' });
|
|
42
|
-
var segment = segmentControl.field.value;
|
|
43
|
-
var error = (_c = segmentControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message;
|
|
44
|
-
React.useEffect(function () {
|
|
45
|
-
if ((segmentTechList === null || segmentTechList === void 0 ? void 0 : segmentTechList.length) > 0) {
|
|
46
|
-
setSegmentList(segmentTechList);
|
|
47
|
-
}
|
|
48
|
-
}, [segmentTechList]);
|
|
49
|
-
var onOpenList = function (event) {
|
|
50
|
-
setAnchorEl(event.currentTarget);
|
|
51
|
-
onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
|
|
52
|
-
};
|
|
53
|
-
var onCloseList = function () {
|
|
54
|
-
setAnchorEl(null);
|
|
55
|
-
onListClose === null || onListClose === void 0 ? void 0 : onListClose();
|
|
56
|
-
};
|
|
57
|
-
var onSelectItem = function (segment) {
|
|
58
|
-
onCloseList();
|
|
59
|
-
segmentControl.field.onChange(segment);
|
|
60
|
-
};
|
|
61
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsx(InputSelect, { required: true, label: t('segment_tech_title'), onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(EndAdornmentExpanded, { anchorEl: anchorEl }), placeholder: t('choose_any_segment'), value: (isAr ? (_d = segment === null || segment === void 0 ? void 0 : segment.name) === null || _d === void 0 ? void 0 : _d.ar : (_e = segment === null || segment === void 0 ? void 0 : segment.name) === null || _e === void 0 ? void 0 : _e.en) || '', warningMessage: error && t(error) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.en', searchValuePath: ['name.ar', 'name.en'], list: segmentList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
62
|
-
var _a, _b;
|
|
63
|
-
return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(IncomeText, __assign({ isSelected: item.id === (segment === null || segment === void 0 ? void 0 : segment.id) }, { children: isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en })) })), item.id === (segment === null || segment === void 0 ? void 0 : segment.id) && _jsx(CheckIcon, {})] }));
|
|
64
|
-
} }) }))] })) })));
|
|
65
|
-
};
|
|
66
|
-
export default SegmentTechs;
|