kui-crm_actions 0.0.77 → 0.0.80

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
@@ -15,6 +15,7 @@ var mobxReact = require('mobx-react');
15
15
  var styled = require('@emotion/styled');
16
16
  var kuiIcon = require('kui-icon');
17
17
  var react = require('react');
18
+ var mobx = require('mobx');
18
19
 
19
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
21
 
@@ -222,7 +223,7 @@ var inspectionsRequestBody = {
222
223
  based_on: null,
223
224
  dropbox_link: inspection.dropboxLink,
224
225
  photo_groups: roomsImages,
225
- regular: this.getPartialInspectionMeters(inspection.meters),
226
+ regular: __assign(__assign({}, this.getInspectionFilling(inspection.filling)), this.getPartialInspectionMeters(inspection.meters)),
226
227
  };
227
228
  },
228
229
  getPostBodyTransferInspection: function (inspection, roomsImages) {
@@ -232,7 +233,15 @@ var inspectionsRequestBody = {
232
233
  based_on: null,
233
234
  dropbox_link: inspection.dropboxLink,
234
235
  photo_groups: roomsImages,
235
- transfer: __assign({ transfer_type: inspection.transferType }, this.getPartialInspectionMeters(inspection.meters)),
236
+ transfer: __assign(__assign({ transfer_type: inspection.transferType }, this.getInspectionFilling(inspection.filling)), this.getPartialInspectionMeters(inspection.meters)),
237
+ };
238
+ },
239
+ getInspectionFilling: function (fillingList) {
240
+ return {
241
+ filling: fillingList.map(function (filling) { return ({
242
+ apartment_feature_id: filling.id,
243
+ is_absent: !filling.check,
244
+ }); }),
236
245
  };
237
246
  },
238
247
  getPartialInspectionMeters: function (meters) {
@@ -983,7 +992,7 @@ var templateObject_1$6;
983
992
 
984
993
  var FillingCardContent = function (props) {
985
994
  var filling = props.filling, warningLabel = props.warningLabel;
986
- return (jsxRuntime.jsxs(kuiBasic.Grid, __assign({ container: true, alignItems: "center" }, { children: [!filling.wasAvailable && (jsxRuntime.jsx(kuiCrm.Tooltip, __assign({ content: jsxRuntime.jsx(kuiBasic.Caption, __assign({ size: "xs" }, { children: warningLabel })) }, { children: jsxRuntime.jsx(StyledWarningIcon, { width: 17, height: 17 }) }))), jsxRuntime.jsxs(StyledLabelWrapper, { children: [jsxRuntime.jsx(kuiBasic.Caption, __assign({ size: "s" }, { children: filling.name })), jsxRuntime.jsxs(StyledSubtitle, __assign({ size: "xs", color: "fiftyP" }, { children: [filling.numberOfSubjects ? "".concat(filling.numberOfSubjects, " pieces") : "", filling.numberOfSubjects && filling.serialNumber ? " \u2022 " : "", filling.serialNumber] }))] })] })));
995
+ return (jsxRuntime.jsxs(kuiBasic.Grid, __assign({ container: true, alignItems: "center" }, { children: [!filling.wasMissing && (jsxRuntime.jsx(kuiCrm.Tooltip, __assign({ content: jsxRuntime.jsx(kuiBasic.Caption, __assign({ size: "xs" }, { children: warningLabel })) }, { children: jsxRuntime.jsx(StyledWarningIcon, { width: 17, height: 17 }) }))), jsxRuntime.jsxs(StyledLabelWrapper, { children: [jsxRuntime.jsx(kuiBasic.Caption, __assign({ size: "s" }, { children: filling.name })), jsxRuntime.jsxs(StyledSubtitle, __assign({ size: "xs", color: "fiftyP" }, { children: [filling.numberOfSubjects ? "".concat(filling.numberOfSubjects, " pieces") : "", filling.numberOfSubjects && filling.serialNumber ? " \u2022 " : "", filling.serialNumber] }))] })] })));
987
996
  };
988
997
  var StyledWarningIcon = styled__default["default"](kuiIcon.WarningIcon)(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n margin-left: 4px;\n path {\n fill: ", ";\n }\n"], ["\n margin-left: 4px;\n path {\n fill: ", ";\n }\n"])), kuiBasic.theme.palette.red.fiftyP);
989
998
  var StyledLabelWrapper = styled__default["default"].div(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject(["\n margin-left: 8px;\n"], ["\n margin-left: 8px;\n"])));
@@ -1012,6 +1021,59 @@ var useMetersValues = function (formStore, metersStore) {
1012
1021
  }, [metersStore.meters, metersStore.loader.isLoading]);
