g1t/apps/web/app/lib/registration.ts

18 lines558 bytesCodeBlame
1import { useRouteLoaderData } from "react-router";
2
3import { signUpCopy } from "./invites";
4
5/**
6 * Whether g1t.sh is invite-only, from the root loader. Invite-only when the
7 * root loader has not answered: no page should offer an open sign-up that
8 * is not there.
9 */
10export function useInviteOnly(): boolean {
11 const root = useRouteLoaderData("root") as { inviteOnly?: boolean } | undefined;
12 return root?.inviteOnly ?? true;
13}
14
15/** What the sign-up buttons say on this page. */
16export function useSignUpCopy() {
17 return signUpCopy(useInviteOnly());
18}