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() { const { dispatch } = this.props; sendSwitchAccount({ 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));