kui-crm 0.0.21 → 0.0.23

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 CHANGED
@@ -2,21 +2,22 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useEffect, useRef, useState, useCallback, useMemo } from 'react';
3
3
  import { observer } from 'mobx-react';
4
4
  import { useWatch, useForm, useController, useFieldArray } from 'react-hook-form';
5
- import { InputWithAutocomplete, AutocompleteOption, getVisibility, InputFile, CheckboxGroupWithTitle, getVisibilitySettings, InputWithController, InputWithMask, InputPhoneWithForm, InputSelectWithController, InputWithDatePicker, InputWithAddressAutocomplete, MapWrapper, useAddressAutocomplete, Loading, RadioGroupWithLabel, InputSelect } from 'kui-complex';
5
+ import { InputWithAutocomplete, AutocompleteOption as AutocompleteOption$1, getVisibility, InputFile, CheckboxGroupWithTitle, getVisibilitySettings, InputWithController, InputWithMask, InputPhoneWithForm, InputSelectWithController, InputWithDatePicker, InputWithAddressAutocomplete, MapWrapper, useAddressAutocomplete, Loading, RadioGroupWithLabel, InputSelect } from 'kui-complex';
6
6
  import to from 'await-to-js';
7
7
  import { makeAutoObservable, runInAction } from 'mobx';
8
- import { deleteCookie, getCookie, Loader, Paginator, SortingFilter, resHandler, useDebounce, isValidWithMaskExp, useToggle, MultistepForm, addToArrayByCondition, promisesWithCallback } from 'kui-utils';
8
+ import { deleteCookie, getCookie, Loader, Paginator, SortingFilter, resHandler, useDebounce, useToggle, getPhoneParamsFromString, MultistepForm, addToArrayByCondition, isValidWithMaskExp as isValidWithMaskExp$1, promisesWithCallback } from 'kui-utils';
9
9
  import axios from 'axios';
10
- import { Box, Grid, theme, Caption, Heading, Modal as Modal$1, Button, Divider, Container } from 'kui-basic';
10
+ import { Box, Grid, theme, Caption, Heading, Modal as Modal$1, CircularProgress, Button, Divider, Container } from 'kui-basic';
11
11
  import styled from '@emotion/styled';
12
- import { css } from '@emotion/react';
12
+ import { css, Global } from '@emotion/react';
13
13
  import { useNavigate } from 'react-router-dom';
14
14
  import { yupResolver } from '@hookform/resolvers/yup';
15
15
  import * as yup from 'yup';
16
- import { CheckIcon, MapIcon, LoupeIcon, CloseIcon, PlusIcon, PrevArrowIcon, NextArrowIcon, MaroomIcon } from 'kui-icon';
17
- import { jsx as jsx$1, jsxs as jsxs$1 } from '@emotion/react/jsx-runtime';
18
16
  import { createPortal } from 'react-dom';
17
+ import { CrossWithCircleIcon, CheckIcon, MapIcon, LoupeIcon, CloseIcon, PlusIcon, PrevArrowIcon, NextArrowIcon, MaroomIcon } from 'kui-icon';
18
+ import { jsx as jsx$1, jsxs as jsxs$1 } from '@emotion/react/jsx-runtime';
19
19
  import _ from 'lodash';
20
+ import { DateTime } from 'luxon';
20
21
 
