import { useEffect, useState } from 'react'; import { useMsalLogin } from '../../auth/Hooks/use-msal-login'; import { useUserInfo } from '../../auth/Hooks/use-user-info'; import { useNavigate } from 'react-router-dom'; // Use useNavigate instead of useHistory function RegisterOrganisation() { const { login, isLoggingIn, error } = useMsalLogin(); const user = useUserInfo(); console.log(user); const navigate = useNavigate(); // Initialize useNavigate hook const [userName, setUserName] = useState(""); const [userEmail, setUserEmail] = useState(""); const [userAzureID, setUserAzureID] = useState(""); const [tenantID, setTenantID] = useState(""); const [organisationName, setOrganisationName] = useState(""); const [userPosition, setUserPosition] = useState(""); const [organisationSize, setOrganisationSize] = useState(""); const [country, setCountry] = useState(""); const [phoneNumber, setPhoneNumber] = useState(""); useEffect(() => { if (user?.name) {setUserName(user.name);} if (user?.email) {setUserEmail(user.email);} if (user?.oid) {setUserAzureID(user.oid);} if (user?.tenantId) {setTenantID(user.tenantId);} }, [user]); const handleRedirectToPricingSetup = () => { // Use navigate to redirect to the pricing setup page navigate('/register-pricing', { state: { user: { userName, userEmail, userAzureID, userPosition, phoneNumber }, organisation: { organisationName, organisationSize, country, tenantID, } } }); }; return (
Great! Please log in with MSAL:
{error &&Login error: {error}
}Hello {user.name}
These are your information:
Now, please enter your organisation's information: