Added profile data but clears after refresh

This commit is contained in:
2023-10-24 01:25:12 -07:00
parent e0fb79f2c9
commit 07a40ee808
5 changed files with 37 additions and 5 deletions
+3 -2
View File
@@ -107,12 +107,13 @@ const SignInForm = () => {
httpOnly: true, // Make the cookie accessible only via HTTP (recommended for security)
};
// Set the login token in a cookie
await setCookie("cmc-token", res.token);
const userProfileData = res.profile;
dispatch({ type: 'SET_USER_PROFILE', payload: userProfileData });
localStorage.setItem("cmc-profile", JSON.stringify(userProfileData));
dispatch({ type: "SET_USER_PROFILE", payload: userProfileData });
enqueueSnackbar("Login Successful", {
variant: "success",
+3 -1
View File
@@ -23,6 +23,8 @@ const Profile = () => {
const { state } = useUserProfile();
const userProfile = state.userProfile;
console.log(userProfile)
const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl);
const handleClick = (event) => {
@@ -102,7 +104,7 @@ const Profile = () => {
fontWeight: "500",
}}
>
Adison Jeck
{`${userProfile?.firstname} ${userProfile?.lastname}`}
</Typography>
</Box>
</MenuItem>