kui-crm_actions 0.0.61 → 0.0.63
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/cjs/index.js +58 -140
- package/cjs/index.js.map +1 -1
- package/index.d.ts +144 -200
- package/index.js +59 -139
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { NumberField, requests, uploadImages, uploadFiles, CountryAutocomplete, RegionAutocomplete, CityAutocomplete, RenovationTypeValues, RenovationStyleValues, RoomTypeValues, RoomTypesValues, BooleanValues, ParkingTypesValues, fieldWithConditionSchema, defaultRequiredMessage, CompanyAutocomplete, TaxTypeValues, phoneWithConditionSchema, positiveNumberSchema, getNumbersValues, TVTypesValues, phoneNonRequiredSchema, InputFileWithVisibility, FillingTypeValues, FillingTagsAutocomplete, PreviewContent, Link, UserBadge, useMapCards, MapOverlay } from 'kui-crm';
|
2
|
-
import { addToArrayByCondition, clearNotValidFields, getPhoneNumberFromPhoneParams, resHandler, callPromises } from 'kui-utils';
|
3
1
|
import * as yup from 'yup';
|
2
|
+
import { requests, uploadFiles, CountryAutocomplete, RegionAutocomplete, CityAutocomplete, RenovationTypeValues, RenovationStyleValues, RoomTypeValues, RoomTypesValues, BooleanValues, ParkingTypesValues, fieldWithConditionSchema, defaultRequiredMessage, getApartmentPaymentFields, phoneWithConditionSchema, positiveNumberSchema, getNumbersValues, TVTypesValues, phoneNonRequiredSchema, InputFileWithVisibility, FillingTypeValues, FillingTagsAutocomplete, PreviewContent, Link, UserBadge, useMapCards, MapOverlay } from 'kui-crm';
|
3
|
+
import { clearNotValidFields, getPhoneNumberFromPhoneParams, resHandler, callPromises, addToArrayByCondition } from 'kui-utils';
|
4
4
|
import to from 'await-to-js';
|
5
5
|
import { DateTime } from 'luxon';
|
6
6
|
import { InputWithAddressAutocomplete, DependentInput, CheckboxWithController, InputPhoneWithForm } from 'kui-complex';
|
@@ -101,26 +101,6 @@ function __makeTemplateObject(cooked, raw) {
|
|
101
101
|
return cooked;
|
102
102
|
}
|
103
103
|
|
104
|
-
var valueOptions = {
|
105
|
-
variant: "custom",
|
106
|
-
CustomInput: NumberField,
|
107
|
-
maxIntegerPart: 7,
|
108
|
-
maxDecimalPart: 3,
|
109
|
-
};
|
110
|
-
var getPartialMeterInfoFields = function (resource, type, name, settings) {
|
111
|
-
var prefixName = name ? "".concat(name, ".") : "";
|
112
|
-
if (resource === "electricity") {
|
113
|
-
return __spreadArray(__spreadArray([
|
114
|
-
__assign({ label: "Number", name: "".concat(prefixName, "number") }, settings === null || settings === void 0 ? void 0 : settings.number),
|
115
|
-
__assign(__assign({ label: "T1 value", name: "".concat(prefixName, "T1") }, valueOptions), settings === null || settings === void 0 ? void 0 : settings.t1)
|
116
|
-
], addToArrayByCondition(type !== "T1", __assign(__assign({ label: "T2 value", name: "".concat(prefixName, "T2") }, valueOptions), settings === null || settings === void 0 ? void 0 : settings.t2)), true), addToArrayByCondition(type === "T3", __assign(__assign({ label: "T3 value", name: "".concat(prefixName, "T3") }, valueOptions), settings === null || settings === void 0 ? void 0 : settings.t3)), true);
|
117
|
-
}
|
118
|
-
return [
|
119
|
-
__assign({ label: "Number", name: "".concat(prefixName, "number") }, settings === null || settings === void 0 ? void 0 : settings.number),
|
120
|
-
__assign(__assign({ label: "Value", name: "".concat(prefixName, "value") }, valueOptions), settings === null || settings === void 0 ? void 0 : settings.value),
|
121
|
-
];
|
122
|
-
};
|
123
|
-
|
124
104
|
var getPartialMeterInfoSchema = function (valuesFields) {
|
125
105
|
var filteredFields = valuesFields
|
126
106
|
.filter(function (field) { return field.type === "number"; })
|
@@ -158,7 +138,7 @@ var inspectionsRequestBody = {
|
|
158
138
|
post_index: inspection.zipCode,
|
159
139
|
floor: inspection.floor,
|
160
140
|
floor_count: inspection.floorCount,
|
161
|
-
room_type: inspection.
|
141
|
+
room_type: inspection.typeOfObject,
|
162
142
|
num_entrance: inspection.entrance,
|
163
143
|
has_intercom: inspection.hasIntercom,
|
164
144
|
intercom_code: inspection.intercomCode,
|
@@ -181,27 +161,27 @@ var inspectionsRequestBody = {
|
|
181
161
|
}); }),
|
182
162
|
};
|
183
163
|
},
|
184
|
-
getPostBodyRegularInspection: function (inspection, roomsImages
|
164
|
+
getPostBodyRegularInspection: function (inspection, roomsImages) {
|
185
165
|
return {
|
186
166
|
date: DateTime.now().toISODate(),
|
187
167
|
inspection_type: "regular",
|
188
168
|
based_on: null,
|
189
169
|
dropbox_link: inspection.dropboxLink,
|
190
170
|
photo_groups: roomsImages,
|
191
|
-
regular: this.getPartialInspectionMeters(inspection.meters
|
171
|
+
regular: this.getPartialInspectionMeters(inspection.meters),
|
192
172
|
};
|
193
173
|
},
|
194
|
-
getPostBodyTransferInspection: function (inspection, roomsImages
|
174
|
+
getPostBodyTransferInspection: function (inspection, roomsImages) {
|
195
175
|
return {
|
196
176
|
date: DateTime.now().toISODate(),
|
197
177
|
inspection_type: "transfer",
|
198
178
|
based_on: null,
|
199
179
|
dropbox_link: inspection.dropboxLink,
|
200
180
|
photo_groups: roomsImages,
|
201
|
-
transfer: __assign({ transfer_type: inspection.transferType }, this.getPartialInspectionMeters(inspection.meters
|
181
|
+
transfer: __assign({ transfer_type: inspection.transferType }, this.getPartialInspectionMeters(inspection.meters)),
|
202
182
|
};
|
203
183
|
},
|
204
|
-
getPartialInspectionMeters: function (meters
|
184
|
+
getPartialInspectionMeters: function (meters) {
|
205
185
|
var _this = this;
|
206
186
|
return {
|
207
187
|
meters: meters.map(function (meter, index) { return ({
|
@@ -209,12 +189,13 @@ var inspectionsRequestBody = {
|
|
209
189
|
resource_type: meter.resource,
|
210
190
|
meter_type: meter.type,
|
211
191
|
passport_number: meter.number,
|
212
|
-
photos:
|
192
|
+
photos: _this.getFilesParams(meter.images),
|
213
193
|
values: clearNotValidFields(_this.getInspectionMeterValues(meter)),
|
214
194
|
}); }),
|
215
195
|
};
|
216
196
|
},
|
217
|
-
getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles
|
197
|
+
getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles) {
|
198
|
+
var _this = this;
|
218
199
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
219
200
|
return {
|
220
201
|
date: DateTime.now().toISODate(),
|
@@ -239,16 +220,16 @@ var inspectionsRequestBody = {
|
|
239
220
|
description: filling.name,
|
240
221
|
serial_code: filling.serialNumber,
|
241
222
|
amount: filling.numberOfSubjects,
|
242
|
-
photos:
|
223
|
+
photos: _this.getFilesParams(filling.images),
|
243
224
|
instruction: fillingFiles[index],
|
244
225
|
});
|
245
|
-
}) }, this.getInventoryInspectionMeters(inspection.meters, metersFiles
|
226
|
+
}) }, this.getInventoryInspectionMeters(inspection.meters, metersFiles)),
|
246
227
|
};
|
247
228
|
},
|
248
|
-
getInventoryInspectionMeters: function (meters, metersFiles
|
229
|
+
getInventoryInspectionMeters: function (meters, metersFiles) {
|
249
230
|
var _this = this;
|
250
231
|
return {
|
251
|
-
meters: (meters === null || meters === void 0 ? void 0 : meters.map(function (meter, index) { return (__assign(__assign({}, _this.getMeterCommonFields(meter)), { passport: metersFiles[index], values: clearNotValidFields(_this.getInspectionMeterValues(meter, "initialValue")), photos:
|
232
|
+
meters: (meters === null || meters === void 0 ? void 0 : meters.map(function (meter, index) { return (__assign(__assign({}, _this.getMeterCommonFields(meter)), { passport: metersFiles[index], values: clearNotValidFields(_this.getInspectionMeterValues(meter, "initialValue")), photos: _this.getFilesParams(meter.images), no_tariff: meter.noTariff, auto_sending: meter.withAutoSending })); })) || [],
|
252
233
|
};
|
253
234
|
},
|
254
235
|
getInspectionMeterValues: function (meter, fieldName) {
|
@@ -291,6 +272,11 @@ var inspectionsRequestBody = {
|
|
291
272
|
last_value: lastValue,
|
292
273
|
});
|
293
274
|
},
|
275
|
+
getFilesParams: function (files) {
|
276
|
+
return files
|
277
|
+
.map(function (file) { return file.uploadedData; })
|
278
|
+
.filter(function (data) { return data; });
|
279
|
+
},
|
294
280
|
};
|
295
281
|
|
296
282
|
var inspectionsRequests = {
|
@@ -309,138 +295,79 @@ var inspectionsRequests = {
|
|
309
295
|
});
|
310
296
|
});
|
311
297
|
},
|
312
|
-
loadInspectionImages: function (loader, roomsImages) {
|
313
|
-
var _a;
|
314
|
-
return __awaiter(this, void 0, void 0, function () {
|
315
|
-
var promises, images, bedroomCount, roomIndex, bedroomIndex;
|
316
|
-
var _this = this;
|
317
|
-
return __generator(this, function (_b) {
|
318
|
-
switch (_b.label) {
|
319
|
-
case 0:
|
320
|
-
promises = [];
|
321
|
-
roomsImages.forEach(function (room) {
|
322
|
-
promises.push(uploadImages(loader, room.files));
|
323
|
-
});
|
324
|
-
return [4 /*yield*/, callPromises(promises)];
|
325
|
-
case 1:
|
326
|
-
images = _b.sent();
|
327
|
-
bedroomCount = (_a = roomsImages.filter(function (imagesGroup) { return imagesGroup.type === "bedroom"; })) === null || _a === void 0 ? void 0 : _a.length;
|
328
|
-
roomIndex = bedroomCount || 0;
|
329
|
-
bedroomIndex = 0;
|
330
|
-
return [2 /*return*/, roomsImages.map(function (room, index) {
|
331
|
-
if (room.type === "room") {
|
332
|
-
return __assign(__assign({}, _this.getRoomParams(room, images[index])), {
|
333
|
-
// eslint-disable-next-line no-plusplus
|
334
|
-
room_order_number: roomIndex++ });
|
335
|
-
}
|
336
|
-
if (room.type === "bedroom") {
|
337
|
-
return __assign(__assign({}, _this.getRoomParams(room, images[index])), {
|
338
|
-
// eslint-disable-next-line no-plusplus
|
339
|
-
room_order_number: bedroomIndex++ });
|
340
|
-
}
|
341
|
-
return _this.getRoomParams(room, images[index]);
|
342
|
-
})];
|
343
|
-
}
|
344
|
-
});
|
345
|
-
});
|
346
|
-
},
|
347
298
|
createInitialInspection: function (data, apartmentId, loader) {
|
348
299
|
return __awaiter(this, void 0, void 0, function () {
|
349
300
|
var roomsImages, body;
|
350
301
|
return __generator(this, function (_a) {
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
case 1:
|
357
|
-
roomsImages = _a.sent();
|
358
|
-
body = inspectionsRequestBody.getPostBodyInitialInspection(data, roomsImages);
|
359
|
-
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
360
|
-
case 2: return [2 /*return*/, null];
|
302
|
+
if (apartmentId) {
|
303
|
+
loader.startLoading("inspection creation");
|
304
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
305
|
+
body = inspectionsRequestBody.getPostBodyInitialInspection(data, roomsImages);
|
306
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
361
307
|
}
|
308
|
+
return [2 /*return*/, null];
|
362
309
|
});
|
363
310
|
});
|
364
311
|
},
|
365
312
|
createRegularInspection: function (data, apartmentId, loader) {
|
366
|
-
var _a;
|
367
313
|
return __awaiter(this, void 0, void 0, function () {
|
368
|
-
var
|
369
|
-
return __generator(this, function (
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
return [4 /*yield*/, callPromises(__spreadArray([
|
376
|
-
this.loadInspectionImages(loader, data.roomsImages)
|
377
|
-
], metersImages, true))];
|
378
|
-
case 1:
|
379
|
-
files = _b.sent();
|
380
|
-
body = inspectionsRequestBody.getPostBodyRegularInspection(data, files[0], files.slice(1));
|
381
|
-
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
382
|
-
case 2: return [2 /*return*/, null];
|
314
|
+
var roomsImages, body;
|
315
|
+
return __generator(this, function (_a) {
|
316
|
+
if (apartmentId) {
|
317
|
+
loader.startLoading("inspection creation");
|
318
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
319
|
+
body = inspectionsRequestBody.getPostBodyRegularInspection(data, roomsImages);
|
320
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
383
321
|
}
|
322
|
+
return [2 /*return*/, null];
|
384
323
|
});
|
385
324
|
});
|
386
325
|
},
|
387
326
|
createTransferInspection: function (data, apartmentId, loader) {
|
388
|
-
var _a;
|
389
327
|
return __awaiter(this, void 0, void 0, function () {
|
390
|
-
var
|
391
|
-
return __generator(this, function (
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
return [4 /*yield*/, callPromises(__spreadArray([
|
398
|
-
this.loadInspectionImages(loader, data.roomsImages)
|
399
|
-
], metersImages, true))];
|
400
|
-
case 1:
|
401
|
-
files = _b.sent();
|
402
|
-
body = inspectionsRequestBody.getPostBodyTransferInspection(data, files[0], files.slice(1));
|
403
|
-
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
404
|
-
case 2: return [2 /*return*/, null];
|
328
|
+
var roomsImages, body;
|
329
|
+
return __generator(this, function (_a) {
|
330
|
+
if (apartmentId) {
|
331
|
+
loader.startLoading("inspection creation");
|
332
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
333
|
+
body = inspectionsRequestBody.getPostBodyTransferInspection(data, roomsImages);
|
334
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
405
335
|
}
|
336
|
+
return [2 /*return*/, null];
|
406
337
|
});
|
407
338
|
});
|
408
339
|
},
|
409
340
|
createInventoryInspection: function (data, apartmentId, loader) {
|
410
|
-
var _a
|
341
|
+
var _a;
|
411
342
|
return __awaiter(this, void 0, void 0, function () {
|
412
|
-
var fillingFiles, metersFiles,
|
413
|
-
return __generator(this, function (
|
414
|
-
switch (
|
343
|
+
var fillingFiles, metersFiles, files, roomsImages, body;
|
344
|
+
return __generator(this, function (_b) {
|
345
|
+
switch (_b.label) {
|
415
346
|
case 0:
|
416
347
|
if (!apartmentId) return [3 /*break*/, 2];
|
417
348
|
loader.startLoading("inspection creation");
|
418
349
|
fillingFiles = data.fillingList.map(function (filling) { return filling.instruction; });
|
419
350
|
metersFiles = ((_a = data.meters) === null || _a === void 0 ? void 0 : _a.map(function (meter) { return meter.passportFile; })) || [];
|
420
|
-
|
421
|
-
fillingImages = data.fillingList.map(function (filling) {
|
422
|
-
return uploadImages(loader, filling.images);
|
423
|
-
});
|
424
|
-
return [4 /*yield*/, callPromises(__spreadArray(__spreadArray([
|
425
|
-
this.loadInspectionImages(loader, data.roomsImages),
|
351
|
+
return [4 /*yield*/, callPromises([
|
426
352
|
uploadFiles(loader, fillingFiles),
|
427
|
-
uploadFiles(loader, metersFiles)
|
428
|
-
]
|
353
|
+
uploadFiles(loader, metersFiles),
|
354
|
+
])];
|
429
355
|
case 1:
|
430
|
-
files =
|
431
|
-
|
356
|
+
files = _b.sent();
|
357
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
358
|
+
body = inspectionsRequestBody.getPostBodyInventoryInspection(data, roomsImages, files[0], files[1]);
|
432
359
|
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
433
360
|
case 2: return [2 /*return*/, null];
|
434
361
|
}
|
435
362
|
});
|
436
363
|
});
|
437
364
|
},
|
438
|
-
getRoomParams: function (
|
439
|
-
return {
|
365
|
+
getRoomParams: function (rooms) {
|
366
|
+
return rooms.map(function (room) { return ({
|
440
367
|
purpose: room.type,
|
441
368
|
comment: room.comment,
|
442
|
-
photos:
|
443
|
-
};
|
369
|
+
photos: inspectionsRequestBody.getFilesParams(room.files),
|
370
|
+
}); });
|
444
371
|
},
|
445
372
|
};
|
446
373
|
|
@@ -558,7 +485,7 @@ var RoomsApartmentInfoFieldsSchema = {
|
|
558
485
|
var RoomsApartmentInfoStepSchema = yup.object(RoomsApartmentInfoFieldsSchema);
|
559
486
|
|
560
487
|
var getSecurityApartmentInfoFields = function (settings) { return [
|
561
|
-
__assign({ label: "Object type", name: "
|
488
|
+
__assign({ label: "Object type", name: "typeOfObject", variant: "select", options: RoomTypesValues }, settings === null || settings === void 0 ? void 0 : settings.typeOfObject),
|
562
489
|
__assign({ label: "Entrance", name: "entrance" }, settings === null || settings === void 0 ? void 0 : settings.entrance),
|
563
490
|
__assign({ name: "hasIntercom", label: "Intercom", variant: "select", options: BooleanValues }, settings === null || settings === void 0 ? void 0 : settings.hasIntercom),
|
564
491
|
__assign({ name: "intercomCode", label: "Intercom code", variant: "custom", CustomInput: DependentInput, dependentInputName: "hasIntercom" }, settings === null || settings === void 0 ? void 0 : settings.intercomCode),
|
@@ -569,7 +496,7 @@ var getSecurityApartmentInfoFields = function (settings) { return [
|
|
569
496
|
]; };
|
570
497
|
|
571
498
|
var SecurityApartmentInfoFieldsSchema = {
|
572
|
-
|
499
|
+
typeOfObject: yup.string().required("This field is required"),
|
573
500
|
entrance: yup.string().required("This field is required"),
|
574
501
|
hasIntercom: yup.string().required("This field is required"),
|
575
502
|
intercomCode: fieldWithConditionSchema("hasIntercom"),
|
@@ -589,13 +516,6 @@ var SecurityApartmentInfoStepSchema = yup.object(SecurityApartmentInfoFieldsSche
|
|
589
516
|
var checkboxLabelProps = {
|
590
517
|
size: "s",
|
591
518
|
};
|
592
|
-
var getApartmentPaymentFields = function (settings) { return [
|
593
|
-
__assign({ name: "payerCode", label: "Payer code" }, settings === null || settings === void 0 ? void 0 : settings.payerCode),
|
594
|
-
__assign({ name: "communalServicesAccount", label: "Operational account number" }, settings === null || settings === void 0 ? void 0 : settings.communalServicesAccount),
|
595
|
-
__assign({ name: "company", label: "Administrative company", variant: "custom", CustomInput: CompanyAutocomplete }, settings === null || settings === void 0 ? void 0 : settings.company),
|
596
|
-
__assign({ name: "countryOfResidence", label: "Country of Residence", variant: "custom", CustomInput: CountryAutocomplete }, settings === null || settings === void 0 ? void 0 : settings.countryOfResidence),
|
597
|
-
__assign({ label: "Tax type", name: "taxesType", variant: "select", options: TaxTypeValues }, settings === null || settings === void 0 ? void 0 : settings.taxesType),
|
598
|
-
]; };
|
599
519
|
var getAdditionalInfoStepFields = function (settings) { return __spreadArray([
|
600
520
|
__assign({ label: "Pets", name: "withPets", variant: "custom", CustomInput: CheckboxWithController, labelProps: checkboxLabelProps }, settings === null || settings === void 0 ? void 0 : settings.withPets),
|
601
521
|
__assign({ label: "Children", name: "withChildren", variant: "custom", CustomInput: CheckboxWithController, labelProps: checkboxLabelProps }, settings === null || settings === void 0 ? void 0 : settings.withChildren),
|
@@ -788,5 +708,5 @@ var ApartmentInspectionOverlay = function (props) {
|
|
788
708
|
var StyledWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
|
789
709
|
var templateObject_1;
|
790
710
|
|
791
|
-
export { AdditionalInfoFieldsSchema, AdditionalInfoStepSchema, ApartmentInspectionOverlay, BasicApartmentInfoFieldsSchema, BasicApartmentInfoStepSchema, DetailApartmentInfoFieldsSchema, DetailApartmentInfoStepSchema, FillingInfoFieldsSchema, HouseServicesInfoFieldsSchema, HouseServicesInfoStepSchema, MetersInfoFieldsSchema, MetersInfoStepSchema, RoomsApartmentInfoFieldsSchema, RoomsApartmentInfoStepSchema, SecurityApartmentInfoFieldsSchema, SecurityApartmentInfoStepSchema, TelecommunicationsInfoFieldsSchema, TelecommunicationsInfoStepSchema, getAdditionalInfoStepFields,
|
711
|
+
export { AdditionalInfoFieldsSchema, AdditionalInfoStepSchema, ApartmentInspectionOverlay, BasicApartmentInfoFieldsSchema, BasicApartmentInfoStepSchema, DetailApartmentInfoFieldsSchema, DetailApartmentInfoStepSchema, FillingInfoFieldsSchema, HouseServicesInfoFieldsSchema, HouseServicesInfoStepSchema, MetersInfoFieldsSchema, MetersInfoStepSchema, RoomsApartmentInfoFieldsSchema, RoomsApartmentInfoStepSchema, SecurityApartmentInfoFieldsSchema, SecurityApartmentInfoStepSchema, TelecommunicationsInfoFieldsSchema, TelecommunicationsInfoStepSchema, getAdditionalInfoStepFields, getBasicApartmentInfoFields, getDetailApartmentInfoFields, getFillingInfoFields, getHouseServicesInfoStep, getMetersInfoStepFields, getPartialMeterInfoSchema, getRoomsApartmentInfoFields, getRoomsImagesSteps, getSecurityApartmentInfoFields, getTelecommunicationsInfoStepFields, inspectionsRequestBody, inspectionsRequests, renderMetersSteps, useMetersValues };
|
792
712
|
//# sourceMappingURL=index.js.map
|