Skip to content

The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.

1.6 KB
Raw Blame
// The centred page (AuthPage) on screens someone reaches signed in: checking out, an invitation, a passkey, no
// workspace yet, the sign-up's last step. Like every setup page's top bar (SetupAccountMenu), it has the account menu
// at the top right: another workspace or the partner area, and Sign out. Nobody signed in yet (the sign-up's first
// steps, an invitation before signing in): no menu. None of these pages is a workspace's own, so the menu lists every
// workspace, the one the tab has open too (`away`): back from a partner's Checkout, its client workspace is a click away.
import { useT } from '@linedesk/i18n/react'
import type { ReactNode } from 'react'
import { auth } from '../auth.ts'
import { AuthPage, Spinner } from '../ui/kit.tsx'
import { SetupAccountMenu } from './SetupAccountMenu.tsx'

/** `install`: the install's branding even in a white-label partner's client workspace (a partner's own page). */
export function SignedInAuthPage({ children, install }: { children: ReactNode; install?: boolean }) {
  const signedIn = !!auth.useSession().data?.user
  return (
    <AuthPage corner={signedIn ? <SetupAccountMenu away /> : undefined} install={install}>
      {children}
    </AuthPage>
  )
}

/**
 * The one wait line of every card before setup (sign-in, sign-up, an invitation, a Checkout coming back): a small
 * spinner and a quiet line, "Connecting…" unless the card says what it waits for. Setup screens keep their skeletons.
 */
export function WaitLine({ text }: { text?: string }) {
  const t = useT()
  return (
    <p className="auth-wait" role="status">
      <Spinner />
      {text ?? t('auth.connecting')}
    </p>
  )
}