@tap-payments/auth-jsconnect 2.4.64-test → 2.4.67-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 +6 -0
- package/build/@types/form.d.ts +3 -0
- package/build/api/data.d.ts +7 -0
- package/build/api/data.js +25 -1
- package/build/api/index.d.ts +12 -0
- package/build/api/individual.d.ts +9 -0
- package/build/assets/locales/ar.json +7 -1
- package/build/assets/locales/en.json +7 -1
- package/build/constants/api.d.ts +3 -0
- package/build/constants/api.js +7 -1
- package/build/features/app/brand/brandStore.d.ts +20 -0
- package/build/features/app/brand/brandStore.js +145 -67
- package/build/features/brand/screens/BrandInfo/BrandInfo.js +33 -14
- package/build/features/brand/screens/BrandInfo/SegmentLocations.d.ts +10 -0
- package/build/features/brand/screens/BrandInfo/{Segments.js → SegmentLocations.js} +5 -6
- package/build/features/brand/screens/BrandInfo/SegmentProfits.d.ts +10 -0
- package/build/features/brand/screens/BrandInfo/SegmentProfits.js +69 -0
- package/build/features/brand/screens/BrandInfo/SegmentTechs.d.ts +10 -0
- package/build/features/brand/screens/BrandInfo/SegmentTechs.js +69 -0
- package/build/features/brand/screens/BrandInfo/TeamSize.js +0 -1
- package/build/features/brand/screens/BrandInfo/validation.d.ts +9 -3
- package/build/features/brand/screens/BrandInfo/validation.js +3 -1
- package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +6 -5
- package/build/features/shared/InputSelect/InputSelect.js +6 -1
- package/package.json +1 -1
- package/build/features/brand/screens/BrandInfo/Segments.d.ts +0 -10
package/build/@types/app.d.ts
CHANGED
|
@@ -451,6 +451,9 @@ export type BrandDataStatus = {
|
|
|
451
451
|
'segment.type': FieldType;
|
|
452
452
|
'segment.teams': FieldType;
|
|
453
453
|
'segment.sale': FieldType;
|
|
454
|
+
'segment.location_type': FieldType;
|
|
455
|
+
'segment.profit_type': FieldType;
|
|
456
|
+
'segment.tech_type': FieldType;
|
|
454
457
|
activities: FieldType;
|
|
455
458
|
channel_services: FieldType;
|
|
456
459
|
};
|
|
@@ -534,6 +537,9 @@ export type BrandDataVerification = {
|
|
|
534
537
|
'segment.sale': string;
|
|
535
538
|
'segment.teams': string;
|
|
536
539
|
'segment.type': string;
|
|
540
|
+
'segment.location_type': string;
|
|
541
|
+
'segment.profit_type': string;
|
|
542
|
+
'segment.tech_type': string;
|
|
537
543
|
terms: string;
|
|
538
544
|
};
|
|
539
545
|
export type EntityDataVerification = {
|
package/build/@types/form.d.ts
CHANGED
|
@@ -32,6 +32,9 @@ export type BrandFormValues = {
|
|
|
32
32
|
brandName: string;
|
|
33
33
|
brandLogoId?: string;
|
|
34
34
|
segment?: Segment | undefined;
|
|
35
|
+
segmentLocation?: Segment | undefined;
|
|
36
|
+
segmentProfit?: Segment | undefined;
|
|
37
|
+
segmentTech?: Segment | undefined;
|
|
35
38
|
teamSize?: TeamSize | undefined;
|
|
36
39
|
salesChannels: Array<SaleChannel>;
|
|
37
40
|
termAndConditionChecked?: boolean;
|
package/build/api/data.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ type GetSegmentsBody = {
|
|
|
8
8
|
type GetTeamSizeBody = {
|
|
9
9
|
page: number;
|
|
10
10
|
};
|
|
11
|
+
type SegmentDataListBody = {
|
|
12
|
+
page: number;
|
|
13
|
+
limit: number;
|
|
14
|
+
};
|
|
11
15
|
type GetMonthlyIncomeBody = {
|
|
12
16
|
page: number;
|
|
13
17
|
country_code: Array<string>;
|
|
@@ -46,5 +50,8 @@ declare const dataService: {
|
|
|
46
50
|
getTeamSize: (data: GetTeamSizeBody) => Promise<any>;
|
|
47
51
|
getActivities: (config?: AxiosRequestConfig) => Promise<any>;
|
|
48
52
|
getActivitiesIsIc: () => Promise<any>;
|
|
53
|
+
getSegmentLocation: (data: SegmentDataListBody) => Promise<any>;
|
|
54
|
+
getSegmentProfit: (data: SegmentDataListBody) => Promise<any>;
|
|
55
|
+
getSegmentTech: (data: SegmentDataListBody) => Promise<any>;
|
|
49
56
|
};
|
|
50
57
|
export { dataService };
|
package/build/api/data.js
CHANGED
|
@@ -84,6 +84,27 @@ var getTeamSize = function (data) {
|
|
|
84
84
|
data: data
|
|
85
85
|
});
|
|
86
86
|
};
|
|
87
|
+
var getSegmentLocation = function (data) {
|
|
88
|
+
return httpClient({
|
|
89
|
+
method: 'post',
|
|
90
|
+
url: "".concat(ENDPOINT_PATHS.SEGMENT_LOCATION, "/list"),
|
|
91
|
+
data: data
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
var getSegmentProfit = function (data) {
|
|
95
|
+
return httpClient({
|
|
96
|
+
method: 'post',
|
|
97
|
+
url: "".concat(ENDPOINT_PATHS.SEGMENT_PROFIT, "/list"),
|
|
98
|
+
data: data
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
var getSegmentTech = function (data) {
|
|
102
|
+
return httpClient({
|
|
103
|
+
method: 'post',
|
|
104
|
+
url: "".concat(ENDPOINT_PATHS.SEGMENT_TECH, "/list"),
|
|
105
|
+
data: data
|
|
106
|
+
});
|
|
107
|
+
};
|
|
87
108
|
var dataService = {
|
|
88
109
|
getChannelsOfServices: getChannelsOfServices,
|
|
89
110
|
getCustomerBases: getCustomerBases,
|
|
@@ -95,6 +116,9 @@ var dataService = {
|
|
|
95
116
|
getSegments: getSegments,
|
|
96
117
|
getTeamSize: getTeamSize,
|
|
97
118
|
getActivities: getActivities,
|
|
98
|
-
getActivitiesIsIc: getActivitiesIsIc
|
|
119
|
+
getActivitiesIsIc: getActivitiesIsIc,
|
|
120
|
+
getSegmentLocation: getSegmentLocation,
|
|
121
|
+
getSegmentProfit: getSegmentProfit,
|
|
122
|
+
getSegmentTech: getSegmentTech
|
|
99
123
|
};
|
|
100
124
|
export { dataService };
|
package/build/api/index.d.ts
CHANGED
|
@@ -110,6 +110,18 @@ declare const API: {
|
|
|
110
110
|
}) => Promise<any>;
|
|
111
111
|
getActivities: (config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<any>;
|
|
112
112
|
getActivitiesIsIc: () => Promise<any>;
|
|
113
|
+
getSegmentLocation: (data: {
|
|
114
|
+
page: number;
|
|
115
|
+
limit: number;
|
|
116
|
+
}) => Promise<any>;
|
|
117
|
+
getSegmentProfit: (data: {
|
|
118
|
+
page: number;
|
|
119
|
+
limit: number;
|
|
120
|
+
}) => Promise<any>;
|
|
121
|
+
getSegmentTech: (data: {
|
|
122
|
+
page: number;
|
|
123
|
+
limit: number;
|
|
124
|
+
}) => Promise<any>;
|
|
113
125
|
};
|
|
114
126
|
individualService: {
|
|
115
127
|
retrieveIndividualInfo: (id: string) => Promise<any>;
|
|
@@ -408,5 +408,11 @@
|
|
|
408
408
|
"mobile_app_label": "تطبيقات هاتف",
|
|
409
409
|
"physical_store_label": "متجر",
|
|
410
410
|
"social_media_label": "وسائل التواصل الاجتماعي",
|
|
411
|
-
"selected_activities": "اختر الأنشطة"
|
|
411
|
+
"selected_activities": "اختر الأنشطة",
|
|
412
|
+
"section_location_title": "الموقع",
|
|
413
|
+
"section_tech_title": "التقنية",
|
|
414
|
+
"section_profit_title": "الربح",
|
|
415
|
+
"alert_choose_segment_location": "يُرجى تحديد الموقع",
|
|
416
|
+
"alert_choose_segment_profit": "يُرجى تحديد الربح",
|
|
417
|
+
"alert_choose_segment_tech": "الرجاء تحديد التقنية"
|
|
412
418
|
}
|
|
@@ -438,5 +438,11 @@
|
|
|
438
438
|
"mobile_app_label": "Mobile App",
|
|
439
439
|
"physical_store_label": "Physical Store",
|
|
440
440
|
"social_media_label": "Social Media",
|
|
441
|
-
"selected_activities": "Selected Activities"
|
|
441
|
+
"selected_activities": "Selected Activities",
|
|
442
|
+
"segment_location_title": "Segment Location",
|
|
443
|
+
"segment_tech_title": "Segment Tech",
|
|
444
|
+
"segment_profit_title": "Segment Profit",
|
|
445
|
+
"alert_choose_segment_location": "Please select segment location",
|
|
446
|
+
"alert_choose_segment_profit": "Please select segment profit",
|
|
447
|
+
"alert_choose_segment_tech": "Please select segment tech"
|
|
442
448
|
}
|
package/build/constants/api.d.ts
CHANGED
package/build/constants/api.js
CHANGED
|
@@ -49,6 +49,9 @@ var TEAM_SIZE_PATH = '/businessSegment/team/list';
|
|
|
49
49
|
var ADDRESS_PATH = '/address';
|
|
50
50
|
var INIT_PATH = 'init';
|
|
51
51
|
var BUSINESS_PATH = '/business';
|
|
52
|
+
var SEGMENT_LOCATION_PATH = "".concat(BRAND_PATH, "/segment/location");
|
|
53
|
+
var SEGMENT_PROFIT_PATH = "".concat(BRAND_PATH, "/segment/profit");
|
|
54
|
+
var SEGMENT_TECH_PATH = "".concat(BRAND_PATH, "/segment/tech");
|
|
52
55
|
export var ENDPOINT_PATHS = {
|
|
53
56
|
CREATE_EXPRESS_AUTH_PATH: CREATE_EXPRESS_AUTH_PATH,
|
|
54
57
|
Verify_Express_Auth_OTP_PATH: Verify_Express_Auth_OTP_PATH,
|
|
@@ -100,5 +103,8 @@ export var ENDPOINT_PATHS = {
|
|
|
100
103
|
INIT: INIT_PATH,
|
|
101
104
|
BUSINESS: BUSINESS_PATH,
|
|
102
105
|
RETRIEVE_ACTIVITIES_ISIC: RETRIEVE_ACTIVITIES_ISIC_PATH,
|
|
103
|
-
CONNECT: CONNECT_PATH
|
|
106
|
+
CONNECT: CONNECT_PATH,
|
|
107
|
+
SEGMENT_LOCATION: SEGMENT_LOCATION_PATH,
|
|
108
|
+
SEGMENT_PROFIT: SEGMENT_PROFIT_PATH,
|
|
109
|
+
SEGMENT_TECH: SEGMENT_TECH_PATH
|
|
104
110
|
};
|
|
@@ -23,6 +23,9 @@ export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
|
|
|
23
23
|
salesChannels: any;
|
|
24
24
|
segmentsList: any;
|
|
25
25
|
teamSizeList: any;
|
|
26
|
+
segmentLocationList: any;
|
|
27
|
+
segmentProfitList: any;
|
|
28
|
+
segmentTechList: any;
|
|
26
29
|
token: string;
|
|
27
30
|
}, VerifyLeadTokenProps, {
|
|
28
31
|
state?: unknown;
|
|
@@ -64,6 +67,9 @@ export declare const verifyBrandLeadOTP: import("@reduxjs/toolkit").AsyncThunk<{
|
|
|
64
67
|
salesChannels: any;
|
|
65
68
|
segmentsList: any;
|
|
66
69
|
teamSizeList: any;
|
|
70
|
+
segmentLocationList: any;
|
|
71
|
+
segmentProfitList: any;
|
|
72
|
+
segmentTechList: any;
|
|
67
73
|
formData: OTPFormValues;
|
|
68
74
|
}, OTPFormValues, {
|
|
69
75
|
state?: unknown;
|
|
@@ -75,6 +81,20 @@ export declare const verifyBrandLeadOTP: import("@reduxjs/toolkit").AsyncThunk<{
|
|
|
75
81
|
fulfilledMeta?: unknown;
|
|
76
82
|
rejectedMeta?: unknown;
|
|
77
83
|
}>;
|
|
84
|
+
export declare const retrieveSegmentDataList: import("@reduxjs/toolkit").AsyncThunk<{
|
|
85
|
+
segmentLocation: any;
|
|
86
|
+
segmentProfit: any;
|
|
87
|
+
segmentTech: any;
|
|
88
|
+
}, void, {
|
|
89
|
+
state?: unknown;
|
|
90
|
+
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
91
|
+
extra?: unknown;
|
|
92
|
+
rejectValue?: unknown;
|
|
93
|
+
serializedErrorType?: unknown;
|
|
94
|
+
pendingMeta?: unknown;
|
|
95
|
+
fulfilledMeta?: unknown;
|
|
96
|
+
rejectedMeta?: unknown;
|
|
97
|
+
}>;
|
|
78
98
|
export declare const retrieveBoardStatus: import("@reduxjs/toolkit").AsyncThunk<{
|
|
79
99
|
flows: any;
|
|
80
100
|
}, void, {
|
|
@@ -66,10 +66,10 @@ import { hasNoneEditableValue, isKW, isTwitter, isWebsite, mapSalesChannel, retr
|
|
|
66
66
|
export var verifyLeadToken = createAsyncThunk('brandVerifyLeadToken', function (_a, thunkApi) {
|
|
67
67
|
var token = _a.token, isInternally = _a.isInternally;
|
|
68
68
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
-
var payload, data, countryIso2, _b, board_id, board_info_id, segmentsList, salesChannels, teamSizeList, boardData, boardInfoData, individualData, _c, id_1, type_1, serviceCallBack, _d, boardRes, individualRes;
|
|
70
|
-
var
|
|
71
|
-
return __generator(this, function (
|
|
72
|
-
switch (
|
|
69
|
+
var payload, data, countryIso2, _b, board_id, board_info_id, segmentsList, segmentLocationList, segmentProfitList, segmentTechList, salesChannels, teamSizeList, boardData, boardInfoData, individualData, _c, id_1, type_1, serviceCallBack, _d, boardRes, individualRes, _e, segmentLocation, segmentProfit, segmentTech;
|
|
70
|
+
var _f, _g, _h, _j;
|
|
71
|
+
return __generator(this, function (_k) {
|
|
72
|
+
switch (_k.label) {
|
|
73
73
|
case 0:
|
|
74
74
|
payload = {
|
|
75
75
|
service_name: 'tap_email',
|
|
@@ -77,7 +77,7 @@ export var verifyLeadToken = createAsyncThunk('brandVerifyLeadToken', function (
|
|
|
77
77
|
};
|
|
78
78
|
return [4, API.leadService.verifyLeadToken(payload)];
|
|
79
79
|
case 1:
|
|
80
|
-
data = (
|
|
80
|
+
data = (_k.sent()).data;
|
|
81
81
|
if ((data === null || data === void 0 ? void 0 : data.errors) && (data === null || data === void 0 ? void 0 : data.mw_error)) {
|
|
82
82
|
throw new Error(data.errors[0].description);
|
|
83
83
|
}
|
|
@@ -91,39 +91,45 @@ export var verifyLeadToken = createAsyncThunk('brandVerifyLeadToken', function (
|
|
|
91
91
|
individualData = undefined;
|
|
92
92
|
if (isInternally)
|
|
93
93
|
data.step_name = BRAND_STEP_NAMES.BRAND_INFO;
|
|
94
|
-
if (!(data.step_name !== BRAND_STEP_NAMES.PHONE_AUTH || isInternally)) return [3,
|
|
94
|
+
if (!(data.step_name !== BRAND_STEP_NAMES.PHONE_AUTH || isInternally)) return [3, 10];
|
|
95
95
|
if (!board_info_id) return [3, 3];
|
|
96
96
|
return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
|
|
97
97
|
case 2:
|
|
98
|
-
boardInfoData =
|
|
99
|
-
|
|
98
|
+
boardInfoData = _k.sent();
|
|
99
|
+
_k.label = 3;
|
|
100
100
|
case 3: return [4, API.boardService.retrieveBoardDetails(board_id)];
|
|
101
101
|
case 4:
|
|
102
|
-
boardData =
|
|
103
|
-
_c = ((
|
|
102
|
+
boardData = _k.sent();
|
|
103
|
+
_c = ((_f = boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification) === null || _f === void 0 ? void 0 : _f.recipient) || {}, id_1 = _c.id, type_1 = _c.type;
|
|
104
104
|
serviceCallBack = function () { return API.individualService.retrieveIndividual(id_1, type_1); };
|
|
105
105
|
return [4, retrieveIndividualData(type_1, boardData, serviceCallBack)];
|
|
106
106
|
case 5:
|
|
107
|
-
_d =
|
|
107
|
+
_d = _k.sent(), boardRes = _d.boardRes, individualRes = _d.individualRes;
|
|
108
108
|
boardData = boardRes;
|
|
109
109
|
individualData = individualRes;
|
|
110
110
|
if (!countryIso2) {
|
|
111
|
-
countryIso2 = (
|
|
111
|
+
countryIso2 = (_g = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _g === void 0 ? void 0 : _g.country;
|
|
112
112
|
if (countryIso2)
|
|
113
113
|
thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
|
|
114
114
|
}
|
|
115
|
-
return [4,
|
|
115
|
+
return [4, thunkApi.dispatch(retrieveSegmentDataList()).unwrap()];
|
|
116
116
|
case 6:
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
_e = _k.sent(), segmentLocation = _e.segmentLocation, segmentProfit = _e.segmentProfit, segmentTech = _e.segmentTech;
|
|
118
|
+
segmentLocationList = segmentLocation;
|
|
119
|
+
segmentProfitList = segmentProfit;
|
|
120
|
+
segmentTechList = segmentTech;
|
|
121
|
+
return [4, API.dataService.getSegments({ page: 0 })];
|
|
119
122
|
case 7:
|
|
120
|
-
|
|
121
|
-
return [4, API.dataService.
|
|
123
|
+
segmentsList = _k.sent();
|
|
124
|
+
return [4, API.dataService.getChannelsOfServices({ page: 0 })];
|
|
122
125
|
case 8:
|
|
123
|
-
|
|
126
|
+
salesChannels = _k.sent();
|
|
127
|
+
return [4, API.dataService.getTeamSize({ page: 0 })];
|
|
128
|
+
case 9:
|
|
129
|
+
teamSizeList = _k.sent();
|
|
124
130
|
thunkApi.dispatch(handleNextScreenStep('BRAND_INFO_STEP'));
|
|
125
|
-
|
|
126
|
-
case
|
|
131
|
+
_k.label = 10;
|
|
132
|
+
case 10: return [2, {
|
|
127
133
|
data: data,
|
|
128
134
|
individualData: individualData,
|
|
129
135
|
boardResponse: {
|
|
@@ -132,8 +138,8 @@ export var verifyLeadToken = createAsyncThunk('brandVerifyLeadToken', function (
|
|
|
132
138
|
entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity,
|
|
133
139
|
bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
|
|
134
140
|
merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
|
|
135
|
-
name: (
|
|
136
|
-
contact: (
|
|
141
|
+
name: (_h = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _h === void 0 ? void 0 : _h.names,
|
|
142
|
+
contact: (_j = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _j === void 0 ? void 0 : _j.contact,
|
|
137
143
|
individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals,
|
|
138
144
|
business: boardData === null || boardData === void 0 ? void 0 : boardData.business,
|
|
139
145
|
notification: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification
|
|
@@ -141,6 +147,9 @@ export var verifyLeadToken = createAsyncThunk('brandVerifyLeadToken', function (
|
|
|
141
147
|
salesChannels: salesChannels,
|
|
142
148
|
segmentsList: segmentsList === null || segmentsList === void 0 ? void 0 : segmentsList.list,
|
|
143
149
|
teamSizeList: teamSizeList === null || teamSizeList === void 0 ? void 0 : teamSizeList.list,
|
|
150
|
+
segmentLocationList: segmentLocationList,
|
|
151
|
+
segmentProfitList: segmentProfitList,
|
|
152
|
+
segmentTechList: segmentTechList,
|
|
144
153
|
token: token
|
|
145
154
|
}];
|
|
146
155
|
}
|
|
@@ -165,24 +174,24 @@ export var resendOTP = createAsyncThunk('brandResendOTP', function (params, thun
|
|
|
165
174
|
});
|
|
166
175
|
}); });
|
|
167
176
|
export var verifyBrandLeadOTP = createAsyncThunk('verifyBrandLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
168
|
-
var _a, brand, settings, responseBody, payload, data, _b, board_id, board_info_id, boardInfoData, individualData, boardData, _c, id, type, serviceCallBack, _d, boardRes, individualRes, segmentsList, salesChannels, teamSizeList;
|
|
169
|
-
var
|
|
170
|
-
return __generator(this, function (
|
|
171
|
-
switch (
|
|
177
|
+
var _a, brand, settings, responseBody, payload, data, _b, board_id, board_info_id, boardInfoData, individualData, boardData, _c, id, type, serviceCallBack, _d, boardRes, individualRes, _e, segmentLocation, segmentProfit, segmentTech, segmentsList, salesChannels, teamSizeList;
|
|
178
|
+
var _f, _g, _h, _j, _k, _l, _m;
|
|
179
|
+
return __generator(this, function (_o) {
|
|
180
|
+
switch (_o.label) {
|
|
172
181
|
case 0:
|
|
173
182
|
_a = thunkApi.getState(), brand = _a.brand, settings = _a.settings;
|
|
174
183
|
responseBody = brand.data.verify.responseBody;
|
|
175
184
|
payload = {
|
|
176
185
|
data: params.otp,
|
|
177
|
-
service_name: (
|
|
186
|
+
service_name: (_f = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _f === void 0 ? void 0 : _f.service_name,
|
|
178
187
|
verify_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token,
|
|
179
188
|
step_name: BRAND_STEP_NAMES.PHONE_AUTH,
|
|
180
189
|
encryption_contract: ['data']
|
|
181
190
|
};
|
|
182
191
|
return [4, API.leadService.verifyLeadOTP(payload)];
|
|
183
192
|
case 1:
|
|
184
|
-
data = (
|
|
185
|
-
if ((
|
|
193
|
+
data = (_o.sent()).data;
|
|
194
|
+
if ((_g = data.errors) === null || _g === void 0 ? void 0 : _g.length)
|
|
186
195
|
throw new Error(data.errors[0].description);
|
|
187
196
|
_b = responseBody || {}, board_id = _b.id, board_info_id = _b.board_info_id;
|
|
188
197
|
if (!board_id) {
|
|
@@ -192,28 +201,31 @@ export var verifyBrandLeadOTP = createAsyncThunk('verifyBrandLeadOTP', function
|
|
|
192
201
|
if (!board_info_id) return [3, 3];
|
|
193
202
|
return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
|
|
194
203
|
case 2:
|
|
195
|
-
boardInfoData =
|
|
196
|
-
|
|
204
|
+
boardInfoData = _o.sent();
|
|
205
|
+
_o.label = 3;
|
|
197
206
|
case 3: return [4, API.boardService.retrieveBoardDetails(board_id)];
|
|
198
207
|
case 4:
|
|
199
|
-
boardData =
|
|
200
|
-
_c = ((
|
|
208
|
+
boardData = _o.sent();
|
|
209
|
+
_c = ((_h = boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification) === null || _h === void 0 ? void 0 : _h.recipient) || {}, id = _c.id, type = _c.type;
|
|
201
210
|
serviceCallBack = function () { return API.individualService.retrieveIndividual(id, type); };
|
|
202
211
|
return [4, retrieveIndividualData(type, boardData, serviceCallBack)];
|
|
203
212
|
case 5:
|
|
204
|
-
_d =
|
|
213
|
+
_d = _o.sent(), boardRes = _d.boardRes, individualRes = _d.individualRes;
|
|
205
214
|
boardData = boardRes;
|
|
206
215
|
individualData = individualRes;
|
|
207
|
-
(
|
|
208
|
-
return [4,
|
|
216
|
+
(_k = (_j = settings.data.appConfig).onStepCompleted) === null || _k === void 0 ? void 0 : _k.call(_j, settings.data.activeScreen.name, { otp: params.otp });
|
|
217
|
+
return [4, thunkApi.dispatch(retrieveSegmentDataList()).unwrap()];
|
|
209
218
|
case 6:
|
|
210
|
-
|
|
211
|
-
return [4, API.dataService.
|
|
219
|
+
_e = _o.sent(), segmentLocation = _e.segmentLocation, segmentProfit = _e.segmentProfit, segmentTech = _e.segmentTech;
|
|
220
|
+
return [4, API.dataService.getSegments({ page: 0 })];
|
|
212
221
|
case 7:
|
|
213
|
-
|
|
214
|
-
return [4, API.dataService.
|
|
222
|
+
segmentsList = _o.sent();
|
|
223
|
+
return [4, API.dataService.getChannelsOfServices({ page: 0 })];
|
|
215
224
|
case 8:
|
|
216
|
-
|
|
225
|
+
salesChannels = _o.sent();
|
|
226
|
+
return [4, API.dataService.getTeamSize({ page: 0 })];
|
|
227
|
+
case 9:
|
|
228
|
+
teamSizeList = _o.sent();
|
|
217
229
|
sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('BRAND_INFO_STEP')); });
|
|
218
230
|
return [2, {
|
|
219
231
|
data: data,
|
|
@@ -224,8 +236,8 @@ export var verifyBrandLeadOTP = createAsyncThunk('verifyBrandLeadOTP', function
|
|
|
224
236
|
entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity,
|
|
225
237
|
bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
|
|
226
238
|
merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
|
|
227
|
-
name: (
|
|
228
|
-
contact: (
|
|
239
|
+
name: (_l = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _l === void 0 ? void 0 : _l.names,
|
|
240
|
+
contact: (_m = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _m === void 0 ? void 0 : _m.contact,
|
|
229
241
|
individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals,
|
|
230
242
|
business: boardData === null || boardData === void 0 ? void 0 : boardData.business,
|
|
231
243
|
notification: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification
|
|
@@ -233,11 +245,38 @@ export var verifyBrandLeadOTP = createAsyncThunk('verifyBrandLeadOTP', function
|
|
|
233
245
|
salesChannels: salesChannels,
|
|
234
246
|
segmentsList: segmentsList === null || segmentsList === void 0 ? void 0 : segmentsList.list,
|
|
235
247
|
teamSizeList: teamSizeList === null || teamSizeList === void 0 ? void 0 : teamSizeList.list,
|
|
248
|
+
segmentLocationList: segmentLocation,
|
|
249
|
+
segmentProfitList: segmentProfit,
|
|
250
|
+
segmentTechList: segmentTech,
|
|
236
251
|
formData: params
|
|
237
252
|
}];
|
|
238
253
|
}
|
|
239
254
|
});
|
|
240
255
|
}); });
|
|
256
|
+
export var retrieveSegmentDataList = createAsyncThunk('brandRetrieveSegmentDataList', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
257
|
+
var dataBody, _a, segmentLocation, segmentProfit, segmentTech;
|
|
258
|
+
return __generator(this, function (_b) {
|
|
259
|
+
switch (_b.label) {
|
|
260
|
+
case 0:
|
|
261
|
+
dataBody = {
|
|
262
|
+
page: 0,
|
|
263
|
+
limit: 50
|
|
264
|
+
};
|
|
265
|
+
return [4, Promise.all([
|
|
266
|
+
API.dataService.getSegmentLocation(dataBody),
|
|
267
|
+
API.dataService.getSegmentProfit(dataBody),
|
|
268
|
+
API.dataService.getSegmentTech(dataBody)
|
|
269
|
+
])];
|
|
270
|
+
case 1:
|
|
271
|
+
_a = _b.sent(), segmentLocation = _a[0].list, segmentProfit = _a[1].list, segmentTech = _a[2].list;
|
|
272
|
+
return [2, {
|
|
273
|
+
segmentLocation: segmentLocation,
|
|
274
|
+
segmentProfit: segmentProfit,
|
|
275
|
+
segmentTech: segmentTech
|
|
276
|
+
}];
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}); });
|
|
241
280
|
export var retrieveBoardStatus = createAsyncThunk('brand/retrieveBoardStatus', function (parmas, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
242
281
|
var brand, board_id, data;
|
|
243
282
|
return __generator(this, function (_a) {
|
|
@@ -295,7 +334,7 @@ export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailabi
|
|
|
295
334
|
export var updateBrand = createAsyncThunk('brandUpdateBrand', function (_a, thunkApi) {
|
|
296
335
|
var formData = _a.formData, originalFormData = _a.originalFormData;
|
|
297
336
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
298
|
-
var _b, settings, brand, brandRes, _c, id, data_status, isNameENNonEditable, isNameARNonEditable, isChannelServicesNonEditable,
|
|
337
|
+
var _b, settings, brand, brandRes, _c, id, data_status, isNameENNonEditable, isNameARNonEditable, isChannelServicesNonEditable, isSegmentLocationNonEditable, isSegmentProfitNonEditable, isSegmentTechNonEditable, isSegmentTeamsNonEditable, salesChannels, brandName, segmentLocation, segmentProfit, segmentTech, teamSize, brandLogoId, segmentLocationId, segmentProfitId, segmentTechId, teamSizeId, hasSegment, getAddress, channel_services, brandNameIsEditable, requestBody, brandData, activities, activityList;
|
|
299
338
|
var _d, _e, _f;
|
|
300
339
|
return __generator(this, function (_g) {
|
|
301
340
|
switch (_g.label) {
|
|
@@ -306,11 +345,16 @@ export var updateBrand = createAsyncThunk('brandUpdateBrand', function (_a, thun
|
|
|
306
345
|
isNameENNonEditable = hasNoneEditableValue(data_status, 'name.en');
|
|
307
346
|
isNameARNonEditable = hasNoneEditableValue(data_status, 'name.ar');
|
|
308
347
|
isChannelServicesNonEditable = hasNoneEditableValue(data_status, 'channel_services');
|
|
309
|
-
|
|
348
|
+
isSegmentLocationNonEditable = hasNoneEditableValue(data_status, 'segment.location_type');
|
|
349
|
+
isSegmentProfitNonEditable = hasNoneEditableValue(data_status, 'segment.profit_type');
|
|
350
|
+
isSegmentTechNonEditable = hasNoneEditableValue(data_status, 'segment.tech_type');
|
|
310
351
|
isSegmentTeamsNonEditable = hasNoneEditableValue(data_status, 'segment.teams');
|
|
311
|
-
salesChannels = formData.salesChannels, brandName = formData.brandName,
|
|
312
|
-
|
|
352
|
+
salesChannels = formData.salesChannels, brandName = formData.brandName, segmentLocation = formData.segmentLocation, segmentProfit = formData.segmentProfit, segmentTech = formData.segmentTech, teamSize = formData.teamSize, brandLogoId = formData.brandLogoId;
|
|
353
|
+
segmentLocationId = isSegmentLocationNonEditable ? undefined : segmentLocation && { id: segmentLocation.id };
|
|
354
|
+
segmentProfitId = isSegmentProfitNonEditable ? undefined : segmentProfit && { id: segmentProfit.id };
|
|
355
|
+
segmentTechId = isSegmentTechNonEditable ? undefined : segmentTech && { id: segmentTech.id };
|
|
313
356
|
teamSizeId = isSegmentTeamsNonEditable ? undefined : teamSize && { id: teamSize.id };
|
|
357
|
+
hasSegment = segmentLocationId || segmentProfitId || segmentTechId || teamSizeId;
|
|
314
358
|
getAddress = function (value, isTwitter, isWeb) {
|
|
315
359
|
if (isTwitter)
|
|
316
360
|
return '@' + value.replaceAll('@', '');
|
|
@@ -331,12 +375,14 @@ export var updateBrand = createAsyncThunk('brandUpdateBrand', function (_a, thun
|
|
|
331
375
|
};
|
|
332
376
|
});
|
|
333
377
|
brandNameIsEditable = brandName && !(isNameENNonEditable && isNameARNonEditable);
|
|
334
|
-
requestBody = __assign(__assign({ id: id }, (brandNameIsEditable && {
|
|
378
|
+
requestBody = __assign(__assign(__assign(__assign({ id: id }, (brandNameIsEditable && {
|
|
335
379
|
name: {
|
|
336
380
|
en: !isNameENNonEditable ? brandName : undefined,
|
|
337
381
|
ar: !isNameARNonEditable ? brandName : undefined
|
|
338
382
|
}
|
|
339
|
-
})), { logo: brandLogoId,
|
|
383
|
+
})), { logo: brandLogoId }), (hasSegment && {
|
|
384
|
+
segment: { location_type: segmentLocationId, profit_type: segmentProfitId, tech_type: segmentTechId, team: teamSizeId }
|
|
385
|
+
})), { channel_services: channel_services });
|
|
340
386
|
return [4, API.brandService.updateBrandInfo(requestBody)];
|
|
341
387
|
case 1:
|
|
342
388
|
brandData = (_g.sent()).brand;
|
|
@@ -547,32 +593,42 @@ export var brandSlice = createSlice({
|
|
|
547
593
|
state.customLoading = true;
|
|
548
594
|
})
|
|
549
595
|
.addCase(verifyLeadToken.fulfilled, function (state, action) {
|
|
550
|
-
var _a, _b, _c, _d;
|
|
596
|
+
var _a, _b, _c, _d, _e, _f;
|
|
551
597
|
state.error = null;
|
|
552
598
|
state.customLoading = false;
|
|
553
|
-
var
|
|
599
|
+
var _g = action.payload, data = _g.data, token = _g.token, boardResponse = _g.boardResponse, segmentsList = _g.segmentsList, teamSizeList = _g.teamSizeList, salesChannels = _g.salesChannels, individualData = _g.individualData, segmentLocationList = _g.segmentLocationList, segmentProfitList = _g.segmentProfitList, segmentTechList = _g.segmentTechList;
|
|
554
600
|
var brand = boardResponse.brand, entity = boardResponse.entity;
|
|
555
601
|
state.data.brandData.brandName = (((_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en) || '').trim();
|
|
556
|
-
var
|
|
602
|
+
var selectedSegmentLocation = (_b = segmentLocationList === null || segmentLocationList === void 0 ? void 0 : segmentLocationList.filter(function (location) {
|
|
557
603
|
var _a, _b;
|
|
558
|
-
return
|
|
604
|
+
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);
|
|
559
605
|
})) === null || _b === void 0 ? void 0 : _b[0];
|
|
560
|
-
var
|
|
606
|
+
var selectedSegmentProfit = (_c = segmentProfitList === null || segmentProfitList === void 0 ? void 0 : segmentProfitList.filter(function (profit) {
|
|
561
607
|
var _a, _b;
|
|
562
|
-
return
|
|
608
|
+
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);
|
|
563
609
|
})) === null || _c === void 0 ? void 0 : _c[0];
|
|
564
|
-
(_d =
|
|
610
|
+
var selectedSegmentTech = (_d = segmentTechList === null || segmentTechList === void 0 ? void 0 : segmentTechList.filter(function (tech) {
|
|
611
|
+
var _a, _b;
|
|
612
|
+
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);
|
|
613
|
+
})) === null || _d === void 0 ? void 0 : _d[0];
|
|
614
|
+
var selectedTeamSize = (_e = teamSizeList === null || teamSizeList === void 0 ? void 0 : teamSizeList.filter(function (team) {
|
|
615
|
+
var _a, _b;
|
|
616
|
+
return team.id === ((_b = (_a = brand === null || brand === void 0 ? void 0 : brand.segment) === null || _a === void 0 ? void 0 : _a.team) === null || _b === void 0 ? void 0 : _b.id);
|
|
617
|
+
})) === null || _e === void 0 ? void 0 : _e[0];
|
|
618
|
+
(_f = brand === null || brand === void 0 ? void 0 : brand.terms) === null || _f === void 0 ? void 0 : _f.forEach(function (element) {
|
|
565
619
|
if ((element === null || element === void 0 ? void 0 : element.term) === 'general') {
|
|
566
620
|
state.data.brandActivities.termAndConditionChecked = element.agree;
|
|
567
621
|
state.data.brandActivities.transactionPolicy = element.agree;
|
|
568
622
|
state.data.brandActivities.refundPolicy = element.agree;
|
|
569
623
|
}
|
|
570
624
|
});
|
|
571
|
-
state.data.brandData.
|
|
625
|
+
state.data.brandData.segmentLocation = selectedSegmentLocation;
|
|
626
|
+
state.data.brandData.segmentProfit = selectedSegmentProfit;
|
|
627
|
+
state.data.brandData.segmentTech = selectedSegmentTech;
|
|
572
628
|
state.data.brandData.teamSize = selectedTeamSize;
|
|
573
629
|
var mappedSalesChannels = mapSalesChannel((brand === null || brand === void 0 ? void 0 : brand.channel_services) || []);
|
|
574
630
|
state.data.brandData.salesChannels = mappedSalesChannels;
|
|
575
|
-
state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), state.data.verify.responseBody), boardResponse), { board_id: data.id, channel_list: (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.list) || [], salesChannels: mappedSalesChannels, activities: entity === null || entity === void 0 ? void 0 : entity.activities, segmentsList: segmentsList, teamSizeList: teamSizeList, individualData: individualData });
|
|
631
|
+
state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), state.data.verify.responseBody), boardResponse), { board_id: data.id, channel_list: (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.list) || [], salesChannels: mappedSalesChannels, activities: entity === null || entity === void 0 ? void 0 : entity.activities, segmentsList: segmentsList, teamSizeList: teamSizeList, individualData: individualData, segmentLocationList: segmentLocationList, segmentProfitList: segmentProfitList, segmentTechList: segmentTechList });
|
|
576
632
|
state.data.verify.token = token;
|
|
577
633
|
})
|
|
578
634
|
.addCase(verifyLeadToken.rejected, function (state, action) {
|
|
@@ -595,34 +651,44 @@ export var brandSlice = createSlice({
|
|
|
595
651
|
state.error = null;
|
|
596
652
|
})
|
|
597
653
|
.addCase(verifyBrandLeadOTP.fulfilled, function (state, action) {
|
|
598
|
-
var _a, _b, _c, _d;
|
|
654
|
+
var _a, _b, _c, _d, _e, _f;
|
|
599
655
|
state.loading = false;
|
|
600
656
|
state.error = null;
|
|
601
|
-
var
|
|
657
|
+
var _g = action.payload, data = _g.data, boardResponse = _g.boardResponse, formData = _g.formData, segmentsList = _g.segmentsList, teamSizeList = _g.teamSizeList, salesChannels = _g.salesChannels, individualData = _g.individualData, segmentLocationList = _g.segmentLocationList, segmentProfitList = _g.segmentProfitList, segmentTechList = _g.segmentTechList;
|
|
602
658
|
var brand = boardResponse.brand, entity = boardResponse.entity;
|
|
603
659
|
state.data.otpData = formData;
|
|
604
660
|
state.data.otpData.responseBody = data;
|
|
605
661
|
state.data.brandData.brandName = (((_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en) || '').trim();
|
|
606
|
-
var
|
|
662
|
+
var selectedTeamSize = (_b = teamSizeList === null || teamSizeList === void 0 ? void 0 : teamSizeList.filter(function (team) {
|
|
607
663
|
var _a, _b;
|
|
608
|
-
return
|
|
664
|
+
return team.id === ((_b = (_a = brand === null || brand === void 0 ? void 0 : brand.segment) === null || _a === void 0 ? void 0 : _a.team) === null || _b === void 0 ? void 0 : _b.id);
|
|
609
665
|
})) === null || _b === void 0 ? void 0 : _b[0];
|
|
610
|
-
var
|
|
666
|
+
var selectedSegmentLocation = (_c = segmentLocationList === null || segmentLocationList === void 0 ? void 0 : segmentLocationList.filter(function (location) {
|
|
611
667
|
var _a, _b;
|
|
612
|
-
return
|
|
668
|
+
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);
|
|
613
669
|
})) === null || _c === void 0 ? void 0 : _c[0];
|
|
614
|
-
|
|
670
|
+
var selectedSegmentProfit = (_d = segmentProfitList === null || segmentProfitList === void 0 ? void 0 : segmentProfitList.filter(function (profit) {
|
|
671
|
+
var _a, _b;
|
|
672
|
+
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);
|
|
673
|
+
})) === null || _d === void 0 ? void 0 : _d[0];
|
|
674
|
+
var selectedSegmentTech = (_e = segmentTechList === null || segmentTechList === void 0 ? void 0 : segmentTechList.filter(function (tech) {
|
|
675
|
+
var _a, _b;
|
|
676
|
+
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);
|
|
677
|
+
})) === null || _e === void 0 ? void 0 : _e[0];
|
|
678
|
+
state.data.brandData.segmentLocation = selectedSegmentLocation;
|
|
679
|
+
state.data.brandData.segmentProfit = selectedSegmentProfit;
|
|
680
|
+
state.data.brandData.segmentTech = selectedSegmentTech;
|
|
615
681
|
state.data.brandData.teamSize = selectedTeamSize;
|
|
616
682
|
var mappedSalesChannels = mapSalesChannel((brand === null || brand === void 0 ? void 0 : brand.channel_services) || []);
|
|
617
683
|
state.data.brandData.salesChannels = mappedSalesChannels;
|
|
618
|
-
(
|
|
684
|
+
(_f = brand === null || brand === void 0 ? void 0 : brand.terms) === null || _f === void 0 ? void 0 : _f.forEach(function (element) {
|
|
619
685
|
if ((element === null || element === void 0 ? void 0 : element.term) === 'general') {
|
|
620
686
|
state.data.brandActivities.termAndConditionChecked = element.agree;
|
|
621
687
|
state.data.brandActivities.transactionPolicy = element.agree;
|
|
622
688
|
state.data.brandActivities.refundPolicy = element.agree;
|
|
623
689
|
}
|
|
624
690
|
});
|
|
625
|
-
state.data.verify.responseBody = __assign(__assign(__assign({}, state.data.verify.responseBody), boardResponse), { board_id: data.id, channel_list: (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.list) || [], activities: entity === null || entity === void 0 ? void 0 : entity.activities, salesChannels: mappedSalesChannels, segmentsList: segmentsList, teamSizeList: teamSizeList, individualData: individualData });
|
|
691
|
+
state.data.verify.responseBody = __assign(__assign(__assign({}, state.data.verify.responseBody), boardResponse), { board_id: data.id, channel_list: (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.list) || [], activities: entity === null || entity === void 0 ? void 0 : entity.activities, salesChannels: mappedSalesChannels, segmentsList: segmentsList, teamSizeList: teamSizeList, individualData: individualData, segmentLocationList: segmentLocationList, segmentProfitList: segmentProfitList, segmentTechList: segmentTechList });
|
|
626
692
|
})
|
|
627
693
|
.addCase(verifyBrandLeadOTP.rejected, function (state, action) {
|
|
628
694
|
state.loading = false;
|
|
@@ -687,6 +753,18 @@ export var brandSlice = createSlice({
|
|
|
687
753
|
.addCase(updateBrand.rejected, function (state, action) {
|
|
688
754
|
state.loading = false;
|
|
689
755
|
state.error = action.error.message;
|
|
756
|
+
})
|
|
757
|
+
.addCase(retrieveSegmentDataList.pending, function (state) {
|
|
758
|
+
state.loading = true;
|
|
759
|
+
state.error = null;
|
|
760
|
+
})
|
|
761
|
+
.addCase(retrieveSegmentDataList.fulfilled, function (state) {
|
|
762
|
+
state.loading = false;
|
|
763
|
+
state.error = null;
|
|
764
|
+
})
|
|
765
|
+
.addCase(retrieveSegmentDataList.rejected, function (state, action) {
|
|
766
|
+
state.loading = false;
|
|
767
|
+
state.error = action.error.message;
|
|
690
768
|
})
|
|
691
769
|
.addCase(retrieveDataList.pending, function (state) {
|
|
692
770
|
state.loading = true;
|
|
@@ -26,9 +26,11 @@ import TeamSize from '../../../brand/screens/BrandInfo/TeamSize';
|
|
|
26
26
|
import Collapse from '../../../../components/Collapse';
|
|
27
27
|
import { mapSalesChannel } from '../../../../utils';
|
|
28
28
|
import BrandName from './BrandName';
|
|
29
|
-
import Segments from './Segments';
|
|
30
29
|
import SalesChannels from './SalesChannels';
|
|
31
30
|
import BrandLogo from './BrandLogo';
|
|
31
|
+
import SegmentLocations from './SegmentLocations';
|
|
32
|
+
import SegmentProfits from './SegmentProfits';
|
|
33
|
+
import SegmentTechs from './SegmentTechs';
|
|
32
34
|
var FormStyled = styled(Form)(function () { return ({
|
|
33
35
|
display: 'flex',
|
|
34
36
|
flexDirection: 'column'
|
|
@@ -37,23 +39,28 @@ var ListType;
|
|
|
37
39
|
(function (ListType) {
|
|
38
40
|
ListType["SegmentsList"] = "SegmentsList";
|
|
39
41
|
ListType["TeamSizeList"] = "TeamSizeList";
|
|
42
|
+
ListType["SegmentLocationList"] = "SegmentLocationList";
|
|
43
|
+
ListType["SegmentProfitList"] = "SegmentProfitList";
|
|
44
|
+
ListType["SegmentTechList"] = "SegmentTechList";
|
|
40
45
|
})(ListType || (ListType = {}));
|
|
41
46
|
var BrandInfo = function (_a) {
|
|
42
|
-
var _b, _c, _d, _e;
|
|
43
|
-
var
|
|
44
|
-
var
|
|
47
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
48
|
+
var _k = React.useState(), listActive = _k[0], setListActive = _k[1];
|
|
49
|
+
var _l = React.useState(false), brandNameChecking = _l[0], setBrandNameChecking = _l[1];
|
|
45
50
|
var dispatch = useAppDispatch();
|
|
46
51
|
var t = useTranslation().t;
|
|
47
52
|
var isAr = useLanguage().isAr;
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
53
|
+
var _m = useAppSelector(brandSelector), data = _m.data, loading = _m.loading, error = _m.error, uploadingBrandLogo = _m.uploadingBrandLogo;
|
|
54
|
+
var _o = data.brandData, brandName = _o.brandName, segmentLocation = _o.segmentLocation, segmentProfit = _o.segmentProfit, segmentTech = _o.segmentTech, teamSize = _o.teamSize, salesChannels = _o.salesChannels, brandLogoId = _o.brandLogoId, responseBody = _o.responseBody;
|
|
55
|
+
var _p = data.verify.responseBody || {}, brand = _p.brand, flows = _p.flows;
|
|
56
|
+
var _q = brand || {}, logo_details = _q.logo_details, data_status = _q.data_status, data_verification = _q.data_verification, name = _q.name, resSegment = _q.segment;
|
|
52
57
|
var methods = useForm({
|
|
53
58
|
resolver: yupResolver(BrandValidationSchema()),
|
|
54
59
|
defaultValues: {
|
|
55
60
|
brandName: brandName,
|
|
56
|
-
|
|
61
|
+
segmentLocation: segmentLocation,
|
|
62
|
+
segmentProfit: segmentProfit,
|
|
63
|
+
segmentTech: segmentTech,
|
|
57
64
|
teamSize: teamSize,
|
|
58
65
|
salesChannels: salesChannels,
|
|
59
66
|
brandLogoId: brandLogoId
|
|
@@ -64,13 +71,23 @@ var BrandInfo = function (_a) {
|
|
|
64
71
|
useSetFromDefaultValues(methods, data.brandData, true);
|
|
65
72
|
var defaultBrandLogoFile = React.useMemo(function () { return logo_details && __assign(__assign({}, logo_details), { docId: '' }); }, [logo_details]);
|
|
66
73
|
var originalReadOnly = useFormReadOnly(methods, { brandLogoId: defaultBrandLogoFile });
|
|
67
|
-
var noneEditable = useDataNoneEditable(data_status, [
|
|
74
|
+
var noneEditable = useDataNoneEditable(data_status, [
|
|
75
|
+
'name.en',
|
|
76
|
+
'name.ar',
|
|
77
|
+
'segment.location_type',
|
|
78
|
+
'segment.profit_type',
|
|
79
|
+
'segment.tech_type',
|
|
80
|
+
'segment.teams',
|
|
81
|
+
'channel_services'
|
|
82
|
+
]);
|
|
68
83
|
var readOnly = useFormErrorAndUpdateReadOnly(methods, originalReadOnly, noneEditable);
|
|
69
84
|
var dataVerified = useDataVerified(data_verification, ['logo', 'name.en', 'name.ar', 'segment.teams', 'segment.type']);
|
|
70
85
|
var getFelids = useExcludeReadOnlyFelids(methods, readOnly).getFelids;
|
|
71
86
|
var isBrandNameVerified = dataVerified['name.en'] && dataVerified['name.ar'] && ((name === null || name === void 0 ? void 0 : name.en) === watch('brandName') || (name === null || name === void 0 ? void 0 : name.ar) === watch('brandName'));
|
|
72
|
-
var
|
|
73
|
-
var
|
|
87
|
+
var isSegmentLocationVerified = dataVerified['segment.location_type'] && ((_b = resSegment === null || resSegment === void 0 ? void 0 : resSegment.location_type) === null || _b === void 0 ? void 0 : _b.id) === ((_c = watch('segmentLocation')) === null || _c === void 0 ? void 0 : _c.id);
|
|
88
|
+
var isSegmentProfitVerified = dataVerified['segment.profit_type'] && ((_d = resSegment === null || resSegment === void 0 ? void 0 : resSegment.profit_type) === null || _d === void 0 ? void 0 : _d.id) === ((_e = watch('segmentProfit')) === null || _e === void 0 ? void 0 : _e.id);
|
|
89
|
+
var isSegmentTechVerified = dataVerified['segment.tech_type'] && ((_f = resSegment === null || resSegment === void 0 ? void 0 : resSegment.tech_type) === null || _f === void 0 ? void 0 : _f.id) === ((_g = watch('segmentTech')) === null || _g === void 0 ? void 0 : _g.id);
|
|
90
|
+
var isTeamSizeVerified = dataVerified['segment.teams'] && ((_h = resSegment === null || resSegment === void 0 ? void 0 : resSegment.team) === null || _h === void 0 ? void 0 : _h.id) === ((_j = watch('teamSize')) === null || _j === void 0 ? void 0 : _j.id);
|
|
74
91
|
var onSubmit = function (data) {
|
|
75
92
|
dispatch(updateBrand(getFelids(data)));
|
|
76
93
|
};
|
|
@@ -98,8 +115,10 @@ var BrandInfo = function (_a) {
|
|
|
98
115
|
var handleMenuClick = function (flag) {
|
|
99
116
|
setListActive(flag);
|
|
100
117
|
};
|
|
101
|
-
var
|
|
118
|
+
var isSegmentLocationListActive = listActive === ListType.SegmentLocationList;
|
|
119
|
+
var isSegmentProfitListActive = listActive === ListType.SegmentProfitList;
|
|
120
|
+
var isSegmentTechListActive = listActive === ListType.SegmentTechList;
|
|
102
121
|
var isTeamSizeListActive = listActive === ListType.TeamSizeList;
|
|
103
|
-
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandName, { readOnly: readOnly['brandName'] || (noneEditable['name.en'] && noneEditable['name.ar']), show: !listActive, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking, isVerified: isBrandNameVerified }), _jsx(BrandLogo, { defaultFile: defaultBrandLogoFile, readOnly: readOnly['brandLogoId'], show: !listActive, isVerified: dataVerified['logo'] }), _jsx(
|
|
122
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandName, { readOnly: readOnly['brandName'] || (noneEditable['name.en'] && noneEditable['name.ar']), show: !listActive, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking, isVerified: isBrandNameVerified }), _jsx(BrandLogo, { defaultFile: defaultBrandLogoFile, readOnly: readOnly['brandLogoId'], show: !listActive, isVerified: dataVerified['logo'] }), _jsx(SegmentLocations, { readOnly: readOnly['segmentLocation'], show: !isTeamSizeListActive && !isSegmentProfitListActive && !isSegmentTechListActive, onListOpen: function () { return handleMenuClick(ListType.SegmentLocationList); }, onListClose: function () { return handleMenuClick(); }, isVerified: isSegmentLocationVerified }), _jsx(SegmentProfits, { readOnly: readOnly['segmentProfit'], show: !isTeamSizeListActive && !isSegmentLocationListActive && !isSegmentTechListActive, onListOpen: function () { return handleMenuClick(ListType.SegmentProfitList); }, onListClose: function () { return handleMenuClick(); }, isVerified: isSegmentProfitVerified }), _jsx(SegmentTechs, { readOnly: readOnly['segmentTech'], show: !isTeamSizeListActive && !isSegmentLocationListActive && !isSegmentProfitListActive, onListOpen: function () { return handleMenuClick(ListType.SegmentTechList); }, onListClose: function () { return handleMenuClick(); }, isVerified: isSegmentTechVerified }), _jsx(TeamSize, { readOnly: readOnly['teamSize'] || noneEditable['segment.teams'], show: !isSegmentLocationListActive && !isSegmentProfitListActive && !isSegmentTechListActive, onListOpen: function () { return handleMenuClick(ListType.TeamSizeList); }, onListClose: function () { return handleMenuClick(); }, isVerified: isTeamSizeVerified }), _jsxs(Collapse, __assign({ in: !listActive }, { children: [_jsx(SalesChannels, { readOnly: readOnly['salesChannels'] || noneEditable['channel_services'] }), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') }))] }))] })) })) }));
|
|
104
123
|
};
|
|
105
124
|
export default BrandInfo;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface SegmentLocationsProps {
|
|
3
|
+
show: boolean;
|
|
4
|
+
onListOpen?: () => void;
|
|
5
|
+
onListClose?: () => void;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
isVerified?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const SegmentLocations: ({ show, onListOpen, onListClose, readOnly, isVerified }: SegmentLocationsProps) => JSX.Element;
|
|
10
|
+
export default SegmentLocations;
|
|
@@ -28,7 +28,7 @@ var IncomeText = styled(Text, { shouldForwardProp: function (prop) { return prop
|
|
|
28
28
|
var theme = _a.theme, isSelected = _a.isSelected;
|
|
29
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
30
|
});
|
|
31
|
-
var
|
|
31
|
+
var SegmentLocations = function (_a) {
|
|
32
32
|
var _b, _c, _d;
|
|
33
33
|
var show = _a.show, onListOpen = _a.onListOpen, onListClose = _a.onListClose, readOnly = _a.readOnly, isVerified = _a.isVerified;
|
|
34
34
|
var _e = React.useState([]), segmentList = _e[0], setSegmentList = _e[1];
|
|
@@ -37,9 +37,9 @@ var Segments = function (_a) {
|
|
|
37
37
|
var isAr = useLanguage().isAr;
|
|
38
38
|
var data = useAppSelector(brandSelector).data;
|
|
39
39
|
var control = useFormContext().control;
|
|
40
|
-
var list = (data.verify.responseBody || {}).
|
|
40
|
+
var list = (data.verify.responseBody || {}).segmentLocationList;
|
|
41
41
|
var segmentsList = list || [];
|
|
42
|
-
var segmentControl = useController({ control: control, name: '
|
|
42
|
+
var segmentControl = useController({ control: control, name: 'segmentLocation' });
|
|
43
43
|
var segment = segmentControl.field.value;
|
|
44
44
|
var error = (_b = segmentControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
45
45
|
React.useEffect(function () {
|
|
@@ -50,7 +50,6 @@ var Segments = function (_a) {
|
|
|
50
50
|
var onOpenList = function (event) {
|
|
51
51
|
if (readOnly)
|
|
52
52
|
return;
|
|
53
|
-
console.log('onOpenList segments');
|
|
54
53
|
setAnchorEl(event.currentTarget);
|
|
55
54
|
onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
|
|
56
55
|
};
|
|
@@ -62,9 +61,9 @@ var Segments = function (_a) {
|
|
|
62
61
|
onCloseList();
|
|
63
62
|
segmentControl.field.onChange(segment);
|
|
64
63
|
};
|
|
65
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsx(InputSelect, { required: true, label: t('
|
|
64
|
+
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'), readOnly: readOnly, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(EndAdornmentExpanded, { anchorEl: anchorEl, isVerified: isVerified }), placeholder: t('choose_any_segment'), value: (isAr ? (_c = segment === null || segment === void 0 ? void 0 : segment.name) === null || _c === void 0 ? void 0 : _c.ar : (_d = segment === null || segment === void 0 ? void 0 : segment.name) === null || _d === void 0 ? void 0 : _d.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) {
|
|
66
65
|
var _a, _b;
|
|
67
66
|
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, { isVerified: isVerified })] }));
|
|
68
67
|
} }) }))] })) })));
|
|
69
68
|
};
|
|
70
|
-
export default
|
|
69
|
+
export default SegmentLocations;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface SegmentProfitsProps {
|
|
3
|
+
show: boolean;
|
|
4
|
+
onListOpen?: () => void;
|
|
5
|
+
onListClose?: () => void;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
isVerified?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const SegmentProfits: ({ show, onListOpen, onListClose, readOnly, isVerified }: SegmentProfitsProps) => JSX.Element;
|
|
10
|
+
export default SegmentProfits;
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { brandSelector } from '../../../app/brand/brandStore';
|
|
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;
|
|
33
|
+
var show = _a.show, onListOpen = _a.onListOpen, onListClose = _a.onListClose, readOnly = _a.readOnly, isVerified = _a.isVerified;
|
|
34
|
+
var _e = React.useState([]), segmentList = _e[0], setSegmentList = _e[1];
|
|
35
|
+
var _f = React.useState(null), anchorEl = _f[0], setAnchorEl = _f[1];
|
|
36
|
+
var t = useTranslation().t;
|
|
37
|
+
var isAr = useLanguage().isAr;
|
|
38
|
+
var data = useAppSelector(brandSelector).data;
|
|
39
|
+
var control = useFormContext().control;
|
|
40
|
+
var list = (data.verify.responseBody || {}).segmentProfitList;
|
|
41
|
+
var segmentsList = list || [];
|
|
42
|
+
var segmentControl = useController({ control: control, name: 'segmentProfit' });
|
|
43
|
+
var segment = segmentControl.field.value;
|
|
44
|
+
var error = (_b = segmentControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
45
|
+
React.useEffect(function () {
|
|
46
|
+
if ((segmentsList === null || segmentsList === void 0 ? void 0 : segmentsList.length) > 0) {
|
|
47
|
+
setSegmentList(segmentsList);
|
|
48
|
+
}
|
|
49
|
+
}, [segmentsList]);
|
|
50
|
+
var onOpenList = function (event) {
|
|
51
|
+
if (readOnly)
|
|
52
|
+
return;
|
|
53
|
+
setAnchorEl(event.currentTarget);
|
|
54
|
+
onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
|
|
55
|
+
};
|
|
56
|
+
var onCloseList = function () {
|
|
57
|
+
setAnchorEl(null);
|
|
58
|
+
onListClose === null || onListClose === void 0 ? void 0 : onListClose();
|
|
59
|
+
};
|
|
60
|
+
var onSelectItem = function (segment) {
|
|
61
|
+
onCloseList();
|
|
62
|
+
segmentControl.field.onChange(segment);
|
|
63
|
+
};
|
|
64
|
+
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'), readOnly: readOnly, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(EndAdornmentExpanded, { anchorEl: anchorEl, isVerified: isVerified }), placeholder: t('choose_any_segment'), value: (isAr ? (_c = segment === null || segment === void 0 ? void 0 : segment.name) === null || _c === void 0 ? void 0 : _c.ar : (_d = segment === null || segment === void 0 ? void 0 : segment.name) === null || _d === void 0 ? void 0 : _d.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) {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
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, { isVerified: isVerified })] }));
|
|
67
|
+
} }) }))] })) })));
|
|
68
|
+
};
|
|
69
|
+
export default SegmentProfits;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface SegmentTechsProps {
|
|
3
|
+
show: boolean;
|
|
4
|
+
onListOpen?: () => void;
|
|
5
|
+
onListClose?: () => void;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
isVerified?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const SegmentTechs: ({ show, onListOpen, onListClose, readOnly, isVerified }: SegmentTechsProps) => JSX.Element;
|
|
10
|
+
export default SegmentTechs;
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { brandSelector } from '../../../app/brand/brandStore';
|
|
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;
|
|
33
|
+
var show = _a.show, onListOpen = _a.onListOpen, onListClose = _a.onListClose, readOnly = _a.readOnly, isVerified = _a.isVerified;
|
|
34
|
+
var _e = React.useState([]), segmentList = _e[0], setSegmentList = _e[1];
|
|
35
|
+
var _f = React.useState(null), anchorEl = _f[0], setAnchorEl = _f[1];
|
|
36
|
+
var t = useTranslation().t;
|
|
37
|
+
var isAr = useLanguage().isAr;
|
|
38
|
+
var data = useAppSelector(brandSelector).data;
|
|
39
|
+
var control = useFormContext().control;
|
|
40
|
+
var list = (data.verify.responseBody || {}).segmentTechList;
|
|
41
|
+
var segmentsList = list || [];
|
|
42
|
+
var segmentControl = useController({ control: control, name: 'segmentTech' });
|
|
43
|
+
var segment = segmentControl.field.value;
|
|
44
|
+
var error = (_b = segmentControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
45
|
+
React.useEffect(function () {
|
|
46
|
+
if ((segmentsList === null || segmentsList === void 0 ? void 0 : segmentsList.length) > 0) {
|
|
47
|
+
setSegmentList(segmentsList);
|
|
48
|
+
}
|
|
49
|
+
}, [segmentsList]);
|
|
50
|
+
var onOpenList = function (event) {
|
|
51
|
+
if (readOnly)
|
|
52
|
+
return;
|
|
53
|
+
setAnchorEl(event.currentTarget);
|
|
54
|
+
onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
|
|
55
|
+
};
|
|
56
|
+
var onCloseList = function () {
|
|
57
|
+
setAnchorEl(null);
|
|
58
|
+
onListClose === null || onListClose === void 0 ? void 0 : onListClose();
|
|
59
|
+
};
|
|
60
|
+
var onSelectItem = function (segment) {
|
|
61
|
+
onCloseList();
|
|
62
|
+
segmentControl.field.onChange(segment);
|
|
63
|
+
};
|
|
64
|
+
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'), readOnly: readOnly, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(EndAdornmentExpanded, { anchorEl: anchorEl, isVerified: isVerified }), placeholder: t('choose_any_segment'), value: (isAr ? (_c = segment === null || segment === void 0 ? void 0 : segment.name) === null || _c === void 0 ? void 0 : _c.ar : (_d = segment === null || segment === void 0 ? void 0 : segment.name) === null || _d === void 0 ? void 0 : _d.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) {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
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, { isVerified: isVerified })] }));
|
|
67
|
+
} }) }))] })) })));
|
|
68
|
+
};
|
|
69
|
+
export default SegmentTechs;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
2
|
export declare const BrandValidationSchema: () => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
3
|
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
4
|
-
|
|
4
|
+
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>>;
|
|
5
|
+
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>>;
|
|
6
|
+
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>>;
|
|
5
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>>;
|
|
6
8
|
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
7
9
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
@@ -14,7 +16,9 @@ export declare const BrandValidationSchema: () => yup.ObjectSchema<import("yup/l
|
|
|
14
16
|
}>>[] | undefined>;
|
|
15
17
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
16
18
|
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
17
|
-
|
|
19
|
+
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>>;
|
|
20
|
+
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>>;
|
|
21
|
+
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>>;
|
|
18
22
|
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>>;
|
|
19
23
|
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
20
24
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
@@ -27,7 +31,9 @@ export declare const BrandValidationSchema: () => yup.ObjectSchema<import("yup/l
|
|
|
27
31
|
}>>[] | undefined>;
|
|
28
32
|
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
29
33
|
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
30
|
-
|
|
34
|
+
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>>;
|
|
35
|
+
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>>;
|
|
36
|
+
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>>;
|
|
31
37
|
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>>;
|
|
32
38
|
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
33
39
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
@@ -83,7 +83,9 @@ export var BrandValidationSchema = function () {
|
|
|
83
83
|
}
|
|
84
84
|
})
|
|
85
85
|
.required('enter_brand_name_english_chars_numbers_space'),
|
|
86
|
-
|
|
86
|
+
segmentLocation: yup.object().required('alert_choose_segment_location'),
|
|
87
|
+
segmentProfit: yup.object().required('alert_choose_segment_profit'),
|
|
88
|
+
segmentTech: yup.object().required('alert_choose_segment_tech'),
|
|
87
89
|
teamSize: yup.object().required('alert_choose_teamSize'),
|
|
88
90
|
salesChannels: yup
|
|
89
91
|
.array()
|
|
@@ -114,15 +114,16 @@ var Occupation = function (props) {
|
|
|
114
114
|
}, [anchorEl, occupationValue]);
|
|
115
115
|
return (_jsx(Collapse, __assign({ in: props.show }, { children: _jsxs(ScreenContainer, __assign({ sx: { pb: 2.5 } }, { children: [_jsx(InputSelect, { required: true, label: t('occupation_title'), value: (isAr ? (_a = occupationValue === null || occupationValue === void 0 ? void 0 : occupationValue.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = occupationValue === null || occupationValue === void 0 ? void 0 : occupationValue.name) === null || _b === void 0 ? void 0 : _b.en) || '', readOnly: props.readOnly, onClick: !!anchorEl ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_any_occupation'), endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: occupation, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (item) {
|
|
116
116
|
var _a;
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
var isSubEmpty = !item.sub || !((_a = item.sub) === null || _a === void 0 ? void 0 : _a.length);
|
|
118
|
+
if (isSubEmpty)
|
|
119
|
+
onSelectItem(item);
|
|
119
120
|
else
|
|
120
121
|
handleOpenSubMenu(item.code);
|
|
121
122
|
}, renderItem: function (item) {
|
|
122
123
|
var _a;
|
|
123
|
-
var
|
|
124
|
-
var showCheck = item.code === (occupationValue === null || occupationValue === void 0 ? void 0 : occupationValue.section_code) &&
|
|
125
|
-
return (_jsxs(ListItemContainer, { children: [_jsxs(ListItem, __assign({ sx: __assign({ bgcolor: 'rgb(196 184 184 / 8%)', borderBottom: '1px solid rgba(227, 232, 238, 0.8)' }, (
|
|
124
|
+
var isSubEmpty = !item.sub || !((_a = item.sub) === null || _a === void 0 ? void 0 : _a.length);
|
|
125
|
+
var showCheck = item.code === (occupationValue === null || occupationValue === void 0 ? void 0 : occupationValue.section_code) && isSubEmpty;
|
|
126
|
+
return (_jsxs(ListItemContainer, { children: [_jsxs(ListItem, __assign({ sx: __assign({ bgcolor: 'rgb(196 184 184 / 8%)', borderBottom: '1px solid rgba(227, 232, 238, 0.8)' }, (isSubEmpty && { bgcolor: 'inherit', borderBottom: 'none' })) }, { children: [_jsx(NameContainer, __assign({ isSelected: item.code === (occupationValue === null || occupationValue === void 0 ? void 0 : occupationValue.section_code), sx: __assign({}, (isSubEmpty && { paddingInlineStart: '5px' })) }, { children: isAr ? item.name.ar : item.name.en })), showCheck ? _jsx(CheckIcon, {}) : !isSubEmpty && _jsx(ExpandIcon, { anchorEl: subIndex === item.code })] })), _jsx(Collapse, __assign({ in: item.code === subIndex && !isSubEmpty }, { children: _jsx(SimpleListStyled, { sx: { pt: 0, pb: 0 }, list: (!isSubEmpty && item.sub) || [], onSelectItem: onSelectItem, listItemProps: { sx: { padding: 0, '&:last-child': { paddingBottom: 0 } } }, renderItem: function (item, idx) {
|
|
126
127
|
return (_jsxs(ListItem, __assign({ sx: { mt: idx === 0 ? 1 : 0 } }, { children: [_jsx(NameContainer, __assign({ isSelected: item.code === (occupationValue === null || occupationValue === void 0 ? void 0 : occupationValue.code) }, { children: isAr ? item.name.ar : item.name.en })), item.code === (occupationValue === null || occupationValue === void 0 ? void 0 : occupationValue.code) && _jsx(CheckIcon, {})] })));
|
|
127
128
|
} }) }))] }));
|
|
128
129
|
} })] }))] })) })));
|
|
@@ -24,5 +24,10 @@ export var InputStyled = styled(Input)(function (_a) {
|
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
export default function InputSelect(props) {
|
|
27
|
-
|
|
27
|
+
var handleFocus = function (event) {
|
|
28
|
+
event.target.blur();
|
|
29
|
+
if (props.onFocus)
|
|
30
|
+
props.onFocus(event);
|
|
31
|
+
};
|
|
32
|
+
return _jsx(InputStyled, __assign({}, props, { inputMode: 'none', onFocus: handleFocus }));
|
|
28
33
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
interface SegmentsProps {
|
|
3
|
-
show: boolean;
|
|
4
|
-
onListOpen?: () => void;
|
|
5
|
-
onListClose?: () => void;
|
|
6
|
-
readOnly?: boolean;
|
|
7
|
-
isVerified?: boolean;
|
|
8
|
-
}
|
|
9
|
-
declare const Segments: ({ show, onListOpen, onListClose, readOnly, isVerified }: SegmentsProps) => JSX.Element;
|
|
10
|
-
export default Segments;
|