diff --git a/src/components/popup-components/ManageFavouritesButton/ManageFavouritesButton.tsx b/src/components/popup-components/ManageFavouritesButton/ManageFavouritesButton.tsx index f9a4d1e..d144a29 100644 --- a/src/components/popup-components/ManageFavouritesButton/ManageFavouritesButton.tsx +++ b/src/components/popup-components/ManageFavouritesButton/ManageFavouritesButton.tsx @@ -7,6 +7,7 @@ import newStorage from "~utils/newStorage" const ManageFavouritesButton = ({ popupId }) => { const storage = newStorage() + const [hasUserSession, setHasUserSession] = useState(false) const [status, setStatus] = useState< "idle" | "loading" | "rejected" >("idle") @@ -17,6 +18,11 @@ const ManageFavouritesButton = ({ popupId }) => { const userSession: UserSession = await storage.get( "arebyte-audience-session" ) + if (!userSession) { + setHasUserSession(false) + return + } + setHasUserSession(true) const { data, error @@ -31,7 +37,8 @@ const ManageFavouritesButton = ({ popupId }) => { if (error) { console.error(error) - return setStatus("rejected") + setStatus("rejected") + return } setIsFavourite(data.favourites.some(fav => fav.id === popupId)) } @@ -60,20 +67,26 @@ const ManageFavouritesButton = ({ popupId }) => { } return ( -
- - {status === "rejected" && ( -

- Something went wrong, try again. -

+ <> + {hasUserSession && ( +
+ + {status === "rejected" && ( +

+ Something went wrong, try again. +

+ )} +
)} -
+ ) } diff --git a/src/components/popup-components/PopupInfo/PopupInfo.css b/src/components/popup-components/PopupInfo/PopupInfo.css index 5458270..4b645ef 100644 --- a/src/components/popup-components/PopupInfo/PopupInfo.css +++ b/src/components/popup-components/PopupInfo/PopupInfo.css @@ -118,7 +118,7 @@ button:focus { display: flex; justify-content: center; align-items: center; - width: 250px; + width: 275px; } /* Styles for buttons controls in info panel */