import { reduxWrapper } from '../store'
import numeral from 'numeral';
import Script from 'next/script';
import jwt from 'jsonwebtoken';
//import 'https://chat.autofaq.ai/widget/static/css/main.css';
import '../css/style.css';
const m = Math.random();
numeral.register('locale', `locale_${ m }`, {
delimiters: {
thousands: ' ',
decimal: ','
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
currency: {
symbol: '₽'
}
});
numeral.locale(`locale_${ m }`);
const WrappedApp = (props) =>
{
const { Component, pageProps, } = props;
return (
<>
{ !props.observer && (
<>
{ process.env.NEXT_PUBLIC_AUTOFAQ_AI_ENABLED == 1 && (
<>
>
) }
>
) }
>
)
}
WrappedApp.getInitialProps = async (props) =>
{
const { req } = props.ctx;
let observer = false;
let acc = null;
let email = null;
if(req !== undefined)
{
const { cookies } = req;
if(cookies !== undefined && cookies !== null)
{
if(cookies.jwt !== undefined && cookies.jwt !== null)
{
let client_jwt_decoded = jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT);
console.log({ client_jwt_decoded });
acc = client_jwt_decoded.acc_number;
email = client_jwt_decoded.login;
}
}
}
if(req !== undefined && req.url !== null && req.url.indexOf("offstage") > -1)
{
observer = true;
}
if(req !== undefined && req.cookies !== undefined && req.cookies.observer !== undefined && req.cookies.observer === "true")
{
observer = true;
}
return {
observer,
acc,
email,
}
}
export default reduxWrapper.withRedux(WrappedApp);