diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/sub-components/consumerItem.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/sub-components/consumerItem.js index fd57803c96..55015125a2 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/sub-components/consumerItem.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/integration/sub-components/consumerItem.js @@ -1,4 +1,5 @@ import React from "react"; +import PropTypes from "prop-types"; import { Box, Text } from "asc-web-components"; import ConsumerToggle from "./consumerToggle"; @@ -29,7 +30,6 @@ class ConsumerItem extends React.Component { { - const { consumers, selectedConsumer } = this.props; - consumers - .find((consumer) => consumer.name === selectedConsumer) - .props.map((p) => - this.setState({ - [`${p.name}`]: p.value, - }) - ); - }; - - onChangeHandler = (e) => { - this.setState({ - [e.target.name]: e.target.value, - }); - }; - - updateConsumerValues = () => { - this.props.onChangeLoading(true); - - const prop = []; - - let i = 0; - let stateLength = Object.keys(this.state).length; - for (i = 0; i < stateLength; i++) { - prop.push({ - name: Object.keys(this.state)[i], - value: Object.values(this.state)[i], - }); + constructor(props) { + super(props); + this.state = {}; } - const data = { - name: this.props.selectedConsumer, - props: prop, + + mapTokenNameToState = () => { + const { consumers, selectedConsumer } = this.props; + consumers + .find((consumer) => consumer.name === selectedConsumer) + .props.map((p) => + this.setState({ + [`${p.name}`]: p.value, + }) + ); }; - this.props - .sendConsumerNewProps(data) - .then(() => { - this.props.onChangeLoading(false); - toastr.success("Consumer properties successfully update"); - }) - .catch((error) => { - this.props.onChangeLoading(false); - toastr.error(error); - }) - .finally(this.props.onModalClose()); - }; - componentDidMount() { - this.mapTokenNameToState(); - } - - render() { - const { - consumers, - selectedConsumer, - onModalClose, - dialogVisible, - isLoading, - t, - i18n, - } = this.props; - const { onChangeHandler } = this; - - const bodyDescription = ( - - - - {t("ThirdPartyHowItWorks")} - - - {t("ThirdPartyBodyDescription")} - - ); - - const bottomDescription = ( - - If you still have some questions on how to connect this service or need - technical assistance, please feel free to contact our{" "} - - Support Team - - - ); - - const getConsumerName = () => { - return consumers.find((consumer) => consumer.name === selectedConsumer) - .name; + onChangeHandler = (e) => { + this.setState({ + [e.target.name]: e.target.value, + }); }; - const getInnerDescription = () => { - return consumers.find((consumer) => consumer.name === selectedConsumer) - .instruction; + + updateConsumerValues = () => { + this.props.onChangeLoading(true); + + const prop = []; + + let i = 0; + let stateLength = Object.keys(this.state).length; + for (i = 0; i < stateLength; i++) { + prop.push({ + name: Object.keys(this.state)[i], + value: Object.values(this.state)[i], + }); + } + const data = { + name: this.props.selectedConsumer, + props: prop, + }; + this.props + .sendConsumerNewProps(data) + .then(() => { + this.props.onChangeLoading(false); + toastr.success("Consumer properties successfully update"); + }) + .catch((error) => { + this.props.onChangeLoading(false); + toastr.error(error); + }) + .finally(this.props.onModalClose()); }; - const getInputFields = () => { - return consumers - .find((consumer) => consumer.name === selectedConsumer) - .props.map((prop, i) => ( - - - - {prop.title}: - - - - + + componentDidMount() { + this.mapTokenNameToState(); + } + + render() { + const { + consumers, + selectedConsumer, + onModalClose, + dialogVisible, + isLoading, + t, + i18n, + } = this.props; + const { onChangeHandler } = this; + + const bodyDescription = ( + + + + {t("ThirdPartyHowItWorks")} + + + {t("ThirdPartyBodyDescription")} - - )); - }; + ); - return ( - - {getInnerDescription()}, - {bodyDescription}, - {getInputFields()}, - {bottomDescription}, - ]} - footerContent={[ -