kui-crm_actions 0.0.137 → 0.0.138

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/index.d.ts CHANGED
@@ -72,6 +72,7 @@ type CommonInspectionFormFields = {
72
72
  basedOn?: number
73
73
  type: InspectionTypes
74
74
  dropboxLink?: string
75
+ contractFile?: InputFileWithVisibilityFields | null
75
76
  }
76
77
 
77
78
  type InspectionRoomImagesParams = {
@@ -456,6 +457,7 @@ declare type RegularlyInspectionFieldsBody = {
456
457
  declare type TransferInspectionFieldsBody = {
457
458
  transfer_type: TransferInspectionTypes;
458
459
  meters: PartialMeterModel[];
460
+ contract_document?: FileBodyRequest | null;
459
461
  } & PostInspectionFillingListModel;
460
462
  declare type InventoryInspectionFieldsBody = {
461
463
  country_of_residence: number | null;
@@ -466,6 +468,7 @@ declare type InventoryInspectionFieldsBody = {
466
468
  allowed_children: boolean;
467
469
  allowed_pets: boolean;
468
470
  additional_terms: string;
471
+ contract_document?: FileBodyRequest | null;
469
472
  } & Partial<ApartmentDetailInfoModelFields$1>;
470
473
  declare type InventoryInspectionPostBody = {
471
474
  inventory: InventoryInspectionFieldsBody;
@@ -497,7 +500,7 @@ declare const inspectionsRequestBody: {
497
500
  getPostBodyInitialInspection(inspection: InitialInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[]): InitialInspectionPostBody;
498
501
  getInitialInspectionFields(inspection: InitialInspectionInfoFields): InitialInspectionFieldsBody;
499
502
  getPostBodyRegularInspection(inspection: RegularInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[]): RegularInspectionPostBody;
500
- getPostBodyTransferInspection(inspection: TransferInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[]): TransferInspectionPostBody;
503
+ getPostBodyTransferInspection(inspection: TransferInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[], contractFile?: FileBodyRequest | null | undefined): TransferInspectionPostBody;
501
504
  getInspectionFilling(fillingList: InspectionFillingItemFields[]): {
502
505
  filling: {
503
506
  apartment_feature_id: number;
@@ -516,7 +519,7 @@ declare const inspectionsRequestBody: {
516
519
  };
517
520
  }[];
518
521
  };
519
- getPostBodyInventoryInspection(inspection: InventoryInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[], fillingFiles: FileBodyRequest[], metersFiles: FileBodyRequest[]): InventoryInspectionPostBody;
522
+ getPostBodyInventoryInspection(inspection: InventoryInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[], fillingFiles: FileBodyRequest[], metersFiles: FileBodyRequest[], contractFile?: FileBodyRequest | null | undefined): InventoryInspectionPostBody;
520
523
  getInventoryInspectionMeters(meters: InspectionMeterFields[], metersFiles: FileBodyRequest[], metersImages?: ImageBodyRequest[][] | undefined): {
521
524
  meters: {
522
525
  passport: FileBodyRequest;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as yup from 'yup';
2
- import { NumberField, requests, uploadFiles, ImageStore, FileStore, matchesAPIFillingTypes, CountryAutocomplete, RegionAutocomplete, CityAutocomplete, HouseTypesValues, WallMaterialsValues, SlabsTypesValues, GasTypesValues, BooleanValues, positiveNumberSchema, defaultRequiredMessage, 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, requests, uploadNewFile, uploadFiles, ImageStore, FileStore, matchesAPIFillingTypes, CountryAutocomplete, RegionAutocomplete, CityAutocomplete, HouseTypesValues, WallMaterialsValues, SlabsTypesValues, GasTypesValues, BooleanValues, positiveNumberSchema, defaultRequiredMessage, 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';
@@ -225,14 +225,14 @@ var inspectionsRequestBody = {
225
225
  regular: __assign(__assign({}, this.getInspectionFilling(inspection.fillingList)), this.getPartialInspectionMeters(inspection.meters)),
226
226
  };
227
227
  },
228
- getPostBodyTransferInspection: function (inspection, roomsImages) {
228
+ getPostBodyTransferInspection: function (inspection, roomsImages, contractFile) {
229
229
  return {
230
230
  date: (inspection.date || DateTime.now()).toISODate(),
231
231
  inspection_type: "transfer",
232
232
  based_on: null,
233
233
  dropbox_link: inspection.dropboxLink,
234
234
  photo_groups: roomsImages,
235
- transfer: __assign(__assign({ transfer_type: inspection.transferType }, this.getInspectionFilling(inspection.fillingList)), this.getPartialInspectionMeters(inspection.meters)),
235
+ transfer: __assign(__assign({ contract_document: contractFile || undefined, transfer_type: inspection.transferType }, this.getInspectionFilling(inspection.fillingList)), this.getPartialInspectionMeters(inspection.meters)),
236
236
  };
237
237
  },
238
238
  getInspectionFilling: function (fillingList) {
@@ -256,7 +256,7 @@ var inspectionsRequestBody = {
256
256
  }); }),
257
257
  };
258
258
  },
259
- getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles) {
259
+ getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles, contractFile) {
260
260
  var _this = this;
261
261
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
262
262
  return {
@@ -265,7 +265,7 @@ var inspectionsRequestBody = {
265
265
  based_on: null,
266
266
  dropbox_link: inspection.dropboxLink,
267
267
  photo_groups: roomsImages,
268
- inventory: __assign({ allowed_children: inspection.withChildren, allowed_pets: inspection.withPets, additional_terms: inspection.additionalTerms, country_of_residence: ((_a = inspection.countryOfResidence) === null || _a === void 0 ? void 0 : _a.id) || null, administrative_company: ((_b = inspection.company) === null || _b === void 0 ? void 0 : _b.id) || null, tax_type: inspection.taxesType, financial_personal_account: inspection.communalServicesAccount, max_electricity_counters: (_c = inspection.maxMeters) === null || _c === void 0 ? void 0 : _c.electricity, max_gas_counters: (_d = inspection.maxMeters) === null || _d === void 0 ? void 0 : _d.gas, max_heating_counters: (_e = inspection.maxMeters) === null || _e === void 0 ? void 0 : _e.heating, max_water_counters: (_f = inspection.maxMeters) === null || _f === void 0 ? void 0 : _f.water, has_barrier: inspection.hasBarrier, has_concierge: inspection.hasConcierge, has_security: inspection.hasSecurity, has_video_surveillance: inspection.hasVideoControl, barrier_phone: inspection.barrierPhone
268
+ inventory: __assign({ contract_document: contractFile || undefined, allowed_children: inspection.withChildren, allowed_pets: inspection.withPets, additional_terms: inspection.additionalTerms, country_of_residence: ((_a = inspection.countryOfResidence) === null || _a === void 0 ? void 0 : _a.id) || null, administrative_company: ((_b = inspection.company) === null || _b === void 0 ? void 0 : _b.id) || null, tax_type: inspection.taxesType, financial_personal_account: inspection.communalServicesAccount, max_electricity_counters: (_c = inspection.maxMeters) === null || _c === void 0 ? void 0 : _c.electricity, max_gas_counters: (_d = inspection.maxMeters) === null || _d === void 0 ? void 0 : _d.gas, max_heating_counters: (_e = inspection.maxMeters) === null || _e === void 0 ? void 0 : _e.heating, max_water_counters: (_f = inspection.maxMeters) === null || _f === void 0 ? void 0 : _f.water, has_barrier: inspection.hasBarrier, has_concierge: inspection.hasConcierge, has_security: inspection.hasSecurity, has_video_surveillance: inspection.hasVideoControl, barrier_phone: inspection.barrierPhone
269
269
  ? getPhoneNumberFromPhoneParams(inspection.barrierPhone)
270
270
  : null, concierge_phone: inspection.conciergePhone
271
271
  ? getPhoneNumberFromPhoneParams(inspection.conciergePhone)
@@ -406,15 +406,20 @@ var inspectionsRequests = {
406
406
  },
407
407
  createTransferInspection: function (data, apartmentId, loader) {
408
408
  return __awaiter(this, void 0, void 0, function () {
409
- var roomsImages, body;
409
+ var roomsImages, file, body;
410
410
  return __generator(this, function (_a) {
411
- if (apartmentId) {
412
- loader.startLoading("inspection creation");
413
- roomsImages = this.getRoomParams(data.roomsImages);
414
- body = inspectionsRequestBody.getPostBodyTransferInspection(data, roomsImages);
415
- return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
411
+ switch (_a.label) {
412
+ case 0:
413
+ if (!apartmentId) return [3 /*break*/, 2];
414
+ loader.startLoading("inspection creation");
415
+ roomsImages = this.getRoomParams(data.roomsImages);
416
+ return [4 /*yield*/, uploadNewFile(loader, data.contractFile)];
417
+ case 1:
418
+ file = _a.sent();
419
+ body = inspectionsRequestBody.getPostBodyTransferInspection(data, roomsImages, file);
420
+ return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
421
+ case 2: return [2 /*return*/, null];
416
422
  }
417
- return [2 /*return*/, null];
418
423
  });
419
424
  });
420
425
  },
@@ -432,11 +437,12 @@ var inspectionsRequests = {
432
437
  return [4 /*yield*/, callPromises([
433
438
  uploadFiles(loader, fillingFiles),
434
439
  uploadFiles(loader, metersFiles),
440
+ uploadNewFile(loader, data.contractFile),
435
441
  ])];
436
442
  case 1:
437
443
  files = _b.sent();
438
444
  roomsImages = this.getRoomParams(data.roomsImages);
439
- body = inspectionsRequestBody.getPostBodyInventoryInspection(data, roomsImages, files[0], files[1]);
445
+ body = inspectionsRequestBody.getPostBodyInventoryInspection(data, roomsImages, files[0], files[1], files[2]);
440
446
  return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
441
447
  case 2: return [2 /*return*/, null];
442
448
  }