All files / src/features/legal/content index.ts

80% Statements 4/5
100% Branches 0/0
75% Functions 3/4
80% Lines 4/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                                    3x           17x                     4x 48x      
import type { LegalDocumentId } from '@/shared/legal'
 
import { privacyPtBR } from './privacy.pt-BR'
import { termsPtBR } from './terms.pt-BR'
import type { LegalContent } from './types'
 
export { BINDING_LOCALE } from './types'
export type { LegalContent, LegalSection } from './types'
 
/**
 * The one place that maps a document to its text.
 *
 * There is a single locale on purpose. The document is governed by Brazilian
 * law and binds in Portuguese; publishing an English and a Spanish "version"
 * would mean three texts to review and three chances for them to disagree about
 * what was agreed to. The other locales render this text with a notice saying
 * which language binds — which is what the page does, rather than pretending.
 */
const CONTENT: Record<LegalDocumentId, LegalContent> = {
  privacy: privacyPtBR,
  terms: termsPtBR,
}
 
export function legalContent(documentId: LegalDocumentId): LegalContent {
  return CONTENT[documentId]
}
 
/**
 * How many sections still need a human before the document can leave `draft`.
 *
 * Used by the page to say so out loud, and by a test to keep `status:
 * 'in-force'` and an unreviewed section from ever coexisting — that pairing is
 * the failure this whole arrangement exists to prevent.
 */
export function sectionsAwaitingReview(documentId: LegalDocumentId): string[] {
  return legalContent(documentId)
    .sections.filter((section) => section.needsReview)
    .map((section) => section.id)
}