()
| 10 | import { removeAuthToken } from "../modules/auth"; |
| 11 | |
| 12 | function UserInvite() { |
| 13 | const navigate = useNavigate(); |
| 14 | const fetchRef = useRef(null); |
| 15 | const dispatch = useDispatch(); |
| 16 | const user = useSelector(selectUser); |
| 17 | const { isDark } = useTheme(); |
| 18 | |
| 19 | useEffect(() => { |
| 20 | if (user.id && !fetchRef.current) { |
| 21 | fetchRef.current = true; |
| 22 | redirectUser("login"); |
| 23 | } |
| 24 | }, [user]); |
| 25 | |
| 26 | const redirectUser = async (route) => { |
| 27 | const params = new URLSearchParams(window.location.search); |
| 28 | const token = params.get("token"); |
| 29 | |
| 30 | removeAuthToken(); |
| 31 | await dispatch(clearUser(true)); |
| 32 | |
| 33 | setTimeout(() => { |
| 34 | if (route === "login") { |
| 35 | navigate(`/login?inviteToken=${token}`); |
| 36 | } else { |
| 37 | navigate(`/signup?inviteToken=${token}`); |
| 38 | } |
| 39 | }, 100); |
| 40 | }; |
| 41 | |
| 42 | return ( |
| 43 | <div className="min-h-screen bg-surface-secondary px-6 py-6 sm:px-8 sm:py-8"> |
| 44 | <div className="mx-auto flex min-h-[calc(100vh-5rem)] max-w-5xl flex-col justify-between gap-12"> |
| 45 | <header className="flex flex-col items-center justify-center"> |
| 46 | <Link to="/"> |
| 47 | <img |
| 48 | src={isDark ? cbLogoDark : cbLogoLight} |
| 49 | className="w-[150px]" |
| 50 | alt="Chartbrew logo" |
| 51 | /> |
| 52 | </Link> |
| 53 | </header> |
| 54 | |
| 55 | <main className="flex flex-1 items-center justify-center"> |
| 56 | <div className="w-full max-w-md"> |
| 57 | <div className="space-y-2 text-center"> |
| 58 | <h1 className="text-balance text-3xl font-semibold tracking-tight text-foreground font-tw"> |
| 59 | You've been invited to join Chartbrew |
| 60 | </h1> |
| 61 | <p className="text-sm text-muted"> |
| 62 | Please select an option below |
| 63 | </p> |
| 64 | </div> |
| 65 | |
| 66 | <div className="h-8" /> |
| 67 | |
| 68 | <div className="space-y-3"> |
| 69 | <Button |
nothing calls this directly
no test coverage detected