kui-crm_actions 0.0.68 → 0.0.69

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 CHANGED
@@ -10,10 +10,10 @@ var to = require('await-to-js');
10
10
  var luxon = require('luxon');
11
11
  var kuiComplex = require('kui-complex');
12
12
  var jsxRuntime = require('react/jsx-runtime');
13
+ var react = require('react');
13
14
  var styled = require('@emotion/styled');
14
- var kuiIcon = require('kui-icon');
15
15
  var kuiBasic = require('kui-basic');
16
- var react = require('react');
16
+ var kuiIcon = require('kui-icon');
17
17
 
18
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
19
 
@@ -423,6 +423,199 @@ var inspectionsRequests = {
423
423
  },
424
424
  };
425
425
 
426
+ var averageWalkMetersPerHour = 5000;
427
+ var minutesPerHour = 60;
428
+ var apartmentFields = {
429
+ getApartmentDescriptionInfo: function (apartment) {
430
+ return __assign(__assign(__assign(__assign(__assign(__assign({}, this.getApartmentMainInfo(apartment)), this.getApartmentSecurityInfo(apartment)), this.getApartmentDetailInfo(apartment)), this.getApartmentTelecommunicationInfo(apartment)), this.getApartmentHouseInfo(apartment)), this.getMaxMetersParams(apartment));
431
+ },
432
+ getApartmentMainInfo: function (apartment) {
433
+ return __assign(__assign({}, apartment), { apartmentNumber: apartment.apartment_number, zipCode: apartment.post_index || "", floorCount: apartment.floor_count, entrance: apartment.num_entrance, geolocation: this.getGeolocationParams(apartment.geolocation), distanceToCenter: apartment.distance_to_center_kilometers || null, typeOfObject: apartment.room_type });
434
+ },
435
+ getApartmentSecurityInfo: function (apartment) {
436
+ var _a, _b, _c, _d, _e, _f;
437
+ return {
438
+ hasIntercom: (_a = apartment.has_intercom) !== null && _a !== void 0 ? _a : null,
439
+ hasGate: (_b = apartment.has_gate) !== null && _b !== void 0 ? _b : null,
440
+ hasBarrier: (_c = apartment.has_barrier) !== null && _c !== void 0 ? _c : null,
441
+ hasSecurity: (_d = apartment.has_security) !== null && _d !== void 0 ? _d : null,
442
+ hasConcierge: (_e = apartment.has_concierge) !== null && _e !== void 0 ? _e : null,
443
+ hasVideoControl: (_f = apartment.has_video_surveillance) !== null && _f !== void 0 ? _f : null,
444
+ intercomCode: apartment.intercom_code || "",
445
+ gateCode: apartment.gate_code || "",
446
+ barrierPhone: apartment.barrier_phone
447
+ ? kuiUtils.getPhoneParamsFromString(apartment.barrier_phone)
448
+ : null,
449
+ conciergePhone: apartment.concierge_phone
450
+ ? kuiUtils.getPhoneParamsFromString(apartment.concierge_phone)
451
+ : null,
452
+ securityPhone: apartment.security_phone
453
+ ? kuiUtils.getPhoneParamsFromString(apartment.security_phone)
454
+ : null,
455
+ videoControlPhone: apartment.video_surveillance_phone
456
+ ? kuiUtils.getPhoneParamsFromString(apartment.video_surveillance_phone)
457
+ : null,
458
+ };
459
+ },
460
+ getApartmentDetailInfo: function (apartment) {
461
+ var _a;
462
+ return {
463
+ area: apartment.area,
464
+ livingArea: apartment.living_area,
465
+ kitchenArea: apartment.kitchen_area,
466
+ roomsNumber: apartment.rooms_number,
467
+ bedroomsNumber: apartment.bedrooms_number,
468
+ bathroomsNumber: apartment.bathrooms_number,
469
+ restroomsNumber: apartment.restrooms_number,
470
+ combinedBathroomsNumber: apartment.combined_bathrooms_number,
471
+ ceilingHeight: apartment.ceiling_height,
472
+ numberOfWindows: apartment.number_of_windows,
473
+ renovation: {
474
+ year: apartment.renovation_year || null,
475
+ type: apartment.renovation_type || null,
476
+ style: apartment.renovation_style || null,
477
+ },
478
+ rooms: ((_a = apartment.rooms) === null || _a === void 0 ? void 0 : _a.map(function (room) { return ({
479
+ id: room.id,
480
+ area: room.area || null,
481
+ type: room.room_type || null,
482
+ }); })) || [],
483
+ };
484
+ },
485
+ getApartmentTelecommunicationInfo: function (apartment) {
486
+ return {
487
+ homePhone: apartment.home_phone
488
+ ? kuiUtils.getPhoneParamsFromString(apartment.home_phone)
489
+ : null,
490
+ wifi: {
491
+ name: apartment.wifi_name,
492
+ password: apartment.wifi_password,
493
+ },
494
+ internetProvider: {
495
+ link: apartment.internet_provider_link,
496
+ login: apartment.internet_provider_login,
497
+ password: apartment.internet_provider_password,
498
+ },
499
+ tvType: apartment.tv_type,
500
+ };
501
+ },
502
+ getApartmentHouseInfo: function (apartment) {
503
+ return {
504
+ typeOfHouse: apartment.type_houses,
505
+ buildingYear: apartment.building_year,
506
+ houseNumber: apartment.serial_number,
507
+ wallMaterial: apartment.wall_type,
508
+ overlapType: apartment.overlap_type,
509
+ parkingType: apartment.parking_type,
510
+ parkingNumber: apartment.parking_number,
511
+ passengerElevatorsCount: apartment.passenger_elevators_number
512
+ ? Number(apartment.passenger_elevators_number)
513
+ : null,
514
+ serviceElevatorsCount: apartment.service_elevators_number
515
+ ? Number(apartment.service_elevators_number)
516
+ : null,
517
+ gasLeads: apartment.type_gas,
518
+ withHotWater: apartment.hot_water,
519
+ };
520
+ },
521
+ getMaxMetersParams: function (apartment) {
522
+ return {
523
+ maxMeters: {
524
+ water: apartment.max_water_counters,
525
+ electricity: apartment.max_electricity_counters,
526
+ gas: apartment.max_gas_counters,
527
+ heating: apartment.max_heating_counters,
528
+ },
529
+ };
530
+ },
531
+ getGeolocationParams: function (geolocation) {
532
+ return geolocation
533
+ ? {
534
+ lat: Number(geolocation.lat),
535
+ lng: Number(geolocation.lon),
536
+ }
537
+ : null;
538
+ },
539
+ getObjectRoomsImages: function (images) {
540
+ return images.map(function (imageBlock) { return ({
541
+ id: imageBlock.id,
542
+ type: imageBlock.purpose,
543
+ comment: imageBlock.comment,
544
+ images: imageBlock.photos.map(function (image) {
545
+ return kuiCrm.ImageStore.initFromImageModel(image);
546
+ }),
547
+ roomNumber: typeof imageBlock.room_order_number === "number"
548
+ ? imageBlock.room_order_number + 1
549
+ : 0,
550
+ }); });
551
+ },
552
+ getInspectionFillingParams: function (filling) {
553
+ var _a;
554
+ return {
555
+ id: filling.id,
556
+ name: filling.description || "",
557
+ tag: {
558
+ id: filling.feature.id,
559
+ name: filling.feature.name,
560
+ },
561
+ images: (_a = filling.photos) === null || _a === void 0 ? void 0 : _a.map(function (image) {
562
+ return kuiCrm.ImageStore.initFromImageModel(image);
563
+ }),
564
+ serialNumber: filling.serial_code,
565
+ numberOfSubjects: Number(filling.amount),
566
+ instruction: filling.instruction
567
+ ? kuiCrm.FileStore.initFromDocumentModel(filling.instruction)
568
+ : null,
569
+ type: kuiCrm.matchesAPIFillingTypes[filling.feature.feature_type],
570
+ };
571
+ },
572
+ getApartmentDescriptionWithMetro: function (apartment) {
573
+ return __assign(__assign({}, this.getApartmentDescriptionInfo(apartment)), { metroStations: this.getMetroStationsParams(apartment === null || apartment === void 0 ? void 0 : apartment.metro_stations) });
574
+ },
575
+ getMetroStationsParams: function (metroStations) {
576
+ return ((metroStations === null || metroStations === void 0 ? void 0 : metroStations.map(function (metroStation) { return ({
577
+ id: metroStation.metro_station_id,
578
+ name: metroStation.name,
579
+ walkDistance: metroStation.distance_walk_meters,
580
+ carDistance: Number(metroStation.distance_car_kilometers),
581
+ carTime: metroStation.time_car_minutes,
582
+ walkTime: Math.round(metroStation.distance_walk_meters /
583
+ (averageWalkMetersPerHour / minutesPerHour)),
584
+ }); })) || []);
585
+ },
586
+ getMeterValues: function (meter, resource, fieldName) {
587
+ var _a, _b, _c, _d, _e, _f;
588
+ if (resource === "electricity") {
589
+ var prefix = fieldName || "";
590
+ return __assign(__assign((_a = {}, _a["".concat(prefix, "T1")] = Number(meter.values.T1), _a), (meter.meter_type !== "T1" && (_b = {},
591
+ _b["".concat(prefix, "T2")] = Number(meter.values.T2),
592
+ _b))), (meter.meter_type === "T3" && (_c = {},
593
+ _c["".concat(prefix, "T3")] = Number(meter.values.T3),
594
+ _c)));
595
+ }
596
+ var valueField = fieldName || "value";
597
+ if (resource === "water") {
598
+ if (meter.meter_type === "cold") {
599
+ return _d = {}, _d["".concat(valueField)] = Number(meter.values.cold), _d;
600
+ }
601
+ return _e = {}, _e["".concat(valueField)] = Number(meter.values.hot), _e;
602
+ }
603
+ return _f = {},
604
+ _f["".concat(valueField)] = Number(meter.values[resource]),
605
+ _f;
606
+ },
607
+ getTransferMetersInfo: function (meters) {
608
+ var _this = this;
609
+ return {
610
+ meters: meters.map(function (meter) {
611
+ var _a;
612
+ return (__assign({ id: meter.id, type: meter.meter_type, number: meter.passport_number, resource: meter.resource_type, images: ((_a = meter.photos) === null || _a === void 0 ? void 0 : _a.map(function (photo) { return kuiCrm.ImageStore.initFromImageModel(photo); })) ||
613
+ [] }, _this.getMeterValues(meter, meter.resource_type)));
614
+ }),
615
+ };
616
+ },
617
+ };
618
+
426
619
  var getBasicApartmentInfoFields = function (handlePlaceSelect, settings) { return [
427
620
  __assign({ name: "country", label: "Country", variant: "custom", CustomInput: kuiCrm.CountryAutocomplete, size: 12 }, settings === null || settings === void 0 ? void 0 : settings.country),
428
621
  __assign({ name: "region", label: "Region", variant: "custom", CustomInput: kuiCrm.RegionAutocomplete }, settings === null || settings === void 0 ? void 0 : settings.region),
@@ -698,31 +891,6 @@ var getRoomsImagesSteps = function (type, settings, roomsParams) { return __spre
698
891
  __assign({ type: "additional" }, settings.additional),
699
892
  ], false); };
