Passed
Pull Request — develop (#758)
by Kevin Van
08:17 queued 04:36
created

src/components/Lineup.tsx   A

Complexity

Total Complexity 14
Complexity/F 0

Size

Lines of Code 33
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 14
eloc 27
mnd 14
bc 14
fnc 0
dl 0
loc 33
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import { LineupPlayer, LineupProps, LineupStaff } from "../Types/Lineup"
2
import "./Lineup.scss"
3
import PlayerTeaser from "./PlayerTeaser"
4
import React from "react"
5
6
const isPlayer = (object: LineupPlayer | LineupStaff): object is LineupPlayer => `field_shirtnumber` in (object || {})
7
8
const Lineup = ({ title = ``, lineup }: LineupProps) => {
9
  return (
10
    <section className="team__lineup__section">
11
      {title && <h2 className="after-border">{title}</h2>}
12
      <ul>
13
        {lineup?.map((player, i) => {
14
          return (
15
            <li className={`team__lineup__item`} key={i}>
16
              <PlayerTeaser
17
                url={player?.path?.alias || ``}
18
                position={
19
                  (isPlayer(player) ? player?.field_shirtnumber?.toString() : player?.field_position_short) || ``
20
                }
21
                first_name={player?.field_firstname || ``}
22
                last_name={player?.field_lastname || ``}
23
                picture={player?.relationships?.field_image?.localFile?.childImageSharp?.gatsbyImageData}
24
              />
25
            </li>
26
          )
27
        })}
28
      </ul>
29
    </section>
30
  )
31
}
32
export default Lineup
33