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

Player.tsx ➔ getData   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 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