kui-crm_actions 0.0.62 → 0.0.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import * as kui_crm from 'kui-crm';
2
- import { InputParams, ResourceTypes, MeterTypes, InputFileWithVisibilityFields, MeterFeaturesFormFields, InspectionTypes, InspectionRoomPhotoTypes, ParkingTypes, ContractLinkModel, ImageBodyRequest, FileBodyRequest, RoomType, ApartmentMainInfoModelFields, TaxesTypes, ApartmentDetailInfoModelFields, CityParams, RoomTypes, RenovationParams, RoomParams, PhoneParams, WifiParams, InternetProviderParams, TVTypes, CompanyAutocompleteFields, CountryAutocompleteFields, MetersCountParams, FillingTagsAutocompleteFields, ApartmentFillingVariants, FillingInfoFormFields as FillingInfoFormFields$1, GeolocationParams } from 'kui-crm';
2
+ import { InputParams, ResourceTypes, MeterTypes, FileStore, InputFileWithVisibilityFields, MeterFeaturesFormFields, InspectionTypes, InspectionRoomPhotoTypes, ParkingTypes, CityParams, RoomTypes, RenovationParams, RoomParams, PhoneParams, WifiParams, InternetProviderParams, TVTypes, CompanyAutocompleteFields, CountryAutocompleteFields, TaxesTypes, MetersCountParams, FillingTagsAutocompleteFields, ApartmentFillingVariants, ImageBodyRequest, FillingInfoFormFields as FillingInfoFormFields$1, ContractLinkModel, FileBodyRequest, RoomType, ApartmentMainInfoModelFields, ApartmentDetailInfoModelFields, GeolocationParams } from 'kui-crm';
3
3
  import { DateTime } from 'luxon';
4
4
  import { Loader, MultistepForm, PhoneParams as PhoneParams$1 } from 'kui-utils';
5
5
  import * as yup from 'yup';
6
- import UploadFileParams$2, { UploadFileParams as UploadFileParams$1 } from 'kui-complex/dist/FileItem';
7
6
  import { InputWithAddressFields } from 'kui-complex/dist/InputWithAddressAutocomplete';
8
7
  import { ReactElement } from 'react';
9
8
 
@@ -13,26 +12,6 @@ declare const getPartialMeterInfoSchema: (valuesFields: InputParams<any>[]) => y
13
12
  [x: string]: any;
14
13
  }, "">;
15
14
 
