diff --git a/actions/authActions.js b/actions/authActions.js index dda2e42..c62a7d3 100644 --- a/actions/authActions.js +++ b/actions/authActions.js @@ -32,10 +32,8 @@ export const sendLoginFormEmail = ({ email, password, dispatch }) => .then((response) => { //console.log("sendLoginFormEmail RESPONSE"); - //console.log(response.data); - if(response.data.status === "success") { const cookies = new Cookies(); @@ -49,7 +47,8 @@ export const sendLoginFormEmail = ({ email, password, dispatch }) => dispatch({ type: actionTypes.COMPANIES, data: { list: response.data.companies } }); resolve(); - Router.push('/'); + //Router.push('/'); + window.location = "/"; }) .catch(() => { @@ -116,10 +115,8 @@ export const sendSmsCode = ({ dispatch, phone, code }) => .then((response) => { //console.log("sendSmsCode RESPONSE"); - //console.log(response.data); - if(response.data.status === "success") { const cookies = new Cookies(); @@ -132,7 +129,8 @@ export const sendSmsCode = ({ dispatch, phone, code }) => dispatch({ type: actionTypes.USER, data: response.data.user }); resolve(); - Router.push('/'); + //Router.push('/'); + window.location = "/"; }) .catch(() => { @@ -176,7 +174,8 @@ export const logout = ({ dispatch, redirect = true }) => resolve(); if(redirect) { - Router.push('/'); + //Router.push('/'); + window.location = "/"; } }); } @@ -210,7 +209,8 @@ export const sendOffstageToken = ({ token, dispatch }) => dispatch({ type: actionTypes.COMPANIES, data: { list: response.data.companies } }); resolve(); - Router.push('/'); + //Router.push('/'); + window.location = "/"; }) .catch(() => { @@ -265,7 +265,8 @@ export const sendSwitchAccount = ({ dispatch, acc_number }) => .then(() => { resolve(); - Router.push('/'); + //Router.push('/'); + window.location = "/"; }) .catch(() => { diff --git a/lib/CRMRequestGet/index.js b/lib/CRMRequestGet/index.js index 9b17def..bf7b23b 100644 --- a/lib/CRMRequestGet/index.js +++ b/lib/CRMRequestGet/index.js @@ -72,7 +72,10 @@ export default async function CRMRequestGet({ req, res, path, params, data = und }) .catch((error) => { - console.error(error); + if(log) + { + console.error(error); + } console.error("-".repeat(30), "error.response.data:"); console.error(error.response.data); diff --git a/pages/_app.js b/pages/_app.js index d07e895..6395be0 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -1,9 +1,8 @@ import { reduxWrapper } from '../store' import numeral from 'numeral'; -import '../css/style.css'; +import Script from 'next/script'; -//import DaData from 'dadata'; -//global.dadata = new DaData(process.env.DADATA_API_KEY, process.env.DADATA_SECRET_KEY); +import '../css/style.css'; const m = Math.random(); numeral.register('locale', `locale_${ m }`, { @@ -23,11 +22,56 @@ numeral.register('locale', `locale_${ m }`, { }); numeral.locale(`locale_${ m }`); -const WrappedApp = ({ Component, pageProps }) => +const WrappedApp = (props) => { + const { Component, pageProps, } = props; + return ( - + <> + { props.observer && ( + <> + + + + ) } + + ) } +WrappedApp.getInitialProps = async (props) => +{ + const { req } = props.ctx; + + let observer = true; + if(req.url.indexOf("offstage") > -1) + { + observer = false; + } + + if(req.cookies !== undefined && req.cookies.observer !== undefined && req.cookies.observer === "true") + { + observer = false; + } + + return { + observer, + } +} + export default reduxWrapper.withRedux(WrappedApp); \ No newline at end of file diff --git a/pages/_document.js b/pages/_document.js index 977a606..587618e 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -1,4 +1,4 @@ -import Document, { Html, Head, Main, NextScript } from 'next/document' +import Document, { Html, Head, Main, NextScript } from 'next/document'; class Doc extends Document { @@ -7,7 +7,6 @@ class Doc extends Document return ( - {/**/} @@ -41,28 +40,6 @@ class Doc extends Document
- -