kui-crm_actions 0.0.151 → 0.0.153
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 +100 -62
- package/cjs/index.js.map +1 -1
- package/index.d.ts +3 -1
- package/index.js +101 -63
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
@@ -502,6 +502,7 @@ type InventoryInspectionPostFormFields = {
|
|
502
502
|
} & Omit<InventoryInspectionFormFields, "fillingList">
|
503
503
|
|
504
504
|
declare const inspectionsRequests: {
|
505
|
+
createInspectionHandler(apartmentId: number, loader: Loader, callback: () => Promise<any>): Promise<number | null | undefined>;
|
505
506
|
getInspectionTypes(apartmentId: number): Promise<[Error | null, InspectionTypes[] | undefined]>;
|
506
507
|
getTransferTypes(apartmentId: number): Promise<[Error | null, TransferInspectionTypes$1[] | undefined]>;
|
507
508
|
createInspection(apartmentId: number, body: any, loader: Loader): Promise<number | undefined>;
|
@@ -513,6 +514,7 @@ declare const inspectionsRequests: {
|
|
513
514
|
purpose: kui_crm.InspectionRoomPhotoTypes;
|
514
515
|
comment: string;
|
515
516
|
photos: kui_crm.ImageBodyRequest[];
|
517
|
+
room_order_number: number | undefined;
|
516
518
|
}[];
|
517
519
|
};
|
518
520
|
|
@@ -751,7 +753,7 @@ declare const DetailApartmentInfoStepSchema: yup.ObjectSchema<{
|
|
751
753
|
ceilingHeight: undefined;
|
752
754
|
}, "">;
|
753
755
|
|
754
|
-
declare const getRoomsApartmentInfoFields: (settings?: InspectionFieldsSettings | undefined) => InputParams<RoomsApartmentInfoStepFields>[];
|
756
|
+
declare const getRoomsApartmentInfoFields: (roomsCount?: string | number | null | undefined, settings?: InspectionFieldsSettings | undefined) => InputParams<RoomsApartmentInfoStepFields>[];
|
755
757
|
|
756
758
|
declare const RoomsApartmentInfoFieldsSchema: {
|
757
759
|
floor: yup.NumberSchema<number | undefined, yup.AnyObject, undefined, "">;
|
package/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as yup from 'yup';
|
2
|
-
import { NumberField, requests, uploadNewFile, uploadFiles, ImageStore, FileStore, matchesAPIFillingTypes, CountryAutocomplete, RegionAutocomplete, CityAutocomplete, defaultRequiredMessage, HouseTypesValues, WallMaterialsValues, SlabsTypesValues, GasTypesValues, BooleanValues, positiveNumberSchema, RenovationTypeValues, RenovationStyleValues, RoomTypeValues, RoomTypesValues, ParkingTypesValues, fieldWithConditionSchema, BigCheckbox, getApartmentPaymentFields, phoneWithConditionSchema, getNumbersValues, TVTypesValues, phoneNonRequiredSchema, InputFileWithVisibility, FillingTypeValues, FillingTagsAutocomplete, getMeterValuesFieldsSchema, basicFieldsOfNewResourceMeter, meterUnitLabel, FormWrapper, MeterTypeRadioGroup, InputByType, Tooltip, ApartmentsAgent, PreviewContent, Link, UserBadge, useMapCards, MapOverlay } from 'kui-crm';
|
2
|
+
import { NumberField, KUISettings, requests, uploadNewFile, uploadFiles, ImageStore, FileStore, matchesAPIFillingTypes, CountryAutocomplete, RegionAutocomplete, CityAutocomplete, defaultRequiredMessage, HouseTypesValues, WallMaterialsValues, SlabsTypesValues, GasTypesValues, BooleanValues, positiveNumberSchema, RenovationTypeValues, RenovationStyleValues, RoomTypeValues, RoomTypesValues, ParkingTypesValues, fieldWithConditionSchema, BigCheckbox, getApartmentPaymentFields, phoneWithConditionSchema, getNumbersValues, TVTypesValues, phoneNonRequiredSchema, InputFileWithVisibility, FillingTypeValues, FillingTagsAutocomplete, getMeterValuesFieldsSchema, basicFieldsOfNewResourceMeter, meterUnitLabel, FormWrapper, MeterTypeRadioGroup, InputByType, Tooltip, ApartmentsAgent, PreviewContent, Link, UserBadge, useMapCards, MapOverlay } from 'kui-crm';
|
3
3
|
import _ from 'lodash';
|
4
4
|
import { clearNotValidFields, getPhoneNumberFromPhoneParams, resHandler, callPromises, getPhoneParamsFromString, addToArrayByCondition, Loader, clearIndexStores, addToIndexDBWithQueue, initIndexDB, readFromIndexDB, addIndexDBStore } from 'kui-utils';
|
5
5
|
import to from 'await-to-js';
|
@@ -252,14 +252,14 @@ var inspectionsRequestBody = {
|
|
252
252
|
getPartialInspectionMeters: function (meters) {
|
253
253
|
var _this = this;
|
254
254
|
return {
|
255
|
-
meters: meters.map(function (meter, index) { return ({
|
255
|
+
meters: (meters === null || meters === void 0 ? void 0 : meters.map(function (meter, index) { return ({
|
256
256
|
id: meter.id,
|
257
257
|
resource_type: meter.resource,
|
258
258
|
meter_type: meter.type,
|
259
259
|
passport_number: meter.number,
|
260
260
|
photos: _this.getFilesParams(meter.images),
|
261
261
|
values: clearNotValidFields(_this.getInspectionMeterValues(meter)),
|
262
|
-
}); }),
|
262
|
+
}); })) || [],
|
263
263
|
};
|
264
264
|
},
|
265
265
|
getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles, contractFile) {
|
@@ -347,13 +347,42 @@ var inspectionsRequestBody = {
|
|
347
347
|
});
|
348
348
|
},
|
349
349
|
getFilesParams: function (files) {
|
350
|
-
return files
|
351
|
-
.map(function (file) { return file.uploadedData; })
|
352
|
-
.filter(function (data) { return data; });
|
350
|
+
return ((files === null || files === void 0 ? void 0 : files.map(function (file) { return file.uploadedData; }).filter(function (data) { return data; })) || []);
|
353
351
|
},
|
354
352
|
};
|
355
353
|
|
356
354
|
var inspectionsRequests = {
|
355
|
+
createInspectionHandler: function (apartmentId, loader, callback) {
|
356
|
+
return __awaiter(this, void 0, void 0, function () {
|
357
|
+
var body, e_1, Sentry;
|
358
|
+
return __generator(this, function (_a) {
|
359
|
+
switch (_a.label) {
|
360
|
+
case 0:
|
361
|
+
if (!apartmentId) return [3 /*break*/, 5];
|
362
|
+
loader.startLoading("inspection creation");
|
363
|
+
body = void 0;
|
364
|
+
_a.label = 1;
|
365
|
+
case 1:
|
366
|
+
_a.trys.push([1, 3, , 4]);
|
367
|
+
return [4 /*yield*/, callback()];
|
368
|
+
case 2:
|
369
|
+
body = _a.sent();
|
370
|
+
return [3 /*break*/, 4];
|
371
|
+
case 3:
|
372
|
+
e_1 = _a.sent();
|
373
|
+
Sentry = KUISettings.getSettings().Sentry;
|
374
|
+
Sentry.captureException(e_1);
|
375
|
+
loader.setError("inspection creation body", e_1);
|
376
|
+
return [3 /*break*/, 4];
|
377
|
+
case 4:
|
378
|
+
if (body)
|
379
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
380
|
+
return [2 /*return*/, null];
|
381
|
+
case 5: return [2 /*return*/, null];
|
382
|
+
}
|
383
|
+
});
|
384
|
+
});
|
385
|
+
},
|
357
386
|
getInspectionTypes: function (apartmentId) {
|
358
387
|
return __awaiter(this, void 0, void 0, function () {
|
359
388
|
var _a, err, res;
|
@@ -401,83 +430,92 @@ var inspectionsRequests = {
|
|
401
430
|
},
|
402
431
|
createInitialInspection: function (data, apartmentId, loader) {
|
403
432
|
return __awaiter(this, void 0, void 0, function () {
|
404
|
-
var
|
433
|
+
var _this = this;
|
405
434
|
return __generator(this, function (_a) {
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
435
|
+
return [2 /*return*/, this.createInspectionHandler(apartmentId, loader, function () { return __awaiter(_this, void 0, void 0, function () {
|
436
|
+
var roomsImages;
|
437
|
+
return __generator(this, function (_a) {
|
438
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
439
|
+
return [2 /*return*/, inspectionsRequestBody.getPostBodyInitialInspection(data, roomsImages)];
|
440
|
+
});
|
441
|
+
}); })];
|
413
442
|
});
|
414
443
|
});
|
415
444
|
},
|
416
445
|
createRegularInspection: function (data, apartmentId, loader) {
|
417
446
|
return __awaiter(this, void 0, void 0, function () {
|
418
|
-
var
|
447
|
+
var _this = this;
|
419
448
|
return __generator(this, function (_a) {
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
449
|
+
return [2 /*return*/, this.createInspectionHandler(apartmentId, loader, function () { return __awaiter(_this, void 0, void 0, function () {
|
450
|
+
var roomsImages;
|
451
|
+
return __generator(this, function (_a) {
|
452
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
453
|
+
return [2 /*return*/, inspectionsRequestBody.getPostBodyRegularInspection(data, roomsImages)];
|
454
|
+
});
|
455
|
+
}); })];
|
427
456
|
});
|
428
457
|
});
|
429
458
|
},
|
430
459
|
createTransferInspection: function (data, apartmentId, loader) {
|
431
460
|
return __awaiter(this, void 0, void 0, function () {
|
432
|
-
var
|
461
|
+
var _this = this;
|
433
462
|
return __generator(this, function (_a) {
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
463
|
+
return [2 /*return*/, this.createInspectionHandler(apartmentId, loader, function () { return __awaiter(_this, void 0, void 0, function () {
|
464
|
+
var roomsImages, file;
|
465
|
+
return __generator(this, function (_a) {
|
466
|
+
switch (_a.label) {
|
467
|
+
case 0:
|
468
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
469
|
+
return [4 /*yield*/, uploadNewFile(loader, data.contractFile)];
|
470
|
+
case 1:
|
471
|
+
file = _a.sent();
|
472
|
+
return [2 /*return*/, inspectionsRequestBody.getPostBodyTransferInspection(data, roomsImages, file)];
|
473
|
+
}
|
474
|
+
});
|
475
|
+
}); })];
|
446
476
|
});
|
447
477
|
});
|
448
478
|
},
|
449
479
|
createInventoryInspection: function (data, apartmentId, loader) {
|
450
|
-
var _a;
|
451
480
|
return __awaiter(this, void 0, void 0, function () {
|
452
|
-
var
|
453
|
-
return __generator(this, function (
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
481
|
+
var _this = this;
|
482
|
+
return __generator(this, function (_a) {
|
483
|
+
return [2 /*return*/, this.createInspectionHandler(apartmentId, loader, function () { return __awaiter(_this, void 0, void 0, function () {
|
484
|
+
var fillingFiles, metersFiles, files, roomsImages;
|
485
|
+
var _a;
|
486
|
+
return __generator(this, function (_b) {
|
487
|
+
switch (_b.label) {
|
488
|
+
case 0:
|
489
|
+
fillingFiles = data.fillingList.map(function (filling) { return filling.instruction; });
|
490
|
+
metersFiles = ((_a = data.meters) === null || _a === void 0 ? void 0 : _a.map(function (meter) { return meter.passportFile; })) || [];
|
491
|
+
return [4 /*yield*/, callPromises([
|
492
|
+
uploadFiles(loader, fillingFiles),
|
493
|
+
uploadFiles(loader, metersFiles),
|
494
|
+
uploadNewFile(loader, data.contractFile),
|
495
|
+
])];
|
496
|
+
case 1:
|
497
|
+
files = _b.sent();
|
498
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
499
|
+
return [2 /*return*/, inspectionsRequestBody.getPostBodyInventoryInspection(data, roomsImages, files[0], files[1], files[2])];
|
500
|
+
}
|
501
|
+
});
|
502
|
+
}); })];
|
472
503
|
});
|
473
504
|
});
|
474
505
|
},
|
475
506
|
getRoomParams: function (rooms) {
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
507
|
+
var roomIndex = -1;
|
508
|
+
return ((rooms === null || rooms === void 0 ? void 0 : rooms.map(function (room) {
|
509
|
+
var withOrderNumber = room.type === "room" || room.type === "bedroom";
|
510
|
+
if (withOrderNumber)
|
511
|
+
roomIndex += 1;
|
512
|
+
return {
|
513
|
+
purpose: room === null || room === void 0 ? void 0 : room.type,
|
514
|
+
comment: room === null || room === void 0 ? void 0 : room.comment,
|
515
|
+
photos: inspectionsRequestBody.getFilesParams(room.files),
|
516
|
+
room_order_number: withOrderNumber ? roomIndex : undefined,
|
517
|
+
};
|
518
|
+
})) || []);
|
481
519
|
},
|
482
520
|
};
|
483
521
|
|
@@ -817,11 +855,11 @@ var DetailApartmentInfoFieldsSchema = {
|
|
817
855
|
};
|
818
856
|
var DetailApartmentInfoStepSchema = yup.object(DetailApartmentInfoFieldsSchema);
|
819
857
|
|
820
|
-
var getRoomsApartmentInfoFields = function (settings) { return [
|
858
|
+
var getRoomsApartmentInfoFields = function (roomsCount, settings) { return [
|
821
859
|
__assign({ label: "Floor", name: "floor", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.floor),
|
822
860
|
__assign({ label: "Floors", name: "floorCount", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.floorCount),
|
823
861
|
__assign({ label: "Rooms", name: "roomsNumber", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.roomsNumber),
|
824
|
-
__assign({ label: "Bedrooms", name: "bedroomsNumber", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.bedroomsNumber),
|
862
|
+
__assign({ label: "Bedrooms", name: "bedroomsNumber", type: "number", isRequired: true, disabled: roomsCount === 0 || roomsCount === "0" }, settings === null || settings === void 0 ? void 0 : settings.bedroomsNumber),
|
825
863
|
__assign({ label: "Bathrooms", name: "bathroomsNumber", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.bathroomsNumber),
|
826
864
|
__assign({ label: "Restrooms", name: "restroomsNumber", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.restroomsNumber),
|
827
865
|
__assign({ label: "Combined bathroom", name: "combinedBathroomsNumber", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.combinedBathroomsNumber),
|