LoginPage.tsx (1246B)
1 import './LoginPage.scss'; 2 import Login from '../components/login/login'; 3 import { memo, useContext, useEffect, useState } from 'react'; 4 import { MatrixContext } from '../app/sdk/client'; 5 import { SDKError } from '../app/sdk/utils'; 6 7 const LoginPage = memo(() => { 8 const matrixClient = useContext(MatrixContext); 9 const [loading, setLoading] = useState(true) 10 11 useEffect(() => { 12 if (loading) { 13 // Ensure logout worked 14 matrixClient.logout().then((error) => { 15 if (error instanceof SDKError) { 16 console.error(error) 17 } 18 setLoading(false) 19 }); 20 } 21 }, [loading, matrixClient]) 22 23 if (loading) { 24 return ( 25 <div className="flex flex-col items-center justify-center min-h-screen bg-img"> 26 <div className="flex flex-col rounded-md shadow p-4 bg-white gap-2 min-w-[30rem]"> 27 <h1 className="text-2xl font-bold text-center">Loading...</h1> 28 </div> 29 </div> 30 ); 31 } 32 33 return ( 34 <div className="flex flex-col items-center justify-center min-h-screen bg-img"> 35 <Login /> 36 </div> 37 ); 38 }) 39 40 export default LoginPage;