From e563c2446e2d69983ebaf0fe9d763b667c8dad1b Mon Sep 17 00:00:00 2001 From: sergesoroka Date: Tue, 19 Nov 2024 13:19:48 +0200 Subject: [PATCH] No Spectra is shown if user logged out --- components/ImageSelect/ImageSelect.jsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/components/ImageSelect/ImageSelect.jsx b/components/ImageSelect/ImageSelect.jsx index eb2822f..f38692e 100755 --- a/components/ImageSelect/ImageSelect.jsx +++ b/components/ImageSelect/ImageSelect.jsx @@ -1,6 +1,18 @@ /* eslint-disable react/prop-types */ import { Navigate } from "react-router-dom"; +import { useAuth } from "react-oidc-context"; +import { useEffect, useState } from "react"; + export default function ImageSelect({ data, imageSelected, setImageSelected }) { + const auth = useAuth(); + + const [isAuth, setIsAuth] = useState(false); + // useEffect(() => { + // if (auth.isAuthenticated) setIsAuth(true); + // }, [auth]); + + console.log(auth.isAuthenticated); + const renderImageSelect = data && data.map((img, i) => ( @@ -34,7 +46,7 @@ export default function ImageSelect({ data, imageSelected, setImageSelected }) { {data && Object.prototype.hasOwnProperty.call(data, "error") && (

Sorry

)} - {data && data.length > 0 ? ( + {data && data.length > 0 && auth.isAuthenticated ? ( renderImageSelect ) : (