updated cookie login and watched cases

This commit is contained in:
2021-11-03 08:24:54 +00:00
parent 30a7e426af
commit fa4c765799
20 changed files with 208 additions and 130 deletions
+16 -2
View File
@@ -1,5 +1,5 @@
import Link from "next/link";
import { useState } from "react";
import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { connect } from "react-redux";
@@ -7,6 +7,7 @@ import { Field, reduxForm } from "redux-form";
import LoadingOverlay from "react-loading-overlay";
import { getLogin } from "../../actions";
import { setLoggedInUserId } from "../../store/accountDetails/action";
import { parseCookies, setCookie, destroyCookie } from "nookies";
const required = (errorMsg) => (value) =>
value || typeof value === "number" ? undefined : errorMsg;
@@ -128,17 +129,30 @@ let Login = (props) => {
data.value.length != 0
? (setValidLoginID(true),
setLoggedInUserId(data.value[0].contactid),
setCookie(null, "pinsUser", data.value[0].contactid, {
path: "/",
}),
spinnerState(),
router.replace({
pathname:
router.locale == "cy" ? "/fymhorth" : "/myportal",
query: { q: data.value[0].contactid },
shallow: true,
}))
: (setShowSpinnerState(false), setValidLoginID(false));
});
};
const cookies = parseCookies();
useEffect(() => {
cookies.pinsUser != null || typeof cookies.pinsUser != "undefined"
? (spinnerState(),
router.replace("/myportal", null, {
shallow: true,
}))
: "";
}, []);
return (
<div className="card" id="login-card">
<form onSubmit={handleSubmit(onHandleSubmit)}>