700
893
 
701
- var InspectionFeedbackComment = function (props) {
702
- var feedback = props.feedback, labels = props.labels;
703
- if (feedback.status === "rejected") {
704
- return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(kuiBasic.Caption, __assign({ size: "xs" }, { children: labels.rejected })), jsxRuntime.jsxs(StyledComment, __assign({ size: "xs" }, { children: [jsxRuntime.jsx(StyledAccent, { children: "Comment:" }), " ", feedback.comment || "-"] }))] }));
705
- }
706
- return jsxRuntime.jsx(kuiBasic.Caption, __assign({ size: "xs" }, { children: labels[feedback.status] }));
707
- };
708
- var StyledComment = styled__default["default"](kuiBasic.Caption)(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n margin-top: 8px;\n"], ["\n margin-top: 8px;\n"])));
709
- var StyledAccent = styled__default["default"].span(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject(["\n color: ", ";\n"], ["\n color: ", ";\n"])), kuiBasic.theme.palette.grey.fiftyP);
710
- var templateObject_1$5, templateObject_2$4;
711
-
712
- var InspectionFeedbackIndicator = function (props) {
713
- var feedback = props.feedback, className = props.className, labels = props.labels;
714
- return (jsxRuntime.jsx("div", __assign({ className: className }, { children: jsxRuntime.jsx(kuiCrm.Tooltip, __assign({ content: jsxRuntime.jsx(InspectionFeedbackComment, { feedback: feedback, labels: labels }) }, { children: indicatorIcon[feedback.status] })) })));
715
- };
716
- var StyledQuestionIcon = styled__default["default"](kuiIcon.QuestionIcon)(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n path {\n fill: ", ";\n }\n"], ["\n path {\n fill: ", ";\n }\n"])), kuiBasic.theme.palette.grey.fiftyP);
717
- var StyledCheckIcon = styled__default["default"](kuiIcon.CheckWithCircleIcon)(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n path {\n fill: ", ";\n }\n"], ["\n path {\n fill: ", ";\n }\n"])), kuiBasic.theme.palette.green.fiftyP);
718
- var StyledErrorIcon = styled__default["default"](kuiIcon.CrossWithCircleIcon)(templateObject_3$1 || (templateObject_3$1 = __makeTemplateObject(["\n width: 14px;\n height: 14px;\n path {\n fill: ", ";\n }\n"], ["\n width: 14px;\n height: 14px;\n path {\n fill: ", ";\n }\n"])), kuiBasic.theme.palette.red.fiftyP);
719
- var indicatorIcon = {
720
- notSigned: jsxRuntime.jsx(StyledQuestionIcon, {}),
721
- signed: jsxRuntime.jsx(StyledCheckIcon, {}),
722
- rejected: jsxRuntime.jsx(StyledErrorIcon, {}),
723
- };
724
- var templateObject_1$4, templateObject_2$3, templateObject_3$1;
725
-
726
894
  var useMetersValues = function (formStore, metersStore) {
727
895
  react.useEffect(function () {
728
896
  var _a, _b;
@@ -794,8 +962,6 @@ exports.DetailApartmentInfoStepSchema = DetailApartmentInfoStepSchema;
794
962
  exports.FillingInfoFieldsSchema = FillingInfoFieldsSchema;
795
963
  exports.HouseServicesInfoFieldsSchema = HouseServicesInfoFieldsSchema;
796
964
  exports.HouseServicesInfoStepSchema = HouseServicesInfoStepSchema;
797
- exports.InspectionFeedbackComment = InspectionFeedbackComment;
798
- exports.InspectionFeedbackIndicator = InspectionFeedbackIndicator;
799
965
  exports.MetersInfoFieldsSchema = MetersInfoFieldsSchema;
800
966
  exports.MetersInfoStepSchema = MetersInfoStepSchema;
801
967
  exports.RoomsApartmentInfoFieldsSchema = RoomsApartmentInfoFieldsSchema;
@@ -805,6 +971,7 @@ exports.SecurityApartmentInfoStepSchema = SecurityApartmentInfoStepSchema;
805
971
  exports.TelecommunicationsInfoFieldsSchema = TelecommunicationsInfoFieldsSchema;
806
972
  exports.TelecommunicationsInfoStepSchema = TelecommunicationsInfoStepSchema;
807
973
  exports.WaterMeterFieldsSchema = WaterMeterFieldsSchema;
974
+ exports.apartmentFields = apartmentFields;
808
975
  exports.getAdditionalInfoStepFields = getAdditionalInfoStepFields;
809
976
  exports.getBasicApartmentInfoFields = getBasicApartmentInfoFields;
810
977
  exports.getDetailApartmentInfoFields = getDetailApartmentInfoFields;