Passed
Push — feature/full-redesign ( 15ceb9...e2df01 )
by Kevin Van
04:43
created

src/components/Lineup.tsx   A

Complexity

Total Complexity 14
Complexity/F 0

Size

Lines of Code 32
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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