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.

3.8 KB
Raw Blame
// Server admin › Sign-up & access (the nav groups, 2026-11-24; lines as on Features since 2026-11-26): under Sign-up
// the self-serve switch (a line with its switch), the countries and the limits; under Emails the setup emails and the
// personal email from a founder. Each is one line with its state; Change opens its card in place.
import { useT } from '@linedesk/i18n/react'
import { useQuery } from '../cachedQuery.ts'
import { FeatureLine, LineGroup, type LineState, onOff, useOpenLines } from '../ui/FeatureLine.tsx'
import { KEPT, loadSelfServe, SELF_SERVE, SelfServeCard, SignupRulesCard } from './Billing.tsx'
import type { Notify } from './notify.ts'
import {
  FOUNDER_EMAIL,
  FounderEmail,
  loadFounderEmail,
  loadSetupEmails,
  SETUP_EMAILS,
  SetupEmails,
} from './Onboarding.tsx'
import { loadSignupAccess, SIGNUP_ACCESS, SignupAccess } from './SignupAccess.tsx'

type LineId = 'countries' | 'limits' | 'setupEmails' | 'founderEmail'

export function SignupAccessPage({ notify }: { notify: Notify }) {
  const t = useT()
  const line = useOpenLines<LineId>()
  const selfServe = useQuery(SELF_SERVE, loadSelfServe, KEPT).data
  const access = useQuery(SIGNUP_ACCESS, loadSignupAccess).data
  const setupEmails = useQuery(SETUP_EMAILS, loadSetupEmails).data
  const founder = useQuery(FOUNDER_EMAIL, loadFounderEmail).data

  const open = access?.countries.filter(c => c.mode === 'open').length ?? 0
  const invited = access?.countries.filter(c => c.mode === 'invited').length ?? 0
  const countriesState: LineState = access
    ? {
        text: invited
          ? t('admin.signupPage.countries.stateInvited', { open, invited })
          : t('admin.signupPage.countries.state', { open }),
        on: open + invited > 0,
        value: true,
      }
    : null
  // On without Turnstile's keys checks nobody (and closes sign-up): a warning, never "on" as if it worked.
  const limitsState: LineState = selfServe
    ? !selfServe.rules.turnstile
      ? { text: t('admin.signupPage.limits.botCheckOff'), on: false, danger: true }
      : selfServe.turnstileReady
        ? { text: t('admin.signupPage.limits.botCheckOn'), on: true }
        : { text: t('admin.signupPage.limits.botCheckNoKeys'), on: false, warning: true }
    : null
  const founderState: LineState = founder
    ? founder.sender
      ? { text: founder.sender.name, on: true, value: true }
      : { text: t('admin.features.off'), on: false }
    : null
  return (
    <>
      <LineGroup>{t('admin.signupPage.group.signup')}</LineGroup>
      <SelfServeCard notify={notify} />
      <FeatureLine
        title={t('admin.system.signupAccess.title')}
        summary={t('admin.signupPage.countries.summary')}
        help={t('admin.system.signupAccess.help')}
        state={countriesState}
        {...line('countries')}
      >
        <SignupAccess />
      </FeatureLine>
      <FeatureLine
        title={t('admin.bills.signupRules.title')}
        summary={t('admin.signupPage.limits.summary')}
        state={limitsState}
        {...line('limits')}
      >
        <SignupRulesCard notify={notify} />
      </FeatureLine>
      <LineGroup>{t('admin.signupPage.group.emails')}</LineGroup>
      <FeatureLine
        title={t('admin.onboarding.setupEmails')}
        summary={t('admin.signupPage.setupEmails.summary')}
        help={t('admin.onboarding.setupEmailsHelp', { partner: setupEmails?.partnerDirectoryUrl ? 'yes' : 'no' })}
        state={onOff(setupEmails?.on, t)}
        {...line('setupEmails')}
      >
        <SetupEmails />
      </FeatureLine>
      <FeatureLine
        title={t('admin.onboarding.founderEmail')}
        summary={t('admin.signupPage.founderEmail.summary')}
        help={t('admin.onboarding.founderEmailHelp')}
        state={founderState}
        {...line('founderEmail')}
      >
        <FounderEmail />
      </FeatureLine>
    </>
  )
}