All files / components/contact ContactProvince.tsx

83.33% Statements 5/6
0% Branches 0/1
66.66% Functions 2/3
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 41 42 43 441x       1x                 2x                                       2x                    
import Markdown from 'markdown-to-jsx'
import {
  ContactProvinceRow,
  ContactProvinceRowProps,
} from './ContactProvinceRow'
 
export interface ContactProvinceProps {
  title: string
  intro: string
  id: string
  details: ContactProvinceRowProps[]
}
 
export const ContactProvince = ({
  title,
  intro,
  id = 'mscaPlaceholder',
  details,
}: ContactProvinceProps) => {
  return (
    <div className="max-w-4xl pb-2 md:pb-4" id={id}>
      <h2 className="py-4 font-display text-4xl font-bold text-gray-darker md:py-6">
        {title}
      </h2>
      <div className="pb-4 text-xl text-gray-darker [&_ul]:ml-4 [&_ul]:list-inside [&_ul]:list-disc">
        <Markdown>{intro}</Markdown>
      </div>
      {/* Ensure provinces are sorted alphabetically regardless of language */}
      {details
        .sort(function (a, b) {
          return a.title.toLowerCase().localeCompare(b.title.toLowerCase())
        })
        .map((item) => (
          <ContactProvinceRow
            key={item.id}
            id={item.id}
            items={item.items}
            title={item.title}
          />
        ))}
    </div>
  )
}