kui-crm_actions 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/index.js ADDED
@@ -0,0 +1,657 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var kuiUtils = require('kui-utils');
6
+ var yup = require('yup');
7
+ var kuiCrm = require('kui-crm');
8
+ var to = require('await-to-js');
9
+ var luxon = require('luxon');
10
+ var kuiComplex = require('kui-complex');
11
+
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
+
14
+ function _interopNamespace(e) {
15
+ if (e && e.__esModule) return e;
16
+ var n = Object.create(null);
17
+ if (e) {
18
+ Object.keys(e).forEach(function (k) {
19
+ if (k !== 'default') {
20
+ var d = Object.getOwnPropertyDescriptor(e, k);
21
+ Object.defineProperty(n, k, d.get ? d : {
22
+ enumerable: true,
23
+ get: function () { return e[k]; }
24
+ });
25
+ }
26
+ });
27
+ }
28
+ n["default"] = e;
29
+ return Object.freeze(n);
30
+ }
31
+
32
+ var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
33
+ var to__default = /*#__PURE__*/_interopDefaultLegacy(to);
34
+
35
+ /******************************************************************************
36
+ Copyright (c) Microsoft Corporation.
37
+
38
+ Permission to use, copy, modify, and/or distribute this software for any
39
+ purpose with or without fee is hereby granted.
40
+
41
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
42
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
43
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
44
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
45
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
46
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
47
+ PERFORMANCE OF THIS SOFTWARE.
48
+ ***************************************************************************** */
49
+
50
+ var __assign = function() {
51
+ __assign = Object.assign || function __assign(t) {
52
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
53
+ s = arguments[i];
54
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
55
+ }
56
+ return t;
57
+ };
58
+ return __assign.apply(this, arguments);
59
+ };
60
+
61
+ function __awaiter(thisArg, _arguments, P, generator) {
62
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
63
+ return new (P || (P = Promise))(function (resolve, reject) {
64
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
65
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
66
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
67
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
68
+ });
69
+ }
70
+
71
+ function __generator(thisArg, body) {
72
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
73
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
74
+ function verb(n) { return function (v) { return step([n, v]); }; }
75
+ function step(op) {
76
+ if (f) throw new TypeError("Generator is already executing.");
77
+ while (_) try {
78
+ 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;
79
+ if (y = 0, t) op = [op[0] & 2, t.value];
80
+ switch (op[0]) {
81
+ case 0: case 1: t = op; break;
82
+ case 4: _.label++; return { value: op[1], done: false };
83
+ case 5: _.label++; y = op[1]; op = [0]; continue;
84
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
85
+ default:
86
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
87
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
88
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
89
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
90
+ if (t[2]) _.ops.pop();
91
+ _.trys.pop(); continue;
92
+ }
93
+ op = body.call(thisArg, _);
94
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
95
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
96
+ }
97
+ }
98
+
99
+ function __spreadArray(to, from, pack) {
100
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
101
+ if (ar || !(i in from)) {
102
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
103
+ ar[i] = from[i];
104
+ }
105
+ }
106
+ return to.concat(ar || Array.prototype.slice.call(from));
107
+ }
108
+
109
+ var getPartialMeterInfoFields = function (resource, type) {
110
+ if (resource === "electricity") {
111
+ return __spreadArray(__spreadArray([
112
+ { label: "Number", name: "number" },
113
+ { label: "T1 value", name: "T1", type: "number" }
114
+ ], kuiUtils.addToArrayByCondition(type !== "T1", {
115
+ label: "T2 value",
116
+ name: "T2",
117
+ type: "number",
118
+ }), true), kuiUtils.addToArrayByCondition(type === "T3", {
119
+ label: "T3 value",
120
+ name: "T3",
121
+ type: "number",
122
+ }), true);
123
+ }
124
+ return [
125
+ { label: "Number", name: "number" },
126
+ { label: "Value", name: "value", type: "number" },
127
+ ];
128
+ };
129
+
130
+ var getPartialMeterInfoSchema = function (valuesFields) {
131
+ var valuesSchema = valuesFields.map(function (field) {
132
+ var _a;
133
+ return (_a = {},
134
+ _a[field] = yup__namespace
135
+ .number()
136
+ .min(0)
137
+ .required("This field is required")
138
+ .transform(function (value) { return (Number.isNaN(value) ? undefined : value); }),
139
+ _a);
140
+ });
141
+ return yup__namespace.object().shape(__assign({ number: yup__namespace.string().trim().required("This field is required") }, Object.assign.apply(Object, __spreadArray([{}], valuesSchema, false))));
142
+ };
143
+
144
+ var inspectionsRequestBody = {
145
+ getPostBodyInitialInspection: function (inspection, roomsImages) {
146
+ return {
147
+ based_on: null,
148
+ date: luxon.DateTime.now().toISODate(),
149
+ inspection_type: "initial",
150
+ rooms_with_photos: roomsImages,
151
+ initial: this.getInitialInspectionFields(inspection),
152
+ };
153
+ },
154
+ getInitialInspectionFields: function (inspection) {
155
+ var _a, _b, _c;
156
+ return {
157
+ city: inspection.city.id,
158
+ address: inspection.apartment.address,
159
+ apartment_number: inspection.apartmentNumber || "",
160
+ post_index: inspection.zipCode,
161
+ floor: inspection.floor,
162
+ floor_count: inspection.floorCount,
163
+ room_type: inspection.typeOfRoom,
164
+ num_entrance: inspection.entrance,
165
+ has_intercom: inspection.hasIntercom,
166
+ intercom_code: inspection.intercomCode,
167
+ has_gate: inspection.hasGate,
168
+ gate_code: inspection.gateCode,
169
+ area: inspection.area,
170
+ living_area: inspection.livingArea,
171
+ kitchen_area: inspection.kitchenArea,
172
+ rooms_number: inspection.roomsNumber,
173
+ bedrooms_number: inspection.bedroomsNumber,
174
+ bathrooms_number: inspection.bathroomsNumber,
175
+ restrooms_number: inspection.restroomsNumber,
176
+ combined_bathrooms_number: inspection.combinedBathroomsNumber,
177
+ ceiling_height: inspection.ceilingHeight,
178
+ number_of_windows: inspection.numberOfWindows,
179
+ renovation_year: (_a = inspection.renovation) === null || _a === void 0 ? void 0 : _a.year,
180
+ renovation_type: (_b = inspection.renovation) === null || _b === void 0 ? void 0 : _b.type,
181
+ renovation_style: (_c = inspection.renovation) === null || _c === void 0 ? void 0 : _c.style,
182
+ rooms: inspection.rooms.map(function (room) { return ({
183
+ area: room.area,
184
+ room_type: room.type,
185
+ }); }),
186
+ };
187
+ },
188
+ getPostBodyQuarterlyInspection: function (inspection, roomsImages) {
189
+ return {
190
+ date: luxon.DateTime.now().toISODate(),
191
+ inspection_type: "quarterly",
192
+ based_on: null,
193
+ rooms_with_photos: roomsImages,
194
+ quarterly: this.getPartialInspectionMeters(inspection.meters),
195
+ };
196
+ },
197
+ getPostBodyTransferInspection: function (inspection, roomsImages) {
198
+ return {
199
+ date: luxon.DateTime.now().toISODate(),
200
+ inspection_type: "transfer",
201
+ based_on: null,
202
+ rooms_with_photos: roomsImages,
203
+ transfer: __assign({ transfer_type: inspection.transferType }, this.getPartialInspectionMeters(inspection.meters)),
204
+ };
205
+ },
206
+ getPartialInspectionMeters: function (meters) {
207
+ return {
208
+ meters: meters.map(function (meter, index) { return ({
209
+ id: meter.id,
210
+ resource_type: meter.resource,
211
+ meter_type: meter.type,
212
+ passport_number: meter.number,
213
+ values: kuiUtils.clearNotValidFields({
214
+ value: meter.value,
215
+ T1: meter.T1,
216
+ T2: meter.T2,
217
+ T3: meter.T3,
218
+ }),
219
+ }); }),
220
+ };
221
+ },
222
+ getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles, fillingImages) {
223
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
224
+ return {
225
+ date: luxon.DateTime.now().toISODate(),
226
+ inspection_type: "inventory",
227
+ based_on: null,
228
+ rooms_with_photos: roomsImages,
229
+ inventory: __assign({ not_allowed_children: !inspection.withChildren, not_allowed_pets: !inspection.withPets, additional_terms: inspection.additionalTerms, country_of_residence: ((_a = inspection.countryOfResidence) === null || _a === void 0 ? void 0 : _a.id) || null, administrative_company: ((_b = inspection.company) === null || _b === void 0 ? void 0 : _b.id) || null, tax_type: inspection.taxesType, financial_personal_account: inspection.communalServicesAccount, max_electricity_counters: (_c = inspection.maxMeters) === null || _c === void 0 ? void 0 : _c.electricity, max_gas_counters: (_d = inspection.maxMeters) === null || _d === void 0 ? void 0 : _d.gas, max_heating_counters: (_e = inspection.maxMeters) === null || _e === void 0 ? void 0 : _e.heating, max_water_counters: (_f = inspection.maxMeters) === null || _f === void 0 ? void 0 : _f.water, has_barrier: inspection.hasBarrier, has_concierge: inspection.hasConcierge, has_security: inspection.hasSecurity, has_video_surveillance: inspection.hasVideoControl, barrier_phone: inspection.barrierPhone
230
+ ? kuiUtils.getPhoneNumberFromPhoneParams(inspection.barrierPhone)
231
+ : null, concierge_phone: inspection.conciergePhone
232
+ ? kuiUtils.getPhoneNumberFromPhoneParams(inspection.conciergePhone)
233
+ : null, security_phone: inspection.securityPhone
234
+ ? kuiUtils.getPhoneNumberFromPhoneParams(inspection.securityPhone)
235
+ : null, video_surveillance_phone: inspection.videoControlPhone
236
+ ? kuiUtils.getPhoneNumberFromPhoneParams(inspection.videoControlPhone)
237
+ : null, home_phone: inspection.homePhone
238
+ ? kuiUtils.getPhoneNumberFromPhoneParams(inspection.homePhone)
239
+ : 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, parking_type: inspection.parkingType, parking_number: inspection.parkingNumber, passenger_elevators_number: inspection.passengerElevatorsCount, service_elevators_number: inspection.serviceElevatorsCount, payer_code: inspection.payerCode, filling: inspection.fillingList.map(function (filling, index) { return ({
240
+ feature: filling.tag.id,
241
+ description: filling.name,
242
+ serial_code: filling.serialNumber,
243
+ amount: filling.numberOfSubjects,
244
+ photos: fillingImages[index],
245
+ instruction: fillingFiles[index],
246
+ }); }) }, this.getInventoryInspectionMeters(inspection.meters, metersFiles)),
247
+ };
248
+ },
249
+ getInventoryInspectionMeters: function (meters, metersFiles) {
250
+ var _this = this;
251
+ return {
252
+ meters: (meters === null || meters === void 0 ? void 0 : meters.map(function (meter, index) { return (__assign(__assign({}, _this.getMeterCommonFields(meter)), { passport: metersFiles[index], values: kuiUtils.clearNotValidFields({
253
+ value: meter.initialValue,
254
+ T1: meter.initialValueT1,
255
+ T2: meter.initialValueT2,
256
+ T3: meter.initialValueT3,
257
+ }) })); })) || [],
258
+ };
259
+ },
260
+ getMeterCommonFields: function (meter) {
261
+ var _a, _b;
262
+ return {
263
+ id: meter.id,
264
+ meter_type: meter.type,
265
+ passport_number: meter.number,
266
+ resource_type: meter.resource,
267
+ activation_date: meter.startDate.toISODate(),
268
+ operating_account: meter.operationalAccountNumber,
269
+ company: (_a = meter.company) === null || _a === void 0 ? void 0 : _a.id,
270
+ tariff: (_b = meter.tariff) === null || _b === void 0 ? void 0 : _b.id,
271
+ };
272
+ },
273
+ getMeterValues: function (initialValue, lastValue) {
274
+ return kuiUtils.clearNotValidFields({
275
+ initial_value: initialValue,
276
+ last_value: lastValue,
277
+ });
278
+ },
279
+ };
280
+
281
+ var inspectionsRequests = {
282
+ createInspection: function (apartmentId, body, loader) {
283
+ var _a;
284
+ return __awaiter(this, void 0, void 0, function () {
285
+ var response;
286
+ return __generator(this, function (_b) {
287
+ switch (_b.label) {
288
+ case 0: return [4 /*yield*/, to__default["default"](kuiCrm.requests.post("/apartments/".concat(apartmentId, "/inspections"), body))];
289
+ case 1:
290
+ response = _b.sent();
291
+ kuiUtils.resHandler(response, loader);
292
+ return [2 /*return*/, (_a = response[1]) === null || _a === void 0 ? void 0 : _a.id];
293
+ }
294
+ });
295
+ });
296
+ },
297
+ loadInspectionImages: function (loader, roomsImages) {
298
+ return __awaiter(this, void 0, void 0, function () {
299
+ var promises, images;
300
+ return __generator(this, function (_a) {
301
+ switch (_a.label) {
302
+ case 0:
303
+ promises = [];
304
+ roomsImages.forEach(function (room) {
305
+ promises.push(kuiCrm.uploadImages(loader, room.files));
306
+ });
307
+ return [4 /*yield*/, kuiUtils.callPromises(promises)];
308
+ case 1:
309
+ images = _a.sent();
310
+ return [2 /*return*/, roomsImages.map(function (room, index) { return ({
311
+ room_purpose: room.type,
312
+ comment: room.comment,
313
+ photos: images[index] || [],
314
+ }); })];
315
+ }
316
+ });
317
+ });
318
+ },
319
+ createInitialInspection: function (data, apartmentId, loader) {
320
+ return __awaiter(this, void 0, void 0, function () {
321
+ var roomsImages, body;
322
+ return __generator(this, function (_a) {
323
+ switch (_a.label) {
324
+ case 0:
325
+ if (!apartmentId) return [3 /*break*/, 2];
326
+ loader.startLoading("inspection creation");
327
+ return [4 /*yield*/, this.loadInspectionImages(loader, data.roomsImages)];
328
+ case 1:
329
+ roomsImages = _a.sent();
330
+ body = inspectionsRequestBody.getPostBodyInitialInspection(data, roomsImages);
331
+ return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
332
+ case 2: return [2 /*return*/, null];
333
+ }
334
+ });
335
+ });
336
+ },
337
+ createQuarterlyInspection: function (data, apartmentId, loader) {
338
+ return __awaiter(this, void 0, void 0, function () {
339
+ var roomsImages, body;
340
+ return __generator(this, function (_a) {
341
+ switch (_a.label) {
342
+ case 0:
343
+ if (!apartmentId) return [3 /*break*/, 2];
344
+ loader.startLoading("inspection creation");
345
+ return [4 /*yield*/, this.loadInspectionImages(loader, data.roomsImages)];
346
+ case 1:
347
+ roomsImages = _a.sent();
348
+ body = inspectionsRequestBody.getPostBodyQuarterlyInspection(data, roomsImages);
349
+ return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
350
+ case 2: return [2 /*return*/, null];
351
+ }
352
+ });
353
+ });
354
+ },
355
+ createTransferInspection: function (data, apartmentId, loader) {
356
+ return __awaiter(this, void 0, void 0, function () {
357
+ var images, body;
358
+ return __generator(this, function (_a) {
359
+ switch (_a.label) {
360
+ case 0:
361
+ if (!apartmentId) return [3 /*break*/, 2];
362
+ loader.startLoading("inspection creation");
363
+ return [4 /*yield*/, this.loadInspectionImages(loader, data.roomsImages)];
364
+ case 1:
365
+ images = _a.sent();
366
+ body = inspectionsRequestBody.getPostBodyTransferInspection(data, images);
367
+ return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
368
+ case 2: return [2 /*return*/, null];
369
+ }
370
+ });
371
+ });
372
+ },
373
+ createInventoryInspection: function (data, apartmentId, loader) {
374
+ var _a;
375
+ return __awaiter(this, void 0, void 0, function () {
376
+ var fillingFiles, metersFiles, fillingImages, files, body;
377
+ return __generator(this, function (_b) {
378
+ switch (_b.label) {
379
+ case 0:
380
+ if (!apartmentId) return [3 /*break*/, 2];
381
+ loader.startLoading("inspection creation");
382
+ fillingFiles = data.fillingList.map(function (filling) { return filling.instruction; });
383
+ metersFiles = ((_a = data.meters) === null || _a === void 0 ? void 0 : _a.map(function (meter) { return meter.passportFile; })) || [];
384
+ fillingImages = data.fillingList.map(function (filling) {
385
+ return kuiCrm.uploadImages(loader, filling.images);
386
+ });
387
+ return [4 /*yield*/, kuiUtils.callPromises(__spreadArray([
388
+ this.loadInspectionImages(loader, data.roomsImages),
389
+ kuiCrm.uploadFiles(loader, fillingFiles),
390
+ kuiCrm.uploadFiles(loader, metersFiles)
391
+ ], fillingImages, true))];
392
+ case 1:
393
+ files = _b.sent();
394
+ body = inspectionsRequestBody.getPostBodyInventoryInspection(data, files[0], files[1], files[2], files.slice(3));
395
+ return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
396
+ case 2: return [2 /*return*/, null];
397
+ }
398
+ });
399
+ });
400
+ },
401
+ };
402
+
403
+ var getBasicApartmentInfoFields = function (settings, handlePlaceSelect) { return [
404
+ __assign({ name: "country", label: "Country", variant: "custom", CustomInput: kuiCrm.CountryAutocomplete, size: 12 }, settings.country),
405
+ __assign({ name: "region", label: "Region", variant: "custom", CustomInput: kuiCrm.RegionAutocomplete }, settings.region),
406
+ __assign({ name: "city", label: "City", variant: "custom", CustomInput: kuiCrm.CityAutocomplete }, settings.city),
407
+ __assign({ name: "apartment", variant: "custom", CustomInput: kuiComplex.InputWithAddressAutocomplete, handlePlaceSelect: handlePlaceSelect, size: 12 }, settings.apartment),
408
+ __assign({ label: "Apartment", name: "apartmentNumber", "data-testid": "apartment_number" }, settings.apartmentNumber),
409
+ __assign({ label: "Zip code", name: "zipCode" }, settings.zipCode),
410
+ ]; };
411
+
412
+ var BasicApartmentInfoFieldsSchema = {
413
+ apartment: yup__namespace.object({
414
+ address: yup__namespace.string().trim().required("This field is required"),
415
+ }),
416
+ apartmentNumber: yup__namespace.string().required("This field is required"),
417
+ city: yup__namespace.object({
418
+ name: yup__namespace.string().required("This field is required"),
419
+ }),
420
+ zipCode: yup__namespace.string().required("This field is required"),
421
+ };
422
+ var BasicApartmentInfoStepSchema = yup__namespace.object(BasicApartmentInfoFieldsSchema);
423
+
424
+ var inputProps = {
425
+ step: 0.1,
426
+ };
427
+ var getDetailApartmentInfoFields = function (settings, roomsCount) {
428
+ var _a, _b;
429
+ return __spreadArray(__spreadArray([
430
+ __assign(__assign({ label: "Total area", name: "area", type: "number" }, inputProps), settings.area),
431
+ __assign(__assign({ label: "Living area", name: "livingArea", type: "number" }, inputProps), settings.livingArea),
432
+ __assign(__assign({ label: "Kitchen area", name: "kitchenArea", type: "number" }, inputProps), settings.kitchenArea)
433
+ ], (roomsCount
434
+ ? new Array(Number(roomsCount))
435
+ .fill(0)
436
+ .map(function (_, key) {
437
+ var _a, _b;
438
+ return [
439
+ __assign(__assign({ name: "rooms.".concat(key, ".area"), label: "Room ".concat(key + 1, " area"), type: "number" }, inputProps), (settings.rooms ? (_a = settings.rooms(key)) === null || _a === void 0 ? void 0 : _a.area : {})),
440
+ __assign({ name: "rooms.".concat(key, ".type"), label: "Room ".concat(key + 1, " type"), variant: "select", options: kuiCrm.RoomTypeValues }, (settings.rooms ? (_b = settings.rooms(key)) === null || _b === void 0 ? void 0 : _b.type : {})),
441
+ ];
442
+ })
443
+ .flat()
444
+ : []), true), [
445
+ __assign(__assign({ name: "ceilingHeight", label: "Ceiling height", type: "number" }, inputProps), settings.ceilingHeight),
446
+ __assign({ name: "numberOfWindows", label: "Windows", type: "number" }, settings.numberOfWindows),
447
+ __assign({ name: "renovation.year", label: "Year of last renovation", type: "number" }, settings.renovation.year),
448
+ __assign({ name: "renovation.type", label: "Type of renovation", variant: "select", options: kuiCrm.RenovationTypeValues }, (_a = settings.renovation) === null || _a === void 0 ? void 0 : _a.type),
449
+ __assign({ name: "renovation.style", label: "Renovation style", variant: "select", options: kuiCrm.RenovationStyleValues }, (_b = settings.renovation) === null || _b === void 0 ? void 0 : _b.style),
450
+ ], false);
451
+ };
452
+
453
+ var DetailApartmentInfoFieldsSchema = {
454
+ area: yup__namespace.number().positive().required("This field is required"),
455
+ livingArea: yup__namespace.number().positive().required("This field is required"),
456
+ kitchenArea: yup__namespace.number().positive().required("This field is required"),
457
+ rooms: yup__namespace.array().of(yup__namespace.object({
458
+ area: yup__namespace.number().positive().required("This field is required"),
459
+ type: yup__namespace.string().required("This field is required"),
460
+ })),
461
+ ceilingHeight: yup__namespace.number().positive().required("This field is required"),
462
+ numberOfWindows: yup__namespace.number().min(0).required("This field is required"),
463
+ renovation: yup__namespace.object({
464
+ year: yup__namespace.number().positive().required("This field is required"),
465
+ type: yup__namespace.string().required("This field is required"),
466
+ style: yup__namespace.string().required("This field is required"),
467
+ }),
468
+ };
469
+ var DetailApartmentInfoStepSchema = yup__namespace.object(DetailApartmentInfoFieldsSchema);
470
+
471
+ var getRoomsApartmentInfoFields = function (settings) { return [
472
+ __assign({ label: "Floor", name: "floor", type: "number" }, settings.floor),
473
+ __assign({ label: "Floors", name: "floorCount", type: "number" }, settings.floorCount),
474
+ __assign({ label: "Rooms", name: "roomsNumber", type: "number" }, settings.roomsNumber),
475
+ __assign({ label: "Bedrooms", name: "bedroomsNumber", type: "number" }, settings.bedroomsNumber),
476
+ __assign({ label: "Bathrooms", name: "bathroomsNumber", type: "number" }, settings.bathroomsNumber),
477
+ __assign({ label: "Restrooms", name: "restroomsNumber", type: "number" }, settings.restroomsNumber),
478
+ __assign({ label: "Combined bathroom", name: "combinedBathroomsNumber", type: "number" }, settings.combinedBathroomsNumber),
479
+ ]; };
480
+
481
+ var RoomsApartmentInfoFieldsSchema = {
482
+ floor: yup__namespace
483
+ .number()
484
+ .integer()
485
+ .min(0)
486
+ .test("is less than floorCount", "Too much", function (value) {
487
+ return value <= this.parent.floorCount;
488
+ }),
489
+ floorCount: yup__namespace
490
+ .number()
491
+ .integer()
492
+ .positive()
493
+ .required("This field is required"),
494
+ roomsNumber: yup__namespace.number().integer().min(0).required("This field is required"),
495
+ bedroomsNumber: yup__namespace
496
+ .number()
497
+ .integer()
498
+ .min(0)
499
+ .required("This field is required"),
500
+ bathroomsNumber: yup__namespace
501
+ .number()
502
+ .integer()
503
+ .min(0)
504
+ .required("This field is required"),
505
+ restroomsNumber: yup__namespace
506
+ .number()
507
+ .integer()
508
+ .min(0)
509
+ .required("This field is required"),
510
+ combinedBathroomsNumber: yup__namespace
511
+ .number()
512
+ .integer()
513
+ .min(0)
514
+ .required("This field is required"),
515
+ };
516
+ var RoomsApartmentInfoStepSchema = yup__namespace.object(RoomsApartmentInfoFieldsSchema);
517
+
518
+ var getSecurityApartmentInfoFields = function (settings) { return [
519
+ __assign({ label: "Object type", name: "typeOfRoom", variant: "select", options: kuiCrm.RoomTypesValues }, settings.typeOfRoom),
520
+ __assign({ label: "Entrance", name: "entrance" }, settings.entrance),
521
+ __assign({ name: "hasIntercom", label: "Intercom", variant: "select", options: kuiCrm.BooleanValues }, settings.hasIntercom),
522
+ __assign({ name: "intercomCode", label: "Intercom code", variant: "custom", CustomInput: kuiComplex.DependentInput, dependentInputName: "hasIntercom" }, settings.intercomCode),
523
+ __assign({ name: "hasGate", label: "Gate", variant: "select", options: kuiCrm.BooleanValues }, settings.hasGate),
524
+ __assign({ name: "gateCode", label: "Gate code", variant: "custom", CustomInput: kuiComplex.DependentInput, dependentInputName: "hasGate" }, settings.gateCode),
525
+ ]; };
526
+
527
+ var SecurityApartmentInfoFieldsSchema = {
528
+ typeOfRoom: yup__namespace.string().required("This field is required"),
529
+ entrance: yup__namespace.string().required("This field is required"),
530
+ hasIntercom: yup__namespace.string().required("This field is required"),
531
+ intercomCode: yup__namespace.string().required("This field is required"),
532
+ hasGate: yup__namespace.string().required("This field is required"),
533
+ gateCode: yup__namespace.string().required("This field is required"),
534
+ };
535
+ var SecurityApartmentInfoStepSchema = yup__namespace.object(SecurityApartmentInfoFieldsSchema);
536
+
537
+ var checkboxLabelProps = {
538
+ size: "s",
539
+ };
540
+ var getApartmentPaymentFields = function (settings) { return [
541
+ __assign({ name: "payerCode", label: "Payer code" }, settings.payerCode),
542
+ __assign({ name: "communalServicesAccount", label: "Operational account number" }, settings.communalServicesAccount),
543
+ __assign({ name: "company", label: "Administrative company", variant: "custom", CustomInput: kuiCrm.CompanyAutocomplete }, settings.company),
544
+ __assign({ name: "countryOfResidence", label: "Country of Residence", variant: "custom", CustomInput: kuiCrm.CountryAutocomplete }, settings.countryOfResidence),
545
+ __assign({ label: "Tax type", name: "taxesType", variant: "select", options: kuiCrm.TaxTypeValues }, settings.taxesType),
546
+ ]; };
547
+ var getAdditionalInfoStepFields = function (settings) { return __spreadArray([
548
+ __assign({ label: "Pets", name: "withPets", variant: "custom", CustomInput: kuiComplex.CheckboxWithController, labelProps: checkboxLabelProps }, settings.withPets),
549
+ __assign({ label: "Children", name: "withChildren", variant: "custom", CustomInput: kuiComplex.CheckboxWithController, labelProps: checkboxLabelProps }, settings.withChildren),
550
+ __assign({ isTextArea: true, placeholder: "other terms", name: "additionalTerms" }, settings.additionalTerms)
551
+ ], getApartmentPaymentFields(settings), true); };
552
+
553
+ var AdditionalInfoFieldsSchema = {
554
+ taxesType: yup__namespace.string().required(kuiCrm.defaultRequiredMessage),
555
+ };
556
+ var AdditionalInfoStepSchema = yup__namespace.object(AdditionalInfoFieldsSchema);
557
+
558
+ var getHouseServicesInfoStep = function (settings) { return [
559
+ __assign({ name: "hasBarrier", label: "Barrier", variant: "select", options: kuiCrm.BooleanValues }, settings.hasBarrier),
560
+ __assign({ name: "barrierPhone", label: "Barrier code", variant: "custom", CustomInput: kuiComplex.DependentInput, dependentInputName: "hasBarrier", Input: kuiComplex.InputPhoneWithForm }, settings.barrierPhone),
561
+ __assign({ name: "hasConcierge", label: "Concierge", variant: "select", options: kuiCrm.BooleanValues }, settings.hasConcierge),
562
+ __assign({ name: "conciergePhone", label: "Concierge", variant: "custom", CustomInput: kuiComplex.DependentInput, dependentInputName: "hasConcierge", Input: kuiComplex.InputPhoneWithForm }, settings.conciergePhone),
563
+ __assign({ name: "hasSecurity", label: "Security", variant: "select", options: kuiCrm.BooleanValues }, settings.hasSecurity),
564
+ __assign({ name: "securityPhone", label: "Security", variant: "custom", CustomInput: kuiComplex.DependentInput, dependentInputName: "hasSecurity", Input: kuiComplex.InputPhoneWithForm }, settings.securityPhone),
565
+ __assign({ name: "hasVideoControl", label: "Video surveillance", variant: "select", options: kuiCrm.BooleanValues }, settings.hasVideoControl),
566
+ __assign({ name: "videoControlPhone", label: "Video surveillance", variant: "custom", CustomInput: kuiComplex.DependentInput, dependentInputName: "hasVideoControl", Input: kuiComplex.InputPhoneWithForm }, settings.videoControlPhone),
567
+ __assign({ name: "parkingType", label: "Parking", variant: "select", options: kuiCrm.ParkingTypesValues }, settings.parkingType),
568
+ __assign({ name: "parkingNumber", label: "Parking number", variant: "custom", CustomInput: kuiComplex.DependentInput, dependentInputName: "parkingType" }, settings.parkingNumber),
569
+ __assign({ name: "passengerElevatorsCount", label: "Passenger elevators", type: "number" }, settings.passengerElevatorsCount),
570
+ __assign({ name: "serviceElevatorsCount", label: "Service elevators", type: "number" }, settings.serviceElevatorsCount),
571
+ ]; };
572
+
573
+ var HouseServicesInfoFieldsSchema = {
574
+ hasBarrier: yup__namespace.string().required(kuiCrm.defaultRequiredMessage),
575
+ barrierPhone: kuiCrm.phoneWithConditionSchema("hasBarrier"),
576
+ hasConcierge: yup__namespace.string().required(kuiCrm.defaultRequiredMessage),
577
+ conciergePhone: kuiCrm.phoneWithConditionSchema("hasConcierge"),
578
+ hasSecurity: yup__namespace.string().required(kuiCrm.defaultRequiredMessage),
579
+ securityPhone: kuiCrm.phoneWithConditionSchema("hasSecurity"),
580
+ hasVideoControl: yup__namespace.string().required(kuiCrm.defaultRequiredMessage),
581
+ videoControlPhone: kuiCrm.phoneWithConditionSchema("hasVideoControl"),
582
+ parkingType: yup__namespace.string().nullable(),
583
+ parkingNumber: yup__namespace
584
+ .string()
585
+ .when("parkingType", {
586
+ is: function (value) { return !!value; },
587
+ then: function (rule) { return rule.required(kuiCrm.defaultRequiredMessage); },
588
+ })
589
+ .nullable(),
590
+ passengerElevatorsCount: kuiCrm.positiveNumberSchema,
591
+ serviceElevatorsCount: kuiCrm.positiveNumberSchema,
592
+ };
593
+ var HouseServicesInfoStepSchema = yup__namespace.object(HouseServicesInfoFieldsSchema);
594
+
595
+ var metersOptions = kuiCrm.getNumbersValues(7);
596
+ var getMetersInfoStepFields = function (settings) {
597
+ var _a, _b, _c, _d;
598
+ return [
599
+ __assign({ name: "maxMeters.water", label: "Water", variant: "select", options: metersOptions }, (_a = settings.maxMeters) === null || _a === void 0 ? void 0 : _a.water),
600
+ __assign({ name: "maxMeters.electricity", label: "Electricity", variant: "select", options: metersOptions }, (_b = settings.maxMeters) === null || _b === void 0 ? void 0 : _b.electricity),
601
+ __assign({ name: "maxMeters.gas", label: "Gas", variant: "select", options: metersOptions }, (_c = settings.maxMeters) === null || _c === void 0 ? void 0 : _c.gas),
602
+ __assign({ name: "maxMeters.heating", label: "Heating", variant: "select", options: metersOptions }, (_d = settings.maxMeters) === null || _d === void 0 ? void 0 : _d.heating),
603
+ ];
604
+ };
605
+
606
+ var MetersInfoFieldsSchema = {
607
+ maxMeters: yup__namespace.object({
608
+ water: kuiCrm.positiveNumberSchema,
609
+ electricity: kuiCrm.positiveNumberSchema,
610
+ gas: kuiCrm.positiveNumberSchema,
611
+ heating: kuiCrm.positiveNumberSchema,
612
+ }),
613
+ };
614
+ var MetersInfoStepSchema = yup__namespace.object(MetersInfoFieldsSchema);
615
+
616
+ var getTelecommunicationsInfoStepFields = function (settings) {
617
+ var _a, _b, _c, _d, _e;
618
+ return [
619
+ __assign({ name: "wifi.name", label: "Name of network" }, (_a = settings.wifi) === null || _a === void 0 ? void 0 : _a.name),
620
+ __assign({ name: "wifi.password", label: "WiFi password" }, (_b = settings.wifi) === null || _b === void 0 ? void 0 : _b.password),
621
+ __assign({ name: "internetProvider.link", label: "Link to provider", size: 12 }, (_c = settings.internetProvider) === null || _c === void 0 ? void 0 : _c.link),
622
+ __assign({ name: "internetProvider.login", label: "Login" }, (_d = settings.internetProvider) === null || _d === void 0 ? void 0 : _d.login),
623
+ __assign({ name: "internetProvider.password", label: "Password" }, (_e = settings.internetProvider) === null || _e === void 0 ? void 0 : _e.password),
624
+ __assign({ name: "tvType", label: "Television", variant: "select", options: kuiCrm.TVTypesValues }, settings.tvType),
625
+ __assign({ name: "homePhone", label: "Home phone", variant: "phone" }, settings.homePhone),
626
+ ];
627
+ };
628
+
629
+ var TelecommunicationsInfoFieldsSchema = {
630
+ tvType: yup__namespace.string().required(kuiCrm.defaultRequiredMessage),
631
+ homePhone: kuiCrm.phoneNonRequiredSchema("homePhone"),
632
+ };
633
+ var TelecommunicationsInfoStepSchema = yup__namespace
634
+ .object()
635
+ .shape(TelecommunicationsInfoFieldsSchema, [["homePhone", "homePhone"]]);
636
+
637
+ exports.AdditionalInfoStepSchema = AdditionalInfoStepSchema;
638
+ exports.BasicApartmentInfoFieldsSchema = BasicApartmentInfoStepSchema;
639
+ exports.DetailApartmentInfoStepSchema = DetailApartmentInfoStepSchema;
640
+ exports.HouseServicesInfoStepSchema = HouseServicesInfoStepSchema;
641
+ exports.MetersInfoStepSchema = MetersInfoStepSchema;
642
+ exports.RoomsApartmentInfoFieldsSchema = RoomsApartmentInfoStepSchema;
643
+ exports.SecurityApartmentInfoStepSchema = SecurityApartmentInfoStepSchema;
644
+ exports.TelecommunicationsInfoStepSchema = TelecommunicationsInfoStepSchema;
645
+ exports.getAdditionalInfoStepFields = getAdditionalInfoStepFields;
646
+ exports.getApartmentPaymentFields = getApartmentPaymentFields;
647
+ exports.getBasicApartmentInfoFields = getBasicApartmentInfoFields;
648
+ exports.getDetailApartmentInfoFields = getDetailApartmentInfoFields;
649
+ exports.getHouseServicesInfoStep = getHouseServicesInfoStep;
650
+ exports.getMetersInfoStepFields = getMetersInfoStepFields;
651
+ exports.getPartialMeterInfoFields = getPartialMeterInfoFields;
652
+ exports.getPartialMeterInfoSchema = getPartialMeterInfoSchema;
653
+ exports.getRoomsApartmentInfoFields = getRoomsApartmentInfoFields;
654
+ exports.getSecurityApartmentInfoFields = getSecurityApartmentInfoFields;
655
+ exports.getTelecommunicationsInfoStepFields = getTelecommunicationsInfoStepFields;
656
+ exports.inspectionsRequests = inspectionsRequests;
657
+ //# sourceMappingURL=index.js.map