added ga switch on cookie options
This commit is contained in:
+2
-1
@@ -31,5 +31,6 @@ I18N_DOMAIN = "cymru.local"
|
||||
|
||||
|
||||
GOOGLE_TAG_MANAGER = GTM-T78CBC3
|
||||
SHOWLOGIN = "true"
|
||||
SHOWLOGIN = "false"
|
||||
SHOWREPRESENTATIONS = "false"
|
||||
BASIC_AUTH_CREDENTIALS = pinswg:password|pinswg2:password2
|
||||
@@ -215,7 +215,7 @@ const CaseSummary = (props) => {
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<a
|
||||
{/* <a
|
||||
onClick={() => {
|
||||
//spinnerState();
|
||||
router.back();
|
||||
@@ -223,7 +223,7 @@ const CaseSummary = (props) => {
|
||||
className="govuk-button govuk-button--secondary"
|
||||
>
|
||||
{t("case:summary-back-button-label")}
|
||||
</a>
|
||||
</a> */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -17,11 +17,22 @@ const CookieBanner = () => {
|
||||
let expDate = new Date(now);
|
||||
|
||||
expDate.setDate(now.getDate() + 365);
|
||||
|
||||
console.log(expDate);
|
||||
cookie.set("planning_casework", true, {
|
||||
expires: expDate,
|
||||
});
|
||||
|
||||
let cookieStr = {
|
||||
"essential": "accepted",
|
||||
"usage": "accepted",
|
||||
"communications": "accepted",
|
||||
"settings": "accepted",
|
||||
};
|
||||
|
||||
cookie.set("CookiePolicy", JSON.stringify(cookieStr).toString(), {
|
||||
expires: expDate,
|
||||
path: "/",
|
||||
});
|
||||
|
||||
setBannerVisible(false);
|
||||
};
|
||||
|
||||
|
||||
@@ -30,9 +30,23 @@ const CookieManagementMain = (props) => {
|
||||
|
||||
cookie.set("CookiePolicy", JSON.stringify(values).toString(), {
|
||||
expires: expDate,
|
||||
path: "/",
|
||||
});
|
||||
|
||||
function delete_cookie(name, path, domain) {
|
||||
document.cookie =
|
||||
name +
|
||||
"=" +
|
||||
(path ? ";path=" + path : "") +
|
||||
(domain ? ";domain=" + domain : "") +
|
||||
";expires=Thu, 01 Jan 1970 00:00:01 GMT";
|
||||
}
|
||||
|
||||
usageState == "revoked" && delete_cookie("CookiePolicy", "/");
|
||||
|
||||
cookie.set("planning_casework", true, {
|
||||
expires: expDate,
|
||||
path: "/",
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -126,12 +126,18 @@ let Login = (props) => {
|
||||
const onHandleSubmit = (values) => {
|
||||
//spinnerState();
|
||||
|
||||
let now = new Date();
|
||||
let expDate = new Date(now);
|
||||
|
||||
expDate.setDate(now.getDate() + 0.41);
|
||||
|
||||
getLogin(values.loginUserID, values.loginUserPassword).then((data) => {
|
||||
data.value.length != 0
|
||||
? (setValidLoginID(true),
|
||||
setLoggedInUserId(data.value[0].contactid),
|
||||
setCookie(null, "pinsUser", data.value[0].contactid, {
|
||||
path: "/",
|
||||
expires: expDate,
|
||||
}),
|
||||
// spinnerState(),
|
||||
router.replace({
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
"next": "^11.0.1",
|
||||
"next-redux-wrapper": "^7.0.2",
|
||||
"next-translate": "^1.0.7",
|
||||
"nextjs-basic-auth-middleware": "^0.2.1",
|
||||
"nookies": "^2.5.2",
|
||||
"path": "^0.12.7",
|
||||
"pm2": "^5.1.0",
|
||||
|
||||
+33
-19
@@ -1,35 +1,49 @@
|
||||
import Document, { Html, Head, Main, NextScript } from "next/document";
|
||||
import SkipLink from "../components/skiplink";
|
||||
import { Tracking, TrackingNoScript } from "../components/tracking";
|
||||
//import basicAuthMiddleware from "nextjs-basic-auth-middleware";
|
||||
import basicAuthMiddleware from "nextjs-basic-auth-middleware";
|
||||
|
||||
class MyDocument extends Document {
|
||||
// static async getInitialProps(ctx) {
|
||||
// const initialProps = await Document.getInitialProps(ctx);
|
||||
// if (ctx.req && ctx.res) {
|
||||
// await basicAuthMiddleware(ctx.req, ctx.res, {
|
||||
// users: [
|
||||
// {
|
||||
// name: "rehab",
|
||||
// password: "preventTesting",
|
||||
// },
|
||||
// ],
|
||||
// });
|
||||
// }
|
||||
// return { ...initialProps };
|
||||
// }
|
||||
static async getInitialProps(ctx) {
|
||||
const initialProps = await Document.getInitialProps(ctx);
|
||||
|
||||
let useGATracking = false;
|
||||
|
||||
if (ctx.req && ctx.req.headers.cookie) {
|
||||
typeof ctx.req.cookies.CookiePolicy != "undefined"
|
||||
? JSON.parse(ctx.req.cookies.CookiePolicy).usage == "accepted"
|
||||
? (useGATracking = true)
|
||||
: (useGATracking = false)
|
||||
: (useGATracking = true);
|
||||
} else {
|
||||
useGATracking = false;
|
||||
}
|
||||
|
||||
// if (ctx.req && ctx.res) {
|
||||
// await basicAuthMiddleware(ctx.req, ctx.res, {
|
||||
// users: process.env.BASIC_AUTH_CREDENTIALS,
|
||||
// });
|
||||
// }
|
||||
|
||||
return { ...initialProps, useGATracking };
|
||||
}
|
||||
|
||||
render() {
|
||||
const googleTagManagerID = process.env.GOOGLE_TAG_MANAGER || null;
|
||||
|
||||
const { useGATracking } = this.props;
|
||||
return (
|
||||
<Html lang="en">
|
||||
<Head>
|
||||
<Tracking googleTagManagerID={googleTagManagerID} />
|
||||
{useGATracking && (
|
||||
<Tracking googleTagManagerID={googleTagManagerID} />
|
||||
)}
|
||||
</Head>
|
||||
<body className="js-enabled">
|
||||
<TrackingNoScript googleTagManagerID={googleTagManagerID} />
|
||||
|
||||
{useGATracking && (
|
||||
<TrackingNoScript
|
||||
googleTagManagerID={googleTagManagerID}
|
||||
/>
|
||||
)}
|
||||
{!process.browser && (
|
||||
<script>
|
||||
window.switchDomain = `{process.env.I18N_DOMAIN}`
|
||||
|
||||
Reference in New Issue
Block a user