166 lines
5.1 KiB
JavaScript
166 lines
5.1 KiB
JavaScript
import React from "react";
|
|
import Head from 'next/head';
|
|
import Image from 'next/image';
|
|
import Link from "next/link";
|
|
import cookie from 'cookie';
|
|
import numeral from "numeral";
|
|
import pluralize from 'pluralize-ru';
|
|
import Select from 'react-select'
|
|
import { SpinnerCircular } from 'spinners-react';
|
|
import { connect } from "react-redux";
|
|
import { withRouter } from 'next/router';
|
|
|
|
import QuestionnaireForm from "../QuestionnaireForm";
|
|
import AddressSuggestsSelect from "../AddressSuggestsSelect";
|
|
import { reduxWrapper } from '../../../../store';
|
|
|
|
class Form_2_Contacts extends QuestionnaireForm
|
|
{
|
|
constructor(props)
|
|
{
|
|
super(props);
|
|
this.state = {
|
|
contacts: {
|
|
address_type: "legal",
|
|
loading: false,
|
|
|
|
fact_address: {
|
|
name: "",
|
|
fias_id: "",
|
|
},
|
|
legal_address: {
|
|
title: "",
|
|
fias_id: "",
|
|
},
|
|
postal_address: {
|
|
name: "",
|
|
fias_id: "",
|
|
},
|
|
}
|
|
};
|
|
}
|
|
|
|
static getDerivedStateFromProps(nextProps, prevState)
|
|
{
|
|
return {
|
|
contacts: nextProps.questionnaire.contacts,
|
|
};
|
|
}
|
|
|
|
componentDidMount()
|
|
{
|
|
}
|
|
|
|
_handle_onFormSubmit = (event) =>
|
|
{
|
|
event.preventDefault();
|
|
console.log("Form_2_Contacts", "_handle_onFormSubmit");
|
|
}
|
|
|
|
_check_fields_disabled = (values) =>
|
|
{
|
|
for(let i in values)
|
|
{
|
|
if(values[i] === "")
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
render()
|
|
{
|
|
const { contacts, loading } = this.state;
|
|
const { address_type, legal_address, fact_address, postal_address, } = contacts;
|
|
|
|
return (
|
|
<React.Fragment>
|
|
<form onSubmit={ this._handle_onFormSubmit } className="questionnaire questionnaire_2">
|
|
<p className="title">2. Адреса лизингополучателя</p>
|
|
|
|
<div className="form_field">
|
|
<label>Фактический адрес</label>
|
|
<AddressSuggestsSelect
|
|
value={ fact_address.title }
|
|
fias={ fact_address.fias_id }
|
|
onChange={ (data) => this._handle_onTextFieldChange("contacts.fact_address", data) }
|
|
/>
|
|
<p>для юр.диц - заполняется, если отличается от указанного в ЕГРЮЛ; для ИП - заполняется всегда</p>
|
|
</div>
|
|
|
|
<p>Прошу оригиналы счетов-фактур и актов отказанных услуг по заключенному договору лизинга направлять:</p>
|
|
|
|
<div className="form_field">
|
|
<div style={{ width: "100%" }}>
|
|
<div className="form_field checkbox">
|
|
<input type="radio" hidden=""
|
|
value="legal"
|
|
id="contacts.address_type_legal"
|
|
name="contacts.address_type"
|
|
checked={ address_type === "legal" ? true : false }
|
|
onChange={ (event) => this._handle_onCheckboxFieldChange(event.target.name, event.target.value) }
|
|
/>
|
|
<label htmlFor="contacts.address_type_legal" className="unselectable">По юридическому адресу, указанному в ЕГРЮЛ (для юрлиц)</label>
|
|
</div>
|
|
|
|
<div className="form_field checkbox">
|
|
<input type="radio" hidden=""
|
|
value="fact"
|
|
id="contacts.address_type_fact"
|
|
name="contacts.address_type"
|
|
checked={ address_type === "fact" ? true : false }
|
|
onChange={ (event) => this._handle_onCheckboxFieldChange(event.target.name, event.target.value) }
|
|
/>
|
|
<label htmlFor="contacts.address_type_fact" className="unselectable">По фактическому адресу, указанному в настоящей анкете</label>
|
|
</div>
|
|
|
|
<div className="form_field checkbox">
|
|
<input type="radio" hidden=""
|
|
value="postal"
|
|
id="contacts.address_type_postal"
|
|
name="contacts.address_type"
|
|
checked={ address_type === "postal" ? true : false }
|
|
onChange={ (event) => this._handle_onCheckboxFieldChange(event.target.name, event.target.value) }
|
|
/>
|
|
<label htmlFor="contacts.address_type_postal" className="unselectable" style={{ width: "100%" }}>
|
|
<span>По следующему адресу</span>
|
|
<AddressSuggestsSelect
|
|
value={ postal_address.title }
|
|
fias={ postal_address.fias_id }
|
|
onChange={ (data) => this._handle_onTextFieldChange("contacts.postal_address", data) }
|
|
disabled={ address_type === "postal" ? false : true }
|
|
/>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="action">
|
|
<button type="submit" className="button button-blue" disabled={ false }>
|
|
{ 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>
|
|
</React.Fragment>
|
|
)
|
|
}
|
|
}
|
|
|
|
function mapStateToProps(state, ownProps)
|
|
{
|
|
return {
|
|
questionnaire: state.questionnaire,
|
|
}
|
|
}
|
|
|
|
export const getServerSideProps = reduxWrapper.getServerSideProps(store =>
|
|
async ({ req, res, query }) =>
|
|
{
|
|
}
|
|
);
|
|
|
|
export default connect(mapStateToProps)(Form_2_Contacts); |