21
22
  /******************************************************************************
22
23
  Copyright (c) Microsoft Corporation.
@@ -149,6 +150,9 @@ var CompaniesAgent = {
149
150
  createLogo: function (companyId, logo) {
150
151
  return requests.put("/companies/".concat(companyId, "/logo"), logo);
151
152
  },
153
+ findCompanyByINN: function (body) {
154
+ return requests.post("/companies/info-by-new-tin", body);
155
+ },
152
156
  };
153
157
 
154
158
  var UploadAgent = {
@@ -341,7 +345,7 @@ function CityAutocomplete(props) {
341
345
  }
342
346
  setIsMounted(true);
343
347
  }, [region === null || region === void 0 ? void 0 : region.id]);
344
- return (jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption, { label: option.name })); }, isLoading: isLoading, options: cities, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, inputRef: inputRef }, otherProps)));
348
+ return (jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption$1, { label: option.name })); }, isLoading: isLoading, options: cities, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, inputRef: inputRef }, otherProps)));
345
349
  }
346
350
  CityAutocomplete.defaultProps = {
347
351
  label: "City",
@@ -392,7 +396,7 @@ function CountryAutocomplete(props) {
392
396
  if (onSelect)
393
397
  onSelect(item);
394
398
  };
395
- return (jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption, { label: option.name })); }, isLoading: isLoading, options: countries, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd }, otherProps)));
399
+ return (jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption$1, { label: option.name })); }, isLoading: isLoading, options: countries, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd }, otherProps)));
396
400
  }
397
401
  CountryAutocomplete.defaultProps = {
398
402
  label: "Country",
@@ -531,7 +535,7 @@ function RegionAutocomplete(props) {
531
535
  }
532
536
  setIsMounted(true);
533
537
  }, [country === null || country === void 0 ? void 0 : country.id]);
534
- return (jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption, { label: option.name })); }, isLoading: isLoading, options: regions, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, inputRef: inputRef }, otherProps)));
538
+ return (jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption$1, { label: option.name })); }, isLoading: isLoading, options: regions, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, inputRef: inputRef }, otherProps)));
535
539
  }
536
540
  RegionAutocomplete.defaultProps = {
537
541
  label: "Region",
@@ -562,49 +566,42 @@ var usePortalPosition = function (portalParentRef) {
562
566
 
563
567
  function TwoOptionForAutocomplete(_a) {
564
568
  var option = _a.option;
565
- return (jsxs(StyledWrapper$5, __assign({ container: true, justify: "space-between" }, { children: [jsx(Grid, __assign({ item: true }, { children: jsx(Caption, __assign({ size: "s", weight: 500 }, { children: option.name })) })), jsx(Grid, __assign({ item: true }, { children: jsx(Caption, __assign({ size: "s", weight: 500, color: "fiftyP" }, { children: option.right })) }))] })));
569
+ return (jsxs(StyledWrapper$8, __assign({ container: true, justify: "space-between" }, { children: [jsx(Grid, __assign({ item: true }, { children: jsx(Caption, __assign({ size: "s", weight: 500 }, { children: option.name })) })), jsx(Grid, __assign({ item: true }, { children: jsx(Caption, __assign({ size: "s", weight: 500, color: "fiftyP" }, { children: option.right })) }))] })));
566
570
  }
567
- var StyledWrapper$5 = styled(Grid)(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\n padding: 8px;\n border-radius: 8px;\n cursor: pointer;\n &:hover {\n background: ", ";\n },\n"], ["\n padding: 8px;\n border-radius: 8px;\n cursor: pointer;\n &:hover {\n background: ", ";\n },\n"])), theme.palette.background.light2);
568
- var templateObject_1$g;
571
+ var StyledWrapper$8 = styled(Grid)(templateObject_1$j || (templateObject_1$j = __makeTemplateObject(["\n padding: 8px;\n border-radius: 8px;\n cursor: pointer;\n &:hover {\n background: ", ";\n },\n"], ["\n padding: 8px;\n border-radius: 8px;\n cursor: pointer;\n &:hover {\n background: ", ";\n },\n"])), theme.palette.background.light2);
572
+ var templateObject_1$j;
569
573
 
570
574
  function SquarePreviewImage(_a) {
571
575
  var imageSrc = _a.imageSrc, name = _a.name, size = _a.size, other = __rest(_a, ["imageSrc", "name", "size"]);
572
576
  var formattedName = name === null || name === void 0 ? void 0 : name.split(" ").map(function (el) { return el[0]; }).slice(0, 2).join("").toUpperCase();
573
- return (jsx(StyledWrapper$4, __assign({ size: size || "lg" }, other, { children: imageSrc ? (jsx(StyledImage$1, { src: imageSrc, alt: "preview image" })) : (jsx(StyledNameWrapper, __assign({ alignItems: "center", justify: "center" }, { children: jsx(Heading, __assign({ size: size === "sm" ? "h4" : "h1", colorGroup: "brand", color: "main" }, { children: formattedName !== null && formattedName !== void 0 ? formattedName : "?" })) }))) })));
577
+ return (jsx(StyledWrapper$7, __assign({ size: size || "lg" }, other, { children: imageSrc ? (jsx(StyledImage$1, { src: imageSrc, alt: "preview image" })) : (jsx(StyledNameWrapper, __assign({ alignItems: "center", justify: "center" }, { children: jsx(Heading, __assign({ size: size === "sm" ? "h4" : "h1", colorGroup: "brand", color: "main" }, { children: formattedName !== null && formattedName !== void 0 ? formattedName : "?" })) }))) })));
574
578
  }
575
579
  var previewSizesStyles = {
576
- lg: css(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\n width: 88px;\n height: 88px;\n border-radius: 16px;\n "], ["\n width: 88px;\n height: 88px;\n border-radius: 16px;\n "]))),
577
- sm: css(templateObject_2$7 || (templateObject_2$7 = __makeTemplateObject(["\n width: 32px;\n height: 32px;\n border-radius: 8px;\n "], ["\n width: 32px;\n height: 32px;\n border-radius: 8px;\n "]))),
580
+ lg: css(templateObject_1$i || (templateObject_1$i = __makeTemplateObject(["\n width: 88px;\n height: 88px;\n border-radius: 16px;\n "], ["\n width: 88px;\n height: 88px;\n border-radius: 16px;\n "]))),
581
+ sm: css(templateObject_2$9 || (templateObject_2$9 = __makeTemplateObject(["\n width: 32px;\n height: 32px;\n border-radius: 8px;\n "], ["\n width: 32px;\n height: 32px;\n border-radius: 8px;\n "]))),
578
582
  };
579
- var StyledImage$1 = styled.img(templateObject_3$6 || (templateObject_3$6 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n display: block;\n object-fit: cover;\n"], ["\n width: 100%;\n height: 100%;\n display: block;\n object-fit: cover;\n"])));
580
- var StyledWrapper$4 = styled.div(templateObject_4$3 || (templateObject_4$3 = __makeTemplateObject(["\n overflow: hidden;\n ", ";\n"], ["\n overflow: hidden;\n ", ";\n"])), function (_a) {
583
+ var StyledImage$1 = styled.img(templateObject_3$8 || (templateObject_3$8 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n display: block;\n object-fit: cover;\n"], ["\n width: 100%;\n height: 100%;\n display: block;\n object-fit: cover;\n"])));
584
+ var StyledWrapper$7 = styled.div(templateObject_4$4 || (templateObject_4$4 = __makeTemplateObject(["\n overflow: hidden;\n ", ";\n"], ["\n overflow: hidden;\n ", ";\n"])), function (_a) {
581
585
  var size = _a.size;
582
586
  return previewSizesStyles[size];
583
587
  });
584
- var StyledNameWrapper = styled(Grid)(templateObject_5$2 || (templateObject_5$2 = __makeTemplateObject(["\n background: ", ";\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n"], ["\n background: ", ";\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n"])), theme.palette.brand.light);
585
- var templateObject_1$f, templateObject_2$7, templateObject_3$6, templateObject_4$3, templateObject_5$2;
588
+ var StyledNameWrapper = styled(Grid)(templateObject_5$3 || (templateObject_5$3 = __makeTemplateObject(["\n background: ", ";\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n"], ["\n background: ", ";\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n"])), theme.palette.brand.light);
589
+ var templateObject_1$i, templateObject_2$9, templateObject_3$8, templateObject_4$4, templateObject_5$3;
586
590
 
587
591
  function Modal(_a) {
588
592
  var open = _a.open, other = __rest(_a, ["open"]);
589
593
  return jsx(StyledModal$1, __assign({ isOpen: open }, other));
590
594
  }
591
- var StyledModal$1 = styled(Modal$1)(templateObject_1$e || (templateObject_1$e = __makeTemplateObject(["\n max-height: calc(100% - 64px);\n .KUI-Modal_header {\n text-align: left;\n }\n .KUI-Modal_title {\n font-size: 24px;\n line-height: 32px;\n padding-bottom: 20px;\n }\n"], ["\n max-height: calc(100% - 64px);\n .KUI-Modal_header {\n text-align: left;\n }\n .KUI-Modal_title {\n font-size: 24px;\n line-height: 32px;\n padding-bottom: 20px;\n }\n"])));
592
- var templateObject_1$e;
595
+ var StyledModal$1 = styled(Modal$1)(templateObject_1$h || (templateObject_1$h = __makeTemplateObject(["\n max-height: calc(100% - 64px);\n .KUI-Modal_header {\n text-align: left;\n }\n .KUI-Modal_title {\n font-size: 24px;\n line-height: 32px;\n padding-bottom: 20px;\n }\n"], ["\n max-height: calc(100% - 64px);\n .KUI-Modal_header {\n text-align: left;\n }\n .KUI-Modal_title {\n font-size: 24px;\n line-height: 32px;\n padding-bottom: 20px;\n }\n"])));
596
+ var templateObject_1$h;
597
+
598
+ const isValidWithMaskExp = /^[^_]+$/;
593
599
 
594
600
  var CompanyCreationSchema = yup.object().shape({
595
601
  name: yup.string().required("Enter the company name"),
602
+ inn: yup.string().required("Enter the company TIN"),
596
603
  office: yup.object({
597
- address: yup
598
- .string()
599
- .required("Enter the company address")
600
- .test("check-latitude-longitude", "Please select an address from the dropdown", function (value) {
601
- var _a = this.parent.location, lat = _a.lat, lon = _a.lon;
602
- return !!(lat && lon);
603
- }),
604
- location: yup.object({
605
- lat: yup.number(),
606
- lon: yup.number(),
607
- }),
604
+ address: yup.string().required("Enter the company address"),
608
605
  }),
609
606
  phone: yup.object({
610
607
  phoneNumber: yup
@@ -612,14 +609,285 @@ var CompanyCreationSchema = yup.object().shape({
612
609
  .matches(isValidWithMaskExp, "Enter correct the company phone")
613
610
  .required("Enter the company phone"),
614
611
  }),
615
- email: yup.string().email(),
612
+ email: yup.string().email().required("This field is required"),
616
613
  type: yup.string().required("Choose the provider type of company"),
617
- zipCode: yup
618
- .string()
619
- .matches(isValidWithMaskExp, "Enter correct the company zip code")
620
- .required("Enter the company zip code"),
621
614
  });
622
615
 
616
+ var TaxTypeValues = [
617
+ { value: "resident", label: "Individual Resident" },
618
+ { value: "nonresident", label: "Individual Non-resident" },
619
+ { value: "self-employed", label: "Self-employed" },
620
+ { value: "individual-entrepreneur", label: "Individual entrepreneur" },
621
+ { value: "company", label: "Company" },
622
+ ];
623
+ var BooleanValues = [
624
+ { value: true, label: "Yes" },
625
+ { value: false, label: "No" },
626
+ ];
627
+ var ElectricityValues = [
628
+ { value: "T1", label: "One-part" },
629
+ { value: "T2", label: "Two-part" },
630
+ { value: "T3", label: "Three-part" },
631
+ ];
632
+ var WaterValues = [
633
+ { value: "cold", label: "Cold" },
634
+ { value: "hot", label: "Hot" },
635
+ ];
636
+ var getNumbersValues = function (count) {
637
+ return new Array(count).fill(0).map(function (value, key) { return ({
638
+ value: "".concat(key),
639
+ label: key,
640
+ }); });
641
+ };
642
+ var ParkingTypesValues = [
643
+ { value: "public", label: "Public" },
644
+ { value: "house", label: "House" },
645
+ { value: "underground", label: "Underground" },
646
+ { value: "private", label: "Private" },
647
+ ];
648
+ var TVTypesValues = [
649
+ { value: "cable", label: "Cable" },
650
+ { value: "satellite", label: "Satellite" },
651
+ { value: "smart_tv", label: "Smart TV" },
652
+ { value: "no", label: "No" },
653
+ ];
654
+ var TaxResidenceValues = [
655
+ { value: "resident", label: "Resident" },
656
+ { value: "not_resident", label: "Non-resident" },
657
+ ];
658
+ var RenovationTypeValues = [
659
+ { value: "capital", label: "Capital" },
660
+ { value: "euro", label: "Euro" },
661
+ { value: "designer", label: "Designer" },
662
+ { value: "cosmetic", label: "Cosmetic" },
663
+ { value: "required", label: "Required" },
664
+ ];
665
+ var RenovationStyleValues = [
666
+ { value: "classic", label: "Classic" },
667
+ { value: "scandinavian", label: "Scandinavian" },
668
+ { value: "loft", label: "Loft" },
669
+ { value: "contemporary", label: "Contemporary" },
670
+ { value: "minimalism", label: "Minimalism" },
671
+ { value: "neoclassic", label: "Neoclassic" },
672
+ { value: "eco", label: "Eco" },
673
+ { value: "provence", label: "Provence" },
674
+ { value: "hi_tech", label: "Hi-tech" },
675
+ { value: "mediterranean", label: "Mediterranean" },
676
+ { value: "eclectic", label: "Eclectic" },
677
+ { value: "ethno", label: "Ethno" },
678
+ { value: "gothic", label: "Gothic" },
679
+ ];
680
+ var RoomTypeValues = [
681
+ { value: "connected", label: "Connected" },
682
+ { value: "separate", label: "Separate" },
683
+ ];
684
+ var InspectionTypeValues = [
685
+ { value: "quarterly", label: "Quarterly" },
686
+ { value: "transfer", label: "Transfer" },
687
+ { value: "appraisal", label: "Appraisal" },
688
+ { value: "impairments", label: "Impairments" },
689
+ { value: "inventory", label: "Inventory" },
690
+ { value: "initial", label: "Initial" },
691
+ ];
692
+ var ImpairmentsTypeValues = [
693
+ { value: "damages", label: "Damages" },
694
+ { value: "wear_tear", label: "Wear&tear" },
695
+ ];
696
+ var FillingTypeValues = [
697
+ { value: "finish", label: "Finish" },
698
+ { value: "furniture", label: "Furniture" },
699
+ { value: "electronics", label: "Electronics" },
700
+ { value: "accessories", label: "Accessories" },
701
+ ];
702
+ var RoomTypesValues = [
703
+ { value: "residential", label: "Residential" },
704
+ { value: "non-residential", label: "Nonresidential" },
705
+ { value: "commercial", label: "Commercial" },
706
+ { value: "garage", label: "Garage" },
707
+ { value: "car_space", label: "Parking" },
708
+ ];
709
+ var CompanyTypesValues = [
710
+ { value: "administrative", label: "Administrative provider" },
711
+ { value: "service", label: "Service provider" },
712
+ { value: "resource", label: "Resource provider" },
713
+ ];
714
+ var ResourceValues = [
715
+ { value: "electricity", label: "Electricity" },
716
+ { value: "water", label: "Water" },
717
+ { value: "gas", label: "Gas" },
718
+ { value: "heating", label: "Heating" },
719
+ ];
720
+ var APIPayerValues = [
721
+ { value: "owner", label: "Landlord" },
722
+ { value: "renter", label: "Tenant" },
723
+ { value: "maroom", label: "Maroom" },
724
+ ];
725
+ var UnitOfPaymentValues = [
726
+ { value: "percent", label: "%" },
727
+ { value: "value", label: "₽" },
728
+ ];
729
+ var PartialPayerValues = [
730
+ { value: "owner", label: "Landlord" },
731
+ { value: "renter", label: "Tenant" },
732
+ { value: "maroom", label: "Maroom" },
733
+ { value: "partial", label: "Partial" },
734
+ ];
735
+
736
+ function AutocompleteOption(_a) {
737
+ var label = _a.label;
738
+ return (jsx(StyledWrapper$6, { children: jsx(Caption, __assign({ size: "s", weight: 500 }, { children: label })) }));
739
+ }
740
+ var StyledWrapper$6 = styled.div(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\n padding: 8px;\n border-radius: 8px;\n cursor: pointer;\n &:hover {\n background: ", ";\n },\n"], ["\n padding: 8px;\n border-radius: 8px;\n cursor: pointer;\n &:hover {\n background: ", ";\n },\n"])), theme.palette.background.light2);
741
+ var templateObject_1$g;
742
+
743
+ var parentClassName$1 = "KUI-ErrorPopup_container";
744
+ var timeout = 3000;
745
+ var createParentNode$1 = function () {
746
+ var node = document.createElement("div");
747
+ node.classList.add(parentClassName$1);
748
+ document.body.append(node);
749
+ return node;
750
+ };
751
+ function ErrorPopup(_a) {
752
+ var label = _a.label, onClose = _a.onClose;
753
+ var isHoverRef = useRef(false);
754
+ var _b = useState(true), open = _b[0], setOpen = _b[1];
755
+ var startHover = function () {
756
+ isHoverRef.current = true;
757
+ };
758
+ var checkIsHoverAndClose = function () {
759
+ if (!isHoverRef.current && open)
760
+ handleClose();
761
+ };
762
+ var handleClose = function () {
763
+ setOpen(false);
764
+ if (onClose) {
765
+ onClose();
766
+ }
767
+ };
768
+ var handleMouseLeave = function () {
769
+ isHoverRef.current = false;
770
+ handleClose();
771
+ };
772
+ useEffect(function () {
773
+ var timeoutId;
774
+ if (open) {
775
+ timeoutId = setTimeout(checkIsHoverAndClose, timeout);
776
+ }
777
+ return function () {
778
+ clearTimeout(timeoutId);
779
+ // handleClose()
780
+ };
781
+ }, [open]);
782
+ if (!open) {
783
+ return null;
784
+ }
785
+ var parentNode = document.querySelector(".".concat(parentClassName$1)) || createParentNode$1();
786
+ return (jsxs(Fragment, { children: [jsx(Global, { styles: containerCSS$1 }), createPortal(jsx(StyledWrapper$5, __assign({ onMouseEnter: startHover, onMouseLeave: handleMouseLeave, className: "KUI-ErrorPopup", container: true, alignItems: "center" }, { children: jsx(Caption, __assign({ size: "xs", weight: 600, color: "zero" }, { children: jsx(StyledContent, { children: label ? "Error in ".concat(label) : "Error" }) })) })), parentNode)] }));
787
+ }
788
+ var containerCSS$1 = css(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\n body {\n position: relative;\n }\n .KUI-ErrorPopup_container {\n display: flex;\n position: fixed;\n top: 120px;\n justify-content: center;\n flex-direction: column;\n width: 100%;\n align-items: center;\n z-index: 10000;\n }\n"], ["\n body {\n position: relative;\n }\n .KUI-ErrorPopup_container {\n display: flex;\n position: fixed;\n top: 120px;\n justify-content: center;\n flex-direction: column;\n width: 100%;\n align-items: center;\n z-index: 10000;\n }\n"])));
789
+ var StyledWrapper$5 = styled(Grid)(templateObject_2$8 || (templateObject_2$8 = __makeTemplateObject(["\n height: 46px;\n border-radius: 12px;\n background: rgba(25, 25, 25, 0.8);\n box-shadow: 0px 26px 34px rgba(0, 0, 0, 0.1);\n padding: 0 24px;\n margin-bottom: 16px;\n width: max-content;\n &:last-child {\n margin-bottom: 0;\n }\n"], ["\n height: 46px;\n border-radius: 12px;\n background: rgba(25, 25, 25, 0.8);\n box-shadow: 0px 26px 34px rgba(0, 0, 0, 0.1);\n padding: 0 24px;\n margin-bottom: 16px;\n width: max-content;\n &:last-child {\n margin-bottom: 0;\n }\n"])));
790
+ var StyledContent = styled.pre(templateObject_3$7 || (templateObject_3$7 = __makeTemplateObject(["\n margin: 0;\n padding: 0;\n"], ["\n margin: 0;\n padding: 0;\n"])));
791
+ var templateObject_1$f, templateObject_2$8, templateObject_3$7;
792
+
793
+ var parentClassName = "KUI-LoadingPopup_container";
794
+ var createParentNode = function () {
795
+ var node = document.createElement("div");
796
+ node.classList.add(parentClassName);
797
+ document.body.append(node);
798
+ return node;
799
+ };
800
+ function LoaderPopup(_a) {
801
+ var label = _a.label, onClose = _a.onClose;
802
+ var _b = useState(true), isOpen = _b[0], setIsOpen = _b[1];
803
+ if (!isOpen) {
804
+ return null;
805
+ }
806
+ var handleClose = function () {
807
+ setIsOpen(false);
808
+ if (onClose) {
809
+ onClose();
810
+ }
811
+ };
812
+ var parentNode = document.querySelector(".".concat(parentClassName)) || createParentNode();
813
+ return (jsxs(Fragment, { children: [jsx(Global, { styles: containerCSS }), createPortal(jsxs(StyledWrapper$4, __assign({ className: "KUI-LoadingPopup", container: true, alignItems: "center" }, { children: [jsx(StyledLoader, {}), jsxs(StyledCaption, __assign({ size: "xs", weight: 600, color: "zero" }, { children: ["Loading ", label] })), jsx(CloseIconWrapper, __assign({ onClick: handleClose }, { children: jsx(CrossWithCircleIcon, {}) }))] })), parentNode)] }));
814
+ }
815
+ var containerCSS = css(templateObject_1$e || (templateObject_1$e = __makeTemplateObject(["\n body {\n position: relative;\n }\n .KUI-LoadingPopup_container {\n display: flex;\n flex-direction: column-reverse;\n position: fixed;\n bottom: 56px;\n justify-content: center;\n width: 100%;\n align-items: center;\n z-index: 10000;\n }\n"], ["\n body {\n position: relative;\n }\n .KUI-LoadingPopup_container {\n display: flex;\n flex-direction: column-reverse;\n position: fixed;\n bottom: 56px;\n justify-content: center;\n width: 100%;\n align-items: center;\n z-index: 10000;\n }\n"])));
816
+ var StyledWrapper$4 = styled(Grid)(templateObject_2$7 || (templateObject_2$7 = __makeTemplateObject(["\n height: 48px;\n border-radius: 66px;\n box-shadow: 0px 26px 34px rgba(0, 0, 0, 0.1);\n background: rgba(25, 25, 25, 0.8);\n padding: 4px 12px 4px 8px;\n margin-top: 16px;\n width: max-content;\n min-width: 247px;\n &:last-child {\n margin-top: 0;\n }\n"], ["\n height: 48px;\n border-radius: 66px;\n box-shadow: 0px 26px 34px rgba(0, 0, 0, 0.1);\n background: rgba(25, 25, 25, 0.8);\n padding: 4px 12px 4px 8px;\n margin-top: 16px;\n width: max-content;\n min-width: 247px;\n &:last-child {\n margin-top: 0;\n }\n"])));
817
+ var StyledCaption = styled(Caption)(templateObject_3$6 || (templateObject_3$6 = __makeTemplateObject(["\n padding: 0 14px;\n"], ["\n padding: 0 14px;\n"])));
818
+ var StyledLoader = styled(CircularProgress)(templateObject_4$3 || (templateObject_4$3 = __makeTemplateObject(["\n color: #f1f1f1;\n width: 28px !important;\n height: 28px !important;\n"], ["\n color: #f1f1f1;\n width: 28px !important;\n height: 28px !important;\n"])));
819
+ var CloseIconWrapper = styled.div(templateObject_5$2 || (templateObject_5$2 = __makeTemplateObject(["\n cursor: pointer;\n margin-left: auto;\n height: 22px;\n"], ["\n cursor: pointer;\n margin-left: auto;\n height: 22px;\n"])));
820
+ var templateObject_1$e, templateObject_2$7, templateObject_3$6, templateObject_4$3, templateObject_5$2;
821
+
822
+ function LoaderState(_a) {
823
+ var loader = _a.loader, onlyError = _a.onlyError;
824
+ useEffect(function () { return function () {
825
+ loader === null || loader === void 0 ? void 0 : loader.cleanError();
826
+ if (!onlyError)
827
+ loader === null || loader === void 0 ? void 0 : loader.endLoading();
828
+ }; }, []);
829
+ return (jsxs(Fragment, { children: [(loader === null || loader === void 0 ? void 0 : loader.hasError) && (jsx(ErrorPopup, { label: loader.errorMessage, onClose: loader === null || loader === void 0 ? void 0 : loader.cleanError })), (loader === null || loader === void 0 ? void 0 : loader.isLoading) && !onlyError && (jsx(LoaderPopup, { label: loader.loadingMessage, onClose: loader.endLoading }))] }));
830
+ }
831
+ var LoaderState$1 = observer(LoaderState);
832
+
833
+ var name = "inn";
834
+ var CompanyInnAutocomplete = function (props) {
835
+ var form = props.form, otherProps = __rest(props, ["form"]);
836
+ var loaderRef = useRef(new Loader());
837
+ var loader = loaderRef.current;
838
+ var _a = useState(""), searchQuery = _a[0], setSearchQuery = _a[1];
839
+ var _b = useState([]), companies = _b[0], setCompanies = _b[1];
840
+ var updateFormFields = function (company) {
841
+ if (company) {
842
+ form.setValue("inn", company.inn);
843
+ form.setValue("name", company.name);
844
+ form.setValue("office", company.office);
845
+ if (company.phone)
846
+ form.setValue("phone", company.phone);
847
+ form.setValue("email", company.email);
848
+ }
849
+ };
850
+ var findCompanyByINN = function (tin) { return __awaiter(void 0, void 0, void 0, function () {
851
+ var _a, err, res;
852
+ return __generator(this, function (_b) {
853
+ switch (_b.label) {
854
+ case 0:
855
+ form.clearErrors(name);
856
+ loader.startLoading();
857
+ return [4 /*yield*/, to(CompaniesAgent.findCompanyByINN({ tin: tin }))];
858
+ case 1:
859
+ _a = _b.sent(), err = _a[0], res = _a[1];
860
+ if (err) {
861
+ if (err.tin) {
862
+ form.setError(name, {
863
+ type: "manual",
864
+ message: "A company with this TIN already exists",
865
+ });
866
+ }
867
+ else {
868
+ loader.setError(err);
869
+ }
870
+ }
871
+ else if (res === null || res === void 0 ? void 0 : res.tin) {
872
+ setCompanies([CompaniesStore.getCompanyFields(res)]);
873
+ }
874
+ else
875
+ setCompanies([]);
876
+ loader.endLoading();
877
+ return [2 /*return*/];
878
+ }
879
+ });
880
+ }); };
881
+ useDebounce(searchQuery, 500, function () {
882
+ if (searchQuery)
883
+ findCompanyByINN(searchQuery);
884
+ else
885
+ setCompanies([]);
886
+ });
887
+ return (jsxs(Fragment, { children: [jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption, { label: option.name })); }, options: companies, label: "TIN", form: form, name: name, isLoading: loader.isLoading, onSearchItem: setSearchQuery, onSelectItem: updateFormFields }, otherProps)), jsx(LoaderState$1, { loader: loader, onlyError: true })] }));
888
+ };
889
+ var CompanyInnAutocomplete$1 = observer(CompanyInnAutocomplete);
890
+
623
891
  function MapComponent(props) {
624
892
  var center = props.center, zoom = props.zoom, withMarker = props.withMarker, setMapProp = props.setMap;
625
893
  var _a = useState(null), map = _a[0], setMap = _a[1];
@@ -836,35 +1104,22 @@ var StyledInput$2 = styled.input(templateObject_4$1 || (templateObject_4$1 = __m
836
1104
  var StyledErrorMessage = styled(Caption)(templateObject_5$1 || (templateObject_5$1 = __makeTemplateObject(["\n margin-top: 4px;\n"], ["\n margin-top: 4px;\n"])));
837
1105
  var templateObject_1$a, templateObject_2$4, templateObject_3$3, templateObject_4$1, templateObject_5$1;
838
1106
 
839
- var companyOfficeFields = [
1107
+ var companyFields = [
840
1108
  {
841
- label: "Zip code",
842
- name: "zipCode",
843
- variant: "mask",
844
- mask: "000000",
845
- size: 6,
846
- },
847
- {
848
- name: "country",
849
- label: "Country",
850
- variant: "custom",
851
- CustomInput: CountryAutocomplete$1,
852
- size: 6,
853
- },
854
- {
855
- name: "region",
856
- label: "Region",
857
- variant: "custom",
858
- CustomInput: RegionAutocomplete$1,
859
- size: 6,
1109
+ label: "Provider type",
1110
+ name: "type",
1111
+ variant: "select",
1112
+ options: CompanyTypesValues,
860
1113
  },
861
1114
  {
862
- name: "city",
863
- label: "City",
1115
+ label: "INN",
1116
+ name: "inn",
864
1117
  variant: "custom",
865
- CustomInput: CityAutocomplete$1,
866
- size: 6,
1118
+ CustomInput: CompanyInnAutocomplete$1,
867
1119
  },
1120
+ { label: "Name", name: "name" },
1121
+ ];
1122
+ var companyOfficeFields = [
868
1123
  {
869
1124
  label: "Address",
870
1125
  name: "office",
@@ -882,126 +1137,6 @@ var companyOfficeFields = [
882
1137
  },
883
1138
  ];
884
1139
 
885
- var TaxTypeValues = [
886
- { value: "resident", label: "Individual Resident" },
887
- { value: "nonresident", label: "Individual Non-resident" },
888
- { value: "self-employed", label: "Self-employed" },
889
- { value: "individual-entrepreneur", label: "Individual entrepreneur" },
890
- { value: "company", label: "Company" },
891
- ];
892
- var BooleanValues = [
893
- { value: true, label: "Yes" },
894
- { value: false, label: "No" },
895
- ];
896
- var ElectricityValues = [
897
- { value: "T1", label: "One-part" },
898
- { value: "T2", label: "Two-part" },
899
- { value: "T3", label: "Three-part" },
900
- ];
901
- var WaterValues = [
902
- { value: "cold", label: "Cold" },
903
- { value: "hot", label: "Hot" },
904
- ];
905
- var getNumbersValues = function (count) {
906
- return new Array(count).fill(0).map(function (value, key) { return ({
907
- value: "".concat(key),
908
- label: key,
909
- }); });
910
- };
911
- var ParkingTypesValues = [
912
- { value: "public", label: "Public" },
913
- { value: "house", label: "House" },
914
- { value: "underground", label: "Underground" },
915
- { value: "private", label: "Private" },
916
- ];
917
- var TVTypesValues = [
918
- { value: "cable", label: "Cable" },
919
- { value: "satellite", label: "Satellite" },
920
- { value: "smart_tv", label: "Smart TV" },
921
- { value: "no", label: "No" },
922
- ];
923
- var TaxResidenceValues = [
924
- { value: "resident", label: "Resident" },
925
- { value: "not_resident", label: "Non-resident" },
926
- ];
927
- var RenovationTypeValues = [
928
- { value: "capital", label: "Capital" },
929
- { value: "euro", label: "Euro" },
930
- { value: "designer", label: "Designer" },
931
- { value: "cosmetic", label: "Cosmetic" },
932
- { value: "required", label: "Required" },
933
- ];
934
- var RenovationStyleValues = [
935
- { value: "classic", label: "Classic" },
936
- { value: "scandinavian", label: "Scandinavian" },
937
- { value: "loft", label: "Loft" },
938
- { value: "contemporary", label: "Contemporary" },
939
- { value: "minimalism", label: "Minimalism" },
940
- { value: "neoclassic", label: "Neoclassic" },
941
- { value: "eco", label: "Eco" },
942
- { value: "provence", label: "Provence" },
943
- { value: "hi_tech", label: "Hi-tech" },
944
- { value: "mediterranean", label: "Mediterranean" },
945
- { value: "eclectic", label: "Eclectic" },
946
- { value: "ethno", label: "Ethno" },
947
- { value: "gothic", label: "Gothic" },
948
- ];
949
- var RoomTypeValues = [
950
- { value: "connected", label: "Connected" },
951
- { value: "separate", label: "Separate" },
952
- ];
953
- var InspectionTypeValues = [
954
- { value: "quarterly", label: "Quarterly" },
955
- { value: "transfer", label: "Transfer" },
956
- { value: "appraisal", label: "Appraisal" },
957
- { value: "impairments", label: "Impairments" },
958
- { value: "inventory", label: "Inventory" },
959
- { value: "initial", label: "Initial" },
960
- ];
961
- var ImpairmentsTypeValues = [
962
- { value: "damages", label: "Damages" },
963
- { value: "wear_tear", label: "Wear&tear" },
964
- ];
965
- var FillingTypeValues = [
966
- { value: "finish", label: "Finish" },
967
- { value: "furniture", label: "Furniture" },
968
- { value: "electronics", label: "Electronics" },
969
- { value: "accessories", label: "Accessories" },
970
- ];
971
- var RoomTypesValues = [
972
- { value: "residential", label: "Residential" },
973
- { value: "non-residential", label: "Nonresidential" },
974
- { value: "commercial", label: "Commercial" },
975
- { value: "garage", label: "Garage" },
976
- { value: "car_space", label: "Parking" },
977
- ];
978
- var CompanyTypesValues = [
979
- { value: "administrative", label: "Administrative provider" },
980
- { value: "service", label: "Service provider" },
981
- { value: "resource", label: "Resource provider" },
982
- ];
983
- var ResourceValues = [
984
- { value: "electricity", label: "Electricity" },
985
- { value: "water", label: "Water" },
986
- { value: "gas", label: "Gas" },
987
- { value: "heating", label: "Heating" },
988
- ];
989
- var APIPayerValues = [
990
- { value: "owner", label: "Landlord" },
991
- { value: "renter", label: "Tenant" },
992
- { value: "maroom", label: "Maroom" },
993
- ];
994
- var UnitOfPaymentValues = [
995
- { value: "percent", label: "%" },
996
- { value: "value", label: "₽" },
997
- ];
998
- var PartialPayerValues = [
999
- { value: "owner", label: "Landlord" },
1000
- { value: "renter", label: "Tenant" },
1001
- { value: "maroom", label: "Maroom" },
1002
- { value: "partial", label: "Partial" },
1003
- ];
1004
-
1005
1140
  function FormBottom(_a) {
1006
1141
  var label = _a.label, variant = _a.variant, handleClick = _a.handleClick, withPrevStep = _a.withPrevStep, handlePrevClick = _a.handlePrevClick, withDeleteButton = _a.withDeleteButton, handleDelete = _a.handleDelete, isFixed = _a.isFixed, isLoading = _a.isLoading, endButton = _a.endButton, otherProps = __rest(_a, ["label", "variant", "handleClick", "withPrevStep", "handlePrevClick", "withDeleteButton", "handleDelete", "isFixed", "isLoading", "endButton"]);
1007
1142
  return (jsxs$1(StyledFooter, __assign({ isFixed: Boolean(isFixed) }, { children: [jsx$1(Divider, {}), jsx$1("div", __assign({ css: { padding: "0 40px" } }, { children: jsxs$1(Grid, __assign({ container: true, justify: "space-between", css: { padding: "12px 0" } }, { children: [jsxs$1(Grid, __assign({ item: true }, { children: [withPrevStep && (jsx$1(Button, __assign({ isCircle: true, "data-testid": "prev_button", onClick: handlePrevClick, size: "s", variant: "transparentWithBorder" }, { children: jsx$1(PrevArrowIcon, {}) }))), withDeleteButton && (jsx$1(Button, __assign({ "data-testid": "delete_button", size: "s", onClick: handleDelete, variant: "white" }, { children: "Delete" })))] })), jsx$1(Grid, __assign({ item: true }, { children: jsxs$1(Grid, __assign({ container: true, alignItems: "center", justify: "flex-end" }, { children: [endButton && (jsx$1(StyledEndButtonWrapper, { children: endButton })), jsx$1(Button, __assign({ "data-testid": "submit_button", size: "s", onClick: handleClick, endIcon: variant === "create" ? jsx$1(CheckIcon, {}) : jsx$1(NextArrowIcon, {}), disabled: isLoading }, otherProps, { children: isLoading ? jsx$1(StyledLoading, {}) : label }))] })) }))] })) }))] })));
@@ -1037,7 +1172,7 @@ function CompanyCreationForm(_a) {
1037
1172
  var form = useForm({
1038
1173
  resolver: yupResolver(CompanyCreationSchema),
1039
1174
  });
1040
- return (jsxs("form", { children: [jsx(Box, __assign({ pr: 5, pl: 5, pb: 3 }, { children: jsxs(Grid, __assign({ container: true, spacing: 2 }, { children: [jsx(Grid, __assign({ item: true, xs: 12 }, { children: jsx(InputWithController, { label: "Name", name: "name", form: form }) })), jsx(Grid, __assign({ item: true, xs: 12 }, { children: jsx(InputSelectWithController, { label: "Provider type", name: "type", form: form, options: CompanyTypesValues }) })), jsx(Grid, __assign({ item: true, xs: 12 }, { children: jsx(Caption, __assign({ weight: 600, size: "s" }, { children: "MAIN OFFICE" })) })), companyOfficeFields.map(function (_a) {
1175
+ return (jsxs("form", { children: [jsx(Box, __assign({ pr: 5, pl: 5, pb: 3 }, { children: jsxs(Grid, __assign({ container: true, spacing: 2 }, { children: [companyFields.map(function (field) { return (jsx(Grid, __assign({ item: true, xs: 12 }, { children: jsx(InputByType, __assign({ form: form }, field)) }), field.name)); }), jsx(Grid, __assign({ item: true, xs: 12 }, { children: jsx(Caption, __assign({ weight: 600, size: "s" }, { children: "MAIN OFFICE" })) })), companyOfficeFields.map(function (_a) {
1041
1176
  var size = _a.size, field = __rest(_a, ["size"]);
1042
1177
  return (jsx(Grid, __assign({ item: true, xs: size || 12 }, { children: jsx(InputByType, __assign({ form: form }, field)) }), field.name));
1043
1178
  })] })) })), jsx(FormBottom, { label: "Add", type: "button", handleClick: form.handleSubmit(handleSubmit) })] }));
@@ -1151,7 +1286,8 @@ var CompaniesStore = /** @class */ (function () {
1151
1286
  _this.companies = _this.paginator.getPageResponse(res, _this.companies, mapper);
1152
1287
  }
1153
1288
  else {
1154
- _this.loader.setError("fetch companies");
1289
+ _this.companies = [];
1290
+ _this.loader.setError("fetch companies", err);
1155
1291
  }
1156
1292
  _this.loader.endLoading();
1157
1293
  });
@@ -1182,10 +1318,10 @@ var CompaniesStore = /** @class */ (function () {
1182
1318
  this.paginator.startFetching();
1183
1319
  }
1184
1320
  else {
1185
- this.creationLoader.setError("company creation");
1321
+ this.creationLoader.setError("company creation", err);
1186
1322
  }
1187
1323
  this.creationLoader.endLoading();
1188
- return [2 /*return*/, this.companies[0]];
1324
+ return [2 /*return*/, res ? this.companies[0] : null];
1189
1325
  }
1190
1326
  });
1191
1327
  }); };
@@ -1200,7 +1336,7 @@ var CompaniesStore = /** @class */ (function () {
1200
1336
  case 1:
1201
1337
  _a = _b.sent(), err = _a[0], res = _a[1];
1202
1338
  if (err) {
1203
- this.creationLoader.setError("logo creation");
1339
+ this.creationLoader.setError("logo creation", err);
1204
1340
  }
1205
1341
  return [2 /*return*/, res === null || res === void 0 ? void 0 : res.logo];
1206
1342
  }
@@ -1213,26 +1349,38 @@ var CompaniesStore = /** @class */ (function () {
1213
1349
  this.filter = new SortingFilter();
1214
1350
  makeAutoObservable(this);
1215
1351
  }
1216
- CompaniesStore.getCompanyParams = function (company) { return ({
1217
- id: company.id,
1218
- name: company.name,
1219
- logo: company.logo,
1220
- }); };
1221
- CompaniesStore.getCreationBody = function (data) {
1222
- var _a;
1223
- return ({
1224
- name: data.name,
1225
- provider_type: matchesCompanyTypes[data.type],
1226
- main_office: {
1227
- address: data.office.address,
1228
- city: (_a = data.city) === null || _a === void 0 ? void 0 : _a.id,
1229
- email: data.email,
1230
- phone: "+".concat(data.phone.phoneCode).concat(data.phone.phoneNumber),
1231
- zip_code: data.zipCode,
1232
- geolocation: {
1352
+ CompaniesStore.getCompanyParams = function (company) { return (__assign({ id: company.id, logo: company.logo }, CompaniesStore.getCompanyFields(company))); };
1353
+ CompaniesStore.getCreationBody = function (data) { return ({
1354
+ name: data.name,
1355
+ provider_type: data.type
1356
+ ? matchesCompanyTypes[data.type]
1357
+ : undefined,
1358
+ tin: data.inn,
1359
+ main_office: {
1360
+ address: data.office.address,
1361
+ email: data.email,
1362
+ phone: data.phone
1363
+ ? "+".concat(data.phone.phoneCode).concat(data.phone.phoneNumber)
1364
+ : null,
1365
+ geolocation: data.office.location
1366
+ ? {
1233
1367
  lat: data.office.location.lat,
1234
1368
  lon: data.office.location.lon,
1235
- },
1369
+ }
1370
+ : undefined,
1371
+ },
1372
+ }); };
1373
+ CompaniesStore.getCompanyFields = function (company) {
1374
+ var _a, _b, _c;
1375
+ return ({
1376
+ inn: company.tin,
1377
+ name: company.name,
1378
+ phone: ((_a = company.main_office) === null || _a === void 0 ? void 0 : _a.phone)
1379
+ ? getPhoneParamsFromString(company.main_office.phone)
1380
+ : null,
1381
+ email: ((_b = company.main_office) === null || _b === void 0 ? void 0 : _b.email) || "",
1382
+ office: {
1383
+ address: ((_c = company.main_office) === null || _c === void 0 ? void 0 : _c.address) || "",
1236
1384
  },
1237
1385
  });
1238
1386
  };
@@ -1293,6 +1441,11 @@ CompanyAutocomplete.defaultProps = {
1293
1441
  };
1294
1442
  var CompanyAutocomplete$1 = observer(CompanyAutocomplete);
1295
1443
 
1444
+ var ChangeReasonSchemaParams = {
1445
+ // reason: yup.mixed().required("Choose a reason file"),
1446
+ };
1447
+ var ChangeReasonSchema = yup.object().shape(ChangeReasonSchemaParams);
1448
+
1296
1449
  function ChangeReasonFields(_a) {
1297
1450
  var form = _a.form, customReasons = _a.customReasons;
1298
1451
  return (jsxs(Grid, __assign({ container: true, spacing: 2 }, { children: [customReasons ? (customReasons.map(function (field) { return (jsx(Grid, __assign({ item: true, xs: 12 }, { children: jsx(InputFileWithVisibility, { form: form, name: field.name || "reason", label: field.label }) }))); })) : (jsx(Grid, __assign({ item: true, xs: 12 }, { children: jsx(InputFileWithVisibility, { form: form, name: "reason", label: "Reason" }) }))), jsx(Grid, __assign({ item: true, xs: 12 }, { children: jsx(InputWithController, { isTextArea: true, form: form, name: "comment", label: "Comment" }) }))] })));
@@ -1431,7 +1584,7 @@ function FillingTagsAutocomplete(_a) {
1431
1584
  }
1432
1585
  });
1433
1586
  }); };
1434
- return (jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption, { label: option.name })); }, options: filteredTags, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), isLoading: loader.isLoading, onSelectItem: onSelectItem, onSearchItem: onSearchItem, creatingLabel: "Add new tag", renderCreatingModal: function (props) { return (jsx(FillingTagCreationModal$1, __assign({ handleSubmit: onCreate }, props))); } }, otherProps)));
1587
+ return (jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption$1, { label: option.name })); }, options: filteredTags, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), isLoading: loader.isLoading, onSelectItem: onSelectItem, onSearchItem: onSearchItem, creatingLabel: "Add new tag", renderCreatingModal: function (props) { return (jsx(FillingTagCreationModal$1, __assign({ handleSubmit: onCreate }, props))); } }, otherProps)));
1435
1588
  }
1436
1589
  FillingTagsAutocomplete.defaultProps = {
1437
1590
  label: "Tag",
@@ -1476,12 +1629,21 @@ var getMeterFeaturesFieldsSchema = function (valuesFields, isReplacementRequired
1476
1629
  .number()
1477
1630
  .required("The maximum number of counters has been created in this object, select the one to replace")
1478
1631
  .transform(function (value) { return (Number.isNaN(value) ? undefined : value); }),
1479
- })), { startDate: yup.mixed().when("replaceableCounter", {
1632
+ })), { startDate: yup
1633
+ .mixed()
1634
+ .when("replaceableCounter", {
1480
1635
  is: function (value) { return value; },
1481
1636
  then: function (rule) { return rule.required("This field is required"); },
1482
- }) }));
1637
+ })
1638
+ .when("startDate", {
1639
+ is: function (value) { return value; },
1640
+ then: function (rule) {
1641
+ return rule.test("check-start-date", "Select a date in the past", function (value) { return Number(value === null || value === void 0 ? void 0 : value.diffNow("days").days) <= 0; });
1642
+ },
1643
+ })
1644
+ .nullable() }));
1483
1645
  });
