Files
accounted/components/settings/sections/index.ts
T
Jakob Wennberg 398c734b93 feat(whatsapp-inbox): intake extension with webhook, phone linking and receipt ack (#1338)
Webhook lifecycle: GET hub.challenge handshake (constant-time verify-token
compare); POST verifies X-Hub-Signature-256 over the RAW body before any
parse, Zod-parses the envelope, persists inbound rows (partial-unique wamid
= dedupe against Meta's up-to-7-day redelivery), acks 200 fast and defers
media processing via the after() idiom. Rejected and rate-limited content
always acks 200 and lands as skipped/error rows, never a retryable status.

Linking: the settings panel (Installningar -> WhatsApp) mints AC- one-time
codes (sha256 stored, 10 min TTL, single use, ambiguity-free alphabet); the
webhook consumes the code, binds phone to user (HMAC-peppered hash + AES-256-
GCM at rest) and confirms with M3. Keyword commands stopp/start/hjalp;
unknown senders get one throttled M1 greeting (1/h, 3/day) behind the
sender-quota RPC, with no media download and no content persistence.

Intake worker: atomic claim on the message row (the durable job record),
company resolution (default -> sole membership -> M6 fallback, no item),
per-company inbox quota (ack-and-drop, M17 once per 10 min per sender),
MIME allowlist, 10 MB stream-checked media download, exact sha256 duplicate
check, then the shared uploadAndExtract funnel (source 'whatsapp',
channel_context caption, whatsapp_message_id) and the M4 ack with extracted
merchant/total/date. Failures wrap to 'error' + error_message + one M18.

uploadAndExtract widened: source 'whatsapp', optional channelMeta + actorId;
email/upload paths behaviorally unchanged.

Deferred to PR4: burst debounce + combined ack (M5), in-chat company choice
(M6 buttons + 8h pin), clarifying questions M7-M10, interpret-answer LLM
call, sweep cron, retention cron.

Co-authored-by: Jakob Wennberg <jakob.wennberg@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-05 14:47:08 +02:00

77 lines
3.2 KiB
TypeScript

import type { ComponentType } from 'react'
import dynamic from 'next/dynamic'
import { SettingsLoadingSkeleton } from '../SettingsLoadingSkeleton'
const AccountSettingsContent = dynamic(() =>
import('./AccountSettingsContent').then((module) => ({ default: module.AccountSettingsContent })),
{ loading: SettingsLoadingSkeleton },
)
const CompanySettingsContent = dynamic(() =>
import('./CompanySettingsContent').then((module) => ({ default: module.CompanySettingsContent })),
{ loading: SettingsLoadingSkeleton },
)
const BookkeepingSettingsContent = dynamic(() =>
import('./BookkeepingSettingsContent').then((module) => ({ default: module.BookkeepingSettingsContent })),
{ loading: SettingsLoadingSkeleton },
)
const TaxSettingsContent = dynamic(() =>
import('./TaxSettingsContent').then((module) => ({ default: module.TaxSettingsContent })),
{ loading: SettingsLoadingSkeleton },
)
const SalarySettingsContent = dynamic(() =>
import('./SalarySettingsContent').then((module) => ({ default: module.SalarySettingsContent })),
{ loading: SettingsLoadingSkeleton },
)
const InvoicingSettingsContent = dynamic(() =>
import('./InvoicingSettingsContent').then((module) => ({ default: module.InvoicingSettingsContent })),
{ loading: SettingsLoadingSkeleton },
)
const TemplatesSettingsContent = dynamic(() =>
import('./TemplatesSettingsContent').then((module) => ({ default: module.TemplatesSettingsContent })),
{ loading: SettingsLoadingSkeleton },
)
const BankingSettingsContent = dynamic(() =>
import('./BankingSettingsContent').then((module) => ({ default: module.BankingSettingsContent })),
{ loading: SettingsLoadingSkeleton },
)
const AssistantSettingsContent = dynamic(() =>
import('./AssistantSettingsContent').then((module) => ({ default: module.AssistantSettingsContent })),
{ loading: SettingsLoadingSkeleton },
)
const ApiSettingsContent = dynamic(() =>
import('./ApiSettingsContent').then((module) => ({ default: module.ApiSettingsContent })),
{ loading: SettingsLoadingSkeleton },
)
const BillingSettingsContent = dynamic(() =>
import('./BillingSettingsContent').then((module) => ({ default: module.BillingSettingsContent })),
{ loading: SettingsLoadingSkeleton },
)
const WhatsAppSettingsContent = dynamic(() =>
import('./WhatsAppSettingsContent').then((module) => ({ default: module.WhatsAppSettingsContent })),
{ loading: SettingsLoadingSkeleton },
)
/**
* Single source of truth mapping a settings section id to the component that
* renders its content. Both the per-section route (`settings/<section>/page.tsx`,
* a thin wrapper) and the routed settings modal (`SettingsModal` → `SettingsShell`)
* resolve content through this map, so there is exactly one place a section's
* composition lives.
*/
export const SETTINGS_SECTIONS: Record<string, ComponentType> = {
account: AccountSettingsContent,
company: CompanySettingsContent,
bookkeeping: BookkeepingSettingsContent,
tax: TaxSettingsContent,
salary: SalarySettingsContent,
invoicing: InvoicingSettingsContent,
templates: TemplatesSettingsContent,
banking: BankingSettingsContent,
assistant: AssistantSettingsContent,
api: ApiSettingsContent,
billing: BillingSettingsContent,
whatsapp: WhatsAppSettingsContent,
}
export type SettingsSectionId = keyof typeof SETTINGS_SECTIONS