Passed
Push — feature/full-redesign ( 58f6d4...ff7e17 )
by Kevin Van
04:32
created

src/components/Player.tsx   A

Complexity

Total Complexity 6
Complexity/F 6

Size

Lines of Code 30
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 26
mnd 5
bc 5
fnc 1
dl 0
loc 30
rs 10
bpm 5
cpm 6
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A Player.tsx ➔ getData 0 3 1
1
import axios from "axios"
2
import React, { useEffect, useState } from "react"
3
import { useSiteMetaData } from "../hooks/use-site-metadata"
4
import { PlayerProps, PlayerStatsDataObject } from "../Types/Player"
5
6
const PlayerDetail = ({ player }: PlayerProps) => {
7
  const [data, setData] = useState<PlayerStatsDataObject[]>([])
8
  const { kcvvPsdApi } = useSiteMetaData()
9
  const playerId = player.field_vv_id
10
11
  useEffect(() => {
12
    async function getData() {
13
      const response = await axios.get(`${kcvvPsdApi}/stats/player/${playerId}`)
14
      setData(response.data)
15
    }
16
    getData()
17
  }, [kcvvPsdApi, playerId])
18
19
  const team = player?.relationships?.node__team || []
20
  const articles = player?.relationships?.node__article || []
21
22
  return (
23
    <>
24
      <article className="player__details">{player?.title}</article>
25
    </>
26
  )
27
}
28
29
export default PlayerDetail
30