All files / src/features/properties housing-company-line.ts

100% Statements 8/8
100% Branches 6/6
100% Functions 1/1
100% Lines 8/8

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                          31x 31x 2x   31x 2x   31x 2x   31x    
// The housing company line on the flat details page's header card: the
// details that are filled in, joined with " · " (openspec: properties,
// "Housing company details of a flat").
import { m } from '#/paraglide/messages.js'
import type { PropertyDetails } from './property'
 
/** Empty when the flat has none of the three details. */
export function housingCompanyLine(
  details: Pick<
    PropertyDetails,
    'housingCompanyName' | 'apartmentNumber' | 'businessId'
  >,
): string {
  const parts: string[] = []
  if (details.housingCompanyName) {
    parts.push(details.housingCompanyName)
  }
  if (details.apartmentNumber) {
    parts.push(m.property_apartment_line({ number: details.apartmentNumber }))
  }
  if (details.businessId) {
    parts.push(m.property_business_id_line({ id: details.businessId }))
  }
  return parts.join(' · ')
}