1484
- return yup.object().shape(__assign(__assign({}, meterFeaturesFieldsSchema), Object.assign.apply(Object, __spreadArray([{}], valuesSchema, false))));
1646
+ return yup.object().shape(__assign(__assign({}, meterFeaturesFieldsSchema), Object.assign.apply(Object, __spreadArray([{}], valuesSchema, false))), [["startDate", "startDate"]]);
1485
1647
  };
1486
1648
 
1487
1649
  var getPartialPayerFields = function (mainPayer, refundFromRef, variant, utilityType) { return [
@@ -1746,7 +1908,7 @@ function DistrictAutocomplete(props) {
1746
1908
  }
1747
1909
  setIsMounted(true);
1748
1910
  }, [city === null || city === void 0 ? void 0 : city.id]);
1749
- return (jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption, { label: option.name })); }, isLoading: isLoading, options: districts, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, inputRef: inputRef }, otherProps)));
1911
+ return (jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption$1, { label: option.name })); }, isLoading: isLoading, options: districts, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, inputRef: inputRef }, otherProps)));
1750
1912
  }
1751
1913
  DistrictAutocomplete.defaultProps = {
1752
1914
  label: "District",
@@ -2020,7 +2182,7 @@ function TariffGroupAutocomplete(props) {
2020
2182
  useEffect(function () {
2021
2183
  filter.updateFilterQuery(filterQuery);
2022
2184
  }, [filterQuery]);
2023
- return (jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption, { label: option.name })); }, options: tariffs, isLoading: loader.isLoading, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, creatingLabel: "Add new tariff group", renderCreatingModal: function (modalProps) { return (jsx(TariffCreationModal, __assign({ creationForm: tariffsStore.creationForm, createTariff: onCreate, defaultResource: resource }, modalProps))); } }, otherProps)));
2185
+ return (jsx(InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsx(AutocompleteOption$1, { label: option.name })); }, options: tariffs, isLoading: loader.isLoading, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, creatingLabel: "Add new tariff group", renderCreatingModal: function (modalProps) { return (jsx(TariffCreationModal, __assign({ creationForm: tariffsStore.creationForm, createTariff: onCreate, defaultResource: resource }, modalProps))); } }, otherProps)));
2024
2186
  }
