diff --git a/actions/authActions.js b/actions/authActions.js
index 410d9f5..87ee0a2 100644
--- a/actions/authActions.js
+++ b/actions/authActions.js
@@ -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();
diff --git a/constants/actionTypes.js b/constants/actionTypes.js
index 3b97b6a..b58f419 100644
--- a/constants/actionTypes.js
+++ b/constants/actionTypes.js
@@ -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';
diff --git a/pages/500.js b/pages/500.js
index 035bf3c..7462cdb 100644
--- a/pages/500.js
+++ b/pages/500.js
@@ -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 (
-
-
- ЛК Эволюция автолизинга
-
-
-
-
-
-
-
-
-
-
Личный кабинет
-
-
-
-
-
-
-
-
- В настоящий момент ведутся технические работы. Если Вам
- необходимо получить информацию, пожалуйста, свяжитесь с нами
- по телефону: 8 800 111 22 33
-
-
-
-
-
-
-
- );
- }
+ render()
+ {
+ return (
+
+
+ ЛК Эволюция автолизинга
+
+
+
+
+
+
+
+
+
+
Личный кабинет
+
+
+
+
+
+
+
+ В настоящий момент ведутся технические работы. Если Вам
+ необходимо получить информацию, пожалуйста, свяжитесь с нами
+ по телефону: 8 800 111 22 33
+
+
+
+
+
+
+
+ );
+ }
}
export default Offline;
diff --git a/pages/api/auth/offstage.js b/pages/api/auth/offstage.js
index 087e2d7..b5c538e 100644
--- a/pages/api/auth/offstage.js
+++ b/pages/api/auth/offstage.js
@@ -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
diff --git a/pages/api/auth/phone/code.js b/pages/api/auth/phone/code.js
index bd53c86..b3f71c1 100644
--- a/pages/api/auth/phone/code.js
+++ b/pages/api/auth/phone/code.js
@@ -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, } });
}
diff --git a/pages/api/auth/switch.js b/pages/api/auth/switch.js
new file mode 100644
index 0000000..487a5ab
--- /dev/null
+++ b/pages/api/auth/switch.js
@@ -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();
+ }
+}
\ No newline at end of file
diff --git a/pages/api/company.js b/pages/api/company.js
index c9e5261..52bd798 100644
--- a/pages/api/company.js
+++ b/pages/api/company.js
@@ -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) =>
{
diff --git a/pages/components/Company/index.js b/pages/components/Company/index.js
index 1a9c663..a3b2760 100644
--- a/pages/components/Company/index.js
+++ b/pages/components/Company/index.js
@@ -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 (
-
{/* className="arrow" */}
+
1 && "arrow" }>{/* className="arrow" */}
{ company.title }
{company.inn != null && ИНН: { company.inn } }
{company.kpp != null && КПП: { company.kpp } }
-
{/* opened */}
-
-
- ООО “ЮКС“
- ИНН: 12345678765 КПП: 13432-02
-
-
-
-
-
- ООО “Еще одно название”
- ИНН: 12345678765 КПП: 13432-02
-
-
-
-
-
- ООО “Друзья и КО”
- ИНН: 12345678765 КПП: 13432-02
-
-
+ { companies !== null && companies.map((entry, index) => (
+
this._handle_onSelectCompany(entry.acc_number) }>
+
+ { entry.title }
+ ИНН: { entry.inn } { entry.kpp !== '' && (<>КПП: { entry.kpp } >) }
+
+
+ )) }
)
@@ -70,6 +66,7 @@ function mapStateToProps(state, ownProps)
{
return {
company: state.company,
+ companies: state.companies.list,
}
}
diff --git a/pages/contract/__change.js b/pages/contract/__change.js
index 3275b48..25c5689 100644
--- a/pages/contract/__change.js
+++ b/pages/contract/__change.js
@@ -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
: ""}
-
+
diff --git a/pages/contract/agreement.js b/pages/contract/agreement.js
index 7991eb9..a19f725 100644
--- a/pages/contract/agreement.js
+++ b/pages/contract/agreement.js
@@ -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
: "" }
-
+
diff --git a/pages/contract/change/index.js b/pages/contract/change/index.js
index 4353790..896571c 100644
--- a/pages/contract/change/index.js
+++ b/pages/contract/change/index.js
@@ -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 номера" }` : "" }
-
+
{ loading ? (
diff --git a/pages/contract/compare.js b/pages/contract/compare.js
index c47e49d..e3e517c 100644
--- a/pages/contract/compare.js
+++ b/pages/contract/compare.js
@@ -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 номера" }` : "" }
-
+
diff --git a/pages/contract/documents.js b/pages/contract/documents.js
index badcebe..b46a703 100644
--- a/pages/contract/documents.js
+++ b/pages/contract/documents.js
@@ -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
: "" }
-
+
diff --git a/pages/contract/events.js b/pages/contract/events.js
index 70085d4..11a8cc9 100644
--- a/pages/contract/events.js
+++ b/pages/contract/events.js
@@ -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
Договор №{ number }
{ 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 номера" }` : "" }
-
+
diff --git a/pages/contract/fines.js b/pages/contract/fines.js
index f57fe58..263f418 100644
--- a/pages/contract/fines.js
+++ b/pages/contract/fines.js
@@ -260,9 +260,9 @@ class ContractDocumentsPage extends React.Component
return (
-
{doc.num} от {moment(doc.date).format("DD.MM.YYYY")}
@@ -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
ЛК Эволюция автолизинга
-
+
@@ -530,10 +530,10 @@ class ContractDocumentsPage extends React.Component
: "" }
-
+
-
+
{ loading ? (
) : (
<>
-
-
Акт сверки
-
-
- {
- this._handle_onReconciliationFileRequest();
- }}
- >
- <>
- {reconciliation_requested ? (
-
- ) : (
- "Скачать"
- )}
- >
-
- {/*Отправить в ЭДО */}
-
-
{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}
-
-
-
-
Счета-уведомления на пени
-
-
-
-
Введите планируемую дату оплаты просроченной задолженности для расчёта пеней
-
-
-
>
) }
diff --git a/pages/contract/gibdd.js b/pages/contract/gibdd.js
index b9aaeab..bf4df83 100644
--- a/pages/contract/gibdd.js
+++ b/pages/contract/gibdd.js
@@ -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 (
-
-
- ЛК Эволюция автолизинга
-
-
-
-
-
-
-
-
-
-
Договор №{number}
-
- {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 номера"
- }`
- : ""}
-
-
-
-
-
-
-
- {loading ? (
-
-
-
- ) : (
-
-
-
-
-
Штрафы ГИБДД
-
-
- Номер постановления: 3432434242334
-
-
- Страховая: 3 400 000,00 ₽
-
-
- Статус: Оплачен
-
-
- Дата: 01/01/2020
-
-
- Штраф:{" "}
- п. 1.15 - Несоблюдение правил парковки
-
-
-
-
-
- № 01/20/2020 (.PDF)
-
- Постановление
-
-
-
-
-
- Договор
-
- 2021_3866 от 25.06.2021
-
-
-
-
-
-
-
-
-
-
- )}
-
-
-
-
-
-
-
- );
- }
+ return (
+
+
+ ЛК Эволюция автолизинга
+
+
+
+
+
+
+
+
+
+
Договор №{number}
+
+ {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 номера"
+ }`
+ : ""}
+
+
+
+
+
+
+
+ {loading ? (
+
+
+
+ ) : (
+
+
+
+
+
Штрафы ГИБДД
+
+
+ Номер постановления: 3432434242334
+
+
+ Страховая: 3 400 000,00 ₽
+
+
+ Статус: Оплачен
+
+
+ Дата: 01/01/2020
+
+
+ Штраф:{" "}
+ п. 1.15 - Несоблюдение правил парковки
+
+
+
+
+
+ № 01/20/2020 (.PDF)
+
+ Постановление
+
+
+
+
+
+ Договор
+
+ 2021_3866 от 25.06.2021
+
+
+
+
+
+
+
+
+
+
+ )}
+
+
+
+
+
+
+
+ );
+ }
}
-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));
diff --git a/pages/contract/index.js b/pages/contract/index.js
index b27521a..89ee0a6 100644
--- a/pages/contract/index.js
+++ b/pages/contract/index.js
@@ -133,7 +133,7 @@ class ContractSchedulePage extends React.Component
Договор №{ number }
{ 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 номера' }` : '' }
-
+
diff --git a/pages/contract/materials.js b/pages/contract/materials.js
index 3bc3b49..942628d 100644
--- a/pages/contract/materials.js
+++ b/pages/contract/materials.js
@@ -90,7 +90,7 @@ class ContractPage extends React.Component
Договор №{ number }
{ 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 номера' }` : '' }
-
+
diff --git a/pages/contract/services.js b/pages/contract/services.js
index 03b3f21..7b7b304 100644
--- a/pages/contract/services.js
+++ b/pages/contract/services.js
@@ -140,7 +140,7 @@ class ContractServicesPage extends React.Component
Договор №{ number }
{ 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 номера' }` : '' }
-
+
diff --git a/pages/documents/calendar.js b/pages/documents/calendar.js
index a25109a..a4bee8b 100644
--- a/pages/documents/calendar.js
+++ b/pages/documents/calendar.js
@@ -244,7 +244,7 @@ class CalendarPage extends React.Component
{/*[{ perweek ? 1 : 0 }, { current_week }, { selected_week }, { weeks_in_month }]*/}
Календарь оплат
-
+
diff --git a/pages/documents/finals.js b/pages/documents/finals.js
index dee49f3..5012a54 100644
--- a/pages/documents/finals.js
+++ b/pages/documents/finals.js
@@ -94,7 +94,7 @@ class FinalsPage extends React.Component
Закрывающие документы
-
+
diff --git a/pages/documents/reconciliations.js b/pages/documents/reconciliations.js
index 5afa419..6f017ae 100644
--- a/pages/documents/reconciliations.js
+++ b/pages/documents/reconciliations.js
@@ -234,7 +234,7 @@ class ReconciliationsPage extends React.Component
Акты сверок
-
+
diff --git a/pages/events.js b/pages/events.js
index 9490eda..3bd9538 100644
--- a/pages/events.js
+++ b/pages/events.js
@@ -93,7 +93,7 @@ class EventsPage extends React.Component
События
-
+
diff --git a/pages/index.js b/pages/index.js
index f6cb145..1e45959 100644
--- a/pages/index.js
+++ b/pages/index.js
@@ -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
Личный кабинет
-
+
diff --git a/pages/settings/admin.js b/pages/settings/admin.js
index 6596095..6cfd6f6 100644
--- a/pages/settings/admin.js
+++ b/pages/settings/admin.js
@@ -91,7 +91,7 @@ class IndexPage extends React.Component
Личный кабинет
-
+
diff --git a/pages/settings/password.js b/pages/settings/password.js
index ab774c6..2a87f89 100644
--- a/pages/settings/password.js
+++ b/pages/settings/password.js
@@ -171,7 +171,7 @@ class IndexPage extends React.Component
Смена пароля
-
+
diff --git a/pages/settings/phone.js b/pages/settings/phone.js
index 51ba697..4618bb3 100644
--- a/pages/settings/phone.js
+++ b/pages/settings/phone.js
@@ -202,7 +202,7 @@ class IndexPage extends React.Component
Вход по номеру телефона
-
+
diff --git a/pages/support/appeals.js b/pages/support/appeals.js
index 4b0c535..16b2c3a 100644
--- a/pages/support/appeals.js
+++ b/pages/support/appeals.js
@@ -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
Мои обращения
-
+
diff --git a/pages/support/index.js b/pages/support/index.js
index 65b4815..be3e394 100644
--- a/pages/support/index.js
+++ b/pages/support/index.js
@@ -130,7 +130,7 @@ class ContractPage extends React.Component
Обращения
-
+
diff --git a/pages/support/request.js b/pages/support/request.js
index 06d3bc2..495fc28 100644
--- a/pages/support/request.js
+++ b/pages/support/request.js
@@ -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
Назад
Новое обращение
-
+
diff --git a/pages/switch.js b/pages/switch.js
new file mode 100644
index 0000000..9e9328a
--- /dev/null
+++ b/pages/switch.js
@@ -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 (
+
+
+ ЛК Эволюция автолизинга
+
+
+
+
+
+
+
+ { error === true ? (
+
Предоставленный токен невалиден или аккаунт не найден
+ ) : (
+
+ ) }
+
+
+
+
+ );
+ }
+}
+
+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));
diff --git a/reducers/companiesReducer.js b/reducers/companiesReducer.js
new file mode 100644
index 0000000..c2aa99e
--- /dev/null
+++ b/reducers/companiesReducer.js
@@ -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;
\ No newline at end of file
diff --git a/reducers/initialState.js b/reducers/initialState.js
index 0960acb..8915623 100644
--- a/reducers/initialState.js
+++ b/reducers/initialState.js
@@ -9,11 +9,14 @@ export const defaultState = {
secondname: "",
phone: "",
},
+ companies: {
+ list: null,
+ },
company: {
title: "",
inn: "",
- kpp: "",
- ogrn: "",
+ kpp: "",
+ ogrn: "",
},
contracts:
{
diff --git a/store/index.js b/store/index.js
index d16ccf9..fcc68ca 100644
--- a/store/index.js
+++ b/store/index.js
@@ -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
};