1013
1022
  };
1014
1023
 
1024
+ var FillingListStore = /** @class */ (function () {
1025
+ function FillingListStore() {
1026
+ var _this = this;
1027
+ this.fetchFillingList = function (apartmentId) { return __awaiter(_this, void 0, void 0, function () {
1028
+ var response;
1029
+ return __generator(this, function (_a) {
1030
+ switch (_a.label) {
1031
+ case 0:
1032
+ this.loader.startLoading();
1033
+ return [4 /*yield*/, to__default["default"](kuiCrm.ApartmentsAgent.getFillingList(apartmentId))];
1034
+ case 1:
1035
+ response = _a.sent();
1036
+ kuiUtils.resHandler(response, this.loader, this.updateFillingList);
1037
+ return [2 /*return*/];
1038
+ }
1039
+ });
1040
+ }); };
1041
+ this.updateFillingList = function (fillingList) {
1042
+ _this.fillingList = fillingList.map(function (filling) { return ({
1043
+ id: filling.id,
1044
+ name: filling.description,
1045
+ serialNumber: filling.serial_code,
1046
+ numberOfSubjects: filling.amount,
1047
+ wasMissing: filling.is_absent,
1048
+ }); });
1049
+ };
1050
+ this.fillingList = [];
1051
+ this.loader = new kuiUtils.Loader();
1052
+ mobx.makeAutoObservable(this);
1053
+ }
1054
+ return FillingListStore;
1055
+ }());
1056
+
1057
+ var useFillingList = function (apartmentId, formStore, fillingStore) {
1058
+ react.useEffect(function () {
1059
+ var _a, _b;
1060
+ if (!((_b = (_a = formStore.fields) === null || _a === void 0 ? void 0 : _a.filling) === null || _b === void 0 ? void 0 : _b.length) && apartmentId) {
1061
+ fillingStore.fetchFillingList(apartmentId);
1062
+ }
1063
+ }, [apartmentId]);
1064
+ react.useEffect(function () {
1065
+ var _a, _b;
1066
+ if (!fillingStore.loader.isLoading && !((_b = (_a = formStore.fields) === null || _a === void 0 ? void 0 : _a.filling) === null || _b === void 0 ? void 0 : _b.length)) {
1067
+ formStore.updateFormFields({
1068
+ filling: fillingStore.fillingList.map(function (filling) { return ({
1069
+ id: filling.id,
1070
+ check: false,
1071
+ }); }),
1072
+ });
1073
+ }
1074
+ }, [fillingStore.fillingList, fillingStore.loader.isLoading]);
1075
+ };
1076
+
1015
1077
  var ApartmentInspectionPoint = function (props) {
1016
1078
  var date = props.date, onClick = props.onClick, isActive = props.isActive, apartment = props.apartment;
1017
1079
  return (jsxRuntime.jsx(kuiBasic.Button, __assign({ size: "xs", variant: isActive ? "primary" : "white", onClick: onClick }, { children: (date === null || date === void 0 ? void 0 : date.toFormat("dd.MM.yyyy")) || "".concat(Number(apartment.roomsCount), "-\u043A\u043E\u043C\u043D.") })));
@@ -1067,6 +1129,7 @@ exports.BasicApartmentInfoStepSchema = BasicApartmentInfoStepSchema;
1067
1129
  exports.DetailApartmentInfoFieldsSchema = DetailApartmentInfoFieldsSchema;
1068
1130
  exports.DetailApartmentInfoStepSchema = DetailApartmentInfoStepSchema;
1069
1131
  exports.FillingInfoFieldsSchema = FillingInfoFieldsSchema;
1132
+ exports.FillingListStore = FillingListStore;
1070
1133
  exports.HouseServicesInfoFieldsSchema = HouseServicesInfoFieldsSchema;
1071
1134
  exports.HouseServicesInfoStepSchema = HouseServicesInfoStepSchema;
1072
1135
  exports.InspectionFeedback = index;
@@ -1096,5 +1159,6 @@ exports.getWaterMeterFields = getWaterMeterFields;
1096
1159
  exports.inspectionsRequestBody = inspectionsRequestBody;
1097
1160
  exports.inspectionsRequests = inspectionsRequests;
1098
1161
  exports.renderMetersSteps = renderMetersSteps;
1162
+ exports.useFillingList = useFillingList;
1099
1163
  exports.useMetersValues = useMetersValues;
1100
1164
  //# sourceMappingURL=index.js.map