2022-08-08 07:05:49 +03:00

76 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from "react";
import { connect } from "react-redux";
class Company extends React.Component
{
constructor(props)
{
super(props);
this.state = {
company: {},
opened: false,
}
}
static getDerivedStateFromProps(nextProps, prevState)
{
return {
company: nextProps.company,
};
}
_handleOnClick = () =>
{
const { opened } = this.state;
//this.setState({ opened: !opened ? true : false })
}
render()
{
const { company, opened } = this.state;
console.log(this.props);
return (
<div className="right company-dropdown" onClick={ this._handleOnClick }>
<p align="right">{/* className="arrow" */}
<b>{ company.title }</b><br/>
{company.inn != null && <span>ИНН: { company.inn } </span>}
{company.kpp != null && <span>КПП: { company.kpp }</span>}
</p>
<div className={`companies_list ${ opened && "opened" }`}> {/* opened */}
<div className="company_item">
<p align="right">
<b>ООО ЮКС</b><br/>
ИНН: <span>12345678765</span> КПП: <span>13432-02</span>
</p>
</div>
<div className="company_item">
<p align="right">
<b>ООО Еще одно название</b><br/>
ИНН: <span>12345678765</span> КПП: <span>13432-02</span>
</p>
</div>
<div className="company_item selected">
<p align="right">
<b>ООО Друзья и КО</b><br/>
ИНН: <span>12345678765</span> КПП: <span>13432-02</span>
</p>
</div>
</div>
</div>
)
}
}
function mapStateToProps(state, ownProps)
{
return {
company: state.company,
}
}
export default connect(mapStateToProps)(Company);