kui-crm_actions 0.0.155 → 0.0.157
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.js +1 -1511
- package/package.json +2 -4
- package/cjs/index.js +0 -1592
- package/cjs/index.js.map +0 -1
- package/index.js.map +0 -1
package/index.js
CHANGED
@@ -1,1511 +1 @@
|
|
1
|
-
import * as yup from 'yup';
|
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
|
-
import _ from 'lodash';
|
4
|
-
import { clearNotValidFields, getPhoneNumberFromPhoneParams, resHandler, callPromises, getPhoneParamsFromString, addToArrayByCondition, Loader, clearIndexStores, addToIndexDBWithQueue, initIndexDB, readFromIndexDB, addIndexDBStore } from 'kui-utils';
|
5
|
-
import to from 'await-to-js';
|
6
|
-
import { DateTime } from 'luxon';
|
7
|
-
import { InputWithAddressAutocomplete, DependentInput, CheckboxWithController, InputPhoneWithForm, InputFile } from 'kui-complex';
|
8
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
9
|
-
import { useState, useMemo, useEffect } from 'react';
|
10
|
-
import { useForm } from 'react-hook-form';
|
11
|
-
import { Caption, theme, Grid, Button } from 'kui-basic';
|
12
|
-
import { yupResolver } from '@hookform/resolvers/yup';
|
13
|
-
import styled from '@emotion/styled';
|
14
|
-
import { WarningIcon, CheckIcon, CancelIcon, CommentIcon, UpdateIcon, PhoneIcon, CloseIcon } from 'kui-icon';
|
15
|
-
import { observer } from 'mobx-react';
|
16
|
-
import { makeAutoObservable } from 'mobx';
|
17
|
-
|
18
|
-
/******************************************************************************
|
19
|
-
Copyright (c) Microsoft Corporation.
|
20
|
-
|
21
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
22
|
-
purpose with or without fee is hereby granted.
|
23
|
-
|
24
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
25
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
26
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
27
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
28
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
29
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
30
|
-
PERFORMANCE OF THIS SOFTWARE.
|
31
|
-
***************************************************************************** */
|
32
|
-
|
33
|
-
var __assign = function() {
|
34
|
-
__assign = Object.assign || function __assign(t) {
|
35
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
36
|
-
s = arguments[i];
|
37
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
38
|
-
}
|
39
|
-
return t;
|
40
|
-
};
|
41
|
-
return __assign.apply(this, arguments);
|
42
|
-
};
|
43
|
-
|
44
|
-
function __rest(s, e) {
|
45
|
-
var t = {};
|
46
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
47
|
-
t[p] = s[p];
|
48
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
49
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
50
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
51
|
-
t[p[i]] = s[p[i]];
|
52
|
-
}
|
53
|
-
return t;
|
54
|
-
}
|
55
|
-
|
56
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
57
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
58
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
59
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
60
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
61
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
62
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
63
|
-
});
|
64
|
-
}
|
65
|
-
|
66
|
-
function __generator(thisArg, body) {
|
67
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
68
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
69
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
70
|
-
function step(op) {
|
71
|
-
if (f) throw new TypeError("Generator is already executing.");
|
72
|
-
while (_) try {
|
73
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
74
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
75
|
-
switch (op[0]) {
|
76
|
-
case 0: case 1: t = op; break;
|
77
|
-
case 4: _.label++; return { value: op[1], done: false };
|
78
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
79
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
80
|
-
default:
|
81
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
82
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
83
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
84
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
85
|
-
if (t[2]) _.ops.pop();
|
86
|
-
_.trys.pop(); continue;
|
87
|
-
}
|
88
|
-
op = body.call(thisArg, _);
|
89
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
90
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
91
|
-
}
|
92
|
-
}
|
93
|
-
|
94
|
-
function __spreadArray(to, from, pack) {
|
95
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
96
|
-
if (ar || !(i in from)) {
|
97
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
98
|
-
ar[i] = from[i];
|
99
|
-
}
|
100
|
-
}
|
101
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
102
|
-
}
|
103
|
-
|
104
|
-
function __makeTemplateObject(cooked, raw) {
|
105
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
106
|
-
return cooked;
|
107
|
-
}
|
108
|
-
|
109
|
-
var getPartialMeterInfoSchema = function (valuesFields) {
|
110
|
-
var filteredFields = valuesFields
|
111
|
-
.filter(function (field) { return field.maxIntegerPart; })
|
112
|
-
.map(function (field) { return field.name; });
|
113
|
-
var valuesSchema = filteredFields.map(function (field) {
|
114
|
-
var _a;
|
115
|
-
return (_a = {},
|
116
|
-
_a[field] = yup
|
117
|
-
.number()
|
118
|
-
.min(0)
|
119
|
-
.required("This field is required")
|
120
|
-
.transform(function (value) { return (Number.isNaN(value) ? undefined : value); }),
|
121
|
-
_a);
|
122
|
-
});
|
123
|
-
return yup.object().shape(__assign({ number: yup.string().trim().required("This field is required") }, Object.assign.apply(Object, __spreadArray([{}], valuesSchema, false))));
|
124
|
-
};
|
125
|
-
var WaterMeterFieldsSchema = yup.object().shape({
|
126
|
-
number: yup.string().trim().required("This field is required"),
|
127
|
-
value: yup
|
128
|
-
.number()
|
129
|
-
.min(0)
|
130
|
-
.required("This field is required")
|
131
|
-
.transform(function (value) { return (Number.isNaN(value) ? undefined : value); }),
|
132
|
-
});
|
133
|
-
|
134
|
-
var getWaterMeterFields = function (meters, meter, withCheckValue, name, settings) {
|
135
|
-
var _a, _b;
|
136
|
-
var prefixName = name ? "".concat(name, ".") : "";
|
137
|
-
var meterOptions = meters.length
|
138
|
-
? meters.map(function (meterParams) { return ({
|
139
|
-
value: meterParams.number,
|
140
|
-
label: "".concat(_.capitalize(meterParams.type || ""), " | #").concat(meterParams.number),
|
141
|
-
}); })
|
142
|
-
: [
|
143
|
-
{
|
144
|
-
value: meter === null || meter === void 0 ? void 0 : meter.number,
|
145
|
-
label: "".concat(_.capitalize((meter === null || meter === void 0 ? void 0 : meter.type) || ""), " | #").concat(meter === null || meter === void 0 ? void 0 : meter.number),
|
146
|
-
},
|
147
|
-
];
|
148
|
-
return [
|
149
|
-
__assign({ label: "Meter", name: "".concat(prefixName, "number"), variant: "select", options: meterOptions, size: 12, isRequired: true, disabled: meterOptions.length === 1 }, settings === null || settings === void 0 ? void 0 : settings.meter),
|
150
|
-
__assign({ label: "Value", name: "".concat(prefixName, "value"), variant: "custom", CustomInput: NumberField, maxIntegerPart: 7, maxDecimalPart: 3, maxValue: ((_a = meter === null || meter === void 0 ? void 0 : meter.maxValue) === null || _a === void 0 ? void 0 : _a.value) && withCheckValue
|
151
|
-
? Number(meter.maxValue.value)
|
152
|
-
: null, warningMessage: "There are deviations in meter readings. It should be no more than", placeholder: (_b = meter === null || meter === void 0 ? void 0 : meter.values) === null || _b === void 0 ? void 0 : _b.value, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.value),
|
153
|
-
];
|
154
|
-
};
|
155
|
-
|
156
|
-
var inspectionsRequestBody = {
|
157
|
-
getPostBodyInitialInspection: function (inspection, roomsImages) {
|
158
|
-
return {
|
159
|
-
based_on: null,
|
160
|
-
date: (inspection.date || DateTime.now()).toISODate(),
|
161
|
-
inspection_type: "initial",
|
162
|
-
dropbox_link: inspection.dropboxLink,
|
163
|
-
photo_groups: roomsImages,
|
164
|
-
initial: this.getInitialInspectionFields(inspection),
|
165
|
-
};
|
166
|
-
},
|
167
|
-
getInitialInspectionFields: function (inspection) {
|
168
|
-
var _a, _b, _c;
|
169
|
-
return {
|
170
|
-
city: inspection.city.id,
|
171
|
-
address: inspection.apartment.address,
|
172
|
-
apartment_number: inspection.apartmentNumber || "",
|
173
|
-
post_index: inspection.zipCode,
|
174
|
-
floor: inspection.floor,
|
175
|
-
floor_count: inspection.floorCount,
|
176
|
-
room_type: inspection.typeOfObject,
|
177
|
-
num_entrance: inspection.entrance,
|
178
|
-
has_intercom: inspection.hasIntercom,
|
179
|
-
intercom_code: inspection.intercomCode,
|
180
|
-
has_gate: inspection.hasGate,
|
181
|
-
gate_code: inspection.gateCode,
|
182
|
-
area: inspection.area,
|
183
|
-
rooms_number: inspection.roomsNumber,
|
184
|
-
bedrooms_number: inspection.bedroomsNumber,
|
185
|
-
bathrooms_number: inspection.bathroomsNumber,
|
186
|
-
restrooms_number: inspection.restroomsNumber,
|
187
|
-
combined_bathrooms_number: inspection.combinedBathroomsNumber,
|
188
|
-
number_of_windows: inspection.numberOfWindows,
|
189
|
-
renovation_year: (_a = inspection.renovation) === null || _a === void 0 ? void 0 : _a.year,
|
190
|
-
renovation_type: (_b = inspection.renovation) === null || _b === void 0 ? void 0 : _b.type,
|
191
|
-
renovation_style: (_c = inspection.renovation) === null || _c === void 0 ? void 0 : _c.style,
|
192
|
-
wall_type: inspection.wallMaterial,
|
193
|
-
overlap_type: inspection.overlapType,
|
194
|
-
passenger_elevators_number: inspection.passengerElevatorsCount,
|
195
|
-
service_elevators_number: inspection.serviceElevatorsCount,
|
196
|
-
ceiling_height: inspection.ceilingHeight,
|
197
|
-
building_year: inspection.buildingYear,
|
198
|
-
serial_number: inspection.houseNumber,
|
199
|
-
type_gas: inspection.gasLeads,
|
200
|
-
hot_water: inspection.withHotWater,
|
201
|
-
type_houses: inspection.typeOfHouse,
|
202
|
-
parking_type: inspection.parkingType,
|
203
|
-
parking_number: inspection.parkingNumber,
|
204
|
-
rooms: inspection.rooms.map(function (room, index) { return ({
|
205
|
-
id: room.id,
|
206
|
-
room_type: room.type,
|
207
|
-
order_number: index,
|
208
|
-
}); }),
|
209
|
-
metro: inspection.metroStations.map(function (station) { return ({
|
210
|
-
name: station.name || "",
|
211
|
-
metro_station_id: station.id,
|
212
|
-
distance_walk_meters: station.walkDistance,
|
213
|
-
distance_car_kilometers: station.carDistance,
|
214
|
-
time_car_minutes: station.carTime,
|
215
|
-
}); }),
|
216
|
-
used_resources: {
|
217
|
-
electricity: inspection.availableResources.electricity,
|
218
|
-
water: inspection.availableResources.water,
|
219
|
-
gas: inspection.availableResources.gas,
|
220
|
-
heating: inspection.availableResources.heating,
|
221
|
-
},
|
222
|
-
};
|
223
|
-
},
|
224
|
-
getPostBodyRegularInspection: function (inspection, roomsImages) {
|
225
|
-
return {
|
226
|
-
date: (inspection.date || DateTime.now()).toISODate(),
|
227
|
-
inspection_type: "regular",
|
228
|
-
based_on: null,
|
229
|
-
dropbox_link: inspection.dropboxLink,
|
230
|
-
photo_groups: roomsImages,
|
231
|
-
regular: __assign(__assign({}, this.getInspectionFilling(inspection.fillingList)), this.getPartialInspectionMeters(inspection.meters)),
|
232
|
-
};
|
233
|
-
},
|
234
|
-
getPostBodyTransferInspection: function (inspection, roomsImages, contractFile) {
|
235
|
-
return {
|
236
|
-
date: (inspection.date || DateTime.now()).toISODate(),
|
237
|
-
inspection_type: "transfer",
|
238
|
-
based_on: null,
|
239
|
-
dropbox_link: inspection.dropboxLink,
|
240
|
-
photo_groups: roomsImages,
|
241
|
-
transfer: __assign(__assign({ contract_document: contractFile || undefined, transfer_type: inspection.transferType }, this.getInspectionFilling(inspection.fillingList)), this.getPartialInspectionMeters(inspection.meters)),
|
242
|
-
};
|
243
|
-
},
|
244
|
-
getInspectionFilling: function (fillingList) {
|
245
|
-
return {
|
246
|
-
filling: fillingList === null || fillingList === void 0 ? void 0 : fillingList.map(function (filling) { return ({
|
247
|
-
apartment_feature_id: filling.id,
|
248
|
-
is_absent: !filling.check,
|
249
|
-
}); }),
|
250
|
-
};
|
251
|
-
},
|
252
|
-
getPartialInspectionMeters: function (meters) {
|
253
|
-
var _this = this;
|
254
|
-
return {
|
255
|
-
meters: (meters === null || meters === void 0 ? void 0 : meters.map(function (meter, index) { return ({
|
256
|
-
id: meter.id,
|
257
|
-
resource_type: meter.resource,
|
258
|
-
meter_type: meter.type,
|
259
|
-
passport_number: meter.number,
|
260
|
-
photos: _this.getFilesParams(meter.images),
|
261
|
-
values: clearNotValidFields(_this.getInspectionMeterValues(meter)),
|
262
|
-
}); })) || [],
|
263
|
-
};
|
264
|
-
},
|
265
|
-
getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles, contractFile) {
|
266
|
-
var _this = this;
|
267
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
268
|
-
return {
|
269
|
-
date: (inspection.date || DateTime.now()).toISODate(),
|
270
|
-
inspection_type: "inventory",
|
271
|
-
based_on: null,
|
272
|
-
dropbox_link: inspection.dropboxLink,
|
273
|
-
photo_groups: roomsImages,
|
274
|
-
inventory: __assign({ contract_document: contractFile || undefined, allowed_children: inspection.withChildren, allowed_pets: inspection.withPets, allowed_smoking: inspection.withSmoking, 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
|
275
|
-
? getPhoneNumberFromPhoneParams(inspection.barrierPhone)
|
276
|
-
: null, concierge_phone: inspection.conciergePhone
|
277
|
-
? getPhoneNumberFromPhoneParams(inspection.conciergePhone)
|
278
|
-
: null, security_phone: inspection.securityPhone
|
279
|
-
? getPhoneNumberFromPhoneParams(inspection.securityPhone)
|
280
|
-
: null, video_surveillance_phone: inspection.videoControlPhone
|
281
|
-
? getPhoneNumberFromPhoneParams(inspection.videoControlPhone)
|
282
|
-
: null, home_phone: inspection.homePhone
|
283
|
-
? getPhoneNumberFromPhoneParams(inspection.homePhone)
|
284
|
-
: null, wifi_name: (_g = inspection.wifi) === null || _g === void 0 ? void 0 : _g.name, wifi_password: (_h = inspection.wifi) === null || _h === void 0 ? void 0 : _h.password, internet_provider_link: (_j = inspection.internetProvider) === null || _j === void 0 ? void 0 : _j.link, internet_provider_login: (_k = inspection.internetProvider) === null || _k === void 0 ? void 0 : _k.login, internet_provider_password: (_l = inspection.internetProvider) === null || _l === void 0 ? void 0 : _l.password, payer_code: inspection.payerCode, filling: inspection.fillingList.map(function (filling, index) {
|
285
|
-
var _a;
|
286
|
-
return ({
|
287
|
-
feature: ((_a = filling.tag) === null || _a === void 0 ? void 0 : _a.id) || 0,
|
288
|
-
description: filling.description,
|
289
|
-
model: filling.name,
|
290
|
-
serial_code: filling.serialNumber,
|
291
|
-
amount: filling.numberOfSubjects,
|
292
|
-
photos: _this.getFilesParams(filling.images),
|
293
|
-
instruction: fillingFiles[index],
|
294
|
-
});
|
295
|
-
}) }, this.getInventoryInspectionMeters(inspection.meters, metersFiles)),
|
296
|
-
};
|
297
|
-
},
|
298
|
-
getInventoryInspectionMeters: function (meters, metersFiles, metersImages) {
|
299
|
-
var _this = this;
|
300
|
-
return {
|
301
|
-
meters: (meters === null || meters === void 0 ? void 0 : meters.map(function (meter, index) { return (__assign(__assign({}, _this.getMeterCommonFields(meter)), { passport: metersFiles[index], values: clearNotValidFields(_this.getInspectionMeterValues(meter, "initialValue")), photos: metersImages
|
302
|
-
? metersImages[index]
|
303
|
-
: _this.getFilesParams(meter.images), no_tariff: meter.noTariff, auto_sending: meter.withAutoSending })); })) || [],
|
304
|
-
};
|
305
|
-
},
|
306
|
-
getInspectionMeterValues: function (meter, fieldName) {
|
307
|
-
var _a;
|
308
|
-
if (meter.resource === "electricity") {
|
309
|
-
var prefix = fieldName || "";
|
310
|
-
var t1 = meter["".concat(prefix, "T1")];
|
311
|
-
var t2 = meter["".concat(prefix, "T2")];
|
312
|
-
var t3 = meter["".concat(prefix, "T3")];
|
313
|
-
return {
|
314
|
-
T1: t1 ? Number(t1) : t1,
|
315
|
-
T2: t2 ? Number(t2) : t2,
|
316
|
-
T3: t3 ? Number(t3) : t3,
|
317
|
-
};
|
318
|
-
}
|
319
|
-
var valueField = (fieldName || "value");
|
320
|
-
if (meter.resource === "water") {
|
321
|
-
if (meter.type === "cold") {
|
322
|
-
var cold = meter[valueField];
|
323
|
-
return { cold: cold ? Number(cold) : cold };
|
324
|
-
}
|
325
|
-
var hot = meter[valueField];
|
326
|
-
return { hot: hot ? Number(hot) : hot };
|
327
|
-
}
|
328
|
-
var value = meter[valueField];
|
329
|
-
return _a = {},
|
330
|
-
_a[meter.resource] = value ? Number(value) : value,
|
331
|
-
_a;
|
332
|
-
},
|
333
|
-
getMeterCommonFields: function (meter) {
|
334
|
-
var _a;
|
335
|
-
return {
|
336
|
-
id: meter.id,
|
337
|
-
meter_type: meter.type,
|
338
|
-
passport_number: meter.number,
|
339
|
-
resource_type: meter.resource,
|
340
|
-
activation_date: ((_a = meter.startDate) === null || _a === void 0 ? void 0 : _a.toISODate()) || null,
|
341
|
-
};
|
342
|
-
},
|
343
|
-
getMeterValues: function (initialValue, lastValue) {
|
344
|
-
return clearNotValidFields({
|
345
|
-
initial_value: initialValue,
|
346
|
-
last_value: lastValue,
|
347
|
-
});
|
348
|
-
},
|
349
|
-
getFilesParams: function (files) {
|
350
|
-
return ((files === null || files === void 0 ? void 0 : files.map(function (file) { return file.uploadedData; }).filter(function (data) { return data; })) || []);
|
351
|
-
},
|
352
|
-
};
|
353
|
-
|
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
|
-
},
|
386
|
-
getInspectionTypes: function (apartmentId) {
|
387
|
-
return __awaiter(this, void 0, void 0, function () {
|
388
|
-
var _a, err, res;
|
389
|
-
return __generator(this, function (_b) {
|
390
|
-
switch (_b.label) {
|
391
|
-
case 0: return [4 /*yield*/, to(requests.get("/apartments/".concat(apartmentId, "/inspection-types")))];
|
392
|
-
case 1:
|
393
|
-
_a = _b.sent(), err = _a[0], res = _a[1];
|
394
|
-
if (err)
|
395
|
-
return [2 /*return*/, [err, undefined]];
|
396
|
-
return [2 /*return*/, [null, res === null || res === void 0 ? void 0 : res.inspection_types]];
|
397
|
-
}
|
398
|
-
});
|
399
|
-
});
|
400
|
-
},
|
401
|
-
getTransferTypes: function (apartmentId) {
|
402
|
-
return __awaiter(this, void 0, void 0, function () {
|
403
|
-
var _a, err, res;
|
404
|
-
return __generator(this, function (_b) {
|
405
|
-
switch (_b.label) {
|
406
|
-
case 0: return [4 /*yield*/, to(requests.get("/apartments/".concat(apartmentId, "/transfer-inspection-types")))];
|
407
|
-
case 1:
|
408
|
-
_a = _b.sent(), err = _a[0], res = _a[1];
|
409
|
-
if (err)
|
410
|
-
return [2 /*return*/, [err, undefined]];
|
411
|
-
return [2 /*return*/, [null, res === null || res === void 0 ? void 0 : res.transfer_inspection_types]];
|
412
|
-
}
|
413
|
-
});
|
414
|
-
});
|
415
|
-
},
|
416
|
-
createInspection: function (apartmentId, body, loader) {
|
417
|
-
var _a;
|
418
|
-
return __awaiter(this, void 0, void 0, function () {
|
419
|
-
var response;
|
420
|
-
return __generator(this, function (_b) {
|
421
|
-
switch (_b.label) {
|
422
|
-
case 0: return [4 /*yield*/, to(requests.post("/apartments/".concat(apartmentId, "/inspections"), body))];
|
423
|
-
case 1:
|
424
|
-
response = _b.sent();
|
425
|
-
resHandler(response, loader);
|
426
|
-
return [2 /*return*/, (_a = response[1]) === null || _a === void 0 ? void 0 : _a.id];
|
427
|
-
}
|
428
|
-
});
|
429
|
-
});
|
430
|
-
},
|
431
|
-
createInitialInspection: function (data, apartmentId, loader) {
|
432
|
-
return __awaiter(this, void 0, void 0, function () {
|
433
|
-
var _this = this;
|
434
|
-
return __generator(this, function (_a) {
|
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
|
-
}); })];
|
442
|
-
});
|
443
|
-
});
|
444
|
-
},
|
445
|
-
createRegularInspection: function (data, apartmentId, loader) {
|
446
|
-
return __awaiter(this, void 0, void 0, function () {
|
447
|
-
var _this = this;
|
448
|
-
return __generator(this, function (_a) {
|
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
|
-
}); })];
|
456
|
-
});
|
457
|
-
});
|
458
|
-
},
|
459
|
-
createTransferInspection: function (data, apartmentId, loader) {
|
460
|
-
return __awaiter(this, void 0, void 0, function () {
|
461
|
-
var _this = this;
|
462
|
-
return __generator(this, function (_a) {
|
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
|
-
}); })];
|
476
|
-
});
|
477
|
-
});
|
478
|
-
},
|
479
|
-
createInventoryInspection: function (data, apartmentId, loader) {
|
480
|
-
return __awaiter(this, void 0, void 0, function () {
|
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
|
-
}); })];
|
503
|
-
});
|
504
|
-
});
|
505
|
-
},
|
506
|
-
getRoomParams: function (rooms) {
|
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
|
-
})) || []);
|
519
|
-
},
|
520
|
-
};
|
521
|
-
|
522
|
-
var averageWalkMetersPerHour = 5000;
|
523
|
-
var minutesPerHour = 60;
|
524
|
-
var apartmentFields = {
|
525
|
-
getApartmentDescriptionInfo: function (apartment) {
|
526
|
-
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));
|
527
|
-
},
|
528
|
-
getApartmentMainInfo: function (apartment) {
|
529
|
-
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 });
|
530
|
-
},
|
531
|
-
getApartmentSecurityInfo: function (apartment) {
|
532
|
-
var _a, _b, _c, _d, _e, _f;
|
533
|
-
return {
|
534
|
-
hasIntercom: (_a = apartment.has_intercom) !== null && _a !== void 0 ? _a : null,
|
535
|
-
hasGate: (_b = apartment.has_gate) !== null && _b !== void 0 ? _b : null,
|
536
|
-
hasBarrier: (_c = apartment.has_barrier) !== null && _c !== void 0 ? _c : null,
|
537
|
-
hasSecurity: (_d = apartment.has_security) !== null && _d !== void 0 ? _d : null,
|
538
|
-
hasConcierge: (_e = apartment.has_concierge) !== null && _e !== void 0 ? _e : null,
|
539
|
-
hasVideoControl: (_f = apartment.has_video_surveillance) !== null && _f !== void 0 ? _f : null,
|
540
|
-
intercomCode: apartment.intercom_code || "",
|
541
|
-
gateCode: apartment.gate_code || "",
|
542
|
-
barrierPhone: apartment.barrier_phone
|
543
|
-
? getPhoneParamsFromString(apartment.barrier_phone)
|
544
|
-
: null,
|
545
|
-
conciergePhone: apartment.concierge_phone
|
546
|
-
? getPhoneParamsFromString(apartment.concierge_phone)
|
547
|
-
: null,
|
548
|
-
securityPhone: apartment.security_phone
|
549
|
-
? getPhoneParamsFromString(apartment.security_phone)
|
550
|
-
: null,
|
551
|
-
videoControlPhone: apartment.video_surveillance_phone
|
552
|
-
? getPhoneParamsFromString(apartment.video_surveillance_phone)
|
553
|
-
: null,
|
554
|
-
};
|
555
|
-
},
|
556
|
-
getApartmentDetailInfo: function (apartment) {
|
557
|
-
var _a;
|
558
|
-
return {
|
559
|
-
area: apartment.area,
|
560
|
-
livingArea: apartment.living_area,
|
561
|
-
kitchenArea: apartment.kitchen_area,
|
562
|
-
roomsNumber: apartment.rooms_number,
|
563
|
-
bedroomsNumber: apartment.bedrooms_number,
|
564
|
-
bathroomsNumber: apartment.bathrooms_number,
|
565
|
-
restroomsNumber: apartment.restrooms_number,
|
566
|
-
combinedBathroomsNumber: apartment.combined_bathrooms_number,
|
567
|
-
ceilingHeight: apartment.ceiling_height,
|
568
|
-
numberOfWindows: apartment.number_of_windows,
|
569
|
-
renovation: {
|
570
|
-
year: apartment.renovation_year || null,
|
571
|
-
type: apartment.renovation_type || null,
|
572
|
-
style: apartment.renovation_style || null,
|
573
|
-
},
|
574
|
-
rooms: ((_a = apartment.rooms) === null || _a === void 0 ? void 0 : _a.map(function (room) { return ({
|
575
|
-
id: room.id,
|
576
|
-
area: room.area || null,
|
577
|
-
type: room.room_type || null,
|
578
|
-
}); })) || [],
|
579
|
-
};
|
580
|
-
},
|
581
|
-
getApartmentTelecommunicationInfo: function (apartment) {
|
582
|
-
return {
|
583
|
-
homePhone: apartment.home_phone
|
584
|
-
? getPhoneParamsFromString(apartment.home_phone)
|
585
|
-
: null,
|
586
|
-
wifi: {
|
587
|
-
name: apartment.wifi_name,
|
588
|
-
password: apartment.wifi_password,
|
589
|
-
},
|
590
|
-
internetProvider: {
|
591
|
-
link: apartment.internet_provider_link,
|
592
|
-
login: apartment.internet_provider_login,
|
593
|
-
password: apartment.internet_provider_password,
|
594
|
-
},
|
595
|
-
tvType: apartment.tv_type,
|
596
|
-
};
|
597
|
-
},
|
598
|
-
getApartmentHouseInfo: function (apartment) {
|
599
|
-
return {
|
600
|
-
typeOfHouse: apartment.type_houses,
|
601
|
-
buildingYear: apartment.building_year,
|
602
|
-
houseNumber: apartment.serial_number,
|
603
|
-
wallMaterial: apartment.wall_type,
|
604
|
-
overlapType: apartment.overlap_type,
|
605
|
-
parkingType: apartment.parking_type,
|
606
|
-
parkingNumber: apartment.parking_number,
|
607
|
-
passengerElevatorsCount: apartment.passenger_elevators_number
|
608
|
-
? Number(apartment.passenger_elevators_number)
|
609
|
-
: null,
|
610
|
-
serviceElevatorsCount: apartment.service_elevators_number
|
611
|
-
? Number(apartment.service_elevators_number)
|
612
|
-
: null,
|
613
|
-
gasLeads: apartment.type_gas,
|
614
|
-
withHotWater: apartment.hot_water,
|
615
|
-
};
|
616
|
-
},
|
617
|
-
getMaxMetersParams: function (apartment) {
|
618
|
-
return {
|
619
|
-
maxMeters: {
|
620
|
-
water: apartment.max_water_counters,
|
621
|
-
electricity: apartment.max_electricity_counters,
|
622
|
-
gas: apartment.max_gas_counters,
|
623
|
-
heating: apartment.max_heating_counters,
|
624
|
-
},
|
625
|
-
};
|
626
|
-
},
|
627
|
-
getGeolocationParams: function (geolocation) {
|
628
|
-
return geolocation
|
629
|
-
? {
|
630
|
-
lat: Number(geolocation.lat),
|
631
|
-
lng: Number(geolocation.lon),
|
632
|
-
}
|
633
|
-
: null;
|
634
|
-
},
|
635
|
-
getObjectRoomsImages: function (images) {
|
636
|
-
return images.map(function (imageBlock) { return ({
|
637
|
-
id: imageBlock.id,
|
638
|
-
type: imageBlock.purpose,
|
639
|
-
comment: imageBlock.comment,
|
640
|
-
images: imageBlock.photos.map(function (image) {
|
641
|
-
return ImageStore.initFromImageModel(image);
|
642
|
-
}),
|
643
|
-
roomNumber: typeof imageBlock.room_order_number === "number"
|
644
|
-
? imageBlock.room_order_number + 1
|
645
|
-
: 0,
|
646
|
-
}); });
|
647
|
-
},
|
648
|
-
getInspectionFillingParams: function (filling, withChecking) {
|
649
|
-
var _a;
|
650
|
-
return __assign({ id: filling.id, name: filling.description || "", tag: {
|
651
|
-
id: filling.feature.id,
|
652
|
-
name: filling.feature.name,
|
653
|
-
}, images: (_a = filling.photos) === null || _a === void 0 ? void 0 : _a.map(function (image) {
|
654
|
-
return ImageStore.initFromImageModel(image);
|
655
|
-
}), serialNumber: filling.serial_code, numberOfSubjects: Number(filling.amount), instruction: filling.instruction
|
656
|
-
? FileStore.initFromDocumentModel(filling.instruction)
|
657
|
-
: null, type: matchesAPIFillingTypes[filling.feature.feature_type] }, (withChecking && filling.feature.feature_type === "appliance"
|
658
|
-
? {
|
659
|
-
check: !filling.is_absent,
|
660
|
-
wasMissing: filling.previously_absent,
|
661
|
-
}
|
662
|
-
: {}));
|
663
|
-
},
|
664
|
-
getApartmentDescriptionWithMetro: function (apartment) {
|
665
|
-
return __assign(__assign({}, this.getApartmentDescriptionInfo(apartment)), { metroStations: this.getMetroStationsParams(apartment === null || apartment === void 0 ? void 0 : apartment.metro_stations) });
|
666
|
-
},
|
667
|
-
getMetroStationsParams: function (metroStations) {
|
668
|
-
return ((metroStations === null || metroStations === void 0 ? void 0 : metroStations.map(function (metroStation) { return ({
|
669
|
-
id: metroStation.metro_station_id,
|
670
|
-
name: metroStation.name,
|
671
|
-
walkDistance: metroStation.distance_walk_meters,
|
672
|
-
carDistance: Number(metroStation.distance_car_kilometers),
|
673
|
-
carTime: metroStation.time_car_minutes,
|
674
|
-
walkTime: Math.round(metroStation.distance_walk_meters /
|
675
|
-
(averageWalkMetersPerHour / minutesPerHour)),
|
676
|
-
}); })) || []);
|
677
|
-
},
|
678
|
-
getMeterValues: function (meter, resource, fieldName) {
|
679
|
-
var _a, _b, _c, _d, _e, _f;
|
680
|
-
if (resource === "electricity") {
|
681
|
-
var prefix = fieldName || "";
|
682
|
-
return __assign(__assign((_a = {}, _a["".concat(prefix, "T1")] = Number(meter.values.T1), _a), (meter.meter_type !== "T1" && (_b = {},
|
683
|
-
_b["".concat(prefix, "T2")] = Number(meter.values.T2),
|
684
|
-
_b))), (meter.meter_type === "T3" && (_c = {},
|
685
|
-
_c["".concat(prefix, "T3")] = Number(meter.values.T3),
|
686
|
-
_c)));
|
687
|
-
}
|
688
|
-
var valueField = fieldName || "value";
|
689
|
-
if (resource === "water") {
|
690
|
-
if (meter.meter_type === "cold") {
|
691
|
-
return _d = {}, _d["".concat(valueField)] = Number(meter.values.cold), _d;
|
692
|
-
}
|
693
|
-
return _e = {}, _e["".concat(valueField)] = Number(meter.values.hot), _e;
|
694
|
-
}
|
695
|
-
return _f = {},
|
696
|
-
_f["".concat(valueField)] = Number(meter.values[resource]),
|
697
|
-
_f;
|
698
|
-
},
|
699
|
-
getTransferMetersInfo: function (meters) {
|
700
|
-
var _this = this;
|
701
|
-
return {
|
702
|
-
meters: meters.map(function (meter) {
|
703
|
-
var _a;
|
704
|
-
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 ImageStore.initFromImageModel(photo); })) ||
|
705
|
-
[], values: _this.getMeterValues(meter, meter.resource_type) }, _this.getMeterValues(meter, meter.resource_type)));
|
706
|
-
}),
|
707
|
-
};
|
708
|
-
},
|
709
|
-
getApartmentPaymentInfo: function (apartment) {
|
710
|
-
return {
|
711
|
-
payerCode: apartment.payer_code,
|
712
|
-
communalServicesAccount: apartment.financial_personal_account,
|
713
|
-
managementCompany: apartment.administrative_company
|
714
|
-
? __assign(__assign({}, apartment.administrative_company), { operatingAccount: apartment.payer_code }) : null,
|
715
|
-
};
|
716
|
-
},
|
717
|
-
getInspectionPaymentInfo: function (inspection) {
|
718
|
-
return __assign(__assign({}, this.getApartmentPaymentInfo(inspection)), { countryOfResidence: inspection.country_of_residence, taxesType: inspection.tax_type });
|
719
|
-
},
|
720
|
-
getMeterInfo: function (meter, resource) {
|
721
|
-
var _a;
|
722
|
-
return {
|
723
|
-
id: meter.id,
|
724
|
-
type: meter.meter_type,
|
725
|
-
number: meter.passport_number,
|
726
|
-
startDate: meter.activation_date
|
727
|
-
? DateTime.fromISO(meter.activation_date)
|
728
|
-
: null,
|
729
|
-
company: meter.company,
|
730
|
-
operationalAccountNumber: meter.operating_account,
|
731
|
-
resource: resource,
|
732
|
-
tariff: meter.tariff
|
733
|
-
? {
|
734
|
-
id: meter.tariff.id,
|
735
|
-
name: meter.tariff.code_name,
|
736
|
-
}
|
737
|
-
: null,
|
738
|
-
passportFile: meter.passport
|
739
|
-
? FileStore.initFromFileModel(meter.passport)
|
740
|
-
: null,
|
741
|
-
images: ((_a = meter.photos) === null || _a === void 0 ? void 0 : _a.map(function (photo) { return ImageStore.initFromImageModel(photo); })) ||
|
742
|
-
[],
|
743
|
-
};
|
744
|
-
},
|
745
|
-
getInventoryMetersInfo: function (inspection) {
|
746
|
-
var _this = this;
|
747
|
-
return {
|
748
|
-
meters: inspection.meters.map(function (meter) { return (__assign(__assign({}, _this.getMeterInfo(meter, meter.resource_type)), _this.getMeterValues(meter, meter.resource_type, "initialValue"))); }),
|
749
|
-
};
|
750
|
-
},
|
751
|
-
};
|
752
|
-
|
753
|
-
var getBasicApartmentInfoFields = function (handlePlaceSelect, settings) { return [
|
754
|
-
__assign({ name: "country", label: "Country", variant: "custom", CustomInput: CountryAutocomplete, size: 12 }, settings === null || settings === void 0 ? void 0 : settings.country),
|
755
|
-
__assign({ name: "region", label: "Region", variant: "custom", CustomInput: RegionAutocomplete }, settings === null || settings === void 0 ? void 0 : settings.region),
|
756
|
-
__assign({ name: "city", label: "City", variant: "custom", CustomInput: CityAutocomplete, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.city),
|
757
|
-
__assign({ name: "apartment", variant: "custom", CustomInput: InputWithAddressAutocomplete, handlePlaceSelect: handlePlaceSelect, size: 12, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.apartment),
|
758
|
-
__assign({ label: "Apartment", name: "apartmentNumber", "data-testid": "apartment_number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.apartmentNumber),
|
759
|
-
__assign({ label: "Zip code", name: "zipCode" }, settings === null || settings === void 0 ? void 0 : settings.zipCode),
|
760
|
-
]; };
|
761
|
-
|
762
|
-
var BasicApartmentInfoFieldsSchema = {
|
763
|
-
apartment: yup.object({
|
764
|
-
address: yup.string().trim().required("This field is required"),
|
765
|
-
}),
|
766
|
-
apartmentNumber: yup.string().required("This field is required"),
|
767
|
-
city: yup.object({
|
768
|
-
name: yup.string().required("This field is required"),
|
769
|
-
}),
|
770
|
-
metroStations: yup.array().of(yup.object({
|
771
|
-
id: yup
|
772
|
-
.number()
|
773
|
-
.transform(function (value) { return (Number.isNaN(value) ? undefined : value); }),
|
774
|
-
name: yup
|
775
|
-
.string()
|
776
|
-
.required(defaultRequiredMessage)
|
777
|
-
.test("check-id", "Please select an metro station from the dropdown", function (value) {
|
778
|
-
return !!this.parent.id;
|
779
|
-
}),
|
780
|
-
walkDistance: yup.string().required(defaultRequiredMessage),
|
781
|
-
carDistance: yup.string().required(defaultRequiredMessage),
|
782
|
-
carTime: yup.string().required(defaultRequiredMessage),
|
783
|
-
})),
|
784
|
-
};
|
785
|
-
var BasicApartmentInfoStepSchema = yup.object(BasicApartmentInfoFieldsSchema);
|
786
|
-
|
787
|
-
var getHouseInfoStep = function (settings) { return [
|
788
|
-
__assign({ name: "typeOfHouse", label: "Type houses", variant: "select", options: HouseTypesValues, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.typeOfHouse),
|
789
|
-
__assign({ name: "houseNumber", label: "House series" }, settings === null || settings === void 0 ? void 0 : settings.houseNumber),
|
790
|
-
__assign({ name: "wallMaterial", label: "Wall material", variant: "select", options: WallMaterialsValues, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.wallMaterial),
|
791
|
-
__assign({ name: "overlapType", label: "Overlap type", variant: "select", options: SlabsTypesValues, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.overlapType),
|
792
|
-
__assign({ name: "gasLeads", label: "Gas", variant: "select", options: GasTypesValues, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.gasLeads),
|
793
|
-
__assign({ name: "withHotWater", label: "Hot water", variant: "select", options: BooleanValues, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.withHotWater),
|
794
|
-
__assign({ name: "passengerElevatorsCount", label: "Passenger elevators", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.passengerElevatorsCount),
|
795
|
-
__assign({ name: "serviceElevatorsCount", label: "Service elevators", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.serviceElevatorsCount),
|
796
|
-
__assign({ name: "buildingYear", label: "Builded", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.buildingYear),
|
797
|
-
]; };
|
798
|
-
|
799
|
-
var HouseInfoFieldsSchema = {
|
800
|
-
passengerElevatorsCount: positiveNumberSchema,
|
801
|
-
serviceElevatorsCount: positiveNumberSchema,
|
802
|
-
typeOfHouse: yup.string().required(defaultRequiredMessage),
|
803
|
-
buildingYear: yup.string().required(defaultRequiredMessage),
|
804
|
-
wallMaterial: yup.string().required(defaultRequiredMessage),
|
805
|
-
overlapType: yup.string().required(defaultRequiredMessage),
|
806
|
-
gasLeads: yup.string().required(defaultRequiredMessage),
|
807
|
-
withHotWater: yup.boolean().required(defaultRequiredMessage),
|
808
|
-
};
|
809
|
-
var HouseInfoStepSchema = yup.object(HouseInfoFieldsSchema);
|
810
|
-
|
811
|
-
var inputProps = {
|
812
|
-
step: 0.01,
|
813
|
-
};
|
814
|
-
var getDetailApartmentInfoFields = function (roomsCount, bedroomsCount, settings) {
|
815
|
-
var _a, _b;
|
816
|
-
return __spreadArray(__spreadArray([
|
817
|
-
__assign(__assign({ label: "Total area", name: "area", type: "number", isRequired: true }, inputProps), settings === null || settings === void 0 ? void 0 : settings.area)
|
818
|
-
], (roomsCount
|
819
|
-
? new Array(Number(roomsCount))
|
820
|
-
.fill(0)
|
821
|
-
.map(function (_, key) {
|
822
|
-
var _a;
|
823
|
-
var label = bedroomsCount && key < bedroomsCount
|
824
|
-
? "Bedroom ".concat(key + 1)
|
825
|
-
: "Room ".concat(key + 1);
|
826
|
-
var settingsKey = bedroomsCount && key < bedroomsCount ? "bedrooms" : "rooms";
|
827
|
-
return [
|
828
|
-
__assign({ name: "rooms.".concat(key, ".type"), label: "".concat(label, " type"), variant: "select", options: RoomTypeValues, isRequired: true }, ((settings === null || settings === void 0 ? void 0 : settings[settingsKey])
|
829
|
-
? (_a = settings[settingsKey](key)) === null || _a === void 0 ? void 0 : _a.type
|
830
|
-
: {})),
|
831
|
-
];
|
832
|
-
})
|
833
|
-
.flat()
|
834
|
-
: []), true), [
|
835
|
-
__assign(__assign({ name: "ceilingHeight", label: "Ceiling height", type: "number", cornerLabel: "m.", isRequired: true }, inputProps), settings === null || settings === void 0 ? void 0 : settings.ceilingHeight),
|
836
|
-
__assign({ name: "numberOfWindows", label: "Windows", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.numberOfWindows),
|
837
|
-
__assign({ name: "renovation.year", label: "Year of last renovation", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.renovation.year),
|
838
|
-
__assign({ name: "renovation.type", label: "Type of renovation", variant: "select", options: RenovationTypeValues, isRequired: true }, (_a = settings === null || settings === void 0 ? void 0 : settings.renovation) === null || _a === void 0 ? void 0 : _a.type),
|
839
|
-
__assign({ name: "renovation.style", label: "Renovation style", variant: "select", options: RenovationStyleValues, isRequired: true }, (_b = settings === null || settings === void 0 ? void 0 : settings.renovation) === null || _b === void 0 ? void 0 : _b.style),
|
840
|
-
], false);
|
841
|
-
};
|
842
|
-
|
843
|
-
var DetailApartmentInfoFieldsSchema = {
|
844
|
-
area: yup.number().positive().required("This field is required"),
|
845
|
-
rooms: yup.array().of(yup.object({
|
846
|
-
type: yup.string().required("This field is required"),
|
847
|
-
})),
|
848
|
-
numberOfWindows: yup.number().min(0).required("This field is required"),
|
849
|
-
renovation: yup.object({
|
850
|
-
year: yup.number().positive().required("This field is required"),
|
851
|
-
type: yup.string().required("This field is required"),
|
852
|
-
style: yup.string().required("This field is required"),
|
853
|
-
}),
|
854
|
-
ceilingHeight: positiveNumberSchema,
|
855
|
-
};
|
856
|
-
var DetailApartmentInfoStepSchema = yup.object(DetailApartmentInfoFieldsSchema);
|
857
|
-
|
858
|
-
var getRoomsApartmentInfoFields = function (roomsCount, settings) { return [
|
859
|
-
__assign({ label: "Floor", name: "floor", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.floor),
|
860
|
-
__assign({ label: "Floors", name: "floorCount", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.floorCount),
|
861
|
-
__assign({ label: "Rooms", name: "roomsNumber", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.roomsNumber),
|
862
|
-
__assign({ label: "Bedrooms", name: "bedroomsNumber", type: "number", isRequired: true, disabled: roomsCount === 0 || roomsCount === "0" }, settings === null || settings === void 0 ? void 0 : settings.bedroomsNumber),
|
863
|
-
__assign({ label: "Bathrooms", name: "bathroomsNumber", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.bathroomsNumber),
|
864
|
-
__assign({ label: "Restrooms", name: "restroomsNumber", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.restroomsNumber),
|
865
|
-
__assign({ label: "Combined bathroom", name: "combinedBathroomsNumber", type: "number", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.combinedBathroomsNumber),
|
866
|
-
]; };
|
867
|
-
|
868
|
-
var RoomsApartmentInfoFieldsSchema = {
|
869
|
-
floor: yup
|
870
|
-
.number()
|
871
|
-
.integer()
|
872
|
-
.min(0)
|
873
|
-
.test("is less than floorCount", "Too much", function (value) {
|
874
|
-
return value <= this.parent.floorCount;
|
875
|
-
}),
|
876
|
-
floorCount: yup
|
877
|
-
.number()
|
878
|
-
.integer()
|
879
|
-
.positive()
|
880
|
-
.required("This field is required"),
|
881
|
-
roomsNumber: yup.number().integer().min(0).required("This field is required"),
|
882
|
-
bedroomsNumber: yup
|
883
|
-
.number()
|
884
|
-
.integer()
|
885
|
-
.min(0)
|
886
|
-
.required("This field is required"),
|
887
|
-
bathroomsNumber: yup
|
888
|
-
.number()
|
889
|
-
.integer()
|
890
|
-
.min(0)
|
891
|
-
.required("This field is required"),
|
892
|
-
restroomsNumber: yup
|
893
|
-
.number()
|
894
|
-
.integer()
|
895
|
-
.min(0)
|
896
|
-
.required("This field is required"),
|
897
|
-
combinedBathroomsNumber: yup
|
898
|
-
.number()
|
899
|
-
.integer()
|
900
|
-
.min(0)
|
901
|
-
.required("This field is required"),
|
902
|
-
};
|
903
|
-
var RoomsApartmentInfoStepSchema = yup.object(RoomsApartmentInfoFieldsSchema);
|
904
|
-
|
905
|
-
var getSecurityApartmentInfoFields = function (settings) { return [
|
906
|
-
__assign({ label: "Object type", name: "typeOfObject", variant: "select", options: RoomTypesValues, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.typeOfObject),
|
907
|
-
__assign({ label: "Entrance", name: "entrance", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.entrance),
|
908
|
-
__assign({ name: "hasIntercom", label: "Intercom", variant: "select", options: BooleanValues, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.hasIntercom),
|
909
|
-
__assign({ name: "intercomCode", label: "Intercom code", variant: "custom", CustomInput: DependentInput, dependentInputName: "hasIntercom" }, settings === null || settings === void 0 ? void 0 : settings.intercomCode),
|
910
|
-
__assign({ name: "hasGate", label: "Gate", variant: "select", options: BooleanValues, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.hasGate),
|
911
|
-
__assign({ name: "gateCode", label: "Gate code", variant: "custom", CustomInput: DependentInput, dependentInputName: "hasGate" }, settings === null || settings === void 0 ? void 0 : settings.gateCode),
|
912
|
-
__assign({ name: "parkingType", label: "Parking", variant: "select", options: ParkingTypesValues }, settings === null || settings === void 0 ? void 0 : settings.parkingType),
|
913
|
-
__assign({ name: "parkingNumber", label: "Parking number", variant: "custom", CustomInput: DependentInput, dependentInputName: "parkingType" }, settings === null || settings === void 0 ? void 0 : settings.parkingNumber),
|
914
|
-
]; };
|
915
|
-
|
916
|
-
var SecurityApartmentInfoFieldsSchema = {
|
917
|
-
typeOfObject: yup.string().required("This field is required"),
|
918
|
-
entrance: yup.string().required("This field is required"),
|
919
|
-
hasIntercom: yup.string().required("This field is required"),
|
920
|
-
intercomCode: fieldWithConditionSchema("hasIntercom"),
|
921
|
-
hasGate: yup.string().required("This field is required"),
|
922
|
-
gateCode: fieldWithConditionSchema("hasGate"),
|
923
|
-
};
|
924
|
-
var SecurityApartmentInfoStepSchema = yup.object(SecurityApartmentInfoFieldsSchema);
|
925
|
-
|
926
|
-
var getAvailableResourcesFields = function (settings) { return [
|
927
|
-
__assign({ label: "Water", name: "availableResources.water", variant: "custom", CustomInput: BigCheckbox }, settings === null || settings === void 0 ? void 0 : settings.water),
|
928
|
-
__assign({ label: "Electricity", name: "availableResources.electricity", variant: "custom", CustomInput: BigCheckbox }, settings === null || settings === void 0 ? void 0 : settings.electricity),
|
929
|
-
__assign({ label: "Gas", name: "availableResources.gas", variant: "custom", CustomInput: BigCheckbox }, settings === null || settings === void 0 ? void 0 : settings.gas),
|
930
|
-
__assign({ label: "Heating", name: "availableResources.heating", variant: "custom", CustomInput: BigCheckbox }, settings === null || settings === void 0 ? void 0 : settings.heating),
|
931
|
-
]; };
|
932
|
-
|
933
|
-
var checkboxLabelProps = {
|
934
|
-
size: "s",
|
935
|
-
};
|
936
|
-
var getAdditionalInfoStepFields = function (settings) { return __spreadArray([
|
937
|
-
__assign({ label: "Pets", name: "withPets", variant: "custom", CustomInput: CheckboxWithController, labelProps: checkboxLabelProps }, settings === null || settings === void 0 ? void 0 : settings.withPets),
|
938
|
-
__assign({ label: "Children", name: "withChildren", variant: "custom", CustomInput: CheckboxWithController, labelProps: checkboxLabelProps }, settings === null || settings === void 0 ? void 0 : settings.withChildren),
|
939
|
-
__assign({ label: "Smoking", name: "withSmoking", variant: "custom", CustomInput: CheckboxWithController, labelProps: checkboxLabelProps }, settings === null || settings === void 0 ? void 0 : settings.withSmoking),
|
940
|
-
__assign({ isTextArea: true, placeholder: "other terms", name: "additionalTerms" }, settings === null || settings === void 0 ? void 0 : settings.additionalTerms)
|
941
|
-
], getApartmentPaymentFields(settings), true); };
|
942
|
-
|
943
|
-
var AdditionalInfoFieldsSchema = {
|
944
|
-
taxesType: yup.string().required(defaultRequiredMessage),
|
945
|
-
countryOfResidence: yup.object({
|
946
|
-
name: yup.string().required(defaultRequiredMessage),
|
947
|
-
}),
|
948
|
-
company: yup.object({
|
949
|
-
name: yup.string().required(defaultRequiredMessage),
|
950
|
-
}),
|
951
|
-
};
|
952
|
-
var AdditionalInfoStepSchema = yup.object(AdditionalInfoFieldsSchema);
|
953
|
-
|
954
|
-
var getHouseServicesInfoStep = function (settings) { return [
|
955
|
-
__assign({ name: "hasBarrier", label: "Barrier", variant: "select", options: BooleanValues, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.hasBarrier),
|
956
|
-
__assign({ name: "barrierPhone", label: "Barrier code", variant: "custom", CustomInput: DependentInput, dependentInputName: "hasBarrier", Input: InputPhoneWithForm }, settings === null || settings === void 0 ? void 0 : settings.barrierPhone),
|
957
|
-
__assign({ name: "hasConcierge", label: "Concierge", variant: "select", options: BooleanValues, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.hasConcierge),
|
958
|
-
__assign({ name: "conciergePhone", label: "Concierge", variant: "custom", CustomInput: DependentInput, dependentInputName: "hasConcierge", Input: InputPhoneWithForm }, settings === null || settings === void 0 ? void 0 : settings.conciergePhone),
|
959
|
-
__assign({ name: "hasSecurity", label: "Security", variant: "select", options: BooleanValues, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.hasSecurity),
|
960
|
-
__assign({ name: "securityPhone", label: "Security", variant: "custom", CustomInput: DependentInput, dependentInputName: "hasSecurity", Input: InputPhoneWithForm }, settings === null || settings === void 0 ? void 0 : settings.securityPhone),
|
961
|
-
__assign({ name: "hasVideoControl", label: "Video surveillance", variant: "select", options: BooleanValues, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.hasVideoControl),
|
962
|
-
__assign({ name: "videoControlPhone", label: "Video surveillance", variant: "custom", CustomInput: DependentInput, dependentInputName: "hasVideoControl", Input: InputPhoneWithForm }, settings === null || settings === void 0 ? void 0 : settings.videoControlPhone),
|
963
|
-
]; };
|
964
|
-
|
965
|
-
var HouseServicesInfoFieldsSchema = {
|
966
|
-
hasBarrier: yup.string().required(defaultRequiredMessage),
|
967
|
-
barrierPhone: phoneWithConditionSchema("hasBarrier"),
|
968
|
-
hasConcierge: yup.string().required(defaultRequiredMessage),
|
969
|
-
conciergePhone: phoneWithConditionSchema("hasConcierge"),
|
970
|
-
hasSecurity: yup.string().required(defaultRequiredMessage),
|
971
|
-
securityPhone: phoneWithConditionSchema("hasSecurity"),
|
972
|
-
hasVideoControl: yup.string().required(defaultRequiredMessage),
|
973
|
-
videoControlPhone: phoneWithConditionSchema("hasVideoControl"),
|
974
|
-
};
|
975
|
-
var HouseServicesInfoStepSchema = yup.object(HouseServicesInfoFieldsSchema);
|
976
|
-
|
977
|
-
var metersOptions = getNumbersValues(7);
|
978
|
-
var getMetersInfoStepFields = function (settings) {
|
979
|
-
var _a, _b, _c, _d;
|
980
|
-
return [
|
981
|
-
__assign({ name: "maxMeters.water", label: "Water", variant: "select", options: metersOptions, isRequired: true }, (_a = settings === null || settings === void 0 ? void 0 : settings.maxMeters) === null || _a === void 0 ? void 0 : _a.water),
|
982
|
-
__assign({ name: "maxMeters.electricity", label: "Electricity", variant: "select", options: metersOptions, isRequired: true }, (_b = settings === null || settings === void 0 ? void 0 : settings.maxMeters) === null || _b === void 0 ? void 0 : _b.electricity),
|
983
|
-
__assign({ name: "maxMeters.gas", label: "Gas", variant: "select", options: metersOptions, isRequired: true }, (_c = settings === null || settings === void 0 ? void 0 : settings.maxMeters) === null || _c === void 0 ? void 0 : _c.gas),
|
984
|
-
__assign({ name: "maxMeters.heating", label: "Heating", variant: "select", options: metersOptions, isRequired: true }, (_d = settings === null || settings === void 0 ? void 0 : settings.maxMeters) === null || _d === void 0 ? void 0 : _d.heating),
|
985
|
-
];
|
986
|
-
};
|
987
|
-
|
988
|
-
var MetersInfoFieldsSchema = {
|
989
|
-
maxMeters: yup.object({
|
990
|
-
water: positiveNumberSchema,
|
991
|
-
electricity: positiveNumberSchema,
|
992
|
-
gas: positiveNumberSchema,
|
993
|
-
heating: positiveNumberSchema,
|
994
|
-
}),
|
995
|
-
};
|
996
|
-
var MetersInfoStepSchema = yup.object(MetersInfoFieldsSchema);
|
997
|
-
|
998
|
-
var getTelecommunicationsInfoStepFields = function (settings) {
|
999
|
-
var _a, _b, _c, _d, _e;
|
1000
|
-
return [
|
1001
|
-
__assign({ name: "wifi.name", label: "Name of network" }, (_a = settings === null || settings === void 0 ? void 0 : settings.wifi) === null || _a === void 0 ? void 0 : _a.name),
|
1002
|
-
__assign({ name: "wifi.password", label: "WiFi password" }, (_b = settings === null || settings === void 0 ? void 0 : settings.wifi) === null || _b === void 0 ? void 0 : _b.password),
|
1003
|
-
__assign({ name: "internetProvider.link", label: "Link to provider", size: 12 }, (_c = settings === null || settings === void 0 ? void 0 : settings.internetProvider) === null || _c === void 0 ? void 0 : _c.link),
|
1004
|
-
__assign({ name: "internetProvider.login", label: "Login" }, (_d = settings === null || settings === void 0 ? void 0 : settings.internetProvider) === null || _d === void 0 ? void 0 : _d.login),
|
1005
|
-
__assign({ name: "internetProvider.password", label: "Password" }, (_e = settings === null || settings === void 0 ? void 0 : settings.internetProvider) === null || _e === void 0 ? void 0 : _e.password),
|
1006
|
-
__assign({ name: "tvType", label: "Television", variant: "select", options: TVTypesValues }, settings === null || settings === void 0 ? void 0 : settings.tvType),
|
1007
|
-
__assign({ name: "homePhone", label: "Home phone", variant: "phone" }, settings === null || settings === void 0 ? void 0 : settings.homePhone),
|
1008
|
-
];
|
1009
|
-
};
|
1010
|
-
|
1011
|
-
var TelecommunicationsInfoFieldsSchema = {
|
1012
|
-
homePhone: phoneNonRequiredSchema("homePhone"),
|
1013
|
-
};
|
1014
|
-
var TelecommunicationsInfoStepSchema = yup
|
1015
|
-
.object()
|
1016
|
-
.shape(TelecommunicationsInfoFieldsSchema, [["homePhone", "homePhone"]]);
|
1017
|
-
|
1018
|
-
var getFillingInfoFields = function (withType, type, setType, settings) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], addToArrayByCondition(withType, __assign({ label: "Filling type", name: "type", variant: "select", options: FillingTypeValues, handleChange: setType, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.type)), true), [
|
1019
|
-
__assign({ label: "Name (tag)", name: "tag", type: type, variant: "custom", CustomInput: FillingTagsAutocomplete, isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.tag)
|
1020
|
-
], false), addToArrayByCondition(type !== "finish", __assign({ label: "Model", name: "name", isRequired: true }, settings === null || settings === void 0 ? void 0 : settings.name)), true), addToArrayByCondition(type !== "finish", __assign({ label: "Serial code", name: "serialNumber", size: 6 }, settings === null || settings === void 0 ? void 0 : settings.serialNumber)), true), addToArrayByCondition(type !== "finish", __assign({ label: "Amount", name: "numberOfSubjects", type: "number", size: 6 }, settings === null || settings === void 0 ? void 0 : settings.numberOfSubjects)), true), [
|
1021
|
-
__assign({ label: "Description", name: "description", isTextArea: true }, settings === null || settings === void 0 ? void 0 : settings.description)
|
1022
|
-
], false), addToArrayByCondition(type !== "finish", __assign({ label: "Instruction", name: "instruction", variant: "custom", CustomInput: InputFileWithVisibility }, settings === null || settings === void 0 ? void 0 : settings.instruction)), true); };
|
1023
|
-
|
1024
|
-
var FillingInfoFieldsSchema = yup.object().shape({
|
1025
|
-
type: yup.string(),
|
1026
|
-
tag: yup.object({
|
1027
|
-
name: yup.string().required(defaultRequiredMessage),
|
1028
|
-
}),
|
1029
|
-
name: yup.string().when("type", {
|
1030
|
-
is: function (value) { return value === "electronics"; },
|
1031
|
-
then: function (rule) { return rule.required(defaultRequiredMessage); },
|
1032
|
-
}),
|
1033
|
-
});
|
1034
|
-
|
1035
|
-
var meterFeaturesFieldsSchema = {
|
1036
|
-
number: yup.string().required("This field is required"),
|
1037
|
-
};
|
1038
|
-
var getMeterFeaturesFieldsSchema = function (valuesFields) {
|
1039
|
-
var valuesSchema = getMeterValuesFieldsSchema(valuesFields);
|
1040
|
-
return yup.object().shape(__assign(__assign({}, meterFeaturesFieldsSchema), Object.assign.apply(Object, __spreadArray([{}], valuesSchema, false))));
|
1041
|
-
};
|
1042
|
-
|
1043
|
-
var getInventoryMeterFields = function (settings, inputsSettings) { return __spreadArray(__spreadArray([], basicFieldsOfNewResourceMeter(settings, inputsSettings), true), [
|
1044
|
-
__assign({ label: "Activation date", name: "startDate", variant: "date", max: DateTime.now() }, inputsSettings === null || inputsSettings === void 0 ? void 0 : inputsSettings.startDate),
|
1045
|
-
__assign({ label: "Passport", name: "passportFile", variant: "custom", CustomInput: InputFile }, inputsSettings === null || inputsSettings === void 0 ? void 0 : inputsSettings.passportFile),
|
1046
|
-
], false); };
|
1047
|
-
|
1048
|
-
var AddedMeterItem = function (props) {
|
1049
|
-
var meter = props.meter, getMeterLabel = props.getMeterLabel;
|
1050
|
-
var resource = meter.resource, type = meter.type, number = meter.number;
|
1051
|
-
var initialValue = meter.initialValue, initialValueT1 = meter.initialValueT1, initialValueT2 = meter.initialValueT2, initialValueT3 = meter.initialValueT3;
|
1052
|
-
var meterValues = [
|
1053
|
-
initialValue,
|
1054
|
-
initialValueT1,
|
1055
|
-
initialValueT2,
|
1056
|
-
initialValueT3,
|
1057
|
-
]
|
1058
|
-
.filter(function (value) { return typeof value !== "undefined"; })
|
1059
|
-
.map(function (value) { return value; })
|
1060
|
-
.join(" / ");
|
1061
|
-
var getDefaultMeterLabel = function () {
|
1062
|
-
return _.capitalize("".concat(type ? "".concat(type, " ") : "").concat(resource, " meter"));
|
1063
|
-
};
|
1064
|
-
var label = getMeterLabel
|
1065
|
-
? getMeterLabel(resource, type)
|
1066
|
-
: getDefaultMeterLabel();
|
1067
|
-
return (jsxs(Caption, __assign({ "data-testid": "addedMeterLine", size: "s" }, { children: ["\u2022 ", label, " #", number, " -", " ", jsxs(StyledAccent, { children: [meterValues, " ", meterUnitLabel[meter.resource]] })] })));
|
1068
|
-
};
|
1069
|
-
var StyledAccent = styled.span(templateObject_1$a || (templateObject_1$a = __makeTemplateObject(["\n font-weight: 600;\n"], ["\n font-weight: 600;\n"])));
|
1070
|
-
var templateObject_1$a;
|
1071
|
-
|
1072
|
-
var AddedMetersBlock = function (props) {
|
1073
|
-
var _a, _b;
|
1074
|
-
var resource = props.resource, formStore = props.formStore, label = props.label, getMeterLabel = props.getMeterLabel;
|
1075
|
-
var addedMeters = (_b = (_a = formStore.fields) === null || _a === void 0 ? void 0 : _a.meters) === null || _b === void 0 ? void 0 : _b.filter(function (meter) { return meter.resource === resource; });
|
1076
|
-
if (!(addedMeters === null || addedMeters === void 0 ? void 0 : addedMeters.length))
|
1077
|
-
return null;
|
1078
|
-
return (jsxs(StyledWrapper$5, __assign({ "data-testid": "addedMetersBlock" }, { children: [jsxs(StyledHeader, __assign({ container: true, alignItems: "center" }, { children: [jsx(StyledIcon, {}), jsx(Caption, __assign({ size: "s", color: "fiftyP" }, { children: label || "In the previous steps were added:" }))] })), addedMeters.map(function (meter) { return (jsx(AddedMeterItem, { getMeterLabel: getMeterLabel, meter: meter }, meter.number)); })] })));
|
1079
|
-
};
|
1080
|
-
var StyledWrapper$5 = styled.div(templateObject_1$9 || (templateObject_1$9 = __makeTemplateObject(["\n border-radius: 8px;\n border: 1px solid ", ";\n padding: 12px 16px;\n background: white;\n"], ["\n border-radius: 8px;\n border: 1px solid ", ";\n padding: 12px 16px;\n background: white;\n"])), theme.palette.grey.fifteenB);
|
1081
|
-
var StyledIcon = styled(WarningIcon)(templateObject_2$6 || (templateObject_2$6 = __makeTemplateObject(["\n margin-right: 8px;\n width: 16px;\n height: 16px;\n path {\n fill: ", ";\n }\n"], ["\n margin-right: 8px;\n width: 16px;\n height: 16px;\n path {\n fill: ", ";\n }\n"])), theme.palette.brand.main);
|
1082
|
-
var StyledHeader = styled(Grid)(templateObject_3$3 || (templateObject_3$3 = __makeTemplateObject(["\n margin-bottom: 8px;\n"], ["\n margin-bottom: 8px;\n"])));
|
1083
|
-
var templateObject_1$9, templateObject_2$6, templateObject_3$3;
|
1084
|
-
|
1085
|
-
function InventoryMeterInfoFields(props) {
|
1086
|
-
var _a, _b;
|
1087
|
-
var resource = props.resource, index = props.index, formStore = props.formStore;
|
1088
|
-
var defaultValues = (_b = (_a = formStore.fields) === null || _a === void 0 ? void 0 : _a.meters) === null || _b === void 0 ? void 0 : _b[index];
|
1089
|
-
var withMeterType = resource === "water" || resource === "electricity";
|
1090
|
-
var defaultType = resource === "water" ? "cold" : "T1";
|
1091
|
-
var defaultMeterType = withMeterType ? defaultType : null;
|
1092
|
-
var _c = useState((defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.type) || defaultMeterType), meterType = _c[0], setMeterType = _c[1];
|
1093
|
-
var meterFields = getInventoryMeterFields({
|
1094
|
-
resource: resource,
|
1095
|
-
meterType: meterType,
|
1096
|
-
});
|
1097
|
-
var valueFieldsName = meterFields
|
1098
|
-
.filter(function (field) { return field.type === "number"; })
|
1099
|
-
.map(function (field) { return field.name; });
|
1100
|
-
var meterFeaturesFieldsSchema = getMeterFeaturesFieldsSchema(valueFieldsName);
|
1101
|
-
var form = useMemo(function () {
|
1102
|
-
return useForm({
|
1103
|
-
resolver: yupResolver(meterFeaturesFieldsSchema),
|
1104
|
-
defaultValues: __assign({}, defaultValues),
|
1105
|
-
values: defaultValues,
|
1106
|
-
});
|
1107
|
-
}, [meterFeaturesFieldsSchema]);
|
1108
|
-
var handleSubmit = function (data) {
|
1109
|
-
formStore.replaceFieldInArray("meters", __assign(__assign({}, data), { resource: resource }), index);
|
1110
|
-
formStore.nextStep();
|
1111
|
-
};
|
1112
|
-
return (jsx(FormWrapper, __assign({ form: form, onSubmit: handleSubmit, label: "Next", variant: "next", withPrevStep: true, handlePrevClick: formStore.prevStep }, { children: jsxs(Grid, __assign({ container: true, spacing: 2 }, { children: [jsx(Grid, __assign({ item: true, xs: 12 }, { children: jsx(AddedMetersBlock, { formStore: formStore, resource: resource }) })), withMeterType && (jsx(Grid, __assign({ item: true, xs: 12 }, { children: jsx(MeterTypeRadioGroup, { form: form, resource: resource, handleChange: setMeterType }) }))), meterFields.map(function (_a) {
|
1113
|
-
var size = _a.size, field = __rest(_a, ["size"]);
|
1114
|
-
return (jsx(Grid, __assign({ item: true, xs: size || 6 }, { children: jsx(InputByType, __assign({ form: form }, field)) }), field.name));
|
1115
|
-
})] })) })));
|
1116
|
-
}
|
1117
|
-
|
1118
|
-
var renderMetersSteps = function (MeterStep, MeterPhotoStep, maxMeters) {
|
1119
|
-
var meters = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], new Array(Number((maxMeters === null || maxMeters === void 0 ? void 0 : maxMeters.water) || 0)).fill("water"), true), new Array(Number((maxMeters === null || maxMeters === void 0 ? void 0 : maxMeters.electricity) || 0)).fill("electricity"), true), new Array(Number((maxMeters === null || maxMeters === void 0 ? void 0 : maxMeters.gas) || 0)).fill("gas"), true), new Array(Number((maxMeters === null || maxMeters === void 0 ? void 0 : maxMeters.heating) || 0)).fill("heating"), true);
|
1120
|
-
return meters.map(function (resource, index) { return [
|
1121
|
-
jsx(MeterStep, { index: index, resource: resource }, "meter_info_".concat(index)),
|
1122
|
-
jsx(MeterPhotoStep, { index: index, resource: resource }, "meter_photo_".concat(index)),
|
1123
|
-
]; });
|
1124
|
-
};
|
1125
|
-
|
1126
|
-
var getRoomsImagesSteps = function (type, settings, roomsParams) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
1127
|
-
__assign({ type: "kitchen" }, settings.kitchen)
|
1128
|
-
], new Array(Number((roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.bedroomsNumber) || 0))
|
1129
|
-
.fill(0)
|
1130
|
-
.map(function (_, index) { return (__assign({ type: "bedroom" }, settings.bedroom((roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.bedroomsNumber) ? "".concat(index + 1, " ") : ""))); }), true), new Array(Math.max(Number((roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.roomsNumber) || 0) -
|
1131
|
-
Number((roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.bedroomsNumber) || 0), 0))
|
1132
|
-
.fill(0)
|
1133
|
-
.map(function (_, index) { return (__assign({ type: "room" }, settings.room((roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.roomsNumber)
|
1134
|
-
? "".concat(index + 1 + ((roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.bedroomsNumber) || 0), " ")
|
1135
|
-
: ""))); }), true), new Array(Number((roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.bathroomsNumber) || 0))
|
1136
|
-
.fill(0)
|
1137
|
-
.map(function (_, index) { return (__assign({ type: "bathroom" }, settings.bathroom((roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.bathroomsNumber) ? "".concat(index + 1, " ") : ""))); }), true), new Array(Number((roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.restroomsNumber) || 0))
|
1138
|
-
.fill(0)
|
1139
|
-
.map(function (_, index) { return (__assign({ type: "toilet" }, settings.toilet((roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.restroomsNumber) ? "".concat(index + 1, " ") : ""))); }), true), new Array(Number((roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.combinedBathroomsNumber) || 0))
|
1140
|
-
.fill(0)
|
1141
|
-
.map(function (_, index) { return (__assign({ type: "combined_bathroom" }, settings.combinedBathroom((roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.combinedBathroomsNumber) ? "".concat(index + 1, " ") : ""))); }), true), [
|
1142
|
-
__assign({ type: "others" }, settings.others)
|
1143
|
-
], false), addToArrayByCondition(type === "initial", __assign({ type: "entrance" }, settings.entrance)), true), addToArrayByCondition(type !== "initial", __assign({ type: "keys" }, settings.keys)), true), addToArrayByCondition(!!(type === "initial" && (roomsParams === null || roomsParams === void 0 ? void 0 : roomsParams.parkingType)), __assign({ type: "parking" }, settings.parking)), true), [
|
1144
|
-
__assign({ type: "additional" }, settings.additional),
|
1145
|
-
], false); };
|
1146
|
-
|
1147
|
-
var InspectionFeedbackBillet = function (props) {
|
1148
|
-
var feedback = props.feedback, label = props.label;
|
1149
|
-
return (jsx(StyledWrapper$4, __assign({ status: feedback.status }, { children: jsxs(Grid, __assign({ container: true, alignItems: "center" }, { children: [jsx(Caption, __assign({ size: "s", weight: 500, color: "fiftyP" }, { children: label })), feedback.status !== "notSigned" && (jsxs(StyledIconWrapper, { children: [feedback.status === "signed" ? (jsx(StyledCheckIcon, {})) : (jsx(StyledErrorIcon, {})), !!feedback.comment && (jsx(Tooltip, __assign({ placement: "bottom", content: jsxs("div", { children: [jsx(Caption, __assign({ size: "xs", color: "fiftyP" }, { children: "Comment" })), jsx(StyledComment, __assign({ size: "xs" }, { children: feedback.comment }))] }) }, { children: jsx(StyledCommentIcon, {}) })))] }))] })) })));
|
1150
|
-
};
|
1151
|
-
var StyledWrapper$4 = styled.div(templateObject_1$8 || (templateObject_1$8 = __makeTemplateObject(["\n background: ", ";\n border-radius: 66px;\n border: 1px solid ", ";\n padding: 6px 16px;\n width: fit-content;\n @media (max-width: ", "px) {\n width: 100%;\n > div {\n justify-content: center;\n }\n }\n"], ["\n background: ", ";\n border-radius: 66px;\n border: 1px solid ", ";\n padding: 6px 16px;\n width: fit-content;\n @media (max-width: ", "px) {\n width: 100%;\n > div {\n justify-content: center;\n }\n }\n"])), function (_a) {
|
1152
|
-
var status = _a.status;
|
1153
|
-
return status === "notSigned"
|
1154
|
-
? theme.palette.background.light1
|
1155
|
-
: theme.palette.grey.zero;
|
1156
|
-
}, theme.palette.grey.fifteenB, theme.breakpoints.sm);
|
1157
|
-
var StyledIconWrapper = styled.div(templateObject_2$5 || (templateObject_2$5 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n margin-left: 8px;\n > div {\n margin-left: 8px;\n }\n"], ["\n display: flex;\n align-items: center;\n margin-left: 8px;\n > div {\n margin-left: 8px;\n }\n"])));
|
1158
|
-
var StyledCheckIcon = styled(CheckIcon)(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n path {\n fill: ", ";\n }\n"], ["\n path {\n fill: ", ";\n }\n"])), theme.palette.green.fiftyP);
|
1159
|
-
var StyledErrorIcon = styled(CancelIcon)(templateObject_4$1 || (templateObject_4$1 = __makeTemplateObject(["\n width: 12px;\n height: 12px;\n path {\n fill: ", ";\n }\n"], ["\n width: 12px;\n height: 12px;\n path {\n fill: ", ";\n }\n"])), theme.palette.red.fiftyP);
|
1160
|
-
var StyledComment = styled(Caption)(templateObject_5$1 || (templateObject_5$1 = __makeTemplateObject(["\n margin-top: 8px;\n"], ["\n margin-top: 8px;\n"])));
|
1161
|
-
var StyledCommentIcon = styled(CommentIcon)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n width: 13px;\n cursor: pointer;\n path {\n fill: ", ";\n stroke: ", ";\n }\n"], ["\n width: 13px;\n cursor: pointer;\n path {\n fill: ", ";\n stroke: ", ";\n }\n"])), theme.palette.grey.zero, theme.palette.grey.thirty);
|
1162
|
-
var templateObject_1$8, templateObject_2$5, templateObject_3$2, templateObject_4$1, templateObject_5$1, templateObject_6;
|
1163
|
-
|
1164
|
-
var InspectionFeedbackStatus = function (props) {
|
1165
|
-
var feedback = props.feedback, label = props.label, resendLabel = props.resendLabel, resend = props.resend;
|
1166
|
-
if (!feedback)
|
1167
|
-
return null;
|
1168
|
-
return (jsx(Grid, __assign({ item: true }, { children: jsxs(Grid, __assign({ container: true, alignItems: "center" }, { children: [jsx(InspectionFeedbackBillet, { feedback: feedback, label: label }), feedback.status === "rejected" && (jsx(StyledButton, __assign({ size: "xs", variant: "orange", onClick: resend, endIcon: jsx(UpdateIcon, {}) }, { children: resendLabel })))] })) })));
|
1169
|
-
};
|
1170
|
-
var InspectionFeedbackStatus$1 = observer(InspectionFeedbackStatus);
|
1171
|
-
var StyledButton = styled(Button)(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject(["\n margin-left: 16px;\n @media (max-width: ", "px) {\n width: 100%;\n margin-left: 0;\n margin-top: 8px;\n }\n"], ["\n margin-left: 16px;\n @media (max-width: ", "px) {\n width: 100%;\n margin-left: 0;\n margin-top: 8px;\n }\n"])), theme.breakpoints.sm);
|
1172
|
-
var templateObject_1$7;
|
1173
|
-
|
1174
|
-
var InspectionFeedback = function (props) {
|
1175
|
-
var tenantFeedback = props.tenantFeedback, landlordFeedback = props.landlordFeedback, resignInspection = props.resignInspection, resendLabel = props.resendLabel;
|
1176
|
-
var tenantLabel = props.tenantLabel, landlordLabel = props.landlordLabel;
|
1177
|
-
if (!tenantFeedback && !landlordFeedback)
|
1178
|
-
return null;
|
1179
|
-
return (jsxs(StyledWrapper$3, __assign({ container: true, spacing: 2, alignItems: "center" }, { children: [jsx(InspectionFeedbackStatus$1, { resend: resignInspection, resendLabel: resendLabel, feedback: tenantFeedback, label: tenantLabel }), jsx(InspectionFeedbackStatus$1, { resend: resignInspection, resendLabel: resendLabel, feedback: landlordFeedback, label: landlordLabel })] })));
|
1180
|
-
};
|
1181
|
-
var index = observer(InspectionFeedback);
|
1182
|
-
var StyledWrapper$3 = styled(Grid)(templateObject_1$6 || (templateObject_1$6 = __makeTemplateObject(["\n padding-top: 8px;\n"], ["\n padding-top: 8px;\n"])));
|
1183
|
-
var templateObject_1$6;
|
1184
|
-
|
1185
|
-
var FillingCardContent = function (props) {
|
1186
|
-
var filling = props.filling, warningLabel = props.warningLabel;
|
1187
|
-
return (jsxs(Grid, __assign({ container: true, alignItems: "center" }, { children: [filling.wasMissing && (jsx(Tooltip, __assign({ content: jsx(Caption, __assign({ size: "xs" }, { children: warningLabel })) }, { children: jsx(StyledWarningIcon, { width: 17, height: 17 }) }))), jsxs(StyledLabelWrapper, { children: [jsxs(Caption, __assign({ size: "s" }, { children: [filling.tagName, " ", filling.name ? " | ".concat(filling.name) : ""] })), !!(filling.numberOfSubjects || filling.serialNumber) && (jsxs(StyledSubtitle, __assign({ size: "xs", color: "fiftyP" }, { children: [filling.numberOfSubjects
|
1188
|
-
? "".concat(filling.numberOfSubjects, " pieces")
|
1189
|
-
: "", filling.numberOfSubjects && filling.serialNumber ? " \u2022 " : "", filling.serialNumber] })))] })] })));
|
1190
|
-
};
|
1191
|
-
var StyledWarningIcon = styled(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"])), theme.palette.red.fiftyP);
|
1192
|
-
var StyledLabelWrapper = styled.div(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject(["\n margin-left: 8px;\n"], ["\n margin-left: 8px;\n"])));
|
1193
|
-
var StyledSubtitle = styled(Caption)(templateObject_3$1 || (templateObject_3$1 = __makeTemplateObject(["\n margin-top: 4px;\n"], ["\n margin-top: 4px;\n"])));
|
1194
|
-
var templateObject_1$5, templateObject_2$4, templateObject_3$1;
|
1195
|
-
|
1196
|
-
var InspectionFillingCard = function (props) {
|
1197
|
-
var className = props.className, form = props.form, index = props.index, disabled = props.disabled, other = __rest(props, ["className", "form", "index", "disabled"]);
|
1198
|
-
return (jsx(StyledCard$1, __assign({ className: className }, { children: jsx(StyledCheckbox
|
1199
|
-
// @ts-ignore
|
1200
|
-
, {
|
1201
|
-
// @ts-ignore
|
1202
|
-
form: form, name: "fillingList.".concat(index, ".check"), label: jsx(FillingCardContent, __assign({}, other)), disabled: disabled }) })));
|
1203
|
-
};
|
1204
|
-
var StyledCard$1 = styled(Grid)(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n padding: 8px 16px;\n border-radius: 12px;\n background: white;\n"], ["\n padding: 8px 16px;\n border-radius: 12px;\n background: white;\n"])));
|
1205
|
-
var StyledCheckbox = styled(CheckboxWithController)(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n .KUI-Label_checkbox {\n margin-left: 0;\n }\n"], ["\n .KUI-Label_checkbox {\n margin-left: 0;\n }\n"])));
|
1206
|
-
var templateObject_1$4, templateObject_2$3;
|
1207
|
-
|
1208
|
-
var useMetersValues = function (formStore, metersStore, shouldBeLoad, onLoad) {
|
1209
|
-
var finishLoad = function () {
|
1210
|
-
if (onLoad)
|
1211
|
-
onLoad();
|
1212
|
-
metersStore.loader.endLoading();
|
1213
|
-
};
|
1214
|
-
var loadMeters = function () { return __awaiter(void 0, void 0, void 0, function () {
|
1215
|
-
var _a, _b;
|
1216
|
-
return __generator(this, function (_c) {
|
1217
|
-
switch (_c.label) {
|
1218
|
-
case 0:
|
1219
|
-
if (!shouldBeLoad) return [3 /*break*/, 3];
|
1220
|
-
if (!!((_b = (_a = formStore.fields) === null || _a === void 0 ? void 0 : _a.meters) === null || _b === void 0 ? void 0 : _b.length)) return [3 /*break*/, 2];
|
1221
|
-
return [4 /*yield*/, metersStore.fetchMeters()];
|
1222
|
-
case 1:
|
1223
|
-
_c.sent();
|
1224
|
-
_c.label = 2;
|
1225
|
-
case 2:
|
1226
|
-
finishLoad();
|
1227
|
-
return [3 /*break*/, 4];
|
1228
|
-
case 3:
|
1229
|
-
if (shouldBeLoad === false)
|
1230
|
-
finishLoad();
|
1231
|
-
_c.label = 4;
|
1232
|
-
case 4: return [2 /*return*/];
|
1233
|
-
}
|
1234
|
-
});
|
1235
|
-
}); };
|
1236
|
-
useEffect(function () {
|
1237
|
-
loadMeters();
|
1238
|
-
}, [shouldBeLoad]);
|
1239
|
-
useEffect(function () {
|
1240
|
-
var _a, _b;
|
1241
|
-
if (!metersStore.loader.isLoading && !((_b = (_a = formStore.fields) === null || _a === void 0 ? void 0 : _a.meters) === null || _b === void 0 ? void 0 : _b.length)) {
|
1242
|
-
formStore.updateFormFields({ meters: metersStore.meters });
|
1243
|
-
}
|
1244
|
-
}, [metersStore.meters, metersStore.loader.isLoading]);
|
1245
|
-
};
|
1246
|
-
|
1247
|
-
var FillingListStore = /** @class */ (function () {
|
1248
|
-
function FillingListStore() {
|
1249
|
-
var _this = this;
|
1250
|
-
this.fetchFillingList = function (apartmentId, fillingType) { return __awaiter(_this, void 0, void 0, function () {
|
1251
|
-
var response;
|
1252
|
-
return __generator(this, function (_a) {
|
1253
|
-
switch (_a.label) {
|
1254
|
-
case 0:
|
1255
|
-
this.loader.startLoading();
|
1256
|
-
return [4 /*yield*/, to(ApartmentsAgent.getFillingList(apartmentId, fillingType))];
|
1257
|
-
case 1:
|
1258
|
-
response = _a.sent();
|
1259
|
-
resHandler(response, this.loader, this.updateFillingList);
|
1260
|
-
return [2 /*return*/];
|
1261
|
-
}
|
1262
|
-
});
|
1263
|
-
}); };
|
1264
|
-
this.updateFillingList = function (fillingList) {
|
1265
|
-
_this.fillingList =
|
1266
|
-
(fillingList === null || fillingList === void 0 ? void 0 : fillingList.map(function (filling) { return ({
|
1267
|
-
id: filling.id,
|
1268
|
-
name: filling.description,
|
1269
|
-
tagName: filling.feature_name,
|
1270
|
-
serialNumber: filling.serial_code,
|
1271
|
-
numberOfSubjects: filling.amount,
|
1272
|
-
wasMissing: filling.is_absent,
|
1273
|
-
}); })) || [];
|
1274
|
-
};
|
1275
|
-
this.fillingList = [];
|
1276
|
-
this.loader = new Loader();
|
1277
|
-
makeAutoObservable(this);
|
1278
|
-
}
|
1279
|
-
return FillingListStore;
|
1280
|
-
}());
|
1281
|
-
|
1282
|
-
var useFillingList = function (apartmentId, formStore, fillingStore, shouldBeLoad, onLoad) {
|
1283
|
-
var finishLoad = function () {
|
1284
|
-
if (onLoad)
|
1285
|
-
onLoad();
|
1286
|
-
fillingStore.loader.endLoading();
|
1287
|
-
};
|
1288
|
-
var loadFillingList = function () { return __awaiter(void 0, void 0, void 0, function () {
|
1289
|
-
var _a, _b;
|
1290
|
-
return __generator(this, function (_c) {
|
1291
|
-
switch (_c.label) {
|
1292
|
-
case 0:
|
1293
|
-
if (!(shouldBeLoad && apartmentId)) return [3 /*break*/, 3];
|
1294
|
-
if (!!((_b = (_a = formStore.fields) === null || _a === void 0 ? void 0 : _a.fillingList) === null || _b === void 0 ? void 0 : _b.length)) return [3 /*break*/, 2];
|
1295
|
-
return [4 /*yield*/, fillingStore.fetchFillingList(apartmentId, "appliance")];
|
1296
|
-
case 1:
|
1297
|
-
_c.sent();
|
1298
|
-
_c.label = 2;
|
1299
|
-
case 2:
|
1300
|
-
finishLoad();
|
1301
|
-
return [3 /*break*/, 4];
|
1302
|
-
case 3:
|
1303
|
-
if (shouldBeLoad === false)
|
1304
|
-
finishLoad();
|
1305
|
-
_c.label = 4;
|
1306
|
-
case 4: return [2 /*return*/];
|
1307
|
-
}
|
1308
|
-
});
|
1309
|
-
}); };
|
1310
|
-
useEffect(function () {
|
1311
|
-
loadFillingList();
|
1312
|
-
}, [apartmentId, shouldBeLoad]);
|
1313
|
-
useEffect(function () {
|
1314
|
-
var _a, _b;
|
1315
|
-
if (!fillingStore.loader.isLoading &&
|
1316
|
-
!((_b = (_a = formStore.fields) === null || _a === void 0 ? void 0 : _a.fillingList) === null || _b === void 0 ? void 0 : _b.length)) {
|
1317
|
-
formStore.updateFormFields({
|
1318
|
-
fillingList: fillingStore.fillingList.map(function (filling) { return (__assign(__assign({}, filling), { check: false })); }),
|
1319
|
-
});
|
1320
|
-
}
|
1321
|
-
}, [fillingStore.fillingList, fillingStore.loader.isLoading]);
|
1322
|
-
};
|
1323
|
-
|
1324
|
-
var onInspectionModalOpen = function (apartmentStore, constants, openModal) {
|
1325
|
-
var inspectionsStore = apartmentStore.inspectionsStore, apartmentId = apartmentStore.apartmentId;
|
1326
|
-
var formStateName = constants.formStateName, formFieldsName = constants.formFieldsName;
|
1327
|
-
var fields = inspectionsStore.creationForm.fields;
|
1328
|
-
if (fields && fields.apartmentId !== apartmentId) {
|
1329
|
-
clearIndexStores(inspectionsStore.indexDB, [formStateName, formFieldsName]);
|
1330
|
-
}
|
1331
|
-
inspectionsStore.setCanUpdateDB(true);
|
1332
|
-
if (openModal)
|
1333
|
-
openModal();
|
1334
|
-
};
|
1335
|
-
var onInspectionModalClose = function (apartmentStore, constants, closeModal) {
|
1336
|
-
var inspectionsStore = apartmentStore.inspectionsStore;
|
1337
|
-
var formStateName = constants.formStateName, formFieldsName = constants.formFieldsName;
|
1338
|
-
inspectionsStore.setCanUpdateDB(false);
|
1339
|
-
inspectionsStore.creationForm.resetForm();
|
1340
|
-
clearIndexStores(inspectionsStore.indexDB, [formStateName, formFieldsName]);
|
1341
|
-
if (closeModal)
|
1342
|
-
closeModal();
|
1343
|
-
};
|
1344
|
-
|
1345
|
-
var useInspectionData = function (apartmentStore) {
|
1346
|
-
var _a;
|
1347
|
-
var apartmentId = apartmentStore.apartmentId, inspectionsStore = apartmentStore.inspectionsStore, metersStore = apartmentStore.metersStore, fillingStore = apartmentStore.fillingStore;
|
1348
|
-
var _b = useState(false), isMetersLoaded = _b[0], setIsMetersLoader = _b[1];
|
1349
|
-
var _c = useState(false), isFillingLoaded = _c[0], setIsFillingLoaded = _c[1];
|
1350
|
-
var formStore = inspectionsStore.creationForm;
|
1351
|
-
var inspectionType = (_a = formStore.fields) === null || _a === void 0 ? void 0 : _a.type;
|
1352
|
-
var canBeLoad = inspectionType
|
1353
|
-
? inspectionType === "regular" || inspectionType === "transfer"
|
1354
|
-
: undefined;
|
1355
|
-
var fillingLoading = fillingStore.loader.isLoading;
|
1356
|
-
var metersLoading = metersStore.loader.isLoading;
|
1357
|
-
var handleMetersLoad = function () { return setIsMetersLoader(true); };
|
1358
|
-
var handleFillingLoad = function () { return setIsFillingLoaded(true); };
|
1359
|
-
useEffect(function () {
|
1360
|
-
if (isMetersLoaded &&
|
1361
|
-
isFillingLoaded &&
|
1362
|
-
!fillingLoading &&
|
1363
|
-
!metersLoading) {
|
1364
|
-
inspectionsStore.setCanLoadDB(true);
|
1365
|
-
}
|
1366
|
-
}, [isMetersLoaded, isFillingLoaded, fillingLoading, metersLoading]);
|
1367
|
-
useMetersValues(formStore, metersStore, canBeLoad, handleMetersLoad);
|
1368
|
-
useFillingList(apartmentId || null, formStore, fillingStore, canBeLoad, handleFillingLoad);
|
1369
|
-
};
|
1370
|
-
|
1371
|
-
var EXPIRATION_TIME = 24 * 60 * 60 * 1000; // 24 часа
|
1372
|
-
var useInspectionIndexDB = function (constants, apartmentStore, openModal) {
|
1373
|
-
var dbCreationTime = constants.dbCreationTime, formFieldsName = constants.formFieldsName, formStateName = constants.formStateName, inspectionCreationFormName = constants.inspectionCreationFormName;
|
1374
|
-
var inspectionsStore = apartmentStore.inspectionsStore, apartmentId = apartmentStore.apartmentId;
|
1375
|
-
var creationForm = inspectionsStore.creationForm, actionLoader = inspectionsStore.actionLoader, indexDB = inspectionsStore.indexDB, setCanUpdateDB = inspectionsStore.setCanUpdateDB, canUpdateDB = inspectionsStore.canUpdateDB;
|
1376
|
-
var dbName = inspectionCreationFormName;
|
1377
|
-
var onupgradeneeded = function (db) {
|
1378
|
-
addIndexDBStore(db, formFieldsName);
|
1379
|
-
addIndexDBStore(db, formStateName);
|
1380
|
-
};
|
1381
|
-
function checkAndDeleteDB() {
|
1382
|
-
var creationTime = localStorage.getItem(dbCreationTime);
|
1383
|
-
var currentTime = Date.now();
|
1384
|
-
if (creationTime && currentTime - Number(creationTime) > EXPIRATION_TIME) {
|
1385
|
-
clearIndexStores(inspectionsStore.indexDB, [
|
1386
|
-
formStateName,
|
1387
|
-
formFieldsName,
|
1388
|
-
]);
|
1389
|
-
localStorage.removeItem(dbCreationTime);
|
1390
|
-
}
|
1391
|
-
}
|
1392
|
-
var initInspectionIndexDB = function () { return __awaiter(void 0, void 0, void 0, function () {
|
1393
|
-
return __generator(this, function (_a) {
|
1394
|
-
initIndexDB(dbName, onupgradeneeded, actionLoader, function (db) { return __awaiter(void 0, void 0, void 0, function () {
|
1395
|
-
var formFields;
|
1396
|
-
return __generator(this, function (_a) {
|
1397
|
-
switch (_a.label) {
|
1398
|
-
case 0:
|
1399
|
-
inspectionsStore.setIndexDB(db);
|
1400
|
-
setCanUpdateDB(false);
|
1401
|
-
checkAndDeleteDB();
|
1402
|
-
return [4 /*yield*/, readFromIndexDB(db, formFieldsName, actionLoader)];
|
1403
|
-
case 1:
|
1404
|
-
formFields = _a.sent();
|
1405
|
-
if (formFields) {
|
1406
|
-
if ((formFields === null || formFields === void 0 ? void 0 : formFields.apartmentId) === apartmentId) {
|
1407
|
-
creationForm.updateFormFields(__assign(__assign({}, formFields), { date: formFields.date ? DateTime.fromISO(formFields.date) : null }));
|
1408
|
-
if (openModal)
|
1409
|
-
openModal();
|
1410
|
-
}
|
1411
|
-
}
|
1412
|
-
else {
|
1413
|
-
setCanUpdateDB(true);
|
1414
|
-
}
|
1415
|
-
return [2 /*return*/];
|
1416
|
-
}
|
1417
|
-
});
|
1418
|
-
}); });
|
1419
|
-
return [2 /*return*/];
|
1420
|
-
});
|
1421
|
-
}); };
|
1422
|
-
var initFormState = function () { return __awaiter(void 0, void 0, void 0, function () {
|
1423
|
-
var formState, formFields;
|
1424
|
-
return __generator(this, function (_a) {
|
1425
|
-
switch (_a.label) {
|
1426
|
-
case 0: return [4 /*yield*/, readFromIndexDB(indexDB, formStateName, actionLoader)];
|
1427
|
-
case 1:
|
1428
|
-
formState = _a.sent();
|
1429
|
-
return [4 /*yield*/, readFromIndexDB(indexDB, formFieldsName, actionLoader)];
|
1430
|
-
case 2:
|
1431
|
-
formFields = _a.sent();
|
1432
|
-
if (formState && (formFields === null || formFields === void 0 ? void 0 : formFields.apartmentId) === apartmentId) {
|
1433
|
-
creationForm.setStep(Number(formState.step));
|
1434
|
-
}
|
1435
|
-
setCanUpdateDB(true);
|
1436
|
-
return [2 /*return*/];
|
1437
|
-
}
|
1438
|
-
});
|
1439
|
-
}); };
|
1440
|
-
useEffect(function () {
|
1441
|
-
if (apartmentId)
|
1442
|
-
initInspectionIndexDB();
|
1443
|
-
}, [apartmentId]);
|
1444
|
-
useEffect(function () {
|
1445
|
-
if (inspectionsStore.canLoadDB && indexDB) {
|
1446
|
-
initFormState();
|
1447
|
-
}
|
1448
|
-
}, [inspectionsStore.canLoadDB, indexDB]);
|
1449
|
-
useEffect(function () {
|
1450
|
-
if (canUpdateDB) {
|
1451
|
-
var formState = {
|
1452
|
-
step: creationForm.step,
|
1453
|
-
};
|
1454
|
-
addToIndexDBWithQueue(indexDB, formStateName, formState, actionLoader);
|
1455
|
-
addToIndexDBWithQueue(indexDB, formFieldsName, creationForm.fields, actionLoader);
|
1456
|
-
if (!localStorage.getItem(dbCreationTime)) {
|
1457
|
-
localStorage.setItem(dbCreationTime, Date.now().toString());
|
1458
|
-
}
|
1459
|
-
}
|
1460
|
-
}, [creationForm.step]);
|
1461
|
-
};
|
1462
|
-
|
1463
|
-
var ObjectForMapPoint = function (props) {
|
1464
|
-
var label = props.label, onClick = props.onClick, isActive = props.isActive;
|
1465
|
-
return (jsx(Button, __assign({ size: "xs", variant: isActive ? "primary" : "white", onClick: onClick }, { children: label })));
|
1466
|
-
};
|
1467
|
-
|
1468
|
-
var MetroStation = function (props) {
|
1469
|
-
var metroStation = props.metroStation;
|
1470
|
-
var color = metroStation.color, name = metroStation.name;
|
1471
|
-
return (jsxs(StyledWrapper$2, __assign({ item: true, container: true, alignItems: "center" }, { children: [jsx(StyledPoint, { style: { background: color } }), jsx(Caption, __assign({ size: "s", color: "sixty" }, { children: name }))] })));
|
1472
|
-
};
|
1473
|
-
var StyledWrapper$2 = styled(Grid)(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n width: auto;\n"], ["\n width: auto;\n"])));
|
1474
|
-
var StyledPoint = styled.div(templateObject_2$2 || (templateObject_2$2 = __makeTemplateObject(["\n width: 6px;\n height: 6px;\n border-radius: 50%;\n margin-right: 6px;\n"], ["\n width: 6px;\n height: 6px;\n border-radius: 50%;\n margin-right: 6px;\n"])));
|
1475
|
-
var templateObject_1$3, templateObject_2$2;
|
1476
|
-
|
1477
|
-
var ContactPhone = function (props) {
|
1478
|
-
var phone = props.phone;
|
1479
|
-
var formattedPhone = getPhoneNumberFromPhoneParams(phone, " ");
|
1480
|
-
var phoneLink = formattedPhone.replace(/\d/g, "");
|
1481
|
-
return (jsxs(StyledWrapper$1, __assign({ container: true, alignItems: "center", wrap: "nowrap" }, { children: [jsx(StyledPhoneIcon, { width: 14, height: 14 }), jsx("a", __assign({ href: "tel:+".concat(phoneLink) }, { children: jsx(Caption, __assign({ size: "s", weight: 500, color: "sixty" }, { children: formattedPhone })) }))] })));
|
1482
|
-
};
|
1483
|
-
var StyledWrapper$1 = styled(Grid)(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n width: auto;\n"], ["\n width: auto;\n"])));
|
1484
|
-
var StyledPhoneIcon = styled(PhoneIcon)(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n margin-right: 6px;\n transform: rotate(15deg);\n path {\n stroke: ", ";\n }\n"], ["\n margin-right: 6px;\n transform: rotate(15deg);\n path {\n stroke: ", ";\n }\n"])), theme.palette.grey.sixty);
|
1485
|
-
var templateObject_1$2, templateObject_2$1;
|
1486
|
-
|
1487
|
-
var ObjectForMapCard = function (props) {
|
1488
|
-
var inspection = props.inspection, onClose = props.onClose, getClientLink = props.getClientLink, getInspectionLink = props.getInspectionLink;
|
1489
|
-
var apartment = inspection.apartment, tenant = inspection.tenant, landlord = inspection.landlord, metroStations = inspection.metroStations;
|
1490
|
-
var client = tenant || landlord;
|
1491
|
-
var clientLink = getClientLink && client ? getClientLink(client === null || client === void 0 ? void 0 : client.id) : "";
|
1492
|
-
var apartmentLink = getInspectionLink(apartment.id, inspection.id);
|
1493
|
-
return (jsxs(StyledCard, { children: [jsx(Link, __assign({ href: apartmentLink }, { children: jsx(StyledPreviewContent, { imageSrc: apartment.previewImage, description: apartment.address }) })), jsx(Grid, __assign({ container: true, spacing: 2, alignItems: "center" }, { children: metroStations.map(function (station) { return (jsx(MetroStation, { metroStation: station }, station.name)); }) })), !!client && (jsxs(StyledTenantInfo, __assign({ container: true, alignItems: "center", justify: "space-between" }, { children: [clientLink ? (jsx(StyledClientLink, __assign({ href: clientLink }, { children: jsx(UserBadge, { weight: 500, user: client }) }))) : (jsx(UserBadge, { weight: 500, user: client })), !!(client === null || client === void 0 ? void 0 : client.phoneNumber) && (jsx(ContactPhone, { phone: client === null || client === void 0 ? void 0 : client.phoneNumber }))] }))), jsx(StyledCloseButton, __assign({ isCircle: true, size: "xs", variant: "whiteWithGray", onClick: onClose }, { children: jsx(CloseIcon, { width: 6, height: 6 }) }))] }));
|
1494
|
-
};
|
1495
|
-
var StyledCard = styled.div(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n width: 330px;\n background: ", ";\n border-radius: 8px;\n padding: 8px;\n position: absolute;\n bottom: 46px;\n left: -115px;\n z-index: 1;\n"], ["\n width: 330px;\n background: ", ";\n border-radius: 8px;\n padding: 8px;\n position: absolute;\n bottom: 46px;\n left: -115px;\n z-index: 1;\n"])), theme.palette.grey.zero);
|
1496
|
-
var StyledPreviewContent = styled(PreviewContent)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-bottom: 8px;\n p {\n font-size: 16px;\n line-height: 24px;\n font-weight: 600;\n }\n"], ["\n margin-bottom: 8px;\n p {\n font-size: 16px;\n line-height: 24px;\n font-weight: 600;\n }\n"])));
|
1497
|
-
var StyledTenantInfo = styled(Grid)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-top: 8px;\n border-top: 1px solid ", ";\n margin-top: 8px;\n"], ["\n padding-top: 8px;\n border-top: 1px solid ", ";\n margin-top: 8px;\n"])), theme.palette.grey.fifteenB);
|
1498
|
-
var StyledCloseButton = styled(Button)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: absolute;\n top: -10px;\n right: -10px;\n width: 24px;\n height: 24px;\n"], ["\n position: absolute;\n top: -10px;\n right: -10px;\n width: 24px;\n height: 24px;\n"])));
|
1499
|
-
var StyledClientLink = styled(Link)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n max-width: calc(100% - 140px);\n"], ["\n max-width: calc(100% - 140px);\n"])));
|
1500
|
-
var templateObject_1$1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
1501
|
-
|
1502
|
-
var ObjectForMapOverlay = function (props) {
|
1503
|
-
var inspection = props.inspection, map = props.map, label = props.label, other = __rest(props, ["inspection", "map", "label"]);
|
1504
|
-
var _a = useMapCards(inspection.location, map), ref = _a.ref, isOpen = _a.isOpen, closeCard = _a.closeCard, toggleCard = _a.toggleCard;
|
1505
|
-
return (jsx(MapOverlay, __assign({ map: map, position: inspection.location }, { children: jsxs(StyledWrapper, __assign({ ref: ref }, { children: [jsx(ObjectForMapPoint, { label: label, isActive: isOpen, onClick: toggleCard }), isOpen && (jsx(ObjectForMapCard, __assign({ inspection: inspection, onClose: closeCard }, other)))] })) })));
|
1506
|
-
};
|
1507
|
-
var StyledWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
|
1508
|
-
var templateObject_1;
|
1509
|
-
|
1510
|
-
export { AddedMetersBlock, AdditionalInfoFieldsSchema, AdditionalInfoStepSchema, BasicApartmentInfoFieldsSchema, BasicApartmentInfoStepSchema, DetailApartmentInfoFieldsSchema, DetailApartmentInfoStepSchema, FillingInfoFieldsSchema, FillingListStore, HouseInfoFieldsSchema, HouseInfoStepSchema, HouseServicesInfoFieldsSchema, HouseServicesInfoStepSchema, index as InspectionFeedback, InspectionFillingCard, InventoryMeterInfoFields, MetersInfoFieldsSchema, MetersInfoStepSchema, ObjectForMapCard, ObjectForMapOverlay, ObjectForMapPoint, RoomsApartmentInfoFieldsSchema, RoomsApartmentInfoStepSchema, SecurityApartmentInfoFieldsSchema, SecurityApartmentInfoStepSchema, TelecommunicationsInfoFieldsSchema, TelecommunicationsInfoStepSchema, WaterMeterFieldsSchema, apartmentFields, getAdditionalInfoStepFields, getAvailableResourcesFields, getBasicApartmentInfoFields, getDetailApartmentInfoFields, getFillingInfoFields, getHouseInfoStep, getHouseServicesInfoStep, getInventoryMeterFields, getMetersInfoStepFields, getPartialMeterInfoSchema, getRoomsApartmentInfoFields, getRoomsImagesSteps, getSecurityApartmentInfoFields, getTelecommunicationsInfoStepFields, getWaterMeterFields, inspectionsRequestBody, inspectionsRequests, onInspectionModalClose, onInspectionModalOpen, renderMetersSteps, useFillingList, useInspectionData, useInspectionIndexDB, useMetersValues };
|
1511
|
-
//# sourceMappingURL=index.js.map
|
1
|
+
import*as e from"yup";import{NumberField as n,KUISettings as t,requests as r,uploadNewFile as i,uploadFiles as o,ImageStore as a,FileStore as l,matchesAPIFillingTypes as s,CountryAutocomplete as u,RegionAutocomplete as c,CityAutocomplete as d,defaultRequiredMessage as m,HouseTypesValues as p,WallMaterialsValues as v,SlabsTypesValues as h,GasTypesValues as f,BooleanValues as b,positiveNumberSchema as g,RenovationTypeValues as y,RenovationStyleValues as _,RoomTypeValues as x,RoomTypesValues as w,ParkingTypesValues as I,fieldWithConditionSchema as N,BigCheckbox as C,getApartmentPaymentFields as q,phoneWithConditionSchema as P,getNumbersValues as k,TVTypesValues as T,phoneNonRequiredSchema as S,InputFileWithVisibility as M,FillingTypeValues as R,FillingTagsAutocomplete as O,getMeterValuesFieldsSchema as L,basicFieldsOfNewResourceMeter as j,meterUnitLabel as F,FormWrapper as B,MeterTypeRadioGroup as A,InputByType as D,Tooltip as z,ApartmentsAgent as V,PreviewContent as H,Link as E,UserBadge as W,useMapCards as G,MapOverlay as U}from"kui-crm";import Y from"lodash";import{clearNotValidFields as K,getPhoneNumberFromPhoneParams as Z,resHandler as J,callPromises as Q,getPhoneParamsFromString as X,addToArrayByCondition as $,Loader as ee,clearIndexStores as ne,addToIndexDBWithQueue as te,initIndexDB as re,readFromIndexDB as ie,addIndexDBStore as oe}from"kui-utils";import ae from"await-to-js";import{DateTime as le}from"luxon";import{InputWithAddressAutocomplete as se,DependentInput as ue,CheckboxWithController as ce,InputPhoneWithForm as de,InputFile as me}from"kui-complex";import{jsxs as pe,jsx as ve}from"react/jsx-runtime";import{useState as he,useMemo as fe,useEffect as be}from"react";import{useForm as ge}from"react-hook-form";import{Caption as ye,theme as _e,Grid as xe,Button as we}from"kui-basic";import{yupResolver as Ie}from"@hookform/resolvers/yup";import Ne from"@emotion/styled";import{WarningIcon as Ce,CheckIcon as qe,CancelIcon as Pe,CommentIcon as ke,UpdateIcon as Te,PhoneIcon as Se,CloseIcon as Me}from"kui-icon";import{observer as Re}from"mobx-react";import{makeAutoObservable as Oe}from"mobx";var Le=function(){return Le=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},Le.apply(this,arguments)};function je(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(t[r[i]]=e[r[i]])}return t}function Fe(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))}function Be(e,n){var t,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=n.call(e,a)}catch(e){o=[6,e],r=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,l])}}}function Ae(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))}function De(e,n){return Object.defineProperty?Object.defineProperty(e,"raw",{value:n}):e.raw=n,e}var ze,Ve,He,Ee,We=function(n){var t=n.filter((function(e){return e.maxIntegerPart})).map((function(e){return e.name})).map((function(n){var t;return(t={})[n]=e.number().min(0).required("This field is required").transform((function(e){return Number.isNaN(e)?void 0:e})),t}));return e.object().shape(Le({number:e.string().trim().required("This field is required")},Object.assign.apply(Object,Ae([{}],t,!1))))},Ge=e.object().shape({number:e.string().trim().required("This field is required"),value:e.number().min(0).required("This field is required").transform((function(e){return Number.isNaN(e)?void 0:e}))}),Ue=function(e,t,r,i,o){var a,l,s=i?"".concat(i,"."):"",u=e.length?e.map((function(e){return{value:e.number,label:"".concat(Y.capitalize(e.type||"")," | #").concat(e.number)}})):[{value:null==t?void 0:t.number,label:"".concat(Y.capitalize((null==t?void 0:t.type)||"")," | #").concat(null==t?void 0:t.number)}];return[Le({label:"Meter",name:"".concat(s,"number"),variant:"select",options:u,size:12,isRequired:!0,disabled:1===u.length},null==o?void 0:o.meter),Le({label:"Value",name:"".concat(s,"value"),variant:"custom",CustomInput:n,maxIntegerPart:7,maxDecimalPart:3,maxValue:(null===(a=null==t?void 0:t.maxValue)||void 0===a?void 0:a.value)&&r?Number(t.maxValue.value):null,warningMessage:"There are deviations in meter readings. It should be no more than",placeholder:null===(l=null==t?void 0:t.values)||void 0===l?void 0:l.value,isRequired:!0},null==o?void 0:o.value)]},Ye={getPostBodyInitialInspection:function(e,n){return{based_on:null,date:(e.date||le.now()).toISODate(),inspection_type:"initial",dropbox_link:e.dropboxLink,photo_groups:n,initial:this.getInitialInspectionFields(e)}},getInitialInspectionFields:function(e){var n,t,r;return{city:e.city.id,address:e.apartment.address,apartment_number:e.apartmentNumber||"",post_index:e.zipCode,floor:e.floor,floor_count:e.floorCount,room_type:e.typeOfObject,num_entrance:e.entrance,has_intercom:e.hasIntercom,intercom_code:e.intercomCode,has_gate:e.hasGate,gate_code:e.gateCode,area:e.area,rooms_number:e.roomsNumber,bedrooms_number:e.bedroomsNumber,bathrooms_number:e.bathroomsNumber,restrooms_number:e.restroomsNumber,combined_bathrooms_number:e.combinedBathroomsNumber,number_of_windows:e.numberOfWindows,renovation_year:null===(n=e.renovation)||void 0===n?void 0:n.year,renovation_type:null===(t=e.renovation)||void 0===t?void 0:t.type,renovation_style:null===(r=e.renovation)||void 0===r?void 0:r.style,wall_type:e.wallMaterial,overlap_type:e.overlapType,passenger_elevators_number:e.passengerElevatorsCount,service_elevators_number:e.serviceElevatorsCount,ceiling_height:e.ceilingHeight,building_year:e.buildingYear,serial_number:e.houseNumber,type_gas:e.gasLeads,hot_water:e.withHotWater,type_houses:e.typeOfHouse,parking_type:e.parkingType,parking_number:e.parkingNumber,rooms:e.rooms.map((function(e,n){return{id:e.id,room_type:e.type,order_number:n}})),metro:e.metroStations.map((function(e){return{name:e.name||"",metro_station_id:e.id,distance_walk_meters:e.walkDistance,distance_car_kilometers:e.carDistance,time_car_minutes:e.carTime}})),used_resources:{electricity:e.availableResources.electricity,water:e.availableResources.water,gas:e.availableResources.gas,heating:e.availableResources.heating}}},getPostBodyRegularInspection:function(e,n){return{date:(e.date||le.now()).toISODate(),inspection_type:"regular",based_on:null,dropbox_link:e.dropboxLink,photo_groups:n,regular:Le(Le({},this.getInspectionFilling(e.fillingList)),this.getPartialInspectionMeters(e.meters))}},getPostBodyTransferInspection:function(e,n,t){return{date:(e.date||le.now()).toISODate(),inspection_type:"transfer",based_on:null,dropbox_link:e.dropboxLink,photo_groups:n,transfer:Le(Le({contract_document:t||void 0,transfer_type:e.transferType},this.getInspectionFilling(e.fillingList)),this.getPartialInspectionMeters(e.meters))}},getInspectionFilling:function(e){return{filling:null==e?void 0:e.map((function(e){return{apartment_feature_id:e.id,is_absent:!e.check}}))}},getPartialInspectionMeters:function(e){var n=this;return{meters:(null==e?void 0:e.map((function(e,t){return{id:e.id,resource_type:e.resource,meter_type:e.type,passport_number:e.number,photos:n.getFilesParams(e.images),values:K(n.getInspectionMeterValues(e))}})))||[]}},getPostBodyInventoryInspection:function(e,n,t,r,i){var o,a,l,s,u,c,d,m,p,v,h,f=this;return{date:(e.date||le.now()).toISODate(),inspection_type:"inventory",based_on:null,dropbox_link:e.dropboxLink,photo_groups:n,inventory:Le({contract_document:i||void 0,allowed_children:e.withChildren,allowed_pets:e.withPets,allowed_smoking:e.withSmoking,additional_terms:e.additionalTerms,country_of_residence:(null===(o=e.countryOfResidence)||void 0===o?void 0:o.id)||null,administrative_company:(null===(a=e.company)||void 0===a?void 0:a.id)||null,tax_type:e.taxesType,financial_personal_account:e.communalServicesAccount,max_electricity_counters:null===(l=e.maxMeters)||void 0===l?void 0:l.electricity,max_gas_counters:null===(s=e.maxMeters)||void 0===s?void 0:s.gas,max_heating_counters:null===(u=e.maxMeters)||void 0===u?void 0:u.heating,max_water_counters:null===(c=e.maxMeters)||void 0===c?void 0:c.water,has_barrier:e.hasBarrier,has_concierge:e.hasConcierge,has_security:e.hasSecurity,has_video_surveillance:e.hasVideoControl,barrier_phone:e.barrierPhone?Z(e.barrierPhone):null,concierge_phone:e.conciergePhone?Z(e.conciergePhone):null,security_phone:e.securityPhone?Z(e.securityPhone):null,video_surveillance_phone:e.videoControlPhone?Z(e.videoControlPhone):null,home_phone:e.homePhone?Z(e.homePhone):null,wifi_name:null===(d=e.wifi)||void 0===d?void 0:d.name,wifi_password:null===(m=e.wifi)||void 0===m?void 0:m.password,internet_provider_link:null===(p=e.internetProvider)||void 0===p?void 0:p.link,internet_provider_login:null===(v=e.internetProvider)||void 0===v?void 0:v.login,internet_provider_password:null===(h=e.internetProvider)||void 0===h?void 0:h.password,payer_code:e.payerCode,filling:e.fillingList.map((function(e,n){var r;return{feature:(null===(r=e.tag)||void 0===r?void 0:r.id)||0,description:e.description,model:e.name,serial_code:e.serialNumber,amount:e.numberOfSubjects,photos:f.getFilesParams(e.images),instruction:t[n]}}))},this.getInventoryInspectionMeters(e.meters,r))}},getInventoryInspectionMeters:function(e,n,t){var r=this;return{meters:(null==e?void 0:e.map((function(e,i){return Le(Le({},r.getMeterCommonFields(e)),{passport:n[i],values:K(r.getInspectionMeterValues(e,"initialValue")),photos:t?t[i]:r.getFilesParams(e.images),no_tariff:e.noTariff,auto_sending:e.withAutoSending})})))||[]}},getInspectionMeterValues:function(e,n){var t;if("electricity"===e.resource){var r=n||"",i=e["".concat(r,"T1")],o=e["".concat(r,"T2")],a=e["".concat(r,"T3")];return{T1:i?Number(i):i,T2:o?Number(o):o,T3:a?Number(a):a}}var l=n||"value";if("water"===e.resource){if("cold"===e.type){var s=e[l];return{cold:s?Number(s):s}}var u=e[l];return{hot:u?Number(u):u}}var c=e[l];return(t={})[e.resource]=c?Number(c):c,t},getMeterCommonFields:function(e){var n;return{id:e.id,meter_type:e.type,passport_number:e.number,resource_type:e.resource,activation_date:(null===(n=e.startDate)||void 0===n?void 0:n.toISODate())||null}},getMeterValues:function(e,n){return K({initial_value:e,last_value:n})},getFilesParams:function(e){return(null==e?void 0:e.map((function(e){return e.uploadedData})).filter((function(e){return e})))||[]}},Ke={createInspectionHandler:function(e,n,r){return Fe(this,void 0,void 0,(function(){var i,o;return Be(this,(function(a){switch(a.label){case 0:if(!e)return[3,5];n.startLoading("inspection creation"),i=void 0,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r()];case 2:return i=a.sent(),[3,4];case 3:return o=a.sent(),t.getSettings().Sentry.captureException(o),n.setError("inspection creation body",o),[3,4];case 4:return i?[2,this.createInspection(e,i,n)]:[2,null];case 5:return[2,null]}}))}))},getInspectionTypes:function(e){return Fe(this,void 0,void 0,(function(){var n,t,i;return Be(this,(function(o){switch(o.label){case 0:return[4,ae(r.get("/apartments/".concat(e,"/inspection-types")))];case 1:return n=o.sent(),t=n[0],i=n[1],t?[2,[t,void 0]]:[2,[null,null==i?void 0:i.inspection_types]]}}))}))},getTransferTypes:function(e){return Fe(this,void 0,void 0,(function(){var n,t,i;return Be(this,(function(o){switch(o.label){case 0:return[4,ae(r.get("/apartments/".concat(e,"/transfer-inspection-types")))];case 1:return n=o.sent(),t=n[0],i=n[1],t?[2,[t,void 0]]:[2,[null,null==i?void 0:i.transfer_inspection_types]]}}))}))},createInspection:function(e,n,t){var i;return Fe(this,void 0,void 0,(function(){var o;return Be(this,(function(a){switch(a.label){case 0:return[4,ae(r.post("/apartments/".concat(e,"/inspections"),n))];case 1:return o=a.sent(),J(o,t),[2,null===(i=o[1])||void 0===i?void 0:i.id]}}))}))},createInitialInspection:function(e,n,t){return Fe(this,void 0,void 0,(function(){var r=this;return Be(this,(function(i){return[2,this.createInspectionHandler(n,t,(function(){return Fe(r,void 0,void 0,(function(){var n;return Be(this,(function(t){return n=this.getRoomParams(e.roomsImages),[2,Ye.getPostBodyInitialInspection(e,n)]}))}))}))]}))}))},createRegularInspection:function(e,n,t){return Fe(this,void 0,void 0,(function(){var r=this;return Be(this,(function(i){return[2,this.createInspectionHandler(n,t,(function(){return Fe(r,void 0,void 0,(function(){var n;return Be(this,(function(t){return n=this.getRoomParams(e.roomsImages),[2,Ye.getPostBodyRegularInspection(e,n)]}))}))}))]}))}))},createTransferInspection:function(e,n,t){return Fe(this,void 0,void 0,(function(){var r=this;return Be(this,(function(o){return[2,this.createInspectionHandler(n,t,(function(){return Fe(r,void 0,void 0,(function(){var n,r;return Be(this,(function(o){switch(o.label){case 0:return n=this.getRoomParams(e.roomsImages),[4,i(t,e.contractFile)];case 1:return r=o.sent(),[2,Ye.getPostBodyTransferInspection(e,n,r)]}}))}))}))]}))}))},createInventoryInspection:function(e,n,t){return Fe(this,void 0,void 0,(function(){var r=this;return Be(this,(function(a){return[2,this.createInspectionHandler(n,t,(function(){return Fe(r,void 0,void 0,(function(){var n,r,a,l,s;return Be(this,(function(u){switch(u.label){case 0:return n=e.fillingList.map((function(e){return e.instruction})),r=(null===(s=e.meters)||void 0===s?void 0:s.map((function(e){return e.passportFile})))||[],[4,Q([o(t,n),o(t,r),i(t,e.contractFile)])];case 1:return a=u.sent(),l=this.getRoomParams(e.roomsImages),[2,Ye.getPostBodyInventoryInspection(e,l,a[0],a[1],a[2])]}}))}))}))]}))}))},getRoomParams:function(e){var n=-1;return(null==e?void 0:e.map((function(e){var t="room"===e.type||"bedroom"===e.type;return t&&(n+=1),{purpose:null==e?void 0:e.type,comment:null==e?void 0:e.comment,photos:Ye.getFilesParams(e.files),room_order_number:t?n:void 0}})).filter((function(e){return e.purpose})))||[]}},Ze={getApartmentDescriptionInfo:function(e){return Le(Le(Le(Le(Le(Le({},this.getApartmentMainInfo(e)),this.getApartmentSecurityInfo(e)),this.getApartmentDetailInfo(e)),this.getApartmentTelecommunicationInfo(e)),this.getApartmentHouseInfo(e)),this.getMaxMetersParams(e))},getApartmentMainInfo:function(e){return Le(Le({},e),{apartmentNumber:e.apartment_number,zipCode:e.post_index||"",floorCount:e.floor_count,entrance:e.num_entrance,geolocation:this.getGeolocationParams(e.geolocation),distanceToCenter:e.distance_to_center_kilometers||null,typeOfObject:e.room_type})},getApartmentSecurityInfo:function(e){var n,t,r,i,o,a;return{hasIntercom:null!==(n=e.has_intercom)&&void 0!==n?n:null,hasGate:null!==(t=e.has_gate)&&void 0!==t?t:null,hasBarrier:null!==(r=e.has_barrier)&&void 0!==r?r:null,hasSecurity:null!==(i=e.has_security)&&void 0!==i?i:null,hasConcierge:null!==(o=e.has_concierge)&&void 0!==o?o:null,hasVideoControl:null!==(a=e.has_video_surveillance)&&void 0!==a?a:null,intercomCode:e.intercom_code||"",gateCode:e.gate_code||"",barrierPhone:e.barrier_phone?X(e.barrier_phone):null,conciergePhone:e.concierge_phone?X(e.concierge_phone):null,securityPhone:e.security_phone?X(e.security_phone):null,videoControlPhone:e.video_surveillance_phone?X(e.video_surveillance_phone):null}},getApartmentDetailInfo:function(e){var n;return{area:e.area,livingArea:e.living_area,kitchenArea:e.kitchen_area,roomsNumber:e.rooms_number,bedroomsNumber:e.bedrooms_number,bathroomsNumber:e.bathrooms_number,restroomsNumber:e.restrooms_number,combinedBathroomsNumber:e.combined_bathrooms_number,ceilingHeight:e.ceiling_height,numberOfWindows:e.number_of_windows,renovation:{year:e.renovation_year||null,type:e.renovation_type||null,style:e.renovation_style||null},rooms:(null===(n=e.rooms)||void 0===n?void 0:n.map((function(e){return{id:e.id,area:e.area||null,type:e.room_type||null}})))||[]}},getApartmentTelecommunicationInfo:function(e){return{homePhone:e.home_phone?X(e.home_phone):null,wifi:{name:e.wifi_name,password:e.wifi_password},internetProvider:{link:e.internet_provider_link,login:e.internet_provider_login,password:e.internet_provider_password},tvType:e.tv_type}},getApartmentHouseInfo:function(e){return{typeOfHouse:e.type_houses,buildingYear:e.building_year,houseNumber:e.serial_number,wallMaterial:e.wall_type,overlapType:e.overlap_type,parkingType:e.parking_type,parkingNumber:e.parking_number,passengerElevatorsCount:e.passenger_elevators_number?Number(e.passenger_elevators_number):null,serviceElevatorsCount:e.service_elevators_number?Number(e.service_elevators_number):null,gasLeads:e.type_gas,withHotWater:e.hot_water}},getMaxMetersParams:function(e){return{maxMeters:{water:e.max_water_counters,electricity:e.max_electricity_counters,gas:e.max_gas_counters,heating:e.max_heating_counters}}},getGeolocationParams:function(e){return e?{lat:Number(e.lat),lng:Number(e.lon)}:null},getObjectRoomsImages:function(e){return e.map((function(e){return{id:e.id,type:e.purpose,comment:e.comment,images:e.photos.map((function(e){return a.initFromImageModel(e)})),roomNumber:"number"==typeof e.room_order_number?e.room_order_number+1:0}}))},getInspectionFillingParams:function(e,n){var t;return Le({id:e.id,name:e.description||"",tag:{id:e.feature.id,name:e.feature.name},images:null===(t=e.photos)||void 0===t?void 0:t.map((function(e){return a.initFromImageModel(e)})),serialNumber:e.serial_code,numberOfSubjects:Number(e.amount),instruction:e.instruction?l.initFromDocumentModel(e.instruction):null,type:s[e.feature.feature_type]},n&&"appliance"===e.feature.feature_type?{check:!e.is_absent,wasMissing:e.previously_absent}:{})},getApartmentDescriptionWithMetro:function(e){return Le(Le({},this.getApartmentDescriptionInfo(e)),{metroStations:this.getMetroStationsParams(null==e?void 0:e.metro_stations)})},getMetroStationsParams:function(e){return(null==e?void 0:e.map((function(e){return{id:e.metro_station_id,name:e.name,walkDistance:e.distance_walk_meters,carDistance:Number(e.distance_car_kilometers),carTime:e.time_car_minutes,walkTime:Math.round(e.distance_walk_meters/(5e3/60))}})))||[]},getMeterValues:function(e,n,t){var r,i,o,a,l,s;if("electricity"===n){var u=t||"";return Le(Le(((r={})["".concat(u,"T1")]=Number(e.values.T1),r),"T1"!==e.meter_type&&((i={})["".concat(u,"T2")]=Number(e.values.T2),i)),"T3"===e.meter_type&&((o={})["".concat(u,"T3")]=Number(e.values.T3),o))}var c=t||"value";return"water"===n?"cold"===e.meter_type?((a={})["".concat(c)]=Number(e.values.cold),a):((l={})["".concat(c)]=Number(e.values.hot),l):((s={})["".concat(c)]=Number(e.values[n]),s)},getTransferMetersInfo:function(e){var n=this;return{meters:e.map((function(e){var t;return Le({id:e.id,type:e.meter_type,number:e.passport_number,resource:e.resource_type,images:(null===(t=e.photos)||void 0===t?void 0:t.map((function(e){return a.initFromImageModel(e)})))||[],values:n.getMeterValues(e,e.resource_type)},n.getMeterValues(e,e.resource_type))}))}},getApartmentPaymentInfo:function(e){return{payerCode:e.payer_code,communalServicesAccount:e.financial_personal_account,managementCompany:e.administrative_company?Le(Le({},e.administrative_company),{operatingAccount:e.payer_code}):null}},getInspectionPaymentInfo:function(e){return Le(Le({},this.getApartmentPaymentInfo(e)),{countryOfResidence:e.country_of_residence,taxesType:e.tax_type})},getMeterInfo:function(e,n){var t;return{id:e.id,type:e.meter_type,number:e.passport_number,startDate:e.activation_date?le.fromISO(e.activation_date):null,company:e.company,operationalAccountNumber:e.operating_account,resource:n,tariff:e.tariff?{id:e.tariff.id,name:e.tariff.code_name}:null,passportFile:e.passport?l.initFromFileModel(e.passport):null,images:(null===(t=e.photos)||void 0===t?void 0:t.map((function(e){return a.initFromImageModel(e)})))||[]}},getInventoryMetersInfo:function(e){var n=this;return{meters:e.meters.map((function(e){return Le(Le({},n.getMeterInfo(e,e.resource_type)),n.getMeterValues(e,e.resource_type,"initialValue"))}))}}},Je=function(e,n){return[Le({name:"country",label:"Country",variant:"custom",CustomInput:u,size:12},null==n?void 0:n.country),Le({name:"region",label:"Region",variant:"custom",CustomInput:c},null==n?void 0:n.region),Le({name:"city",label:"City",variant:"custom",CustomInput:d,isRequired:!0},null==n?void 0:n.city),Le({name:"apartment",variant:"custom",CustomInput:se,handlePlaceSelect:e,size:12,isRequired:!0},null==n?void 0:n.apartment),Le({label:"Apartment",name:"apartmentNumber","data-testid":"apartment_number",isRequired:!0},null==n?void 0:n.apartmentNumber),Le({label:"Zip code",name:"zipCode"},null==n?void 0:n.zipCode)]},Qe={apartment:e.object({address:e.string().trim().required("This field is required")}),apartmentNumber:e.string().required("This field is required"),city:e.object({name:e.string().required("This field is required")}),metroStations:e.array().of(e.object({id:e.number().transform((function(e){return Number.isNaN(e)?void 0:e})),name:e.string().required(m).test("check-id","Please select an metro station from the dropdown",(function(e){return!!this.parent.id})),walkDistance:e.string().required(m),carDistance:e.string().required(m),carTime:e.string().required(m)}))},Xe=e.object(Qe),$e=function(e){return[Le({name:"typeOfHouse",label:"Type houses",variant:"select",options:p,isRequired:!0},null==e?void 0:e.typeOfHouse),Le({name:"houseNumber",label:"House series"},null==e?void 0:e.houseNumber),Le({name:"wallMaterial",label:"Wall material",variant:"select",options:v,isRequired:!0},null==e?void 0:e.wallMaterial),Le({name:"overlapType",label:"Overlap type",variant:"select",options:h,isRequired:!0},null==e?void 0:e.overlapType),Le({name:"gasLeads",label:"Gas",variant:"select",options:f,isRequired:!0},null==e?void 0:e.gasLeads),Le({name:"withHotWater",label:"Hot water",variant:"select",options:b,isRequired:!0},null==e?void 0:e.withHotWater),Le({name:"passengerElevatorsCount",label:"Passenger elevators",type:"number",isRequired:!0},null==e?void 0:e.passengerElevatorsCount),Le({name:"serviceElevatorsCount",label:"Service elevators",type:"number",isRequired:!0},null==e?void 0:e.serviceElevatorsCount),Le({name:"buildingYear",label:"Builded",isRequired:!0},null==e?void 0:e.buildingYear)]},en={passengerElevatorsCount:g,serviceElevatorsCount:g,typeOfHouse:e.string().required(m),buildingYear:e.string().required(m),wallMaterial:e.string().required(m),overlapType:e.string().required(m),gasLeads:e.string().required(m),withHotWater:e.boolean().required(m)},nn=e.object(en),tn={step:.01},rn=function(e,n,t){var r,i;return Ae(Ae([Le(Le({label:"Total area",name:"area",type:"number",isRequired:!0},tn),null==t?void 0:t.area)],e?new Array(Number(e)).fill(0).map((function(e,r){var i,o=n&&r<n?"Bedroom ".concat(r+1):"Room ".concat(r+1),a=n&&r<n?"bedrooms":"rooms";return[Le({name:"rooms.".concat(r,".type"),label:"".concat(o," type"),variant:"select",options:x,isRequired:!0},(null==t?void 0:t[a])?null===(i=t[a](r))||void 0===i?void 0:i.type:{})]})).flat():[],!0),[Le(Le({name:"ceilingHeight",label:"Ceiling height",type:"number",cornerLabel:"m.",isRequired:!0},tn),null==t?void 0:t.ceilingHeight),Le({name:"numberOfWindows",label:"Windows",type:"number",isRequired:!0},null==t?void 0:t.numberOfWindows),Le({name:"renovation.year",label:"Year of last renovation",type:"number",isRequired:!0},null==t?void 0:t.renovation.year),Le({name:"renovation.type",label:"Type of renovation",variant:"select",options:y,isRequired:!0},null===(r=null==t?void 0:t.renovation)||void 0===r?void 0:r.type),Le({name:"renovation.style",label:"Renovation style",variant:"select",options:_,isRequired:!0},null===(i=null==t?void 0:t.renovation)||void 0===i?void 0:i.style)],!1)},on={area:e.number().positive().required("This field is required"),rooms:e.array().of(e.object({type:e.string().required("This field is required")})),numberOfWindows:e.number().min(0).required("This field is required"),renovation:e.object({year:e.number().positive().required("This field is required"),type:e.string().required("This field is required"),style:e.string().required("This field is required")}),ceilingHeight:g},an=e.object(on),ln=function(e,n){return[Le({label:"Floor",name:"floor",type:"number",isRequired:!0},null==n?void 0:n.floor),Le({label:"Floors",name:"floorCount",type:"number",isRequired:!0},null==n?void 0:n.floorCount),Le({label:"Rooms",name:"roomsNumber",type:"number",isRequired:!0},null==n?void 0:n.roomsNumber),Le({label:"Bedrooms",name:"bedroomsNumber",type:"number",isRequired:!0,disabled:0===e||"0"===e},null==n?void 0:n.bedroomsNumber),Le({label:"Bathrooms",name:"bathroomsNumber",type:"number",isRequired:!0},null==n?void 0:n.bathroomsNumber),Le({label:"Restrooms",name:"restroomsNumber",type:"number",isRequired:!0},null==n?void 0:n.restroomsNumber),Le({label:"Combined bathroom",name:"combinedBathroomsNumber",type:"number",isRequired:!0},null==n?void 0:n.combinedBathroomsNumber)]},sn={floor:e.number().integer().min(0).test("is less than floorCount","Too much",(function(e){return e<=this.parent.floorCount})),floorCount:e.number().integer().positive().required("This field is required"),roomsNumber:e.number().integer().min(0).required("This field is required"),bedroomsNumber:e.number().integer().min(0).required("This field is required"),bathroomsNumber:e.number().integer().min(0).required("This field is required"),restroomsNumber:e.number().integer().min(0).required("This field is required"),combinedBathroomsNumber:e.number().integer().min(0).required("This field is required")},un=e.object(sn),cn=function(e){return[Le({label:"Object type",name:"typeOfObject",variant:"select",options:w,isRequired:!0},null==e?void 0:e.typeOfObject),Le({label:"Entrance",name:"entrance",isRequired:!0},null==e?void 0:e.entrance),Le({name:"hasIntercom",label:"Intercom",variant:"select",options:b,isRequired:!0},null==e?void 0:e.hasIntercom),Le({name:"intercomCode",label:"Intercom code",variant:"custom",CustomInput:ue,dependentInputName:"hasIntercom"},null==e?void 0:e.intercomCode),Le({name:"hasGate",label:"Gate",variant:"select",options:b,isRequired:!0},null==e?void 0:e.hasGate),Le({name:"gateCode",label:"Gate code",variant:"custom",CustomInput:ue,dependentInputName:"hasGate"},null==e?void 0:e.gateCode),Le({name:"parkingType",label:"Parking",variant:"select",options:I},null==e?void 0:e.parkingType),Le({name:"parkingNumber",label:"Parking number",variant:"custom",CustomInput:ue,dependentInputName:"parkingType"},null==e?void 0:e.parkingNumber)]},dn={typeOfObject:e.string().required("This field is required"),entrance:e.string().required("This field is required"),hasIntercom:e.string().required("This field is required"),intercomCode:N("hasIntercom"),hasGate:e.string().required("This field is required"),gateCode:N("hasGate")},mn=e.object(dn),pn=function(e){return[Le({label:"Water",name:"availableResources.water",variant:"custom",CustomInput:C},null==e?void 0:e.water),Le({label:"Electricity",name:"availableResources.electricity",variant:"custom",CustomInput:C},null==e?void 0:e.electricity),Le({label:"Gas",name:"availableResources.gas",variant:"custom",CustomInput:C},null==e?void 0:e.gas),Le({label:"Heating",name:"availableResources.heating",variant:"custom",CustomInput:C},null==e?void 0:e.heating)]},vn={size:"s"},hn=function(e){return Ae([Le({label:"Pets",name:"withPets",variant:"custom",CustomInput:ce,labelProps:vn},null==e?void 0:e.withPets),Le({label:"Children",name:"withChildren",variant:"custom",CustomInput:ce,labelProps:vn},null==e?void 0:e.withChildren),Le({label:"Smoking",name:"withSmoking",variant:"custom",CustomInput:ce,labelProps:vn},null==e?void 0:e.withSmoking),Le({isTextArea:!0,placeholder:"other terms",name:"additionalTerms"},null==e?void 0:e.additionalTerms)],q(e),!0)},fn={taxesType:e.string().required(m),countryOfResidence:e.object({name:e.string().required(m)}),company:e.object({name:e.string().required(m)})},bn=e.object(fn),gn=function(e){return[Le({name:"hasBarrier",label:"Barrier",variant:"select",options:b,isRequired:!0},null==e?void 0:e.hasBarrier),Le({name:"barrierPhone",label:"Barrier code",variant:"custom",CustomInput:ue,dependentInputName:"hasBarrier",Input:de},null==e?void 0:e.barrierPhone),Le({name:"hasConcierge",label:"Concierge",variant:"select",options:b,isRequired:!0},null==e?void 0:e.hasConcierge),Le({name:"conciergePhone",label:"Concierge",variant:"custom",CustomInput:ue,dependentInputName:"hasConcierge",Input:de},null==e?void 0:e.conciergePhone),Le({name:"hasSecurity",label:"Security",variant:"select",options:b,isRequired:!0},null==e?void 0:e.hasSecurity),Le({name:"securityPhone",label:"Security",variant:"custom",CustomInput:ue,dependentInputName:"hasSecurity",Input:de},null==e?void 0:e.securityPhone),Le({name:"hasVideoControl",label:"Video surveillance",variant:"select",options:b,isRequired:!0},null==e?void 0:e.hasVideoControl),Le({name:"videoControlPhone",label:"Video surveillance",variant:"custom",CustomInput:ue,dependentInputName:"hasVideoControl",Input:de},null==e?void 0:e.videoControlPhone)]},yn={hasBarrier:e.string().required(m),barrierPhone:P("hasBarrier"),hasConcierge:e.string().required(m),conciergePhone:P("hasConcierge"),hasSecurity:e.string().required(m),securityPhone:P("hasSecurity"),hasVideoControl:e.string().required(m),videoControlPhone:P("hasVideoControl")},_n=e.object(yn),xn=k(7),wn=function(e){var n,t,r,i;return[Le({name:"maxMeters.water",label:"Water",variant:"select",options:xn,isRequired:!0},null===(n=null==e?void 0:e.maxMeters)||void 0===n?void 0:n.water),Le({name:"maxMeters.electricity",label:"Electricity",variant:"select",options:xn,isRequired:!0},null===(t=null==e?void 0:e.maxMeters)||void 0===t?void 0:t.electricity),Le({name:"maxMeters.gas",label:"Gas",variant:"select",options:xn,isRequired:!0},null===(r=null==e?void 0:e.maxMeters)||void 0===r?void 0:r.gas),Le({name:"maxMeters.heating",label:"Heating",variant:"select",options:xn,isRequired:!0},null===(i=null==e?void 0:e.maxMeters)||void 0===i?void 0:i.heating)]},In={maxMeters:e.object({water:g,electricity:g,gas:g,heating:g})},Nn=e.object(In),Cn=function(e){var n,t,r,i,o;return[Le({name:"wifi.name",label:"Name of network"},null===(n=null==e?void 0:e.wifi)||void 0===n?void 0:n.name),Le({name:"wifi.password",label:"WiFi password"},null===(t=null==e?void 0:e.wifi)||void 0===t?void 0:t.password),Le({name:"internetProvider.link",label:"Link to provider",size:12},null===(r=null==e?void 0:e.internetProvider)||void 0===r?void 0:r.link),Le({name:"internetProvider.login",label:"Login"},null===(i=null==e?void 0:e.internetProvider)||void 0===i?void 0:i.login),Le({name:"internetProvider.password",label:"Password"},null===(o=null==e?void 0:e.internetProvider)||void 0===o?void 0:o.password),Le({name:"tvType",label:"Television",variant:"select",options:T},null==e?void 0:e.tvType),Le({name:"homePhone",label:"Home phone",variant:"phone"},null==e?void 0:e.homePhone)]},qn={homePhone:S("homePhone")},Pn=e.object().shape(qn,[["homePhone","homePhone"]]),kn=function(e,n,t,r){return Ae(Ae(Ae(Ae(Ae(Ae(Ae([],$(e,Le({label:"Filling type",name:"type",variant:"select",options:R,handleChange:t,isRequired:!0},null==r?void 0:r.type)),!0),[Le({label:"Name (tag)",name:"tag",type:n,variant:"custom",CustomInput:O,isRequired:!0},null==r?void 0:r.tag)],!1),$("finish"!==n,Le({label:"Model",name:"name",isRequired:!0},null==r?void 0:r.name)),!0),$("finish"!==n,Le({label:"Serial code",name:"serialNumber",size:6},null==r?void 0:r.serialNumber)),!0),$("finish"!==n,Le({label:"Amount",name:"numberOfSubjects",type:"number",size:6},null==r?void 0:r.numberOfSubjects)),!0),[Le({label:"Description",name:"description",isTextArea:!0},null==r?void 0:r.description)],!1),$("finish"!==n,Le({label:"Instruction",name:"instruction",variant:"custom",CustomInput:M},null==r?void 0:r.instruction)),!0)},Tn=e.object().shape({type:e.string(),tag:e.object({name:e.string().required(m)}),name:e.string().when("type",{is:function(e){return"electronics"===e},then:function(e){return e.required(m)}})}),Sn={number:e.string().required("This field is required")},Mn=function(n){var t=L(n);return e.object().shape(Le(Le({},Sn),Object.assign.apply(Object,Ae([{}],t,!1))))},Rn=function(e,n){return Ae(Ae([],j(e,n),!0),[Le({label:"Activation date",name:"startDate",variant:"date",max:le.now()},null==n?void 0:n.startDate),Le({label:"Passport",name:"passportFile",variant:"custom",CustomInput:me},null==n?void 0:n.passportFile)],!1)},On=function(e){var n=e.meter,t=e.getMeterLabel,r=n.resource,i=n.type,o=n.number,a=[n.initialValue,n.initialValueT1,n.initialValueT2,n.initialValueT3].filter((function(e){return void 0!==e})).map((function(e){return e})).join(" / "),l=t?t(r,i):Y.capitalize("".concat(i?"".concat(i," "):"").concat(r," meter"));return pe(ye,Le({"data-testid":"addedMeterLine",size:"s"},{children:["• ",l," #",o," -"," ",pe(Ln,{children:[a," ",F[n.resource]]})]}))},Ln=Ne.span(ze||(ze=De(["\n font-weight: 600;\n"],["\n font-weight: 600;\n"]))),jn=function(e){var n,t,r=e.resource,i=e.formStore,o=e.label,a=e.getMeterLabel,l=null===(t=null===(n=i.fields)||void 0===n?void 0:n.meters)||void 0===t?void 0:t.filter((function(e){return e.resource===r}));return(null==l?void 0:l.length)?pe(Fn,Le({"data-testid":"addedMetersBlock"},{children:[pe(An,Le({container:!0,alignItems:"center"},{children:[ve(Bn,{}),ve(ye,Le({size:"s",color:"fiftyP"},{children:o||"In the previous steps were added:"}))]})),l.map((function(e){return ve(On,{getMeterLabel:a,meter:e},e.number)}))]})):null},Fn=Ne.div(Ve||(Ve=De(["\n border-radius: 8px;\n border: 1px solid ",";\n padding: 12px 16px;\n background: white;\n"],["\n border-radius: 8px;\n border: 1px solid ",";\n padding: 12px 16px;\n background: white;\n"])),_e.palette.grey.fifteenB),Bn=Ne(Ce)(He||(He=De(["\n margin-right: 8px;\n width: 16px;\n height: 16px;\n path {\n fill: ",";\n }\n"],["\n margin-right: 8px;\n width: 16px;\n height: 16px;\n path {\n fill: ",";\n }\n"])),_e.palette.brand.main),An=Ne(xe)(Ee||(Ee=De(["\n margin-bottom: 8px;\n"],["\n margin-bottom: 8px;\n"])));function Dn(e){var n,t,r=e.resource,i=e.index,o=e.formStore,a=null===(t=null===(n=o.fields)||void 0===n?void 0:n.meters)||void 0===t?void 0:t[i],l="water"===r||"electricity"===r,s=l?"water"===r?"cold":"T1":null,u=he((null==a?void 0:a.type)||s),c=u[0],d=u[1],m=Rn({resource:r,meterType:c}),p=m.filter((function(e){return"number"===e.type})).map((function(e){return e.name})),v=Mn(p),h=fe((function(){return ge({resolver:Ie(v),defaultValues:Le({},a),values:a})}),[v]);return ve(B,Le({form:h,onSubmit:function(e){o.replaceFieldInArray("meters",Le(Le({},e),{resource:r}),i),o.nextStep()},label:"Next",variant:"next",withPrevStep:!0,handlePrevClick:o.prevStep},{children:pe(xe,Le({container:!0,spacing:2},{children:[ve(xe,Le({item:!0,xs:12},{children:ve(jn,{formStore:o,resource:r})})),l&&ve(xe,Le({item:!0,xs:12},{children:ve(A,{form:h,resource:r,handleChange:d})})),m.map((function(e){var n=e.size,t=je(e,["size"]);return ve(xe,Le({item:!0,xs:n||6},{children:ve(D,Le({form:h},t))}),t.name)}))]}))}))}var zn,Vn,Hn,En,Wn,Gn,Un,Yn,Kn,Zn,Jn,Qn,Xn,$n,et,nt,tt,rt,it,ot,at,lt,st,ut=function(e,n,t){return Ae(Ae(Ae(Ae([],new Array(Number((null==t?void 0:t.water)||0)).fill("water"),!0),new Array(Number((null==t?void 0:t.electricity)||0)).fill("electricity"),!0),new Array(Number((null==t?void 0:t.gas)||0)).fill("gas"),!0),new Array(Number((null==t?void 0:t.heating)||0)).fill("heating"),!0).map((function(t,r){return[ve(e,{index:r,resource:t},"meter_info_".concat(r)),ve(n,{index:r,resource:t},"meter_photo_".concat(r))]}))},ct=function(e,n,t){return Ae(Ae(Ae(Ae(Ae(Ae(Ae(Ae(Ae(Ae([Le({type:"kitchen"},n.kitchen)],new Array(Number((null==t?void 0:t.bedroomsNumber)||0)).fill(0).map((function(e,r){return Le({type:"bedroom"},n.bedroom((null==t?void 0:t.bedroomsNumber)?"".concat(r+1," "):""))})),!0),new Array(Math.max(Number((null==t?void 0:t.roomsNumber)||0)-Number((null==t?void 0:t.bedroomsNumber)||0),0)).fill(0).map((function(e,r){return Le({type:"room"},n.room((null==t?void 0:t.roomsNumber)?"".concat(r+1+((null==t?void 0:t.bedroomsNumber)||0)," "):""))})),!0),new Array(Number((null==t?void 0:t.bathroomsNumber)||0)).fill(0).map((function(e,r){return Le({type:"bathroom"},n.bathroom((null==t?void 0:t.bathroomsNumber)?"".concat(r+1," "):""))})),!0),new Array(Number((null==t?void 0:t.restroomsNumber)||0)).fill(0).map((function(e,r){return Le({type:"toilet"},n.toilet((null==t?void 0:t.restroomsNumber)?"".concat(r+1," "):""))})),!0),new Array(Number((null==t?void 0:t.combinedBathroomsNumber)||0)).fill(0).map((function(e,r){return Le({type:"combined_bathroom"},n.combinedBathroom((null==t?void 0:t.combinedBathroomsNumber)?"".concat(r+1," "):""))})),!0),[Le({type:"others"},n.others)],!1),$("initial"===e,Le({type:"entrance"},n.entrance)),!0),$("initial"!==e,Le({type:"keys"},n.keys)),!0),$(!("initial"!==e||!(null==t?void 0:t.parkingType)),Le({type:"parking"},n.parking)),!0),[Le({type:"additional"},n.additional)],!1)},dt=function(e){var n=e.feedback,t=e.label;return ve(mt,Le({status:n.status},{children:pe(xe,Le({container:!0,alignItems:"center"},{children:[ve(ye,Le({size:"s",weight:500,color:"fiftyP"},{children:t})),"notSigned"!==n.status&&pe(pt,{children:["signed"===n.status?ve(vt,{}):ve(ht,{}),!!n.comment&&ve(z,Le({placement:"bottom",content:pe("div",{children:[ve(ye,Le({size:"xs",color:"fiftyP"},{children:"Comment"})),ve(ft,Le({size:"xs"},{children:n.comment}))]})},{children:ve(bt,{})}))]})]}))}))},mt=Ne.div(zn||(zn=De(["\n background: ",";\n border-radius: 66px;\n border: 1px solid ",";\n padding: 6px 16px;\n width: fit-content;\n @media (max-width: ","px) {\n width: 100%;\n > div {\n justify-content: center;\n }\n }\n"],["\n background: ",";\n border-radius: 66px;\n border: 1px solid ",";\n padding: 6px 16px;\n width: fit-content;\n @media (max-width: ","px) {\n width: 100%;\n > div {\n justify-content: center;\n }\n }\n"])),(function(e){return"notSigned"===e.status?_e.palette.background.light1:_e.palette.grey.zero}),_e.palette.grey.fifteenB,_e.breakpoints.sm),pt=Ne.div(Vn||(Vn=De(["\n display: flex;\n align-items: center;\n margin-left: 8px;\n > div {\n margin-left: 8px;\n }\n"],["\n display: flex;\n align-items: center;\n margin-left: 8px;\n > div {\n margin-left: 8px;\n }\n"]))),vt=Ne(qe)(Hn||(Hn=De(["\n path {\n fill: ",";\n }\n"],["\n path {\n fill: ",";\n }\n"])),_e.palette.green.fiftyP),ht=Ne(Pe)(En||(En=De(["\n width: 12px;\n height: 12px;\n path {\n fill: ",";\n }\n"],["\n width: 12px;\n height: 12px;\n path {\n fill: ",";\n }\n"])),_e.palette.red.fiftyP),ft=Ne(ye)(Wn||(Wn=De(["\n margin-top: 8px;\n"],["\n margin-top: 8px;\n"]))),bt=Ne(ke)(Gn||(Gn=De(["\n width: 13px;\n cursor: pointer;\n path {\n fill: ",";\n stroke: ",";\n }\n"],["\n width: 13px;\n cursor: pointer;\n path {\n fill: ",";\n stroke: ",";\n }\n"])),_e.palette.grey.zero,_e.palette.grey.thirty),gt=Re((function(e){var n=e.feedback,t=e.label,r=e.resendLabel,i=e.resend;return n?ve(xe,Le({item:!0},{children:pe(xe,Le({container:!0,alignItems:"center"},{children:[ve(dt,{feedback:n,label:t}),"rejected"===n.status&&ve(yt,Le({size:"xs",variant:"orange",onClick:i,endIcon:ve(Te,{})},{children:r}))]}))})):null})),yt=Ne(we)(Un||(Un=De(["\n margin-left: 16px;\n @media (max-width: ","px) {\n width: 100%;\n margin-left: 0;\n margin-top: 8px;\n }\n"],["\n margin-left: 16px;\n @media (max-width: ","px) {\n width: 100%;\n margin-left: 0;\n margin-top: 8px;\n }\n"])),_e.breakpoints.sm),_t=Re((function(e){var n=e.tenantFeedback,t=e.landlordFeedback,r=e.resignInspection,i=e.resendLabel,o=e.tenantLabel,a=e.landlordLabel;return n||t?pe(xt,Le({container:!0,spacing:2,alignItems:"center"},{children:[ve(gt,{resend:r,resendLabel:i,feedback:n,label:o}),ve(gt,{resend:r,resendLabel:i,feedback:t,label:a})]})):null})),xt=Ne(xe)(Yn||(Yn=De(["\n padding-top: 8px;\n"],["\n padding-top: 8px;\n"]))),wt=function(e){var n=e.filling,t=e.warningLabel;return pe(xe,Le({container:!0,alignItems:"center"},{children:[n.wasMissing&&ve(z,Le({content:ve(ye,Le({size:"xs"},{children:t}))},{children:ve(It,{width:17,height:17})})),pe(Nt,{children:[pe(ye,Le({size:"s"},{children:[n.tagName," ",n.name?" | ".concat(n.name):""]})),!(!n.numberOfSubjects&&!n.serialNumber)&&pe(Ct,Le({size:"xs",color:"fiftyP"},{children:[n.numberOfSubjects?"".concat(n.numberOfSubjects," pieces"):"",n.numberOfSubjects&&n.serialNumber?" • ":"",n.serialNumber]}))]})]}))},It=Ne(Ce)(Kn||(Kn=De(["\n margin-left: 4px;\n path {\n fill: ",";\n }\n"],["\n margin-left: 4px;\n path {\n fill: ",";\n }\n"])),_e.palette.red.fiftyP),Nt=Ne.div(Zn||(Zn=De(["\n margin-left: 8px;\n"],["\n margin-left: 8px;\n"]))),Ct=Ne(ye)(Jn||(Jn=De(["\n margin-top: 4px;\n"],["\n margin-top: 4px;\n"]))),qt=function(e){var n=e.className,t=e.form,r=e.index,i=e.disabled,o=je(e,["className","form","index","disabled"]);return ve(Pt,Le({className:n},{children:ve(kt,{form:t,name:"fillingList.".concat(r,".check"),label:ve(wt,Le({},o)),disabled:i})}))},Pt=Ne(xe)(Qn||(Qn=De(["\n padding: 8px 16px;\n border-radius: 12px;\n background: white;\n"],["\n padding: 8px 16px;\n border-radius: 12px;\n background: white;\n"]))),kt=Ne(ce)(Xn||(Xn=De(["\n .KUI-Label_checkbox {\n margin-left: 0;\n }\n"],["\n .KUI-Label_checkbox {\n margin-left: 0;\n }\n"]))),Tt=function(e,n,t,r){var i=function(){r&&r(),n.loader.endLoading()};be((function(){Fe(void 0,void 0,void 0,(function(){var r,o;return Be(this,(function(a){switch(a.label){case 0:return t?(null===(o=null===(r=e.fields)||void 0===r?void 0:r.meters)||void 0===o?void 0:o.length)?[3,2]:[4,n.fetchMeters()]:[3,3];case 1:a.sent(),a.label=2;case 2:return i(),[3,4];case 3:!1===t&&i(),a.label=4;case 4:return[2]}}))}))}),[t]),be((function(){var t,r;n.loader.isLoading||(null===(r=null===(t=e.fields)||void 0===t?void 0:t.meters)||void 0===r?void 0:r.length)||e.updateFormFields({meters:n.meters})}),[n.meters,n.loader.isLoading])},St=function(){var e=this;this.fetchFillingList=function(n,t){return Fe(e,void 0,void 0,(function(){var e;return Be(this,(function(r){switch(r.label){case 0:return this.loader.startLoading(),[4,ae(V.getFillingList(n,t))];case 1:return e=r.sent(),J(e,this.loader,this.updateFillingList),[2]}}))}))},this.updateFillingList=function(n){e.fillingList=(null==n?void 0:n.map((function(e){return{id:e.id,name:e.description,tagName:e.feature_name,serialNumber:e.serial_code,numberOfSubjects:e.amount,wasMissing:e.is_absent}})))||[]},this.fillingList=[],this.loader=new ee,Oe(this)},Mt=function(e,n,t,r,i){var o=function(){i&&i(),t.loader.endLoading()};be((function(){Fe(void 0,void 0,void 0,(function(){var i,a;return Be(this,(function(l){switch(l.label){case 0:return r&&e?(null===(a=null===(i=n.fields)||void 0===i?void 0:i.fillingList)||void 0===a?void 0:a.length)?[3,2]:[4,t.fetchFillingList(e,"appliance")]:[3,3];case 1:l.sent(),l.label=2;case 2:return o(),[3,4];case 3:!1===r&&o(),l.label=4;case 4:return[2]}}))}))}),[e,r]),be((function(){var e,r;t.loader.isLoading||(null===(r=null===(e=n.fields)||void 0===e?void 0:e.fillingList)||void 0===r?void 0:r.length)||n.updateFormFields({fillingList:t.fillingList.map((function(e){return Le(Le({},e),{check:!1})}))})}),[t.fillingList,t.loader.isLoading])},Rt=function(e,n,t){var r=e.inspectionsStore,i=e.apartmentId,o=n.formStateName,a=n.formFieldsName,l=r.creationForm.fields;l&&l.apartmentId!==i&&ne(r.indexDB,[o,a]),r.setCanUpdateDB(!0),t&&t()},Ot=function(e,n,t){var r=e.inspectionsStore,i=n.formStateName,o=n.formFieldsName;r.setCanUpdateDB(!1),r.creationForm.resetForm(),ne(r.indexDB,[i,o]),t&&t()},Lt=function(e){var n,t=e.apartmentId,r=e.inspectionsStore,i=e.metersStore,o=e.fillingStore,a=he(!1),l=a[0],s=a[1],u=he(!1),c=u[0],d=u[1],m=r.creationForm,p=null===(n=m.fields)||void 0===n?void 0:n.type,v=p?"regular"===p||"transfer"===p:void 0,h=o.loader.isLoading,f=i.loader.isLoading;be((function(){l&&c&&!h&&!f&&r.setCanLoadDB(!0)}),[l,c,h,f]),Tt(m,i,v,(function(){return s(!0)})),Mt(t||null,m,o,v,(function(){return d(!0)}))},jt=function(e,n,t){var r=e.dbCreationTime,i=e.formFieldsName,o=e.formStateName,a=e.inspectionCreationFormName,l=n.inspectionsStore,s=n.apartmentId,u=l.creationForm,c=l.actionLoader,d=l.indexDB,m=l.setCanUpdateDB,p=l.canUpdateDB,v=a,h=function(e){oe(e,i),oe(e,o)};var f=function(){return Fe(void 0,void 0,void 0,(function(){return Be(this,(function(e){return re(v,h,c,(function(e){return Fe(void 0,void 0,void 0,(function(){var n;return Be(this,(function(a){switch(a.label){case 0:return l.setIndexDB(e),m(!1),d=localStorage.getItem(r),p=Date.now(),d&&p-Number(d)>864e5&&(ne(l.indexDB,[o,i]),localStorage.removeItem(r)),[4,ie(e,i,c)];case 1:return(n=a.sent())?(null==n?void 0:n.apartmentId)===s&&(u.updateFormFields(Le(Le({},n),{date:n.date?le.fromISO(n.date):null})),t&&t()):m(!0),[2]}var d,p}))}))})),[2]}))}))};be((function(){s&&f()}),[s]),be((function(){l.canLoadDB&&d&&Fe(void 0,void 0,void 0,(function(){var e,n;return Be(this,(function(t){switch(t.label){case 0:return[4,ie(d,o,c)];case 1:return e=t.sent(),[4,ie(d,i,c)];case 2:return n=t.sent(),e&&(null==n?void 0:n.apartmentId)===s&&u.setStep(Number(e.step)),m(!0),[2]}}))}))}),[l.canLoadDB,d]),be((function(){if(p){var e={step:u.step};te(d,o,e,c),te(d,i,u.fields,c),localStorage.getItem(r)||localStorage.setItem(r,Date.now().toString())}}),[u.step])},Ft=function(e){var n=e.label,t=e.onClick,r=e.isActive;return ve(we,Le({size:"xs",variant:r?"primary":"white",onClick:t},{children:n}))},Bt=function(e){var n=e.metroStation,t=n.color,r=n.name;return pe(At,Le({item:!0,container:!0,alignItems:"center"},{children:[ve(Dt,{style:{background:t}}),ve(ye,Le({size:"s",color:"sixty"},{children:r}))]}))},At=Ne(xe)($n||($n=De(["\n width: auto;\n"],["\n width: auto;\n"]))),Dt=Ne.div(et||(et=De(["\n width: 6px;\n height: 6px;\n border-radius: 50%;\n margin-right: 6px;\n"],["\n width: 6px;\n height: 6px;\n border-radius: 50%;\n margin-right: 6px;\n"]))),zt=function(e){var n=e.phone,t=Z(n," "),r=t.replace(/\d/g,"");return pe(Vt,Le({container:!0,alignItems:"center",wrap:"nowrap"},{children:[ve(Ht,{width:14,height:14}),ve("a",Le({href:"tel:+".concat(r)},{children:ve(ye,Le({size:"s",weight:500,color:"sixty"},{children:t}))}))]}))},Vt=Ne(xe)(nt||(nt=De(["\n width: auto;\n"],["\n width: auto;\n"]))),Ht=Ne(Se)(tt||(tt=De(["\n margin-right: 6px;\n transform: rotate(15deg);\n path {\n stroke: ",";\n }\n"],["\n margin-right: 6px;\n transform: rotate(15deg);\n path {\n stroke: ",";\n }\n"])),_e.palette.grey.sixty),Et=function(e){var n=e.inspection,t=e.onClose,r=e.getClientLink,i=e.getInspectionLink,o=n.apartment,a=n.tenant,l=n.landlord,s=n.metroStations,u=a||l,c=r&&u?r(null==u?void 0:u.id):"",d=i(o.id,n.id);return pe(Wt,{children:[ve(E,Le({href:d},{children:ve(Gt,{imageSrc:o.previewImage,description:o.address})})),ve(xe,Le({container:!0,spacing:2,alignItems:"center"},{children:s.map((function(e){return ve(Bt,{metroStation:e},e.name)}))})),!!u&&pe(Ut,Le({container:!0,alignItems:"center",justify:"space-between"},{children:[c?ve(Kt,Le({href:c},{children:ve(W,{weight:500,user:u})})):ve(W,{weight:500,user:u}),!!(null==u?void 0:u.phoneNumber)&&ve(zt,{phone:null==u?void 0:u.phoneNumber})]})),ve(Yt,Le({isCircle:!0,size:"xs",variant:"whiteWithGray",onClick:t},{children:ve(Me,{width:6,height:6})}))]})},Wt=Ne.div(rt||(rt=De(["\n width: 330px;\n background: ",";\n border-radius: 8px;\n padding: 8px;\n position: absolute;\n bottom: 46px;\n left: -115px;\n z-index: 1;\n"],["\n width: 330px;\n background: ",";\n border-radius: 8px;\n padding: 8px;\n position: absolute;\n bottom: 46px;\n left: -115px;\n z-index: 1;\n"])),_e.palette.grey.zero),Gt=Ne(H)(it||(it=De(["\n margin-bottom: 8px;\n p {\n font-size: 16px;\n line-height: 24px;\n font-weight: 600;\n }\n"],["\n margin-bottom: 8px;\n p {\n font-size: 16px;\n line-height: 24px;\n font-weight: 600;\n }\n"]))),Ut=Ne(xe)(ot||(ot=De(["\n padding-top: 8px;\n border-top: 1px solid ",";\n margin-top: 8px;\n"],["\n padding-top: 8px;\n border-top: 1px solid ",";\n margin-top: 8px;\n"])),_e.palette.grey.fifteenB),Yt=Ne(we)(at||(at=De(["\n position: absolute;\n top: -10px;\n right: -10px;\n width: 24px;\n height: 24px;\n"],["\n position: absolute;\n top: -10px;\n right: -10px;\n width: 24px;\n height: 24px;\n"]))),Kt=Ne(E)(lt||(lt=De(["\n max-width: calc(100% - 140px);\n"],["\n max-width: calc(100% - 140px);\n"]))),Zt=function(e){var n=e.inspection,t=e.map,r=e.label,i=je(e,["inspection","map","label"]),o=G(n.location,t),a=o.ref,l=o.isOpen,s=o.closeCard,u=o.toggleCard;return ve(U,Le({map:t,position:n.location},{children:pe(Jt,Le({ref:a},{children:[ve(Ft,{label:r,isActive:l,onClick:u}),l&&ve(Et,Le({inspection:n,onClose:s},i))]}))}))},Jt=Ne.div(st||(st=De(["\n position: relative;\n"],["\n position: relative;\n"])));export{jn as AddedMetersBlock,fn as AdditionalInfoFieldsSchema,bn as AdditionalInfoStepSchema,Qe as BasicApartmentInfoFieldsSchema,Xe as BasicApartmentInfoStepSchema,on as DetailApartmentInfoFieldsSchema,an as DetailApartmentInfoStepSchema,Tn as FillingInfoFieldsSchema,St as FillingListStore,en as HouseInfoFieldsSchema,nn as HouseInfoStepSchema,yn as HouseServicesInfoFieldsSchema,_n as HouseServicesInfoStepSchema,_t as InspectionFeedback,qt as InspectionFillingCard,Dn as InventoryMeterInfoFields,In as MetersInfoFieldsSchema,Nn as MetersInfoStepSchema,Et as ObjectForMapCard,Zt as ObjectForMapOverlay,Ft as ObjectForMapPoint,sn as RoomsApartmentInfoFieldsSchema,un as RoomsApartmentInfoStepSchema,dn as SecurityApartmentInfoFieldsSchema,mn as SecurityApartmentInfoStepSchema,qn as TelecommunicationsInfoFieldsSchema,Pn as TelecommunicationsInfoStepSchema,Ge as WaterMeterFieldsSchema,Ze as apartmentFields,hn as getAdditionalInfoStepFields,pn as getAvailableResourcesFields,Je as getBasicApartmentInfoFields,rn as getDetailApartmentInfoFields,kn as getFillingInfoFields,$e as getHouseInfoStep,gn as getHouseServicesInfoStep,Rn as getInventoryMeterFields,wn as getMetersInfoStepFields,We as getPartialMeterInfoSchema,ln as getRoomsApartmentInfoFields,ct as getRoomsImagesSteps,cn as getSecurityApartmentInfoFields,Cn as getTelecommunicationsInfoStepFields,Ue as getWaterMeterFields,Ye as inspectionsRequestBody,Ke as inspectionsRequests,Ot as onInspectionModalClose,Rt as onInspectionModalOpen,ut as renderMetersSteps,Mt as useFillingList,Lt as useInspectionData,jt as useInspectionIndexDB,Tt as useMetersValues};
|