account switch update

This commit is contained in:
merelendor 2022-08-15 23:50:12 +03:00
parent 3b6c7de531
commit 77b7b96ab0
34 changed files with 515 additions and 336 deletions

View File

@ -92,8 +92,7 @@ export const sendLoginFormPhone = ({ phone }) =>
})
.catch((error) =>
{
console.log("DATA !!! ");
console.log("error");
console.error("sendLoginFormPhone", "error");
console.error(error);
reject();
@ -137,8 +136,7 @@ export const sendSmsCode = ({ dispatch, phone, code }) =>
})
.catch((error) =>
{
console.log("DATA !!! ");
console.log("error");
console.error("sendSmsCode", "error");
console.error(error);
reject();
@ -186,7 +184,9 @@ export const sendOffstageToken = ({ token, dispatch }) =>
{
dispatch({ type: actionTypes.AUTH, data: { logged: true, observer: true } });
dispatch({ type: actionTypes.USER, data: response.data.user });
dispatch({ type: actionTypes.COMPANIES, data: { list: response.data.companies } });
resolve();
Router.push('/');
})
@ -203,7 +203,50 @@ export const sendOffstageToken = ({ token, dispatch }) =>
})
.catch((error) =>
{
console.log("error");
console.error("sendOffstageToken", "error");
console.error(error);
reject();
});
});
}
export const sendSwitchAccount = ({ dispatch, acc_number }) =>
{
console.log("ACTION", "sendSwitchAccount()", `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/auth/switch/`);
return new Promise((resolve, reject) =>
{
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/auth/switch/`, { acc_number })
.then((response) =>
{
console.log("sendSwitchAccount RESPONSE");
console.log(response.data);
if(response.data.status === "success")
{
const cookies = new Cookies();
cookies.set('jwt', response.data.token, new Date(moment().add(7, 'day').toDate()));
getCompanyInfo({ dispatch })
.then(() =>
{
resolve();
Router.push('/');
})
.catch(() =>
{
reject();
});
}
else
{
reject();
}
})
.catch((error) =>
{
console.error("sendSwitchAccount", "error");
console.error(error);
reject();

View File

@ -1,6 +1,7 @@
export const AUTH = 'AUTH';
export const USER = 'USER';
export const COMPANY = 'COMPANY';
export const COMPANIES = 'COMPANIES';
export const CONTRACTS = 'CONTRACTS';
export const CONTRACT = 'CONTRACT';
export const CONTRACT_PAYMENTS = 'CONTRACT_PAYMENTS';

View File

@ -5,53 +5,56 @@ import Header from "./components/Header";
import Footer from "./components/Footer";
import Company from "./components/Company";
class Offline extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
class Offline extends React.Component
{
constructor(props)
{
super(props);
this.state = {};
}
static getDerivedStateFromProps(nextProps, prevState) {
return {};
}
static getDerivedStateFromProps(nextProps, prevState)
{
return {};
}
componentDidMount() {}
componentDidMount() {}
render() {
return (
<React.Fragment>
<Head>
<title>ЛК Эволюция автолизинга</title>
<meta name="description" content="ЛК Эволюция автолизинга" />
</Head>
<Header {...this.props} />
<main>
<section>
<div className="clear"></div>
<div className="container">
<div className="title_wrapper">
<div className="left">
<h1 className="section_title">Личный кабинет</h1>
</div>
<div className="right">
<Company />
</div>
</div>
<div className="offline">
<p>
В настоящий момент ведутся технические работы. Если Вам
необходимо получить информацию, пожалуйста, свяжитесь с нами
по телефону: 8 800 111 22 33
</p>
</div>
</div>
</section>
</main>
<Footer />
</React.Fragment>
);
}
render()
{
return (
<React.Fragment>
<Head>
<title>ЛК Эволюция автолизинга</title>
<meta name="description" content="ЛК Эволюция автолизинга" />
</Head>
<Header {...this.props} />
<main>
<section>
<div className="clear"></div>
<div className="container">
<div className="title_wrapper">
<div className="left">
<h1 className="section_title">Личный кабинет</h1>
</div>
<div className="right">
<Company { ...this.props }/>
</div>
</div>
<div className="offline">
<p>
В настоящий момент ведутся технические работы. Если Вам
необходимо получить информацию, пожалуйста, свяжитесь с нами
по телефону: 8 800 111 22 33
</p>
</div>
</div>
</section>
</main>
<Footer />
</React.Fragment>
);
}
}
export default Offline;

View File

@ -25,8 +25,6 @@ export default async function handler(req, res)
console.log(api_response.data);
res.status(200).send(api_response.data);
//resolve(api_response.data);
})
.catch((error) =>
{
@ -34,7 +32,6 @@ export default async function handler(req, res)
console.error(error);
res.status(403).json();
//reject();
});
}
else

View File

@ -31,7 +31,7 @@ export default async function handler(req, res)
console.log(existed_data_json);
console.log("*".repeat(50));
token = jwt.sign({ "acc_number": existed_data_json.acc_number, }, process.env.JWT_SECRET_CLIENT, { noTimestamp: true });
token = jwt.sign({ "acc_number": existed_data_json.acc_number, login: existed_data_json.user.email, companies: existed_data_json.companies, }, process.env.JWT_SECRET_CLIENT, { noTimestamp: true });
res.status(200).json({ ...existed_data_json, ...{ status: "success", token: token, } });
}

74
pages/api/auth/switch.js Normal file
View File

@ -0,0 +1,74 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import axios from 'axios';
import { Cookies } from 'react-cookie';
import cookie from 'cookie';
import moment from 'moment';
import jwt from 'jsonwebtoken';
import { cors } from '../../../lib/cors';
export default async function handler(req, res)
{
await cors(req, res);
let { acc_number } = req.body;
console.log("API", "auth/switch");
if(req.headers.cookie !== undefined)
{
const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : "");
if(cookies.jwt !== undefined && cookies.jwt !== null)
{
let allow = false;
let company = {};
let client_jwt_decoded = jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT);
console.log("API", "auth/switch", "client_jwt_decoded", client_jwt_decoded);
const { companies } = client_jwt_decoded;
if(companies !== undefined && companies !== null)
{
for(let i in companies)
{
if(companies[i].acc_number === acc_number)
{
company = companies[i];
allow = true;
break;
}
}
if(allow)
{
const new_client_jwt = jwt.sign({
acc_number: acc_number,
login: client_jwt_decoded.login,
companies: client_jwt_decoded.companies,
}, process.env.JWT_SECRET_CLIENT, { noTimestamp: true });
res.status(200).send({
status: "success",
token: new_client_jwt,
});
}
else
{
res.status(403).json();
}
}
else
{
res.status(403).json();
}
}
else
{
res.status(403).json();
}
}
else
{
res.status(403).json();
}
}

View File

@ -29,7 +29,7 @@ export default async function handler(req, res)
})
.then((crm_response) =>
{
res.status(200).json(crm_response.data);
res.status(200).json({ ...crm_response.data, ...{ active: client_jwt_decoded.acc_number } });
})
.catch((error) =>
{

View File

@ -1,5 +1,6 @@
import React from "react";
import { connect } from "react-redux";
import { sendSwitchAccount } from "../../../actions";
class Company extends React.Component
{
@ -9,57 +10,52 @@ class Company extends React.Component
this.state = {
company: {},
opened: false,
companies: null,
}
}
static getDerivedStateFromProps(nextProps, prevState)
{
return {
company: nextProps.company,
company: nextProps.company,
companies: nextProps.companies,
};
}
_handleOnClick = () =>
{
const { opened } = this.state;
//this.setState({ opened: !opened ? true : false })
const { companies, opened } = this.state;
if(companies !== null && companies.length > 1)
{
this.setState({ opened: !opened ? true : false })
}
}
_handle_onSelectCompany = (acc_number) =>
{
this.props.router.push(`/switch/?account=${ acc_number }`);
}
render()
{
const { company, opened } = this.state;
console.log(this.props);
const { company, companies, opened } = this.state;
return (
<div className="right company-dropdown" onClick={ this._handleOnClick }>
<p align="right">{/* className="arrow" */}
<p align="right" className={ companies !== null && companies.length > 1 && "arrow" }>{/* 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>
{ companies !== null && companies.map((entry, index) => (
<div key={ index } className={ `company_item ${ company.active === entry.acc_number && "selected" }` } onClick={ () => this._handle_onSelectCompany(entry.acc_number) }>
<p align="right">
<b>{ entry.title }</b><br/>
ИНН: <span>{ entry.inn }</span> { entry.kpp !== '' && (<>КПП: <span>{ entry.kpp }</span></>) }
</p>
</div>
)) }
</div>
</div>
)
@ -70,6 +66,7 @@ function mapStateToProps(state, ownProps)
{
return {
company: state.company,
companies: state.companies.list,
}
}

View File

@ -87,8 +87,8 @@ class ChangeGraphicPage extends React.Component
render()
{
const { loading, date, car, contract_date, agreement, rules } = this.state;
const { number } = this.props;
const { loading, date, car, contract_date, agreement, rules } = this.state;
console.log("rules", rules);
@ -123,7 +123,7 @@ class ChangeGraphicPage extends React.Component
: ""}
</h5>
</div>
<Company />
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu number={number} {...this.props} />

View File

@ -84,8 +84,8 @@ class ContractPage extends React.Component
render()
{
const { loading, date, car, contract_date, agreement, rules } = this.state;
const { number } = this.props;
const { loading, date, car, contract_date, agreement, rules } = this.state;
console.log("rules", rules);
@ -127,7 +127,7 @@ class ContractPage extends React.Component
: "" }
</h5>
</div>
<Company />
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu number={number} {...this.props} />

View File

@ -288,7 +288,7 @@ class ChangeGraphicPage extends React.Component
{ car !== undefined && car !== null ? ` - ${car.brand.name} ${car.model.name} | ${ car.reg_number !== null ? car.reg_number : "без рег. номера" } | ${ car.vin_number !== null ? car.vin_number : "без VIN номера" }` : "" }
</h5>
</div>
<Company />
<Company { ...this.props }/>
</div>
{ loading ? (
<div className="aside_container about">

View File

@ -83,9 +83,10 @@ class ChangeGraphicComparePage extends React.Component
}
}
render() {
const { loading, date, car, contract_date, agreement, rules } = this.state;
render()
{
const { number } = this.props;
const { loading, date, car, contract_date, agreement, rules } = this.state;
console.log("rules", rules);
@ -108,7 +109,7 @@ class ChangeGraphicComparePage extends React.Component
{ car !== undefined && car !== null ? ` - ${car.brand.name} ${car.model.name} | ${ car.reg_number !== null ? car.reg_number : "без рег. номера" } | ${ car.vin_number !== null ? car.vin_number : "без VIN номера" }` : "" }
</h5>
</div>
<Company />
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<article className="compare">

View File

@ -390,6 +390,7 @@ class ContractDocumentsPage extends React.Component
render()
{
const { number } = this.props;
const {
loading,
date,
@ -407,7 +408,6 @@ class ContractDocumentsPage extends React.Component
penalties_date,
penalties_result,
} = this.state;
const { number } = this.props;
console.log("documentsdocumentsdocumentsdocumentsdocuments");
console.log(documents);
@ -514,7 +514,7 @@ class ContractDocumentsPage extends React.Component
: "" }
</h5>
</div>
<Company />
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu number={ number } { ...this.props }/>

View File

@ -63,8 +63,8 @@ class ContractPage extends React.Component
render()
{
const { loading, date, car, contract_date, events_loaded, filtered, } = this.state;
const { number } = this.props;
const { loading, date, car, contract_date, events_loaded, filtered, } = this.state;
//console.log("rules", rules);
@ -84,7 +84,7 @@ class ContractPage extends React.Component
<h1 className="section_title">Договор { number }</h1>
<h5 style={{ fontSize: "14px" }}>{ date !== undefined && date !== null && date !== null && (<> от { moment(date).format("DD.MM.YYYY") }</>)}{ car !== undefined && car !== null ? ` - ${ car.brand.name } ${ car.model.name } | ${ car.reg_number !== null ? car.reg_number : "без рег. номера" } | ${ car.vin_number !== null ? car.vin_number : "без VIN номера" }` : "" }</h5>
</div>
<Company />
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu number={ number } { ...this.props } />

View File

@ -260,9 +260,9 @@ class ContractDocumentsPage extends React.Component
return (
<div className="row" key={index}>
<p
className="doc_name i-pdf i-medium"
data-format={doc.extension}
<p
className="doc_name i-pdf i-medium"
data-format={ doc.extension }
>
{doc.num} от {moment(doc.date).format("DD.MM.YYYY")}
</p>
@ -477,6 +477,7 @@ class ContractDocumentsPage extends React.Component
render()
{
const { number } = this.props;
const {
loading,
date,
@ -491,7 +492,6 @@ class ContractDocumentsPage extends React.Component
reconciliation_disabled,
opened,
} = this.state;
const { number } = this.props;
console.log("documentsdocumentsdocumentsdocumentsdocuments");
console.log(documents);
@ -505,7 +505,7 @@ class ContractDocumentsPage extends React.Component
<title>ЛК Эволюция автолизинга</title>
<meta name="description" content="ЛК Эволюция автолизинга" />
</Head>
<Header {...this.props} />
<Header { ...this.props } />
<main>
<section>
<div className="clear"></div>
@ -530,10 +530,10 @@ class ContractDocumentsPage extends React.Component
: "" }
</h5>
</div>
<Company />
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu number={number} {...this.props} />
<InnerMenu number={ number } { ...this.props }/>
<article>
{ loading ? (
<div
@ -555,84 +555,12 @@ class ContractDocumentsPage extends React.Component
</div>
) : (
<>
<div className="reconciliation_form">
<p>Акт сверки</p>
<div className="form_group">
<div className="form_field">
<DateInput
placeholder="Дата начала периода"
value={period_date_start}
min={valid_date_start}
max={valid_date_end}
onChange={this._handle_onPeriodDate_start}
/>
</div>
<div className="form_field">
<DateInput
placeholder="Дата окончания периода"
value={period_date_end}
min={valid_date_start}
max={valid_date_end}
onChange={this._handle_onPeriodDate_end}
/>
</div>
</div>
<div className="form_group">
<button
className="button button-blue"
disabled={reconciliation_disabled}
onClick={() => {
this._handle_onReconciliationFileRequest();
}}
>
<>
{reconciliation_requested ? (
<SpinnerCircular size={ 24 } thickness={ 100 } speed={ 100 } color="rgba(255, 255, 255, 1)" secondaryColor="rgba(255, 255, 255, 0.5)"/>
) : (
"Скачать"
)}
</>
</button>
{/*<button className="button button-blue">Отправить в ЭДО</button>*/}
</div>
</div>
<div className="dropdown_blocks_list">
{documents !== undefined && documents !== null ? (
<>
{this._renderDocuments(documents.upd, "upd")}
{this._renderDocuments(
documents.upd_avans,
"upd_avans"
)}
{this._renderDocuments(
documents.billfines,
"billfines"
)}
{this._renderFines(documents.fines, "fines")}
</>
) : null}
<div className="block-column">
<div className="dropdown_block ">
<div className="block_header">
<p>Счета-уведомления на пени</p>
</div>
</div>
<div className="block_with_form">
<p>Введите планируемую дату оплаты просроченной задолженности для расчёта пеней</p>
<form className="paymentDateForm">
<div className="form_field">
<DateInput
placeholder="Планируемая дата"
value={period_date_start}
min={valid_date_start}
max={valid_date_end}
onChange={this._handle_onPeriodDate_start}
/>
</div>
<button className="button button-blue">Применить</button>
</form>
</div>
</div>
</div>
</>
) }

View File

@ -100,156 +100,158 @@ class ContractServicesPage extends React.Component {
this.setState({ opened: opened });
};
render() {
const {
opened,
loading,
date,
car,
contract_date,
helpcard,
insurance,
registration,
telematic,
} = this.state;
const { number } = this.props;
render()
{
const { number } = this.props;
const {
opened,
loading,
date,
car,
contract_date,
helpcard,
insurance,
registration,
telematic,
} = this.state;
return (
<React.Fragment>
<Head>
<title>ЛК Эволюция автолизинга</title>
<meta name="description" content="ЛК Эволюция автолизинга" />
</Head>
<Header {...this.props} />
<main>
<section>
<div className="clear"></div>
<div className="container">
<div className="title_wrapper">
<div className="left" style={{ flexDirection: "column" }}>
<h1 className="section_title">Договор {number}</h1>
<h5 style={{ fontSize: "14px" }}>
{date !== undefined && date !== null && date !== null && (
<> от {moment(date).format("DD.MM.YYYY")}</>
)}
{car !== undefined && car !== null
? ` - ${car.brand.name} ${car.model.name} | ${
car.reg_number !== null
? car.reg_number
: "без рег. номера"
} | ${
car.vin_number !== null
? car.vin_number
: "без VIN номера"
}`
: ""}
</h5>
</div>
<Company />
</div>
<div className="aside_container about">
<InnerMenu number={number} {...this.props} />
<article>
{loading ? (
<div
className="table_row table_header"
style={{
minHeight: 300,
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
>
<SpinnerCircular
size={90}
thickness={51}
speed={100}
color="rgba(28, 1, 169, 1)"
secondaryColor="rgba(236, 239, 244, 1)"
/>
</div>
) : (
<div className="dropdown_blocks_list zero-margin gibdd">
<div className={`dropdown_block open`}>
<div className="block_body full">
<div className="company">
<p className="title lower">Штрафы ГИБДД</p>
<ul>
<li>
Номер постановления: <b>3432434242334</b>
</li>
<li>
Страховая: <b>3 400 000,00 </b>
</li>
<li>
Статус: <b>Оплачен</b>
</li>
<li>
Дата: <b>01/01/2020 </b>
</li>
<li>
Штраф:{" "}
<b>п. 1.15 - Несоблюдение правил парковки </b>
</li>
<li>
<div className="dosc_list medium-icon">
<div className="row">
<p className="doc_name i-pdf extension">
01/20/2020 (.PDF)
<span style={{"width":"100%"}}>
Постановление
</span>
</p>
</div>
<div className="row">
<p className="doc_name i-pdf extension">
Договор
<span style={{"width":"100%"}}>
2021_3866 от 25.06.2021
</span>
</p>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
)}
</article>
</div>
</div>
</section>
</main>
<Footer />
</React.Fragment>
);
}
return (
<React.Fragment>
<Head>
<title>ЛК Эволюция автолизинга</title>
<meta name="description" content="ЛК Эволюция автолизинга" />
</Head>
<Header {...this.props} />
<main>
<section>
<div className="clear"></div>
<div className="container">
<div className="title_wrapper">
<div className="left" style={{ flexDirection: "column" }}>
<h1 className="section_title">Договор {number}</h1>
<h5 style={{ fontSize: "14px" }}>
{date !== undefined && date !== null && date !== null && (
<> от {moment(date).format("DD.MM.YYYY")}</>
)}
{car !== undefined && car !== null
? ` - ${car.brand.name} ${car.model.name} | ${
car.reg_number !== null
? car.reg_number
: "без рег. номера"
} | ${
car.vin_number !== null
? car.vin_number
: "без VIN номера"
}`
: ""}
</h5>
</div>
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu number={number} {...this.props} />
<article>
{loading ? (
<div
className="table_row table_header"
style={{
minHeight: 300,
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
>
<SpinnerCircular
size={90}
thickness={51}
speed={100}
color="rgba(28, 1, 169, 1)"
secondaryColor="rgba(236, 239, 244, 1)"
/>
</div>
) : (
<div className="dropdown_blocks_list zero-margin gibdd">
<div className={`dropdown_block open`}>
<div className="block_body full">
<div className="company">
<p className="title lower">Штрафы ГИБДД</p>
<ul>
<li>
Номер постановления: <b>3432434242334</b>
</li>
<li>
Страховая: <b>3 400 000,00 </b>
</li>
<li>
Статус: <b>Оплачен</b>
</li>
<li>
Дата: <b>01/01/2020 </b>
</li>
<li>
Штраф:{" "}
<b>п. 1.15 - Несоблюдение правил парковки </b>
</li>
<li>
<div className="dosc_list medium-icon">
<div className="row">
<p className="doc_name i-pdf extension">
01/20/2020 (.PDF)
<span style={{"width":"100%"}}>
Постановление
</span>
</p>
</div>
<div className="row">
<p className="doc_name i-pdf extension">
Договор
<span style={{"width":"100%"}}>
2021_3866 от 25.06.2021
</span>
</p>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
)}
</article>
</div>
</div>
</section>
</main>
<Footer />
</React.Fragment>
);
}
}
function mapStateToProps(state, ownProps) {
return {
contract_date: state.contract.date,
date: state.contract.date,
car: state.contract.car,
helpcard: state.contract.helpcard,
insurance: state.contract.insurance,
registration: state.contract.registration,
telematic: state.contract.telematic,
};
function mapStateToProps(state, ownProps)
{
return {
contract_date: state.contract.date,
date: state.contract.date,
car: state.contract.car,
helpcard: state.contract.helpcard,
insurance: state.contract.insurance,
registration: state.contract.registration,
telematic: state.contract.telematic,
};
}
export const getServerSideProps = reduxWrapper.getServerSideProps(
(store) =>
async ({ req, res, query }) => {
return {
props: {
//number: query.number,
number: null,
},
};
}
(store) =>
async ({ req, res, query }) => {
return {
props: {
//number: query.number,
number: null,
},
};
}
);
export default withRouter(connect(mapStateToProps)(ContractServicesPage));

View File

@ -133,7 +133,7 @@ class ContractSchedulePage extends React.Component
<h1 className="section_title">Договор { number }</h1>
<p className="section_subtitle">{ date !== undefined && date !== null && date !== null && (<> от { moment(date).format("DD.MM.YYYY") }</>)}{ car !== undefined && car !== null ? ` - ${ car.brand.name } ${ car.model.name } | ${ car.reg_number !== null ? car.reg_number : 'без рег. номера' } | ${ car.vin_number !== null ? car.vin_number : 'без VIN номера' }` : '' }</p>
</div>
<Company/>
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu number={ number } { ...this.props }/>

View File

@ -90,7 +90,7 @@ class ContractPage extends React.Component
<h1 className="section_title">Договор { number }</h1>
<h5 style={{ fontSize: '14px' }}>{ date !== undefined && date !== null && date !== null && (<> от { moment(date).format("DD.MM.YYYY") }</>)}{ car !== undefined && car !== null ? ` - ${ car.brand.name } ${ car.model.name } | ${ car.reg_number !== null ? car.reg_number : 'без рег. номера' } | ${ car.vin_number !== null ? car.vin_number : 'без VIN номера' }` : '' }</h5>
</div>
<Company/>
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu number={ number } { ...this.props }/>

View File

@ -140,7 +140,7 @@ class ContractServicesPage extends React.Component
<h1 className="section_title">Договор { number }</h1>
<h5 style={{ fontSize: '14px' }}>{ date !== undefined && date !== null && date !== null && (<> от { moment(date).format("DD.MM.YYYY") }</>)}{ car !== undefined && car !== null ? ` - ${ car.brand.name } ${ car.model.name } | ${ car.reg_number !== null ? car.reg_number : 'без рег. номера' } | ${ car.vin_number !== null ? car.vin_number : 'без VIN номера' }` : '' }</h5>
</div>
<Company/>
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu number={ number } { ...this.props }/>

View File

@ -244,7 +244,7 @@ class CalendarPage extends React.Component
{/*[{ perweek ? 1 : 0 }, { current_week }, { selected_week }, { weeks_in_month }]*/}
<h1 className="section_title">Календарь оплат</h1>
</div>
<Company/>
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu { ...this.props }/>

View File

@ -94,7 +94,7 @@ class FinalsPage extends React.Component
<div className="left">
<h1 className="section_title">Закрывающие документы</h1>
</div>
<Company/>
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu { ...this.props }/>

View File

@ -234,7 +234,7 @@ class ReconciliationsPage extends React.Component
<div className="left">
<h1 className="section_title">Акты сверок</h1>
</div>
<Company/>
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu { ...this.props }/>

View File

@ -93,7 +93,7 @@ class EventsPage extends React.Component
<div className="left" style={{ flexDirection: "column" }}>
<h1 className="section_title">События</h1>
</div>
<Company />
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu { ...this.props }/>

View File

@ -150,6 +150,7 @@ class IndexPage extends React.Component
render()
{
const { company, loading, page, pages, search, date_from, date_from_type, date_to, date_to_type, contracts, sort_number, sort_date, sort_status, all } = this.state;
const contract_status = {
"Действующий": "opened",
"Закрыт": "closed",
@ -177,7 +178,7 @@ class IndexPage extends React.Component
<h1 className="section_title">Личный кабинет</h1>
</div>
<div className="right">
<Company company={ company }/>
<Company company={ company } { ...this.props }/>
</div>
</div>
<AnnouncementsList />

View File

@ -91,7 +91,7 @@ class IndexPage extends React.Component
<div className="left">
<h1 className="section_title">Личный кабинет</h1>
</div>
<Company/>
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu { ...this.props }/>

View File

@ -171,7 +171,7 @@ class IndexPage extends React.Component
<div className="left">
<h1 className="section_title">Смена пароля</h1>
</div>
<Company/>
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu { ...this.props }/>

View File

@ -202,7 +202,7 @@ class IndexPage extends React.Component
<div className="left">
<h1 className="section_title">Вход по номеру телефона</h1>
</div>
<Company/>
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu { ...this.props }/>

View File

@ -94,8 +94,9 @@ class SupportAppealsPage extends React.Component
render()
{
const { loading, appeals } = this.state;
const { number } = this.props;
const { loading, appeals } = this.state;
const status = {
active: { title: "Активное", color: "#04A8A4" },
closed: { title: "Закрыто", color: "#000", },
@ -119,7 +120,7 @@ class SupportAppealsPage extends React.Component
<div className="left" style={{ flexDirection: "column" }}>
<h1 className="section_title">Мои обращения</h1>
</div>
<Company />
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu { ...this.props } />

View File

@ -130,7 +130,7 @@ class ContractPage extends React.Component
<div className="left" style={{ flexDirection: "column" }}>
<h1 className="section_title">Обращения</h1>
</div>
<Company />
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<InnerMenu { ...this.props } />

View File

@ -159,8 +159,8 @@ class SupportRequestPage extends React.Component
render()
{
const { loading, themes, opened_theme, opened_question } = this.state;
const { number } = this.props;
const { loading, themes, opened_theme, opened_question } = this.state;
const procedure = themes !== undefined && themes !== null ? themes[opened_theme].questions[opened_question] : undefined;
@ -180,7 +180,7 @@ class SupportRequestPage extends React.Component
<button className="back" onClick={ this._handle_onBack }>Назад</button>
<h1 className="section_title">Новое обращение</h1>
</div>
<Company />
<Company { ...this.props }/>
</div>
<div className="aside_container about">
<article className="full">

102
pages/switch.js Normal file
View File

@ -0,0 +1,102 @@
import React from "react";
import Head from 'next/head';
import Image from 'next/image';
import { connect } from "react-redux";
import { withRouter } from 'next/router';
import { reduxWrapper } from '../store';
import pluralize from 'pluralize-ru';
import { SpinnerCircular } from 'spinners-react';
import Header from './components/Header';
import Footer from './components/Footer';
import MainHeader from "./components/MainHeader";
import FormRequest from "./components/FormRequest";
import { sendOffstageToken, sendSwitchAccount } from '../actions';
class SwitchPage extends React.Component
{
constructor(props)
{
super(props);
this.state = {
error: undefined,
};
}
static getDerivedStateFromProps(nextProps, prevState)
{
return {
};
}
componentDidMount()
{
sendSwitchAccount({ dispatch: this.props.dispatch, acc_number: this.props.account })
.then(() =>
{
this.setState({ error: false });
})
.catch(() =>
{
this.setState({ error: true });
});
}
render()
{
const { error } = this.state;
return (
<React.Fragment>
<Head>
<title>ЛК Эволюция автолизинга</title>
<meta
name="description"
content="ЛК Эволюция автолизинга"
/>
</Head>
<MainHeader logo_url={ process.env.NEXT_PUBLIC_MAIN_SITE } />
<main>
<section>
<div className="clear"></div>
<div className="container" style={{ width: "100vw", height: "80vh", display: "flex", alignItems: "center", justifyContent: "center", }}>
{ error === true ? (
<p>Предоставленный токен невалиден или аккаунт не найден</p>
) : (
<SpinnerCircular size={90} thickness={51} speed={100} color="rgba(28, 1, 169, 1)" secondaryColor="rgba(236, 239, 244, 1)" />
) }
</div>
</section>
</main>
</React.Fragment>
);
}
}
function mapStateToProps(state, ownProps)
{
return {
}
}
export const getServerSideProps = reduxWrapper.getServerSideProps(store =>
async ({ req, res, query }) =>
{
if(query.account === undefined)
{
res.statusCode = 302;
res.setHeader('Location', `/`);
}
else
{
return {
props: {
account: query.account,
}
}
}
}
);
export default withRouter(connect(mapStateToProps)(SwitchPage));

View File

@ -0,0 +1,24 @@
import { HYDRATE } from 'next-redux-wrapper';
import * as actionTypes from '../constants/actionTypes';
import initialState from "./initialState";
const companiesReducer = (state = initialState.companies, action) =>
{
switch (action.type)
{
case actionTypes.COMPANIES:
{
return {
...state,
...action.data,
};
}
default: {
return state;
}
}
};
export default companiesReducer;

View File

@ -9,11 +9,14 @@ export const defaultState = {
secondname: "",
phone: "",
},
companies: {
list: null,
},
company: {
title: "",
inn: "",
kpp: "",
ogrn: "",
kpp: "",
ogrn: "",
},
contracts:
{

View File

@ -4,6 +4,7 @@ import { createWrapper } from 'next-redux-wrapper';
import authReducer from '../reducers/authReducer';
import userReducer from '../reducers/userReducer';
import companyReducer from '../reducers/companyReducer';
import companiesReducer from '../reducers/companiesReducer';
import contractsReducer from '../reducers/contractsReducer';
import contractReducer from '../reducers/contractReducer';
import calendarReducer from '../reducers/calendarReducer';
@ -14,6 +15,7 @@ const combinedReducer = combineReducers({
auth: authReducer,
user: userReducer,
company: companyReducer,
companies: companiesReducer,
contracts: contractsReducer,
contract: contractReducer,
calendar: calendarReducer,
@ -36,7 +38,7 @@ const makeStore = (context) =>
const persistConfig = {
key: 'nextjs',
whitelist: [ 'auth', 'user', 'company', ],
whitelist: [ 'auth', 'user', 'company', 'companies' ],
storage
};