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 -

-
-
-
-
-