16
- type FileParams = {
17
- id: number | null
18
- name: string
19
- url: string
20
- date: DateTime | null
21
- size: number | null
22
- createdBy: string
23
- extension: string
24
- }
25
-
26
- type UploadFileParams = {
27
- id?: number | null
28
- index?: number | string
29
- size?: number | null
30
- file?: File | FileParams
31
- name?: string
32
- title?: string
33
- url?: string
34
- }
35
-
36
15
  type PartialMeterInfoStepProps = {
37
16
  resource: ResourceTypes
38
17
  index: number
@@ -48,18 +27,18 @@ type PartialMeterInfoFields = {
48
27
  T1?: string | number | null
49
28
  T2?: string | number | null
50
29
  T3?: string | number | null
51
- images: UploadFileParams[]
30
+ images: FileStore[]
52
31
  }
53
32
 
54
- type InspectionMeterFields$1 = {
33
+ type InspectionMeterFields = {
55
34
  id?: number
56
35
  resource: ResourceTypes
57
36
  passportFile?: InputFileWithVisibilityFields
58
- images: UploadFileParams$1[]
37
+ images: FileStore[]
59
38
  } & MeterFeaturesFormFields
60
39
 
61
- type InspectionMetersStepFields$1 = {
62
- meters: InspectionMeterFields$1[]
40
+ type InspectionMetersStepFields = {
41
+ meters: InspectionMeterFields[]
63
42
  }
64
43
 
65
44
  type InspectionPartialMetersStepFields = {
@@ -81,7 +60,7 @@ type CommonInspectionFormFields = {
81
60
 
82
61
  type InspectionRoomImagesParams = {
83
62
  type: InspectionRoomPhotoTypes
84
- files: UploadFileParams$2[]
63
+ files: FileStore[]
85
64
  comment: string
86
65
  }
87
66
 
@@ -102,6 +81,51 @@ type InspectionImageFieldsSettings = {
102
81
  [key: string]: any
103
82
  }
104
83
 
84
+ type BasicApartmentInfoStepFields = {
85
+ apartment: InputWithAddressFields
86
+ apartmentNumber: number | string | null
87
+ city: CityParams | null
88
+ zipCode?: string
89
+ }
90
+
91
+ type SecurityApartmentInfoStepFields = {
92
+ typeOfObject: RoomTypes | null
93
+ entrance: string
94
+ hasIntercom: boolean | null
95
+ intercomCode: string
96
+ hasGate: boolean | null
97
+ gateCode: string
98
+ }
99
+
100
+ type RoomsApartmentInfoStepFields = {
101
+ floor: number | null
102
+ floorCount: number | null
103
+ roomsNumber: number | null
104
+ bedroomsNumber: number | null
105
+ bathroomsNumber: number | null
106
+ restroomsNumber: number | null
107
+ combinedBathroomsNumber: number | null
108
+ }
109
+
110
+ type DetailApartmentInfoStepFields = {
111
+ area: number | string | null
112
+ livingArea: number | string | null
113
+ kitchenArea: number | string | null
114
+ ceilingHeight: number | string | null
115
+ numberOfWindows: number | null
116
+ renovation: RenovationParams | null
117
+ rooms: RoomParams[]
118
+ }
119
+
120
+ type InitialInspectionFormFields = CommonInspectionFormFields &
121
+ InitialInspectionInfoFields &
122
+ InspectionRoomsImagesFields
123
+
124
+ type InitialInspectionInfoFields = BasicApartmentInfoStepFields &
125
+ SecurityApartmentInfoStepFields &
126
+ RoomsApartmentInfoStepFields &
127
+ DetailApartmentInfoStepFields
128
+
105
129
  type TransferInspectionTypes =
106
130
  | "maroom_tenant"
107
131
  | "tenant_maroom"
@@ -132,6 +156,87 @@ type MeterValuesFields = {
132
156
  initialValueT3?: MeterValue
133
157
  }
134
158
 
159
+ type HouseServicesInfoStepFields = {
160
+ hasBarrier: boolean | null
161
+ barrierPhone: PhoneParams | null
162
+ hasConcierge: boolean | null
163
+ conciergePhone: PhoneParams | null
164
+ hasSecurity: boolean | null
165
+ securityPhone: PhoneParams | null
166
+ hasVideoControl: boolean | null
167
+ videoControlPhone: PhoneParams | null
168
+ parkingType: ParkingTypes | null
169
+ parkingNumber: string
170
+ passengerElevatorsCount: number | null
171
+ serviceElevatorsCount: number | null
172
+ }
173
+
174
+ type TelecommunicationsInfoStepFields = {
175
+ wifi: WifiParams | null
176
+ internetProvider: InternetProviderParams | null
177
+ tvType: TVTypes | null
178
+ homePhone: PhoneParams | null
179
+ }
180
+
181
+ type ApartmentPaymentsFormFields = {
182
+ payerCode: string
183
+ communalServicesAccount: string
184
+ company: CompanyAutocompleteFields | null
185
+ countryOfResidence: CountryAutocompleteFields | null
186
+ taxesType: TaxesTypes | null
187
+ }
188
+
189
+ type AdditionalInfoStepFields = {
190
+ withPets: boolean
191
+ withChildren: boolean
192
+ additionalTerms: string
193
+ } & ApartmentPaymentsFormFields
194
+
195
+ type MetersInfoStepFields = {
196
+ maxMeters: MetersCountParams | null
197
+ }
198
+
199
+ type FillingInfoFormFields = {
200
+ tag: FillingTagsAutocompleteFields
201
+ serialNumber?: string
202
+ numberOfSubjects?: string | number | null
203
+ name?: string
204
+ type?: ApartmentFillingVariants
205
+ instruction?: InputFileWithVisibilityFields
206
+ tempImages?: ImageBodyRequest[]
207
+ }
208
+
209
+ type FillingInfoStepFields = {
210
+ images: FileStore[]
211
+ } & FillingInfoFormFields$1
212
+
213
+ type FillingListInfoStepFields = {
214
+ fillingList: FillingInfoStepFields[]
215
+ }
216
+
217
+
218
+ type InventoryInspectionFormFields = CommonInspectionFormFields &
219
+ HouseServicesInfoStepFields &
220
+ TelecommunicationsInfoStepFields &
221
+ AdditionalInfoStepFields &
222
+ MetersInfoStepFields &
223
+ InspectionMetersStepFields &
224
+ FillingListInfoStepFields &
225
+ InspectionRoomsImagesFields
226
+
227
+ declare const inspectionsRequests: {
228
+ createInspection(apartmentId: number, body: any, loader: Loader): Promise<number | undefined>;
229
+ createInitialInspection(data: InitialInspectionFormFields, apartmentId: number, loader: Loader): Promise<number | null | undefined>;
230
+ createRegularInspection(data: RegularInspectionFormFields, apartmentId: number, loader: Loader): Promise<number | null | undefined>;
231
+ createTransferInspection(data: TransferInspectionFormFields, apartmentId: number, loader: Loader): Promise<number | null | undefined>;
232
+ createInventoryInspection(data: InventoryInspectionFormFields, apartmentId: number, loader: Loader): Promise<number | null | undefined>;
233
+ getRoomParams(rooms: InspectionRoomImagesParams[]): {
234
+ purpose: kui_crm.InspectionRoomPhotoTypes;
235
+ comment: string;
236
+ photos: kui_crm.ImageBodyRequest[];
237
+ }[];
238
+ };
239
+
135
240
  declare type InspectionAppraisalLiteModel = {
136
241
  id: number;
137
242
  date: string;
@@ -259,150 +364,12 @@ declare type InspectionRoomPhotoRequest = {
259
364
  room_order_number?: number;
260
365
  };
261
366
 
262
- type BasicApartmentInfoStepFields = {
263
- apartment: InputWithAddressFields
264
- apartmentNumber: number | string | null
265
- city: CityParams | null
266
- zipCode?: string
267
- }
268
-
269
- type SecurityApartmentInfoStepFields = {
270
- typeOfObject: RoomTypes | null
271
- entrance: string
272
- hasIntercom: boolean | null
273
- intercomCode: string
274
- hasGate: boolean | null
275
- gateCode: string
276
- }
277
-
278
- type RoomsApartmentInfoStepFields = {
279
- floor: number | null
280
- floorCount: number | null
281
- roomsNumber: number | null
282
- bedroomsNumber: number | null
283
- bathroomsNumber: number | null
284
- restroomsNumber: number | null
285
- combinedBathroomsNumber: number | null
286
- }
287
-
288
- type DetailApartmentInfoStepFields = {
289
- area: number | string | null
290
- livingArea: number | string | null
291
- kitchenArea: number | string | null
292
- ceilingHeight: number | string | null
293
- numberOfWindows: number | null
294
- renovation: RenovationParams | null
295
- rooms: RoomParams[]
296
- }
297
-
298
- type InitialInspectionFormFields = CommonInspectionFormFields &
299
- InitialInspectionInfoFields &
300
- InspectionRoomsImagesFields
301
-
302
- type InitialInspectionInfoFields = BasicApartmentInfoStepFields &
303
- SecurityApartmentInfoStepFields &
304
- RoomsApartmentInfoStepFields &
305
- DetailApartmentInfoStepFields
306
-
307
- type HouseServicesInfoStepFields = {
308
- hasBarrier: boolean | null
309
- barrierPhone: PhoneParams | null
310
- hasConcierge: boolean | null
311
- conciergePhone: PhoneParams | null
312
- hasSecurity: boolean | null
313
- securityPhone: PhoneParams | null
314
- hasVideoControl: boolean | null
315
- videoControlPhone: PhoneParams | null
316
- parkingType: ParkingTypes | null
317
- parkingNumber: string
318
- passengerElevatorsCount: number | null
319
- serviceElevatorsCount: number | null
320
- }
321
-
322
- type TelecommunicationsInfoStepFields = {
323
- wifi: WifiParams | null
324
- internetProvider: InternetProviderParams | null
325
- tvType: TVTypes | null
326
- homePhone: PhoneParams | null
327
- }
328
-
329
- type ApartmentPaymentsFormFields = {
330
- payerCode: string
331
- communalServicesAccount: string
332
- company: CompanyAutocompleteFields | null
333
- countryOfResidence: CountryAutocompleteFields | null
334
- taxesType: TaxesTypes | null
335
- }
336
-
337
- type AdditionalInfoStepFields = {
338
- withPets: boolean
339
- withChildren: boolean
340
- additionalTerms: string
341
- } & ApartmentPaymentsFormFields
342
-
343
- type MetersInfoStepFields = {
344
- maxMeters: MetersCountParams | null
345
- }
346
-
347
- type FillingInfoFormFields = {
348
- tag: FillingTagsAutocompleteFields
349
- serialNumber?: string
350
- numberOfSubjects?: string | number | null
351
- name?: string
352
- type?: ApartmentFillingVariants
353
- instruction?: InputFileWithVisibilityFields
354
- tempImages?: ImageBodyRequest[]
355
- }
356
-
357
- type InspectionMeterFields = {
358
- id?: number
359
- resource: ResourceTypes
360
- passportFile?: InputFileWithVisibilityFields
361
- images: UploadFileParams$1[]
362
- } & MeterFeaturesFormFields
363
-
364
- type InspectionMetersStepFields = {
365
- meters: InspectionMeterFields[]
366
- }
367
-
368
- type FillingInfoStepFields = {
369
- images: UploadFileParams$1[]
370
- } & FillingInfoFormFields$1
371
-
372
- type FillingListInfoStepFields = {
373
- fillingList: FillingInfoStepFields[]
374
- }
375
-
376
-
377
- type InventoryInspectionFormFields = CommonInspectionFormFields &
378
- HouseServicesInfoStepFields &
379
- TelecommunicationsInfoStepFields &
380
- AdditionalInfoStepFields &
381
- MetersInfoStepFields &
382
- InspectionMetersStepFields &
383
- FillingListInfoStepFields &
384
- InspectionRoomsImagesFields
385
-
386
- declare const inspectionsRequests: {
387
- createInspection(apartmentId: number, body: any, loader: Loader): Promise<number | undefined>;
388
- loadInspectionImages(loader: Loader, roomsImages: InspectionRoomImagesParams[]): Promise<InspectionRoomPhotoRequest[]>;
389
- createInitialInspection(data: InitialInspectionFormFields, apartmentId: number, loader: Loader): Promise<number | null | undefined>;
390
- createRegularInspection(data: RegularInspectionFormFields, apartmentId: number, loader: Loader): Promise<number | null | undefined>;
391
- createTransferInspection(data: TransferInspectionFormFields, apartmentId: number, loader: Loader): Promise<number | null | undefined>;
392
- createInventoryInspection(data: InventoryInspectionFormFields, apartmentId: number, loader: Loader): Promise<number | null | undefined>;
393
- getRoomParams(room: InspectionRoomImagesParams, photos?: ImageBodyRequest[] | undefined): {
394
- purpose: kui_crm.InspectionRoomPhotoTypes;
395
- comment: string;
396
- photos: ImageBodyRequest[];
397
- };
398
- };
399
-
400
367
  declare const inspectionsRequestBody: {
401
368
  getPostBodyInitialInspection(inspection: InitialInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[]): InitialInspectionPostBody;
402
369
  getInitialInspectionFields(inspection: InitialInspectionInfoFields): InitialInspectionFieldsBody;
403
- getPostBodyRegularInspection(inspection: RegularInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[], metersImages: ImageBodyRequest[][]): RegularInspectionPostBody;
404
- getPostBodyTransferInspection(inspection: TransferInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[], metersImages: ImageBodyRequest[][]): TransferInspectionPostBody;
405
- getPartialInspectionMeters(meters: PartialMeterInfoFields[], metersImages: ImageBodyRequest[][]): {
370
+ getPostBodyRegularInspection(inspection: RegularInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[]): RegularInspectionPostBody;
371
+ getPostBodyTransferInspection(inspection: TransferInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[]): TransferInspectionPostBody;
372
+ getPartialInspectionMeters(meters: PartialMeterInfoFields[]): {
406
373
  meters: {
407
374
  id: number;
408
375
  resource_type: kui_crm.ResourceTypes;
@@ -414,8 +381,8 @@ declare const inspectionsRequestBody: {
414
381
  };
415
382
  }[];
416
383
  };
417
- getPostBodyInventoryInspection(inspection: InventoryInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[], fillingFiles: FileBodyRequest[], metersFiles: FileBodyRequest[], metersImages: ImageBodyRequest[][], fillingImages: ImageBodyRequest[][]): InventoryInspectionPostBody;
418
- getInventoryInspectionMeters(meters: InspectionMeterFields$1[], metersFiles: FileBodyRequest[], metersImages: ImageBodyRequest[][]): {
384
+ getPostBodyInventoryInspection(inspection: InventoryInspectionFormFields, roomsImages: InspectionRoomPhotoRequest[], fillingFiles: FileBodyRequest[], metersFiles: FileBodyRequest[]): InventoryInspectionPostBody;
385
+ getInventoryInspectionMeters(meters: InspectionMeterFields[], metersFiles: FileBodyRequest[], metersImages?: ImageBodyRequest[][] | undefined): {
419
386
  meters: {
420
387
  passport: FileBodyRequest;
421
388
  values: {
@@ -460,7 +427,7 @@ declare const inspectionsRequestBody: {
460
427
  cold?: undefined;
461
428
  hot?: undefined;
462
429
  };
463
- getMeterCommonFields(meter: InspectionMeterFields$1): {
430
+ getMeterCommonFields(meter: InspectionMeterFields): {
464
431
  id: number | undefined;
465
432
  meter_type: kui_crm.MeterTypes | undefined;
466
433
  passport_number: string;
@@ -473,6 +440,7 @@ declare const inspectionsRequestBody: {
473
440
  getMeterValues(initialValue?: string | number | null | undefined, lastValue?: string | number | null | undefined): {
474
441
  [key: string]: any;
475
442
  };
443
+ getFilesParams(files: FileStore[]): ImageBodyRequest[];
476
444
  };
477
445
 
478
446
  declare const getBasicApartmentInfoFields: (handlePlaceSelect?: ((coords: google.maps.LatLngLiteral) => void) | undefined, settings?: InspectionFieldsSettings | undefined) => InputParams<BasicApartmentInfoStepFields>[];
@@ -837,4 +805,4 @@ type ApartmentOverlayProps = {
837
805
 
838
806
  declare const ApartmentInspectionOverlay: (props: ApartmentOverlayProps) => JSX.Element;
839
807
 
840
- export { AdditionalInfoFieldsSchema, AdditionalInfoStepFields, AdditionalInfoStepSchema, ApartmentInspectionModel, ApartmentInspectionOverlay, ApartmentInspectionParams, ApartmentLinkParams, ApartmentPaymentsFormFields, BasicApartmentInfoFieldsSchema, BasicApartmentInfoStepFields, BasicApartmentInfoStepSchema, CommonInspectionFields, CommonInspectionFormFields, DetailApartmentInfoFieldsSchema, DetailApartmentInfoStepFields, DetailApartmentInfoStepSchema, FillingInfoFieldsSchema, FillingInfoFormFields, FillingInfoStepFields, FillingListInfoStepFields, HouseServicesInfoFieldsSchema, HouseServicesInfoStepFields, HouseServicesInfoStepSchema, InitialInspectionFieldsBody, InitialInspectionFormFields, InitialInspectionInfoFields, InitialInspectionPostBody, InitialInspectionRoomParams, InspectionAppraisalLiteModel, InspectionFieldsSettings, InspectionFillingParams, InspectionImpairmentLiteModel, InspectionMeterCommonFields, InspectionMeterFields$1 as InspectionMeterFields, InspectionMeterValueModel, InspectionMetersStepFields$1 as InspectionMetersStepFields, InspectionPartialMetersStepFields, InspectionRoomImagesParams, InspectionRoomPhotoRequest, InspectionRoomsImagesFields, InventoryInspectionFieldsBody, InventoryInspectionFormFields, InventoryInspectionPostBody, InventoryMeterModel, MeterInfoStepProps, MeterValueModel, MeterValuesFields, MetersInfoFieldsSchema, MetersInfoStepFields, MetersInfoStepSchema, MetroStationParams, PartialMeterInfoFields, PartialMeterInfoStepProps, PartialMeterModel, PostApartmentInspectionRequest, RegularInspectionFormFields, RegularInspectionPostBody, RegularlyInspectionFieldsBody, RoomsApartmentInfoFieldsSchema, RoomsApartmentInfoStepFields, RoomsApartmentInfoStepSchema, SecurityApartmentInfoFieldsSchema, SecurityApartmentInfoStepFields, SecurityApartmentInfoStepSchema, TelecommunicationsInfoFieldsSchema, TelecommunicationsInfoStepFields, TelecommunicationsInfoStepSchema, TenantParams, TransferInspectionFieldsBody, TransferInspectionFormFields, TransferInspectionPostBody, TransferInspectionTypes, getAdditionalInfoStepFields, getBasicApartmentInfoFields, getDetailApartmentInfoFields, getFillingInfoFields, getHouseServicesInfoStep, getMetersInfoStepFields, getPartialMeterInfoSchema, getRoomsApartmentInfoFields, getRoomsImagesSteps, getSecurityApartmentInfoFields, getTelecommunicationsInfoStepFields, inspectionsRequestBody, inspectionsRequests, renderMetersSteps, useMetersValues };
808
+ export { AdditionalInfoFieldsSchema, AdditionalInfoStepFields, AdditionalInfoStepSchema, ApartmentInspectionModel, ApartmentInspectionOverlay, ApartmentInspectionParams, ApartmentLinkParams, ApartmentPaymentsFormFields, BasicApartmentInfoFieldsSchema, BasicApartmentInfoStepFields, BasicApartmentInfoStepSchema, CommonInspectionFields, CommonInspectionFormFields, DetailApartmentInfoFieldsSchema, DetailApartmentInfoStepFields, DetailApartmentInfoStepSchema, FillingInfoFieldsSchema, FillingInfoFormFields, FillingInfoStepFields, FillingListInfoStepFields, HouseServicesInfoFieldsSchema, HouseServicesInfoStepFields, HouseServicesInfoStepSchema, InitialInspectionFieldsBody, InitialInspectionFormFields, InitialInspectionInfoFields, InitialInspectionPostBody, InitialInspectionRoomParams, InspectionAppraisalLiteModel, InspectionFieldsSettings, InspectionFillingParams, InspectionImpairmentLiteModel, InspectionMeterCommonFields, InspectionMeterFields, InspectionMeterValueModel, InspectionMetersStepFields, InspectionPartialMetersStepFields, InspectionRoomImagesParams, InspectionRoomPhotoRequest, InspectionRoomsImagesFields, InventoryInspectionFieldsBody, InventoryInspectionFormFields, InventoryInspectionPostBody, InventoryMeterModel, MeterInfoStepProps, MeterValueModel, MeterValuesFields, MetersInfoFieldsSchema, MetersInfoStepFields, MetersInfoStepSchema, MetroStationParams, PartialMeterInfoFields, PartialMeterInfoStepProps, PartialMeterModel, PostApartmentInspectionRequest, RegularInspectionFormFields, RegularInspectionPostBody, RegularlyInspectionFieldsBody, RoomsApartmentInfoFieldsSchema, RoomsApartmentInfoStepFields, RoomsApartmentInfoStepSchema, SecurityApartmentInfoFieldsSchema, SecurityApartmentInfoStepFields, SecurityApartmentInfoStepSchema, TelecommunicationsInfoFieldsSchema, TelecommunicationsInfoStepFields, TelecommunicationsInfoStepSchema, TenantParams, TransferInspectionFieldsBody, TransferInspectionFormFields, TransferInspectionPostBody, TransferInspectionTypes, getAdditionalInfoStepFields, getBasicApartmentInfoFields, getDetailApartmentInfoFields, getFillingInfoFields, getHouseServicesInfoStep, getMetersInfoStepFields, getPartialMeterInfoSchema, getRoomsApartmentInfoFields, getRoomsImagesSteps, getSecurityApartmentInfoFields, getTelecommunicationsInfoStepFields, inspectionsRequestBody, inspectionsRequests, renderMetersSteps, useMetersValues };
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as yup from 'yup';
2
- import { requests, uploadImages, uploadFiles, CountryAutocomplete, RegionAutocomplete, CityAutocomplete, RenovationTypeValues, RenovationStyleValues, RoomTypeValues, RoomTypesValues, BooleanValues, ParkingTypesValues, fieldWithConditionSchema, defaultRequiredMessage, getApartmentPaymentFields, phoneWithConditionSchema, positiveNumberSchema, getNumbersValues, TVTypesValues, phoneNonRequiredSchema, InputFileWithVisibility, FillingTypeValues, FillingTagsAutocomplete, PreviewContent, Link, UserBadge, useMapCards, MapOverlay } from 'kui-crm';
2
+ import { requests, uploadFiles, CountryAutocomplete, RegionAutocomplete, CityAutocomplete, RenovationTypeValues, RenovationStyleValues, RoomTypeValues, RoomTypesValues, BooleanValues, ParkingTypesValues, fieldWithConditionSchema, defaultRequiredMessage, getApartmentPaymentFields, phoneWithConditionSchema, positiveNumberSchema, getNumbersValues, TVTypesValues, phoneNonRequiredSchema, InputFileWithVisibility, FillingTypeValues, FillingTagsAutocomplete, PreviewContent, Link, UserBadge, useMapCards, MapOverlay } from 'kui-crm';
3
3
  import { clearNotValidFields, getPhoneNumberFromPhoneParams, resHandler, callPromises, addToArrayByCondition } from 'kui-utils';
4
4
  import to from 'await-to-js';
5
5
  import { DateTime } from 'luxon';
@@ -161,27 +161,27 @@ var inspectionsRequestBody = {
161
161
  }); }),
162
162
  };
163
163
  },
164
- getPostBodyRegularInspection: function (inspection, roomsImages, metersImages) {
164
+ getPostBodyRegularInspection: function (inspection, roomsImages) {
165
165
  return {
166
166
  date: DateTime.now().toISODate(),
167
167
  inspection_type: "regular",
168
168
  based_on: null,
169
169
  dropbox_link: inspection.dropboxLink,
170
170
  photo_groups: roomsImages,
171
- regular: this.getPartialInspectionMeters(inspection.meters, metersImages),
171
+ regular: this.getPartialInspectionMeters(inspection.meters),
172
172
  };
173
173
  },
174
- getPostBodyTransferInspection: function (inspection, roomsImages, metersImages) {
174
+ getPostBodyTransferInspection: function (inspection, roomsImages) {
175
175
  return {
176
176
  date: DateTime.now().toISODate(),
177
177
  inspection_type: "transfer",
178
178
  based_on: null,
179
179
  dropbox_link: inspection.dropboxLink,
180
180
  photo_groups: roomsImages,
181
- transfer: __assign({ transfer_type: inspection.transferType }, this.getPartialInspectionMeters(inspection.meters, metersImages)),
181
+ transfer: __assign({ transfer_type: inspection.transferType }, this.getPartialInspectionMeters(inspection.meters)),
182
182
  };
183
183
  },
184
- getPartialInspectionMeters: function (meters, metersImages) {
184
+ getPartialInspectionMeters: function (meters) {
185
185
  var _this = this;
186
186
  return {
187
187
  meters: meters.map(function (meter, index) { return ({
@@ -189,12 +189,13 @@ var inspectionsRequestBody = {
189
189
  resource_type: meter.resource,
190
190
  meter_type: meter.type,
191
191
  passport_number: meter.number,
192
- photos: metersImages[index],
192
+ photos: _this.getFilesParams(meter.images),
193
193
  values: clearNotValidFields(_this.getInspectionMeterValues(meter)),
194
194
  }); }),
195
195
  };
196
196
  },
197
- getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles, metersImages, fillingImages) {
197
+ getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles) {
198
+ var _this = this;
198
199
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
199
200
  return {
200
201
  date: DateTime.now().toISODate(),
@@ -219,16 +220,18 @@ var inspectionsRequestBody = {
219
220
  description: filling.name,
220
221
  serial_code: filling.serialNumber,
221
222
  amount: filling.numberOfSubjects,
222
- photos: fillingImages[index],
223
+ photos: _this.getFilesParams(filling.images),
223
224
  instruction: fillingFiles[index],
224
225
  });
225
- }) }, this.getInventoryInspectionMeters(inspection.meters, metersFiles, metersImages)),
226
+ }) }, this.getInventoryInspectionMeters(inspection.meters, metersFiles)),
226
227
  };
227
228
  },
228
229
  getInventoryInspectionMeters: function (meters, metersFiles, metersImages) {
229
230
  var _this = this;
230
231
  return {
231
- 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[index], no_tariff: meter.noTariff, auto_sending: meter.withAutoSending })); })) || [],
232
+ 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
233
+ ? metersImages[index]
234
+ : _this.getFilesParams(meter.images), no_tariff: meter.noTariff, auto_sending: meter.withAutoSending })); })) || [],
232
235
  };
