I want to redirect a user to the onboarding page if he has no organization attached to his account. But if he has an organization attached to his account, he should proceed directly to the homepage. I'm using Redux toolkit. I tried checking for this condition in the homepage but it doesn't work. How do I go about this?
const { organization } = useSelector((state) => state.organization);
const navigate = useNavigate();
useEffect(() => {
if (!organization) {
navigate('/auth/onboarding')
} else {
navigate('/admin/dashboard')
}
}, [organization])