()
| 4 | import RedirectTemplate from "./RedirectTemplate"; |
| 5 | |
| 6 | const RedirectSharedGraph: FC = () => { |
| 7 | const { uid: sharedGraphID } = useParams<{ uid: string }>(); |
| 8 | const { isAuthenticated, isLoading, user } = useAuthState(); |
| 9 | |
| 10 | const userID = useMemo(() => { |
| 11 | return user ? user.uid : ""; |
| 12 | }, [user]); |
| 13 | |
| 14 | const navigate = useNavigate(); |
| 15 | |
| 16 | useEffect(() => { |
| 17 | // If the user is loading, it does nothing |
| 18 | if (isLoading) { |
| 19 | return; |
| 20 | } |
| 21 | |
| 22 | sessionStorage.removeItem("focusedAddressData"); |
| 23 | |
| 24 | // If the user is authenticated, it redirects to the graph on user account, otherwise, it redirects to the public graph |
| 25 | if (isAuthenticated) { |
| 26 | navigate(`/${userID}/graph/${sharedGraphID}`); |
| 27 | } else { |
| 28 | navigate(`/public/graph/${sharedGraphID}`); |
| 29 | } |
| 30 | |
| 31 | }, [isLoading, userID]) |
| 32 | |
| 33 | return <RedirectTemplate title="Redirecting to the graph..." />; |
| 34 | }; |
| 35 | |
| 36 | export default RedirectSharedGraph; |
nothing calls this directly
no test coverage detected