2025
2187
  TariffGroupAutocomplete.defaultProps = {
2026
2188
  name: "tariffGroup",
@@ -2064,7 +2226,12 @@ var getValuesFields = function (resource, variant, meterType) {
2064
2226
  var commonMeterFields = function (_a) {
2065
2227
  var withPassport = _a.withPassport, isNewResource = _a.isNewResource, withLastValue = _a.withLastValue, resource = _a.resource, tariffFilter = _a.tariffFilter, disableOperatingAccount = _a.disableOperatingAccount, handleCompanyChange = _a.handleCompanyChange, withNextCheck = _a.withNextCheck, apartmentId = _a.apartmentId;
2066
2228
  return __spreadArray(__spreadArray(__spreadArray(__spreadArray([
2067
- { label: "Activation date", name: "startDate", variant: "date" }
2229
+ {
2230
+ label: "Activation date",
2231
+ name: "startDate",
2232
+ variant: "date",
2233
+ max: DateTime.now(),
2234
+ }
2068
2235
  ], addToArrayByCondition(withPassport, {
2069
2236
  label: "Passport",
2070
2237
  name: "passportFile",
@@ -2080,6 +2247,7 @@ var commonMeterFields = function (_a) {
2080
2247
  variant: "custom",
2081
2248
  size: 12,
2082
2249
  CustomInput: PartialPayer,
2250
+ utilityType: resource,
2083
2251
  }), true), [
2084
2252
  {
2085
2253
  label: "Tariff group",
@@ -2122,7 +2290,7 @@ var getMeterFields = function (settings) {
2122
2290
  function ReplaceableCountersBlock(_a) {
2123
2291
  var form = _a.form, counters = _a.counters, setIsReplaceable = _a.setIsReplaceable;
2124
2292
  var options = counters.map(function (counter) { return ({
2125
- label: counter.passport,
2293
+ label: counter.number,
2126
2294
  value: counter.id,
2127
2295
  }); });
2128
2296
  var handleChange = function (e, value) {
@@ -2149,6 +2317,9 @@ function MeterFeaturesFields(props) {
2149
2317
  form.setValue("operationalAccountNumber", administrativeCompany === null || administrativeCompany === void 0 ? void 0 : administrativeCompany.operatingAccount);
2150
2318
  setDisableOperatingAccount(true);
2151
2319
  }
2320
+ else {
2321
+ setDisableOperatingAccount(false);
2322
+ }
2152
2323
  };
2153
2324
  var meterFields = getMeterFields({
2154
2325
  resource: resource,
@@ -2190,12 +2361,12 @@ function MeterTypeRadioGroup(props) {
2190
2361
  }
2191
2362
 
2192
2363
  function MeterFeaturesForm(props) {
2193
- var formStore = props.formStore, handleSubmit = props.handleSubmit, resource = props.resource, maxMeters = props.maxMeters, handleMeterTypeChange = props.handleMeterTypeChange, other = __rest(props, ["formStore", "handleSubmit", "resource", "maxMeters", "handleMeterTypeChange"]);
2364
+ var formStore = props.formStore, handleSubmit = props.handleSubmit, resource = props.resource, maxMeters = props.maxMeters, handleMeterTypeChange = props.handleMeterTypeChange, defaultValues = props.defaultValues, other = __rest(props, ["formStore", "handleSubmit", "resource", "maxMeters", "handleMeterTypeChange", "defaultValues"]);
2194
2365
  var _a = useState(false), isReplaceable = _a[0], setIsReplaceable = _a[1];
2195
2366
  var withMeterType = (resource === "water" && maxMeters !== 1) || resource === "electricity";
2196
2367
  var defaultType = resource === "water" ? "cold" : "T1";
2197
2368
  var defaultMeterType = withMeterType ? defaultType : null;
2198
- var _b = useState(defaultMeterType), meterType = _b[0], setMeterType = _b[1];
2369
+ var _b = useState((defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.type) || defaultMeterType), meterType = _b[0], setMeterType = _b[1];
2199
2370
  useEffect(function () {
2200
2371
  if (handleMeterTypeChange) {
2201
2372
  handleMeterTypeChange(meterType);
@@ -2210,7 +2381,7 @@ function MeterFeaturesForm(props) {
2210
2381
  handleSubmit(data);
2211
2382
  }
2212
2383
  };
2213
- return (jsx(MeterFeaturesFields, __assign({ resource: resource, handleSubmit: handleFormSubmit, meterType: meterType, maxMeters: maxMeters, withLastValue: isReplaceable, setIsReplaceable: setIsReplaceable, renderMeterType: withMeterType
2384
+ return (jsx(MeterFeaturesFields, __assign({ resource: resource, handleSubmit: handleFormSubmit, meterType: meterType, maxMeters: maxMeters, withLastValue: isReplaceable, setIsReplaceable: setIsReplaceable, defaultValues: defaultValues, renderMeterType: withMeterType
2214
2385
  ? function (form) { return (jsx(MeterTypeRadioGroup, { form: form, resource: resource, handleChange: setMeterType })); }
2215
2386
  : null }, other)));
2216
2387
  }
@@ -2298,7 +2469,7 @@ var setFileFromFileWithVisibility = function (formData, document, fileField, nam
2298
2469
  var phoneSchema = yup.object({
2299
2470
  phoneNumber: yup
2300
2471
  .string()
2301
- .matches(isValidWithMaskExp, "Enter the correct phone")
2472
+ .matches(isValidWithMaskExp$1, "Enter the correct phone")
2302
2473
  .required("Enter the phone"),
2303
2474
  });
2304
2475
  var positiveNumberSchema = yup
@@ -2316,7 +2487,7 @@ var phoneWithConditionSchema = function (condition) {
2316
2487
  return rule.shape({
2317
2488
  phoneNumber: yup
2318
2489
  .string()
2319
- .matches(isValidWithMaskExp, "Enter the correct phone")
2490
+ .matches(isValidWithMaskExp$1, "Enter the correct phone")
2320
2491
  .required("Enter the phone"),
2321
2492
  });
2322
2493
  },
@@ -2332,7 +2503,7 @@ var phoneNonRequiredSchema = function (name) {
2332
2503
  return rule.shape({
2333
2504
  phoneNumber: yup
2334
2505
  .string()
2335
- .matches(isValidWithMaskExp, "Enter the correct phone")
2506
+ .matches(isValidWithMaskExp$1, "Enter the correct phone")
2336
2507
  .required("Enter the phone"),
2337
2508
  });
2338
2509
  },
@@ -2520,5 +2691,5 @@ var uploadDocument = function (loader, file) { return __awaiter(void 0, void 0,
2520
2691
  });
2521
2692
  }); };
2522
2693
 
2523
- export { APIPayerValues, BooleanValues, CatalogsAgent, ChangeReasonFields, CitiesStore, CityAutocomplete$1 as CityAutocomplete, CompaniesAgent, CompaniesStore, CompanyAutocomplete$1 as CompanyAutocomplete, CompanyCreationForm, CompanyCreationModal$1 as CompanyCreationModal, CompanyTypesValues, CountriesStore, CountryAutocomplete$1 as CountryAutocomplete, DistrictAutocomplete$1 as DistrictAutocomplete, DistrictsStore, ElectricityValues, FileUploaderWithPreview, FillingTagCreationForm, FillingTagCreationModal$1 as FillingTagCreationModal, FillingTagsAgent, FillingTagsAutocomplete$1 as FillingTagsAutocomplete, FillingTagsStore, FillingTypeValues, FormBottom, FormWrapper, HeadingWithButton, ImpairmentsTypeValues, InputByType, InputFileWithVisibility, InputWithMap, InspectionTypeValues, kuiSettings as KUISettings, MapComponent$1 as MapComponent, MeterFeaturesFields, MeterFeaturesForm, MeterTypeRadioGroup, Modal, ModalWithMap$1 as ModalWithMap, OpenMapButton, ParkingTypesValues, PartialPayer, PartialPayerValues, PreviewImageCard, RegionAutocomplete$1 as RegionAutocomplete, RegionsStore, RenovationStyleValues, RenovationTypeValues, ReplaceableCountersBlock$1 as ReplaceableCountersBlock, ResourceValues, RoomTypeValues, RoomTypesValues, index as SignInPage, SquarePreviewImage, TVTypesValues, TariffCreationForm$1 as TariffCreationForm, TariffCreationModal, TariffGroupAutocomplete$1 as TariffGroupAutocomplete, TariffReplacementField, TariffReplacementFields, TariffsAgent, TariffsLiteStore, TaxResidenceValues, TaxTypeValues, TwoOptionForAutocomplete, UnitOfPaymentValues, UploadAgent, WaterValues, authFlag, csrfTokenKey, defaultRequiredMessage, genderMatches, getFillingInfoFields, getNumbersValues, matchesAPICompanyTypes, matchesAPIFillingTypes, matchesAPISubjectRoles, matchesAPIVisibilityVariants, matchesApartmentStatuses, matchesCompanyTypes, matchesFillingTypes, matchesServiceTypes, matchesSubjectRoles, matchesVisibilityVariants, phoneNonRequiredSchema, phoneSchema, phoneWithConditionSchema, positiveNumberSchema, requests, sessionIdKey, setFileFromFileWithVisibility, uploadDocument, uploadDocuments, uploadFile, uploadFiles, uploadImages, uploadNewFile };
2694
+ export { APIPayerValues, BooleanValues, CatalogsAgent, ChangeReasonFields, ChangeReasonSchema, CitiesStore, CityAutocomplete$1 as CityAutocomplete, CommonTariffFieldsSchema, CompaniesAgent, CompaniesStore, CompanyAutocomplete$1 as CompanyAutocomplete, CompanyCreationForm, CompanyCreationModal$1 as CompanyCreationModal, CompanyInnAutocomplete$1 as CompanyInnAutocomplete, CompanyTypesValues, CountriesStore, CountryAutocomplete$1 as CountryAutocomplete, DistrictAutocomplete$1 as DistrictAutocomplete, DistrictsStore, ElectricityValues, ErrorPopup, FileUploaderWithPreview, FillingTagCreationForm, FillingTagCreationModal$1 as FillingTagCreationModal, FillingTagsAgent, FillingTagsAutocomplete$1 as FillingTagsAutocomplete, FillingTagsStore, FillingTypeValues, FormBottom, FormWrapper, HeadingWithButton, ImpairmentsTypeValues, InputByType, InputFileWithVisibility, InputWithMap, InspectionTypeValues, kuiSettings as KUISettings, LoaderPopup, LoaderState$1 as LoaderState, MapComponent$1 as MapComponent, MeterFeaturesFields, MeterFeaturesForm, MeterTypeRadioGroup, Modal, ModalWithMap$1 as ModalWithMap, OpenMapButton, ParkingTypesValues, PartialPayer, PartialPayerValues, PreviewImageCard, RegionAutocomplete$1 as RegionAutocomplete, RegionsStore, RenovationStyleValues, RenovationTypeValues, ReplaceableCountersBlock$1 as ReplaceableCountersBlock, ResourceValues, RoomTypeValues, RoomTypesValues, index as SignInPage, SquarePreviewImage, TVTypesValues, TariffCreationForm$1 as TariffCreationForm, TariffCreationModal, TariffGroupAutocomplete$1 as TariffGroupAutocomplete, TariffReplacementField, TariffReplacementFields, TariffsAgent, TariffsLiteStore, TaxResidenceValues, TaxTypeValues, TwoOptionForAutocomplete, UnitOfPaymentValues, UploadAgent, WaterValues, authFlag, csrfTokenKey, defaultRequiredMessage, genderMatches, getFillingInfoFields, getMeterFeaturesFieldsSchema, getMeterFields, getNumbersValues, getPartialPayerFields, matchesAPICompanyTypes, matchesAPIFillingTypes, matchesAPISubjectRoles, matchesAPIVisibilityVariants, matchesApartmentStatuses, matchesCompanyTypes, matchesFillingTypes, matchesServiceTypes, matchesSubjectRoles, matchesVisibilityVariants, phoneNonRequiredSchema, phoneSchema, phoneWithConditionSchema, positiveNumberSchema, requests, sessionIdKey, setFileFromFileWithVisibility, uploadDocument, uploadDocuments, uploadFile, uploadFiles, uploadImages, uploadNewFile };
2524
2695
  //# sourceMappingURL=index.js.map