105 lines
3.1 KiB
JavaScript
105 lines
3.1 KiB
JavaScript
import React from "react";
|
|
import { connect } from "react-redux";
|
|
import moment from "moment";
|
|
//import { getDeals, getDealOffers, getDealDocuments, getDealContracts } from "../../actions";
|
|
|
|
class EDOSign extends React.Component
|
|
{
|
|
constructor(props)
|
|
{
|
|
super(props)
|
|
this.state = {
|
|
list: null,
|
|
loading: false,
|
|
selected: {},
|
|
}
|
|
}
|
|
|
|
static getDerivedStateFromProps(nextProps, prevState)
|
|
{
|
|
console.log("EDOSign", "getDerivedStateFromProps", { nextProps });
|
|
return {
|
|
list: nextProps.list,
|
|
}
|
|
}
|
|
|
|
componentDidMount()
|
|
{
|
|
if(this.state.selected.box_id === undefined)
|
|
{
|
|
this.setState({ selected: this.state.list !== null && this.state.list[0] !== undefined ? this.state.list[0] : {} });
|
|
}
|
|
}
|
|
|
|
_handle_onFormSubmit = () =>
|
|
{
|
|
|
|
}
|
|
|
|
_handle_onSelectOperator = (operator) =>
|
|
{
|
|
this.setState({ selected: operator });
|
|
}
|
|
|
|
render()
|
|
{
|
|
const { list, loading, selected } = this.state;
|
|
const { onCancel, document } = this.props;
|
|
console.log({ list });
|
|
|
|
return (
|
|
<>
|
|
<div className="docs_list medium-icon">
|
|
<p className="list_title">Подписание через ЭДО</p>
|
|
</div>
|
|
<div className="docs_list medium-icon">
|
|
<p className="doc_name i-pdf extension edo_sign_document" data-format={ document.extension }>
|
|
{ document.name }
|
|
<span style={{ width: "100%" }}>
|
|
{ document.number } от{" "} { moment(document.date).format("DD.MM.YYYY") }
|
|
</span>
|
|
{ document.type !== undefined && (<span>{ document.type }</span>) }
|
|
</p>
|
|
</div>
|
|
<form ref={ this.ref_form } onSubmit={ this._handle_onFormSubmit } onKeyDown={(e) => {if (e.key === 'Enter') e.preventDefault() }}>
|
|
<div className="form_field edo_list_field">
|
|
<label>Выберите оператора для отправки пакета документов</label>
|
|
<div className="edo_list_selection">
|
|
{ list !== undefined && list !== null && list.map((operator, index) => (
|
|
<div className="form_field checkbox item" key={ index }>
|
|
<input type="radio"
|
|
checked={ operator.box_id === selected.box_id }
|
|
hidden=""
|
|
id={ `operator_${ index }` }
|
|
name={ `operator_${ index }` }
|
|
onChange={ (event) => this._handle_onSelectOperator(operator) }
|
|
disabled={ false }
|
|
/>
|
|
<label htmlFor={ `operator_${ index }` } className="unselectable">{ operator.box_name }</label>
|
|
</div>
|
|
)) }
|
|
</div>
|
|
</div>
|
|
<div className="form_field" style={{ display: "flex", justifyContent: "space-between" }}>
|
|
<button className="button button-blue" onClick={ onCancel }>Отменить</button>
|
|
<button type="submit" className="button button-blue">
|
|
{ loading ? (
|
|
<SpinnerCircular size={24} thickness={100} speed={100} color="rgba(255, 255, 255, 1)" secondaryColor="rgba(255, 255, 255, 0.5)" style={{ marginTop: "4px" }}/>
|
|
) : "Продолжить" }
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</>
|
|
)
|
|
}
|
|
}
|
|
|
|
function mapStateToProps(state, ownProps)
|
|
{
|
|
console.log("EDOSign", "mapStateToProps", { state: state });
|
|
return {
|
|
list: state.edo.list,
|
|
}
|
|
}
|
|
|
|
export default connect(mapStateToProps)(EDOSign) |