import Link from "next/link"; import Image from "next/image"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; import Banner from "../components/banner"; import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; import { setLogout } from "../store/accountDetails/action"; import _ from "lodash"; import { parseCookies, setCookie, destroyCookie } from "nookies"; const Header = (props) => { let { t, lang } = useTranslation(); const router = useRouter(); const { locale } = router; const { setLogout, serviceName } = props; const noSignoutLink = [ "/", "/logout", "/dns", "/dns/application-process", "/dns/help", "/dns/contact-us", "/dns/applications", "/dns/application-view", "/searchresults", "/case", "/advancedsearch", "/advancedsearchresults", "/dnsapplications", "/dnsdetails", "/404", "/account/register", "/myportal/error", "/accessibility", "/details-about-cookies", ]; const hasContactLink = [ "/dns/application-process", "/dns/help", "/dns/contact-us", "/dns/applications", "/dns/application-view", ]; let domainSwitch; if (process.browser) { domainSwitch = window.switchDomain; } else { domainSwitch = process.env.I18N_DOMAIN; } return (
gov.wales
{/*
{ window.localStorage.clear(); }} className="govuk-header__link govuk-header__link--service-name" > {serviceName || t("common:service-name")}
*/}
{/*
*/}
{hasContactLink.includes(router.pathname) == true ? ( Contact ) : ( "" )} {noSignoutLink.includes(router.pathname) == true ? ( "" ) : ( { destroyCookie({}, "pinsUser"), window.localStorage.clear(); }} className="govuk-header__link govuk-!-margin-right-3" > {t("common:signout-label")} )} key + "=" + router.query[key] ) .join("&") : _.isEmpty(router.query) != false ? router.asPath + "?" + Object.keys(router.query) .map( (key) => key + "=" + router.query[key] ) .join("&") : router.asPath } locale={locale == "en" ? "cy" : "en"} > {" "} {t("common:available-in")}
); }; const mapDispatchToProps = (dispatch) => { return { setLogout: () => { dispatch(setLogout()); }, }; }; export default connect(null, mapDispatchToProps)(Header);