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.
TypeScript ai-receptionistanswering-serviceappointment-bookinglivekitlocal-firstmcpopen-sourceself-hostedsiptelephonytypescriptvoice-agentvoice-ai
Billing › Review and Stripe events: no second title on the card (PR 1903)
Janikb336893d2f61
diff --git a/apps/web/src/admin/AdminMode.tsx b/apps/web/src/admin/AdminMode.tsxindex 2282aa1a..26575c48 100644--- a/apps/web/src/admin/AdminMode.tsx+++ b/apps/web/src/admin/AdminMode.tsx@@ -2,35 +2,35 @@// (SettingsLayout: title bar, sections at the left, one column), with a back button where the inbox's menu button is.// Sections are routes (`#admin/<section>[/<id>]`). Esc steps back: from a detail to its list, from a list out of// admin mode to where the user was.-import { PasskeyStepUpHost } from './PasskeyStepUp.tsx'++import { type MessageKey, msg } from '@linedesk/i18n'+import { useFormat, useT } from '@linedesk/i18n/react'import { type ReactNode, useCallback, useEffect, useRef, useState } from 'react'+import type { AdminSecondFactor } from '../auth.ts'+import { refreshQuery, useQuery } from '../cachedQuery.ts'+import { i18n } from '../i18n/index.tsx'import { Toast } from '../shell/Toast.tsx'+import { HelpTip } from '../ui/form.tsx'+import { helpContent } from '../ui/HelpTip.tsx'import { Button, Icon } from '../ui/kit.tsx'-import { SettingsLayout } from '../ui/SettingsLayout.tsx'-import { useFormat, useT } from '@linedesk/i18n/react'-import { type MessageKey, msg } from '@linedesk/i18n'-import { i18n } from '../i18n/index.tsx'import { Loading, SkeletonRows } from '../ui/LoadStates.tsx'+import { SettingsLayout } from '../ui/SettingsLayout.tsx'import { StatusMark } from '../ui/StatusMark.tsx'import type { ListKeys } from './AdminList.tsx'-import { ADMIN_HEALTH, type HealthPart, loadHealth, watchAdminSignIn } from './api.ts'-import type { AdminSecondFactor } from '../auth.ts'-import { SecondFactorPrompt } from './SecondFactorPrompt.tsx'-import { SecondPasskeyNote } from './SecondPasskeyNote.tsx'import { AuditLog } from './AuditLog.tsx'-import { Billing, billingPartTitle, useBillTitle } from './Billing.tsx'-import { SignupAccessPage } from './SignupAccessPage.tsx'-import { refreshQuery, useQuery } from '../cachedQuery.ts'-import { errorText, type Notify } from './notify.ts'-import { AtRisk } from './Onboarding.tsx'+import { ADMIN_HEALTH, type HealthPart, loadHealth, watchAdminSignIn } from './api.ts'+import { Billing, billingPartIntro, billingPartTitle, useBillTitle } from './Billing.tsx'+import { BrandingSettings } from './Branding.tsx'+import { Features } from './Features.tsx'import { Funnel } from './Funnel.tsx'import { NeedsYou } from './NeedsYou.tsx'+import { errorText, type Notify } from './notify.ts'+import { AtRisk } from './Onboarding.tsx'import { Overview } from './Overview.tsx'import { Partners } from './Partners.tsx'+import { PasskeyStepUpHost } from './PasskeyStepUp.tsx'import { Providers } from './Providers.tsx'import { useProviderStatus } from './providerStatus.ts'-import { useAdminData } from './useAdminData.ts'-import { StatusCard } from './StatusCard.tsx'import {adminSections,isListPlace,@@ -41,12 +41,15 @@ import {tabSwitchesSection,useAdminPlace,} from './route.ts'-import { Features } from './Features.tsx'+import { SecondFactorPrompt } from './SecondFactorPrompt.tsx'+import { SecondPasskeyNote } from './SecondPasskeyNote.tsx'import { CallQualityPage } from './Settings.tsx'+import { SignupAccessPage } from './SignupAccessPage.tsx'+import { StatusCard } from './StatusCard.tsx'import { SystemPrompt } from './SystemPrompt.tsx'-import { BrandingSettings } from './Branding.tsx'import { Usage } from './Usage.tsx'import { UserDetail, UsersList } from './UsersPage.tsx'+import { useAdminData } from './useAdminData.ts'import {NewWorkspaceButton,useWorkspaceView,@@ -204,6 +207,8 @@ export function AdminMode({ currentUserId, onExit }: Props) {// The crumb names where it goes: a bill goes up to Billing › Bills, everything else to its section.const up = placeUp(place)const crumb = (place.section === 'billing' && billingPartTitle(t, up?.id ?? null)) || t(meta.label)+ // A part of Billing that is one card (Review, Stripe events) has its line and help here, not as a second title.+ const intro = place.section === 'billing' ? billingPartIntro(t, place.id) : nullconst viewerWorkspaces = new Set(lists?.users.find(u => u.id === currentUserId)?.workspaces.map(w => w.id))function page(): ReactNode {@@ -229,7 +234,9 @@ export function AdminMode({ currentUserId, onExit }: Props) {)// Billing loads its own rows (the bills, the Stripe events), and says itself when a bill is not found.if (place.section === 'billing')- return <Billing id={place.id} onOpen={open} notify={notify} keysRef={listKeys} data={data} />+ return (+ <Billing id={place.id} onOpen={open} notify={notify} keysRef={listKeys} data={data} headActions={headActions} />+ )// Pages that load their own data never wait for the lists or the providers.if (place.section === 'branding') return <BrandingSettings />if (place.section === 'features') return <Features focus={place.id} />@@ -358,7 +365,14 @@ export function AdminMode({ currentUserId, onExit }: Props) {<Icon name="left" size={13} />{crumb}</button>- <h2>{detailTitle}</h2>+ <div className="adm-head-row">+ <h2>+ {detailTitle}+ {intro && <HelpTip {...helpContent(intro.help)} />}+ </h2>+ <div className="adm-head-actions" ref={setHeadActions} />+ </div>+ {intro && <p>{intro.description}</p>}</>) : (<>diff --git a/apps/web/src/admin/Billing.tsx b/apps/web/src/admin/Billing.tsxindex af41ab45..c0ad85dd 100644--- a/apps/web/src/admin/Billing.tsx+++ b/apps/web/src/admin/Billing.tsx@@ -26,6 +26,7 @@ import { SIGNUP_RULE_RANGES, type SignupCountRule } from '@linedesk/db/types'import { type MessageKey, msg } from '@linedesk/i18n'import { T, useT } from '@linedesk/i18n/react'import { type FormEvent, Fragment, type ReactNode, useContext, useEffect, useMemo, useState } from 'react'+import { createPortal } from 'react-dom'import { refreshQuery, setQueryData, useQuery } from '../cachedQuery.ts'import { fmt } from '../i18n/format.ts'import { AppLink, appLink, LinkButton } from '../ui/AppLink.tsx'@@ -211,9 +212,11 @@ type Props = {keysRef: { current: ListKeys | null }/** The admin data (null until it is read): the billing switch reads Stripe's keys from it. */data: AdminData | null+ /** The page header's actions slot: Stripe events puts its filter there. */+ headActions?: HTMLElement | null}-export function Billing({ id, onOpen, notify, keysRef, data }: Props) {+export function Billing({ id, onOpen, notify, keysRef, data, headActions }: Props) {const tab = billingTab(id)if (!tab) return <BillDetail id={id!} notify={notify} />switch (tab) {@@ -224,7 +227,7 @@ export function Billing({ id, onOpen, notify, keysRef, data }: Props) {case 'review':return <ReviewCard onOpen={onOpen} notify={notify} />case 'events':- return <EventsCard notify={notify} />+ return <EventsCard notify={notify} headActions={headActions ?? null} />case 'rules':return <RulesCard notify={notify} />case 'stripe':@@ -252,6 +255,19 @@ export function billingPartTitle(t: Translate, id: string | null): string | nullreturn tab && tab !== 'overview' ? t(TAB_LABELS[tab]) : null}+/**+ * The line under a part's title and its help, for the parts that are one card (Review, Stripe events): shown in the+ * page header, so the card does not repeat the title. Null for the other parts and for a bill.+ */+export function billingPartIntro(t: Translate, id: string | null): { description: string; help: string } | null {+ const tab = billingTab(id)+ if (tab === 'review')+ return { description: t('admin.bills.review.description'), help: t('admin.bills.review.radarHelp') }+ if (tab === 'events')+ return { description: t('admin.bills.events.descriptionShort'), help: t('admin.bills.events.description') }+ return null+}+// ---- Billing's own page: a line per part, under Money and Setup ----/** Billing at a glance (also the Overview's Needs you, NeedsYou.tsx). */@@ -461,12 +477,7 @@ function ReviewCard({ onOpen, notify }: { onOpen: (id: string) => void; notify:const [deciding, setDeciding] = useState<{ row: AdminReviewRow; decision: 'approve' | 'deny' } | null>(null)const rows = query.data ? [...query.data.held, ...query.data.newTrials] : []return (- <Card- title={t('admin.bills.review.title')}- description={t('admin.bills.review.description')}- help={t('admin.bills.review.radarHelp')}- className="adm-detail"- >+ <Card className="adm-detail"><Loadingwhat={t('admin.bills.review.title')}loading={!query.data}@@ -593,7 +604,7 @@ const FILTERS: Record<BillingEventFilter, MessageKey> = {}/** Stripe's events: Billing › Stripe events (`#admin/billing/events`; in the Audit log from LIN-747 to LIN-833). */-function EventsCard({ notify }: { notify: Notify }) {+function EventsCard({ notify, headActions }: { notify: Notify; headActions: HTMLElement | null }) {const t = useT()const [filter, setFilter] = useHashFilter(eventFilterOfHash, eventsHref)const query = useQuery(eventsKey(filter), loadEvents(filter))@@ -623,122 +634,121 @@ function EventsCard({ notify }: { notify: Notify }) {return t('admin.bills.events.queued', { type: event.type })}+ const filterSelect = (+ <Select+ value={filter}+ options={options}+ onChange={value => {+ setOlder(null)+ setFilter(value)+ }}+ label={t('admin.bills.events.filter.label')}+ size="sm"+ align="end"+ />+ )return (- <Card- title={t('admin.bills.events.title')}- description={t('admin.bills.events.descriptionShort')}- help={t('admin.bills.events.description')}- actions={- <Select- value={filter}- options={options}- onChange={value => {- setOlder(null)- setFilter(value)- }}- label={t('admin.bills.events.filter.label')}- size="sm"- align="end"- />- }- className="adm-detail"- >- <Loading- what={t('admin.bills.events.title')}- loading={!query.data}- error={query.error}- onRetry={() => void query.reload()}- skeleton={<SkeletonRows rows={4} columns={4} />}- >- {events.length ? (- <div className="adm-scroll">- <table className="adm-table adm-stack adm-events">- <thead>- <tr>- <th scope="col">{t('admin.bills.events.column.event')}</th>- <th scope="col">{t('admin.bills.events.column.state')}</th>- <th scope="col">{t('admin.bills.events.column.received')}</th>- <th scope="col" className="adm-num">- {t('admin.bills.events.column.attempts')}- </th>- <th scope="col">- <span className="sr-only">{t('admin.bills.column.actions')}</span>- </th>- </tr>- </thead>- <tbody>- {events.map(e => (- <tr key={e.id}>- <th scope="row" data-label={t('admin.bills.events.column.event')}>- <span className="adm-mono">{e.type}</span>- <span className="adm-sub adm-mono">- {e.id}- {!e.livemode && ` · ${t('admin.bills.events.test')}`}- </span>- {e.billId && (- <span className="adm-sub">- <AppLink to={`#admin/billing/${encodeURIComponent(e.billId)}`}>- {t('admin.bills.events.openBill')}- </AppLink>- </span>- )}- {e.lastError && e.state !== 'processed' && <span className="adm-sub">{e.lastError}</span>}+ <>+ {/* The filter sits next to the page title (its card has no title of its own); in a card while the header is not there. */}+ {headActions && createPortal(filterSelect, headActions)}+ <Card actions={headActions ? undefined : filterSelect} className="adm-detail">+ <Loading+ what={t('admin.bills.events.title')}+ loading={!query.data}+ error={query.error}+ onRetry={() => void query.reload()}+ skeleton={<SkeletonRows rows={4} columns={4} />}+ >+ {events.length ? (+ <div className="adm-scroll">+ <table className="adm-table adm-stack adm-events">+ <thead>+ <tr>+ <th scope="col">{t('admin.bills.events.column.event')}</th>+ <th scope="col">{t('admin.bills.events.column.state')}</th>+ <th scope="col">{t('admin.bills.events.column.received')}</th>+ <th scope="col" className="adm-num">+ {t('admin.bills.events.column.attempts')}+ </th>+ <th scope="col">+ <span className="sr-only">{t('admin.bills.column.actions')}</span></th>- <td data-label={t('admin.bills.events.column.state')}>- <Badge tone={EVENT_TONE[e.state]}>{t(EVENT_STATE[e.state])}</Badge>- </td>- <td data-label={t('admin.bills.events.column.received')}>- <Ago iso={e.receivedAt} />- </td>- <td className="adm-num" data-label={t('admin.bills.events.column.attempts')}>- {fmt().number(e.attempts)}- </td>- <td>- {e.state !== 'processed' && (- <Button- size="sm"- icon="restart"- title={t('admin.bills.events.reprocessTip')}- onClick={() => setReprocessing(e)}- >- {t('admin.bills.events.reprocess')}- </Button>- )}- </td></tr>- ))}- </tbody>- </table>- </div>- ) : filter === 'all' ? (- <p className="adm-notice">- <T k="admin.bills.events.emptyHow" values={{ link: appLink('#admin/providers/stripe') }} />- </p>- ) : (- <p className="adm-notice">- {t('admin.bills.events.empty')}{' '}- <LinkButton onClick={() => setFilter('all')}>{t('admin.bills.events.showAll')}</LinkButton>- </p>- )}- {next && (- <div>- <Button size="sm" variant="ghost" onClick={() => void more()}>- {t('admin.bills.events.older')}- </Button>- </div>+ </thead>+ <tbody>+ {events.map(e => (+ <tr key={e.id}>+ <th scope="row" data-label={t('admin.bills.events.column.event')}>+ <span className="adm-mono">{e.type}</span>+ <span className="adm-sub adm-mono">+ {e.id}+ {!e.livemode && ` · ${t('admin.bills.events.test')}`}+ </span>+ {e.billId && (+ <span className="adm-sub">+ <AppLink to={`#admin/billing/${encodeURIComponent(e.billId)}`}>+ {t('admin.bills.events.openBill')}+ </AppLink>+ </span>+ )}+ {e.lastError && e.state !== 'processed' && <span className="adm-sub">{e.lastError}</span>}+ </th>+ <td data-label={t('admin.bills.events.column.state')}>+ <Badge tone={EVENT_TONE[e.state]}>{t(EVENT_STATE[e.state])}</Badge>+ </td>+ <td data-label={t('admin.bills.events.column.received')}>+ <Ago iso={e.receivedAt} />+ </td>+ <td className="adm-num" data-label={t('admin.bills.events.column.attempts')}>+ {fmt().number(e.attempts)}+ </td>+ <td>+ {e.state !== 'processed' && (+ <Button+ size="sm"+ icon="restart"+ title={t('admin.bills.events.reprocessTip')}+ onClick={() => setReprocessing(e)}+ >+ {t('admin.bills.events.reprocess')}+ </Button>+ )}+ </td>+ </tr>+ ))}+ </tbody>+ </table>+ </div>+ ) : filter === 'all' ? (+ <p className="adm-notice">+ <T k="admin.bills.events.emptyHow" values={{ link: appLink('#admin/providers/stripe') }} />+ </p>+ ) : (+ <p className="adm-notice">+ {t('admin.bills.events.empty')}{' '}+ <LinkButton onClick={() => setFilter('all')}>{t('admin.bills.events.showAll')}</LinkButton>+ </p>+ )}+ {next && (+ <div>+ <Button size="sm" variant="ghost" onClick={() => void more()}>+ {t('admin.bills.events.older')}+ </Button>+ </div>+ )}+ </Loading>+ {reprocessing && (+ <ReasonDialog+ title={t('admin.bills.events.reprocessTitle', { type: reprocessing.type })}+ description={t('admin.bills.events.reprocessText')}+ submit={t('admin.bills.events.reprocess')}+ run={reason => reprocess(reprocessing, reason)}+ notify={notify}+ onClose={() => setReprocessing(null)}+ />)}- </Loading>- {reprocessing && (- <ReasonDialog- title={t('admin.bills.events.reprocessTitle', { type: reprocessing.type })}- description={t('admin.bills.events.reprocessText')}- submit={t('admin.bills.events.reprocess')}- run={reason => reprocess(reprocessing, reason)}- notify={notify}- onClose={() => setReprocessing(null)}- />- )}- </Card>+ </Card>+ </>)}