233
236
  },
234
237
  getInspectionMeterValues: function (meter, fieldName) {
@@ -271,6 +274,11 @@ var inspectionsRequestBody = {
271
274
  last_value: lastValue,
272
275
  });
273
276
  },
277
+ getFilesParams: function (files) {
278
+ return files
279
+ .map(function (file) { return file.uploadedData; })
280
+ .filter(function (data) { return data; });
281
+ },
274
282
  };
275
283
 
276
284
  var inspectionsRequests = {
@@ -289,138 +297,79 @@ var inspectionsRequests = {
289
297
  });
290
298
  });
291
299
  },
292
- loadInspectionImages: function (loader, roomsImages) {
293
- var _a;
294
- return __awaiter(this, void 0, void 0, function () {
295
- var promises, images, bedroomCount, roomIndex, bedroomIndex;
296
- var _this = this;
297
- return __generator(this, function (_b) {
298
- switch (_b.label) {
299
- case 0:
300
- promises = [];
301
- roomsImages.forEach(function (room) {
302
- promises.push(uploadImages(loader, room.files));
303
- });
304
- return [4 /*yield*/, callPromises(promises)];
305
- case 1:
306
- images = _b.sent();
307
- bedroomCount = (_a = roomsImages.filter(function (imagesGroup) { return imagesGroup.type === "bedroom"; })) === null || _a === void 0 ? void 0 : _a.length;
308
- roomIndex = bedroomCount || 0;
309
- bedroomIndex = 0;
310
- return [2 /*return*/, roomsImages.map(function (room, index) {
311
- if (room.type === "room") {
312
- return __assign(__assign({}, _this.getRoomParams(room, images[index])), {
313
- // eslint-disable-next-line no-plusplus
314
- room_order_number: roomIndex++ });
315
- }
316
- if (room.type === "bedroom") {
317
- return __assign(__assign({}, _this.getRoomParams(room, images[index])), {
318
- // eslint-disable-next-line no-plusplus
319
- room_order_number: bedroomIndex++ });
320
- }
321
- return _this.getRoomParams(room, images[index]);
322
- })];
323
- }
324
- });
325
- });
326
- },
327
300
  createInitialInspection: function (data, apartmentId, loader) {
328
301
  return __awaiter(this, void 0, void 0, function () {
329
302
  var roomsImages, body;
330
303
  return __generator(this, function (_a) {
331
- switch (_a.label) {
332
- case 0:
333
- if (!apartmentId) return [3 /*break*/, 2];
334
- loader.startLoading("inspection creation");
335
- return [4 /*yield*/, this.loadInspectionImages(loader, data.roomsImages)];
336
- case 1:
337
- roomsImages = _a.sent();
338
- body = inspectionsRequestBody.getPostBodyInitialInspection(data, roomsImages);
339
- return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
340
- case 2: return [2 /*return*/, null];
304
+ if (apartmentId) {
305
+ loader.startLoading("inspection creation");
306
+ roomsImages = this.getRoomParams(data.roomsImages);
307
+ body = inspectionsRequestBody.getPostBodyInitialInspection(data, roomsImages);
308
+ return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
341
309
  }
310
+ return [2 /*return*/, null];
342
311
  });
343
312
  });
344
313
  },
345
314
  createRegularInspection: function (data, apartmentId, loader) {
346
- var _a;
347
315
  return __awaiter(this, void 0, void 0, function () {
348
- var metersImages, files, body;
349
- return __generator(this, function (_b) {
350
- switch (_b.label) {
351
- case 0:
352
- if (!apartmentId) return [3 /*break*/, 2];
353
- loader.startLoading("inspection creation");
354
- metersImages = ((_a = data.meters) === null || _a === void 0 ? void 0 : _a.map(function (meter) { return uploadImages(loader, meter.images); })) || [];
355
- return [4 /*yield*/, callPromises(__spreadArray([
356
- this.loadInspectionImages(loader, data.roomsImages)
357
- ], metersImages, true))];
358
- case 1:
359
- files = _b.sent();
360
- body = inspectionsRequestBody.getPostBodyRegularInspection(data, files[0], files.slice(1));
361
- return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
362
- case 2: return [2 /*return*/, null];
316
+ var roomsImages, body;
317
+ return __generator(this, function (_a) {
318
+ if (apartmentId) {
319
+ loader.startLoading("inspection creation");
320
+ roomsImages = this.getRoomParams(data.roomsImages);
321
+ body = inspectionsRequestBody.getPostBodyRegularInspection(data, roomsImages);
322
+ return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
363
323
  }
324
+ return [2 /*return*/, null];
364
325
  });
365
326
  });
366
327
  },
367
328
  createTransferInspection: function (data, apartmentId, loader) {
368
- var _a;
369
329
  return __awaiter(this, void 0, void 0, function () {
370
- var metersImages, files, body;
371
- return __generator(this, function (_b) {
372
- switch (_b.label) {
373
- case 0:
374
- if (!apartmentId) return [3 /*break*/, 2];
375
- loader.startLoading("inspection creation");
376
- metersImages = ((_a = data.meters) === null || _a === void 0 ? void 0 : _a.map(function (meter) { return uploadImages(loader, meter.images); })) || [];
377
- return [4 /*yield*/, callPromises(__spreadArray([
378
- this.loadInspectionImages(loader, data.roomsImages)
379
- ], metersImages, true))];
380
- case 1:
381
- files = _b.sent();
382
- body = inspectionsRequestBody.getPostBodyTransferInspection(data, files[0], files.slice(1));
383
- return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
384
- case 2: return [2 /*return*/, null];
330
+ var roomsImages, body;
331
+ return __generator(this, function (_a) {
332
+ if (apartmentId) {
333
+ loader.startLoading("inspection creation");
334
+ roomsImages = this.getRoomParams(data.roomsImages);
335
+ body = inspectionsRequestBody.getPostBodyTransferInspection(data, roomsImages);
336
+ return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
385
337
  }
338
+ return [2 /*return*/, null];
386
339
  });
387
340
  });
388
341
  },
389
342
  createInventoryInspection: function (data, apartmentId, loader) {
390
- var _a, _b;
343
+ var _a;
391
344
  return __awaiter(this, void 0, void 0, function () {
392
- var fillingFiles, metersFiles, metersImages, fillingImages, files, body;
393
- return __generator(this, function (_c) {
394
- switch (_c.label) {
345
+ var fillingFiles, metersFiles, files, roomsImages, body;
346
+ return __generator(this, function (_b) {
347
+ switch (_b.label) {
395
348
  case 0:
396
349
  if (!apartmentId) return [3 /*break*/, 2];
397
350
  loader.startLoading("inspection creation");
398
351
  fillingFiles = data.fillingList.map(function (filling) { return filling.instruction; });
399
352
  metersFiles = ((_a = data.meters) === null || _a === void 0 ? void 0 : _a.map(function (meter) { return meter.passportFile; })) || [];
400
- metersImages = ((_b = data.meters) === null || _b === void 0 ? void 0 : _b.map(function (meter) { return uploadImages(loader, meter.images); })) || [];
401
- fillingImages = data.fillingList.map(function (filling) {
402
- return uploadImages(loader, filling.images);
403
- });
404
- return [4 /*yield*/, callPromises(__spreadArray(__spreadArray([
405
- this.loadInspectionImages(loader, data.roomsImages),
353
+ return [4 /*yield*/, callPromises([
406
354
  uploadFiles(loader, fillingFiles),
407
- uploadFiles(loader, metersFiles)
408
- ], metersImages, true), fillingImages, true))];
355
+ uploadFiles(loader, metersFiles),
356
+ ])];
409
357
  case 1:
410
- files = _c.sent();
411
- body = inspectionsRequestBody.getPostBodyInventoryInspection(data, files[0], files[1], files[2], files.slice(3, metersImages.length + 3), files.slice(metersImages.length + 3));
358
+ files = _b.sent();
359
+ roomsImages = this.getRoomParams(data.roomsImages);
360
+ body = inspectionsRequestBody.getPostBodyInventoryInspection(data, roomsImages, files[0], files[1]);
412
361
  return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
413
362
  case 2: return [2 /*return*/, null];
414
363
  }
415
364
  });
416
365
  });
417
366
  },
418
- getRoomParams: function (room, photos) {
419
- return {
367
+ getRoomParams: function (rooms) {
368
+ return rooms.map(function (room) { return ({
420
369
  purpose: room.type,
421
370
  comment: room.comment,
422
- photos: photos || [],
423
- };
371
+ photos: inspectionsRequestBody.getFilesParams(room.files),
372
+ }); });
424
373
  },
425
374
  };
426
375