Skip to main content

Pages


LoginPagesrc/pages/login.tsx

/login. Submits credentials via authClient.signIn.email. Navigates to /dashboard on success, alerts the error message on failure.

State

FieldTypeDescription
emailstringEmail input value. Init: "".
passwordstringPassword input value. Init: "".
loadingbooleanNever set to true in the current implementation. Reserved for a loading indicator.

handleLogin(): Promise<void>

Calls authClient.signIn.email with current state.

Preconditions:

  • email is a valid email format.
  • password is non-empty.

Postconditions (success): router.push("/dashboard"). Session cookie set.

Postconditions (failure): alert(ctx.error.message). No navigation.

Throws: None. Errors surface through onError.

data-testid attributes

data-testidElementDescription
email-login<input type="email">Email field.
password-login<input type="password">Password field.
login-button<button type="submit">Submit. Disabled when loading is true.

SignUpPagesrc/pages/signup.tsx

/signup. Registers a new account via authClient.signUp.email. Navigates to /dashboard on success, alerts on failure.

State

FieldTypeDescription
emailstringEmail input value. Init: "".
passwordstringPassword input value. Init: "".
namestringDisplay name input value. Init: "".
loadingbooleanNever set to true in the current implementation. Reserved for a loading indicator.

handleSignUp(): Promise<void>

Calls authClient.signUp.email with current state.

Preconditions:

  • email is a valid email format and not already registered.
  • password is at least 8 characters (enforced server-side).
  • name is non-empty.

Postconditions (success): User record created in DB. router.push("/dashboard"). Session cookie set.

Postconditions (failure): alert(ctx.error.message). No record created. No navigation.

Throws: None. Errors surface through onError.

data-testid attributes

data-testidElementDescription
name-signup<input type="text">Display name field.
email-signup<input type="email">Email field.
password-signup<input type="password">Password field.
signup-button<button type="submit">Submit. Disabled when loading is true.

DashboardPagesrc/pages/dashboard/index.tsx

/dashboard. Protected page. Renders a welcome message and a sign-out button. Redirects to /login if unauthenticated.

State

FieldTypeDescription
sessionSession | nullFrom authClient.useSession().
isPendingbooleantrue while the initial session fetch is in flight.
errorError | nullNon-null only if the session fetch itself failed (not just unauthenticated).

Auth guard

useEffect runs when isPending or session changes. Once isPending is false, if session is null, calls router.push("/login"). This is a client-side guard only. proxy.ts handles the server-side optimistic redirect for the same route. Both are required.

Render states

ConditionOutput
isPending === true<p>Loading...</p>
isPending === false && session === nullnull (redirect in-flight)
isPending === false && session !== nullWelcome heading + Sign Out button

Sign Out button

Calls authClient.signOut(). Deletes session from DB and clears cookie. Handled internally by BetterAuth.


FindPartnerPagesrc/pages/findPartnerPage.tsx

Composition of HeaderSimple, PartnerSearch, and StatsGroup in a full-viewport flex column. No props. No API calls. No session checks.

Layout

A Stack with h="100vh" and gap={0}:

RegionComponentCSS behavior
TopHeaderSimpleNatural height.
MiddlePartnerSearch in Boxflex: 1 — fills remaining space.
BottomStatsGroupNatural height.

Props passed to children

ChildProps
HeaderSimplelinks={["Time", "Players", "Tournament"]}, title="Code BattleGrounds"
PartnerSearch(none)
StatsGroup(none)