updated the cookies functionality

This commit is contained in:
2021-12-09 13:32:15 +00:00
parent 9c5c35fa4e
commit 0e18aa35b8
18 changed files with 507 additions and 182 deletions
+31 -12
View File
@@ -20,7 +20,7 @@ const CookieManagementMain = (props) => {
Object.assign(values, {
"essential": "accepted",
"usage": usageState,
"communications": communicationsState,
// "communications": communicationsState,
"settings": settingsState,
});
@@ -42,14 +42,15 @@ const CookieManagementMain = (props) => {
";expires=Thu, 01 Jan 1970 00:00:01 GMT";
}
usageState == "revoked" && delete_cookie("CookiePolicy", "/"),
delete_cookie("_ga", "/"),
usageState == "revoked" && delete_cookie("_ga", "/"),
delete_cookie("_gid", "/");
cookie.set("planning_casework", true, {
expires: expDate,
path: "/",
});
setSavedState(true);
};
let cookieCheck = parseCookies();
@@ -59,14 +60,16 @@ const CookieManagementMain = (props) => {
? {}
: JSON.parse(cookieCheck.CookiePolicy);
const [savedState, setSavedState] = useState(false);
const [usageState, setUsageState] = useState(
typeof cookieCheck.CookiePolicy == "undefined" ? null : cookieObj.usage
);
const [communicationsState, setCommunicationsState] = useState(
typeof cookieCheck.CookiePolicy == "undefined"
? null
: cookieObj.communications
);
// const [communicationsState, setCommunicationsState] = useState(
// typeof cookieCheck.CookiePolicy == "undefined"
// ? null
// : cookieObj.communications
// );
const [settingsState, setSettingsState] = useState(
typeof cookieCheck.CookiePolicy == "undefined"
? null
@@ -78,9 +81,9 @@ const CookieManagementMain = (props) => {
case "usage":
setUsageState(value);
break;
case "communications":
setCommunicationsState(value);
break;
// case "communications":
// setCommunicationsState(value);
// break;
case "settings":
setSettingsState(value);
break;
@@ -102,6 +105,22 @@ const CookieManagementMain = (props) => {
{t("cookies:cookie-title-heading")}
</h1>
<hr className="govuk-section-break govuk-section-break--visible" />
{savedState && (
<div
id="cookieSettingsMessageSuccess"
className="govuk-inset-text paragraph--type--call-out-message call-out-type-positive-alert-message"
>
<h2 className="govuk-heading-l">
<strong>
{t("cookies:cookie-saved-heading")}
</strong>
</h2>
<p className="govuk-body">
{t("cookies:cookie-saved-paragraph")}
</p>
</div>
)}
{typeof cookieCheck.CookiePolicy == "undefined" ? (
<>
<div className="govuk-inset-text paragraph--type--call-out-message">
@@ -455,7 +474,7 @@ const mapStateToProps = (state) => {
return {
initialValues: {
usage: state.accountDetails.cookieObj.usage,
communications: state.accountDetails.cookieObj.communications,
//communications: state.accountDetails.cookieObj.communications,
settings: state.accountDetails.cookieObj.settings,
},
};