Merge branch 'login-tabs' of WrenchBoard/Users-Wrench into master

This commit is contained in:
2023-07-07 10:07:06 +00:00
committed by Gogs
3 changed files with 17 additions and 14 deletions
+6 -6
View File
@@ -108,7 +108,7 @@ export default function Login() {
localStorage.setItem("uid", `${res.data.uid}`); localStorage.setItem("uid", `${res.data.uid}`);
localStorage.setItem("session_token", `${res.data.session}`); localStorage.setItem("session_token", `${res.data.session}`);
// localStorage.setItem("session", `${res.data.session}`); // localStorage.setItem("session", `${res.data.session}`);
dispatch(updateUserDetails(res.data)); dispatch(updateUserDetails({...res.data, loggedIn:true}));
setTimeout(() => { setTimeout(() => {
navigate("/", { replace: true }); navigate("/", { replace: true });
setLoginLoading(false); setLoginLoading(false);
@@ -207,11 +207,11 @@ export default function Login() {
</div> </div>
{/* switch login component */} {/* switch login component */}
<div className="flex justify-start items-end"> <div className="flex justify-start items-center gap-3">
<button <button
name="full" name="full"
className={`px-2 py-1 w-[100px] text-left h-[40px] text-lg font-bold text-[#4687ba] hover:text-[#009ef7] tracking-wide transition outline-none border-2 border-b-0 border-r-0 border-[#4687ba] ${ className={`login-type-btn px-4 py-1 rounded-t-[3px] transition duration-200 ${
loginType=='full' && "border-r-2 h-[45px]" loginType=='full' ? "bg-white text-[#000] border-t-[3px] border-[#4687ba]" : "bg-[#4687ba] text-white"
}`} }`}
onClick={handleLoginType} onClick={handleLoginType}
> >
@@ -219,8 +219,8 @@ export default function Login() {
</button> </button>
<button <button
name="family" name="family"
className={`px-2 py-1 w-[100px] text-left h-[40px] text-lg font-bold text-[#4687ba] hover:text-[#009ef7] tracking-wide transition outline-none border-2 border-b-0 border-l-0 border-[#4687ba] ${ className={`login-type-btn px-4 py-1 rounded-t-[3px] transition duration-200 ${
loginType=='family' && "border-l-2 h-[45px]" loginType=='family' ? "bg-white text-[#000] border-t-[3px] border-[#4687ba]" : "bg-[#4687ba] text-white"
}`} }`}
onClick={handleLoginType} onClick={handleLoginType}
> >
+4
View File
@@ -937,4 +937,8 @@ TODO: Responsive ===========================
/* TO REMOVE SLIDER COMPONENT FROM CENTRALIZED */ /* TO REMOVE SLIDER COMPONENT FROM CENTRALIZED */
.slider-left .slick-slider .slick-track{ .slider-left .slick-slider .slick-track{
margin: 0; margin: 0;
}
.login-type-btn{
box-shadow: 0 0 0.8rem #00000080;
} }
+7 -8
View File
@@ -18,6 +18,8 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
const { jobListTable } = useSelector((state) => state.tableReload); const { jobListTable } = useSelector((state) => state.tableReload);
const { userDetails:{loggedIn} } = useSelector((state) => state?.userDetails); // CHECKS IF LOGGEDIN IS TRUE
useEffect(() => { useEffect(() => {
//Removing Data stored at localStorage after session expires //Removing Data stored at localStorage after session expires
const expireSession = () => { const expireSession = () => {
@@ -68,7 +70,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
}, [resetTime]); }, [resetTime]);
useEffect(() => { useEffect(() => {
if (!isLogin.status) { if (!loggedIn) {
const loadProfile = () => { const loadProfile = () => {
// function to load user profile // function to load user profile
setIsLogin({ loading: true, status: false }); setIsLogin({ loading: true, status: false });
@@ -80,7 +82,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
return; return;
} }
setLoadProfileDetails(res.data); setLoadProfileDetails(res.data);
dispatch(updateUserDetails(res.data)); dispatch(updateUserDetails({...res.data, loggedIn:true}));
setIsLogin({ loading: false, status: true }); setIsLogin({ loading: false, status: true });
}) })
.catch((error) => { .catch((error) => {
@@ -134,13 +136,10 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
}); });
},[]) },[])
return isLogin.loading ? ( return isLogin.loading && !loggedIn ? (
<LoadingSpinner size="32" color="sky-blue" height="h-screen" /> <LoadingSpinner size="32" color="sky-blue" height="h-screen" />
) : // Stills needs fixing ) :
// <div className="h-screen m-auto"> !isLogin.status && !loggedIn ? (
// <img src={WrenchBoard} alt="wrenchboard" className="h-10" />
// </div>
!isLogin.status ? (
<Navigate to={redirectPath} replace /> <Navigate to={redirectPath} replace />
) : ( ) : (
children || <Outlet /> children || <Outlet />