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/cjs/index.js
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
+
var yup = require('yup');
|
5
6
|
var kuiCrm = require('kui-crm');
|
6
7
|
var kuiUtils = require('kui-utils');
|
7
|
-
var yup = require('yup');
|
8
8
|
var to = require('await-to-js');
|
9
9
|
var luxon = require('luxon');
|
10
10
|
var kuiComplex = require('kui-complex');
|
@@ -129,26 +129,6 @@ function __makeTemplateObject(cooked, raw) {
|
|
129
129
|
return cooked;
|
130
130
|
}
|
131
131
|
|
132
|
-
var valueOptions = {
|
133
|
-
variant: "custom",
|
134
|
-
CustomInput: kuiCrm.NumberField,
|
135
|
-
maxIntegerPart: 7,
|
136
|
-
maxDecimalPart: 3,
|
137
|
-
};
|
138
|
-
var getPartialMeterInfoFields = function (resource, type, name, settings) {
|
139
|
-
var prefixName = name ? "".concat(name, ".") : "";
|
140
|
-
if (resource === "electricity") {
|
141
|
-
return __spreadArray(__spreadArray([
|
142
|
-
__assign({ label: "Number", name: "".concat(prefixName, "number") }, settings === null || settings === void 0 ? void 0 : settings.number),
|
143
|
-
__assign(__assign({ label: "T1 value", name: "".concat(prefixName, "T1") }, valueOptions), settings === null || settings === void 0 ? void 0 : settings.t1)
|
144
|
-
], kuiUtils.addToArrayByCondition(type !== "T1", __assign(__assign({ label: "T2 value", name: "".concat(prefixName, "T2") }, valueOptions), settings === null || settings === void 0 ? void 0 : settings.t2)), true), kuiUtils.addToArrayByCondition(type === "T3", __assign(__assign({ label: "T3 value", name: "".concat(prefixName, "T3") }, valueOptions), settings === null || settings === void 0 ? void 0 : settings.t3)), true);
|
145
|
-
}
|
146
|
-
return [
|
147
|
-
__assign({ label: "Number", name: "".concat(prefixName, "number") }, settings === null || settings === void 0 ? void 0 : settings.number),
|
148
|
-
__assign(__assign({ label: "Value", name: "".concat(prefixName, "value") }, valueOptions), settings === null || settings === void 0 ? void 0 : settings.value),
|
149
|
-
];
|
150
|
-
};
|
151
|
-
|
152
132
|
var getPartialMeterInfoSchema = function (valuesFields) {
|
153
133
|
var filteredFields = valuesFields
|
154
134
|
.filter(function (field) { return field.type === "number"; })
|
@@ -186,7 +166,7 @@ var inspectionsRequestBody = {
|
|
186
166
|
post_index: inspection.zipCode,
|
187
167
|
floor: inspection.floor,
|
188
168
|
floor_count: inspection.floorCount,
|
189
|
-
room_type: inspection.
|
169
|
+
room_type: inspection.typeOfObject,
|
190
170
|
num_entrance: inspection.entrance,
|
191
171
|
has_intercom: inspection.hasIntercom,
|
192
172
|
intercom_code: inspection.intercomCode,
|
@@ -209,27 +189,27 @@ var inspectionsRequestBody = {
|
|
209
189
|
}); }),
|
210
190
|
};
|
211
191
|
},
|
212
|
-
getPostBodyRegularInspection: function (inspection, roomsImages
|
192
|
+
getPostBodyRegularInspection: function (inspection, roomsImages) {
|
213
193
|
return {
|
214
194
|
date: luxon.DateTime.now().toISODate(),
|
215
195
|
inspection_type: "regular",
|
216
196
|
based_on: null,
|
217
197
|
dropbox_link: inspection.dropboxLink,
|
218
198
|
photo_groups: roomsImages,
|
219
|
-
regular: this.getPartialInspectionMeters(inspection.meters
|
199
|
+
regular: this.getPartialInspectionMeters(inspection.meters),
|
220
200
|
};
|
221
201
|
},
|
222
|
-
getPostBodyTransferInspection: function (inspection, roomsImages
|
202
|
+
getPostBodyTransferInspection: function (inspection, roomsImages) {
|
223
203
|
return {
|
224
204
|
date: luxon.DateTime.now().toISODate(),
|
225
205
|
inspection_type: "transfer",
|
226
206
|
based_on: null,
|
227
207
|
dropbox_link: inspection.dropboxLink,
|
228
208
|
photo_groups: roomsImages,
|
229
|
-
transfer: __assign({ transfer_type: inspection.transferType }, this.getPartialInspectionMeters(inspection.meters
|
209
|
+
transfer: __assign({ transfer_type: inspection.transferType }, this.getPartialInspectionMeters(inspection.meters)),
|
230
210
|
};
|
231
211
|
},
|
232
|
-
getPartialInspectionMeters: function (meters
|
212
|
+
getPartialInspectionMeters: function (meters) {
|
233
213
|
var _this = this;
|
234
214
|
return {
|
235
215
|
meters: meters.map(function (meter, index) { return ({
|
@@ -237,12 +217,13 @@ var inspectionsRequestBody = {
|
|
237
217
|
resource_type: meter.resource,
|
238
218
|
meter_type: meter.type,
|
239
219
|
passport_number: meter.number,
|
240
|
-
photos:
|
220
|
+
photos: _this.getFilesParams(meter.images),
|
241
221
|
values: kuiUtils.clearNotValidFields(_this.getInspectionMeterValues(meter)),
|
242
222
|
}); }),
|
243
223
|
};
|
244
224
|
},
|
245
|
-
getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles
|
225
|
+
getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles) {
|
226
|
+
var _this = this;
|
246
227
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
247
228
|
return {
|
248
229
|
date: luxon.DateTime.now().toISODate(),
|
@@ -267,16 +248,16 @@ var inspectionsRequestBody = {
|
|
267
248
|
description: filling.name,
|
268
249
|
serial_code: filling.serialNumber,
|
269
250
|
amount: filling.numberOfSubjects,
|
270
|
-
photos:
|
251
|
+
photos: _this.getFilesParams(filling.images),
|
271
252
|
instruction: fillingFiles[index],
|
272
253
|
});
|
273
|
-
}) }, this.getInventoryInspectionMeters(inspection.meters, metersFiles
|
254
|
+
}) }, this.getInventoryInspectionMeters(inspection.meters, metersFiles)),
|
274
255
|
};
|
275
256
|
},
|
276
|
-
getInventoryInspectionMeters: function (meters, metersFiles
|
257
|
+
getInventoryInspectionMeters: function (meters, metersFiles) {
|
277
258
|
var _this = this;
|
278
259
|
return {
|
279
|
-
meters: (meters === null || meters === void 0 ? void 0 : meters.map(function (meter, index) { return (__assign(__assign({}, _this.getMeterCommonFields(meter)), { passport: metersFiles[index], values: kuiUtils.clearNotValidFields(_this.getInspectionMeterValues(meter, "initialValue")), photos:
|
260
|
+
meters: (meters === null || meters === void 0 ? void 0 : meters.map(function (meter, index) { return (__assign(__assign({}, _this.getMeterCommonFields(meter)), { passport: metersFiles[index], values: kuiUtils.clearNotValidFields(_this.getInspectionMeterValues(meter, "initialValue")), photos: _this.getFilesParams(meter.images), no_tariff: meter.noTariff, auto_sending: meter.withAutoSending })); })) || [],
|
280
261
|
};
|
281
262
|
},
|
282
263
|
getInspectionMeterValues: function (meter, fieldName) {
|
@@ -319,6 +300,11 @@ var inspectionsRequestBody = {
|
|
319
300
|
last_value: lastValue,
|
320
301
|
});
|
321
302
|
},
|
303
|
+
getFilesParams: function (files) {
|
304
|
+
return files
|
305
|
+
.map(function (file) { return file.uploadedData; })
|
306
|
+
.filter(function (data) { return data; });
|
307
|
+
},
|
322
308
|
};
|
323
309
|
|
324
310
|
var inspectionsRequests = {
|
@@ -337,138 +323,79 @@ var inspectionsRequests = {
|
|
337
323
|
});
|
338
324
|
});
|
339
325
|
},
|
340
|
-
loadInspectionImages: function (loader, roomsImages) {
|
341
|
-
var _a;
|
342
|
-
return __awaiter(this, void 0, void 0, function () {
|
343
|
-
var promises, images, bedroomCount, roomIndex, bedroomIndex;
|
344
|
-
var _this = this;
|
345
|
-
return __generator(this, function (_b) {
|
346
|
-
switch (_b.label) {
|
347
|
-
case 0:
|
348
|
-
promises = [];
|
349
|
-
roomsImages.forEach(function (room) {
|
350
|
-
promises.push(kuiCrm.uploadImages(loader, room.files));
|
351
|
-
});
|
352
|
-
return [4 /*yield*/, kuiUtils.callPromises(promises)];
|
353
|
-
case 1:
|
354
|
-
images = _b.sent();
|
355
|
-
bedroomCount = (_a = roomsImages.filter(function (imagesGroup) { return imagesGroup.type === "bedroom"; })) === null || _a === void 0 ? void 0 : _a.length;
|
356
|
-
roomIndex = bedroomCount || 0;
|
357
|
-
bedroomIndex = 0;
|
358
|
-
return [2 /*return*/, roomsImages.map(function (room, index) {
|
359
|
-
if (room.type === "room") {
|
360
|
-
return __assign(__assign({}, _this.getRoomParams(room, images[index])), {
|
361
|
-
// eslint-disable-next-line no-plusplus
|
362
|
-
room_order_number: roomIndex++ });
|
363
|
-
}
|
364
|
-
if (room.type === "bedroom") {
|
365
|
-
return __assign(__assign({}, _this.getRoomParams(room, images[index])), {
|
366
|
-
// eslint-disable-next-line no-plusplus
|
367
|
-
room_order_number: bedroomIndex++ });
|
368
|
-
}
|
369
|
-
return _this.getRoomParams(room, images[index]);
|
370
|
-
})];
|
371
|
-
}
|
372
|
-
});
|
373
|
-
});
|
374
|
-
},
|
375
326
|
createInitialInspection: function (data, apartmentId, loader) {
|
376
327
|
return __awaiter(this, void 0, void 0, function () {
|
377
328
|
var roomsImages, body;
|
378
329
|
return __generator(this, function (_a) {
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
case 1:
|
385
|
-
roomsImages = _a.sent();
|
386
|
-
body = inspectionsRequestBody.getPostBodyInitialInspection(data, roomsImages);
|
387
|
-
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
388
|
-
case 2: return [2 /*return*/, null];
|
330
|
+
if (apartmentId) {
|
331
|
+
loader.startLoading("inspection creation");
|
332
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
333
|
+
body = inspectionsRequestBody.getPostBodyInitialInspection(data, roomsImages);
|
334
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
389
335
|
}
|
336
|
+
return [2 /*return*/, null];
|
390
337
|
});
|
391
338
|
});
|
392
339
|
},
|
393
340
|
createRegularInspection: function (data, apartmentId, loader) {
|
394
|
-
var _a;
|
395
341
|
return __awaiter(this, void 0, void 0, function () {
|
396
|
-
var
|
397
|
-
return __generator(this, function (
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
return [4 /*yield*/, kuiUtils.callPromises(__spreadArray([
|
404
|
-
this.loadInspectionImages(loader, data.roomsImages)
|
405
|
-
], metersImages, true))];
|
406
|
-
case 1:
|
407
|
-
files = _b.sent();
|
408
|
-
body = inspectionsRequestBody.getPostBodyRegularInspection(data, files[0], files.slice(1));
|
409
|
-
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
410
|
-
case 2: return [2 /*return*/, null];
|
342
|
+
var roomsImages, body;
|
343
|
+
return __generator(this, function (_a) {
|
344
|
+
if (apartmentId) {
|
345
|
+
loader.startLoading("inspection creation");
|
346
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
347
|
+
body = inspectionsRequestBody.getPostBodyRegularInspection(data, roomsImages);
|
348
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
411
349
|
}
|
350
|
+
return [2 /*return*/, null];
|
412
351
|
});
|
413
352
|
});
|
414
353
|
},
|
415
354
|
createTransferInspection: function (data, apartmentId, loader) {
|
416
|
-
var _a;
|
417
355
|
return __awaiter(this, void 0, void 0, function () {
|
418
|
-
var
|
419
|
-
return __generator(this, function (
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
return [4 /*yield*/, kuiUtils.callPromises(__spreadArray([
|
426
|
-
this.loadInspectionImages(loader, data.roomsImages)
|
427
|
-
], metersImages, true))];
|
428
|
-
case 1:
|
429
|
-
files = _b.sent();
|
430
|
-
body = inspectionsRequestBody.getPostBodyTransferInspection(data, files[0], files.slice(1));
|
431
|
-
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
432
|
-
case 2: return [2 /*return*/, null];
|
356
|
+
var roomsImages, body;
|
357
|
+
return __generator(this, function (_a) {
|
358
|
+
if (apartmentId) {
|
359
|
+
loader.startLoading("inspection creation");
|
360
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
361
|
+
body = inspectionsRequestBody.getPostBodyTransferInspection(data, roomsImages);
|
362
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
433
363
|
}
|
364
|
+
return [2 /*return*/, null];
|
434
365
|
});
|
435
366
|
});
|
436
367
|
},
|
437
368
|
createInventoryInspection: function (data, apartmentId, loader) {
|
438
|
-
var _a
|
369
|
+
var _a;
|
439
370
|
return __awaiter(this, void 0, void 0, function () {
|
440
|
-
var fillingFiles, metersFiles,
|
441
|
-
return __generator(this, function (
|
442
|
-
switch (
|
371
|
+
var fillingFiles, metersFiles, files, roomsImages, body;
|
372
|
+
return __generator(this, function (_b) {
|
373
|
+
switch (_b.label) {
|
443
374
|
case 0:
|
444
375
|
if (!apartmentId) return [3 /*break*/, 2];
|
445
376
|
loader.startLoading("inspection creation");
|
446
377
|
fillingFiles = data.fillingList.map(function (filling) { return filling.instruction; });
|
447
378
|
metersFiles = ((_a = data.meters) === null || _a === void 0 ? void 0 : _a.map(function (meter) { return meter.passportFile; })) || [];
|
448
|
-
|
449
|
-
fillingImages = data.fillingList.map(function (filling) {
|
450
|
-
return kuiCrm.uploadImages(loader, filling.images);
|
451
|
-
});
|
452
|
-
return [4 /*yield*/, kuiUtils.callPromises(__spreadArray(__spreadArray([
|
453
|
-
this.loadInspectionImages(loader, data.roomsImages),
|
379
|
+
return [4 /*yield*/, kuiUtils.callPromises([
|
454
380
|
kuiCrm.uploadFiles(loader, fillingFiles),
|
455
|
-
kuiCrm.uploadFiles(loader, metersFiles)
|
456
|
-
]
|
381
|
+
kuiCrm.uploadFiles(loader, metersFiles),
|
382
|
+
])];
|
457
383
|
case 1:
|
458
|
-
files =
|
459
|
-
|
384
|
+
files = _b.sent();
|
385
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
386
|
+
body = inspectionsRequestBody.getPostBodyInventoryInspection(data, roomsImages, files[0], files[1]);
|
460
387
|
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
461
388
|
case 2: return [2 /*return*/, null];
|
462
389
|
}
|
463
390
|
});
|
464
391
|
});
|
465
392
|
},
|
466
|
-
getRoomParams: function (
|
467
|
-
return {
|
393
|
+
getRoomParams: function (rooms) {
|
394
|
+
return rooms.map(function (room) { return ({
|
468
395
|
purpose: room.type,
|
469
396
|
comment: room.comment,
|
470
|
-
photos:
|
471
|
-
};
|
397
|
+
photos: inspectionsRequestBody.getFilesParams(room.files),
|
398
|
+
}); });
|
472
399
|
},
|
473
400
|
};
|
474
401
|
|
@@ -586,7 +513,7 @@ var RoomsApartmentInfoFieldsSchema = {
|
|
586
513
|
var RoomsApartmentInfoStepSchema = yup__namespace.object(RoomsApartmentInfoFieldsSchema);
|
587
514
|
|
588
515
|
var getSecurityApartmentInfoFields = function (settings) { return [
|
589
|
-
__assign({ label: "Object type", name: "
|
516
|
+
__assign({ label: "Object type", name: "typeOfObject", variant: "select", options: kuiCrm.RoomTypesValues }, settings === null || settings === void 0 ? void 0 : settings.typeOfObject),
|
590
517
|
__assign({ label: "Entrance", name: "entrance" }, settings === null || settings === void 0 ? void 0 : settings.entrance),
|
591
518
|
__assign({ name: "hasIntercom", label: "Intercom", variant: "select", options: kuiCrm.BooleanValues }, settings === null || settings === void 0 ? void 0 : settings.hasIntercom),
|
592
519
|
__assign({ name: "intercomCode", label: "Intercom code", variant: "custom", CustomInput: kuiComplex.DependentInput, dependentInputName: "hasIntercom" }, settings === null || settings === void 0 ? void 0 : settings.intercomCode),
|
@@ -597,7 +524,7 @@ var getSecurityApartmentInfoFields = function (settings) { return [
|
|
597
524
|
]; };
|
598
525
|
|
599
526
|
var SecurityApartmentInfoFieldsSchema = {
|
600
|
-
|
527
|
+
typeOfObject: yup__namespace.string().required("This field is required"),
|
601
528
|
entrance: yup__namespace.string().required("This field is required"),
|
602
529
|
hasIntercom: yup__namespace.string().required("This field is required"),
|
603
530
|
intercomCode: kuiCrm.fieldWithConditionSchema("hasIntercom"),
|
@@ -617,18 +544,11 @@ var SecurityApartmentInfoStepSchema = yup__namespace.object(SecurityApartmentInf
|
|
617
544
|
var checkboxLabelProps = {
|
618
545
|
size: "s",
|
619
546
|
};
|
620
|
-
var getApartmentPaymentFields = function (settings) { return [
|
621
|
-
__assign({ name: "payerCode", label: "Payer code" }, settings === null || settings === void 0 ? void 0 : settings.payerCode),
|
622
|
-
__assign({ name: "communalServicesAccount", label: "Operational account number" }, settings === null || settings === void 0 ? void 0 : settings.communalServicesAccount),
|
623
|
-
__assign({ name: "company", label: "Administrative company", variant: "custom", CustomInput: kuiCrm.CompanyAutocomplete }, settings === null || settings === void 0 ? void 0 : settings.company),
|
624
|
-
__assign({ name: "countryOfResidence", label: "Country of Residence", variant: "custom", CustomInput: kuiCrm.CountryAutocomplete }, settings === null || settings === void 0 ? void 0 : settings.countryOfResidence),
|
625
|
-
__assign({ label: "Tax type", name: "taxesType", variant: "select", options: kuiCrm.TaxTypeValues }, settings === null || settings === void 0 ? void 0 : settings.taxesType),
|
626
|
-
]; };
|
627
547
|
var getAdditionalInfoStepFields = function (settings) { return __spreadArray([
|
628
548
|
__assign({ label: "Pets", name: "withPets", variant: "custom", CustomInput: kuiComplex.CheckboxWithController, labelProps: checkboxLabelProps }, settings === null || settings === void 0 ? void 0 : settings.withPets),
|
629
549
|
__assign({ label: "Children", name: "withChildren", variant: "custom", CustomInput: kuiComplex.CheckboxWithController, labelProps: checkboxLabelProps }, settings === null || settings === void 0 ? void 0 : settings.withChildren),
|
630
550
|
__assign({ isTextArea: true, placeholder: "other terms", name: "additionalTerms" }, settings === null || settings === void 0 ? void 0 : settings.additionalTerms)
|
631
|
-
], getApartmentPaymentFields(settings), true); };
|
551
|
+
], kuiCrm.getApartmentPaymentFields(settings), true); };
|
632
552
|
|
633
553
|
var AdditionalInfoFieldsSchema = {
|
634
554
|
taxesType: yup__namespace.string().required(kuiCrm.defaultRequiredMessage),
|
@@ -835,13 +755,11 @@ exports.SecurityApartmentInfoStepSchema = SecurityApartmentInfoStepSchema;
|
|
835
755
|
exports.TelecommunicationsInfoFieldsSchema = TelecommunicationsInfoFieldsSchema;
|
836
756
|
exports.TelecommunicationsInfoStepSchema = TelecommunicationsInfoStepSchema;
|
837
757
|
exports.getAdditionalInfoStepFields = getAdditionalInfoStepFields;
|
838
|
-
exports.getApartmentPaymentFields = getApartmentPaymentFields;
|
839
758
|
exports.getBasicApartmentInfoFields = getBasicApartmentInfoFields;
|
840
759
|
exports.getDetailApartmentInfoFields = getDetailApartmentInfoFields;
|
841
760
|
exports.getFillingInfoFields = getFillingInfoFields;
|
842
761
|
exports.getHouseServicesInfoStep = getHouseServicesInfoStep;
|
843
762
|
exports.getMetersInfoStepFields = getMetersInfoStepFields;
|
844
|
-
exports.getPartialMeterInfoFields = getPartialMeterInfoFields;
|
845
763
|
exports.getPartialMeterInfoSchema = getPartialMeterInfoSchema;
|
846
764
|
exports.getRoomsApartmentInfoFields = getRoomsApartmentInfoFields;
|
847
765
|
exports.getRoomsImagesSteps = getRoomsImagesSteps;
|