1
|
|
|
import axios from "axios" |
2
|
|
|
import { graphql, Link } from "gatsby" |
3
|
|
|
import { GatsbyImage, getSrc, StaticImage } from "gatsby-plugin-image" |
4
|
|
|
import React, { useEffect, useState } from "react" |
5
|
|
|
import { Card } from "../components/Card" |
6
|
|
|
import Icon from "../components/Icon" |
7
|
|
|
import { Seo } from "../components/Seo" |
8
|
|
|
import { useSiteMetaData } from "../hooks/use-site-metadata" |
9
|
|
|
import Layout from "../layouts" |
10
|
|
|
import moment from "moment" |
11
|
|
|
import "moment-timezone" |
12
|
|
|
import "moment/locale/nl-be" |
13
|
|
|
import { mapPositionCode } from "../scripts/helper" |
14
|
|
|
import { |
15
|
|
|
PlayerQuery, |
16
|
|
|
PlayerStatsDataObject, |
17
|
|
|
PlayerStatsDataResponseObject, |
18
|
|
|
PlayerStatsReportsResponseObject, |
19
|
|
|
StaffQuery, |
20
|
|
|
} from "../Types/Player" |
21
|
|
|
import "./Player.scss" |
22
|
|
|
import iconCardRed from "../images/i_card_red.png" |
23
|
|
|
import iconCardYellow from "../images/i_card_yellow.png" |
24
|
|
|
import iconCleansheet from "../images/i_cleansheet.png" |
25
|
|
|
import iconGoal from "../images/i_goal.png" |
26
|
|
|
|
27
|
|
|
const Staff = ({ data: { nodeStaff } }: StaffQuery) => { |
28
|
|
|
const cleanBody = |
29
|
|
|
(nodeStaff?.body && |
30
|
|
|
nodeStaff?.body?.processed?.replaceAll(`/sites/default/`, `${process.env.GATSBY_API_DOMAIN}/sites/default/`)) || |
31
|
|
|
`` |
32
|
|
|
const picture = nodeStaff?.relationships?.field_image?.localFile?.childImageSharp?.gatsbyImageData && ( |
33
|
|
|
<GatsbyImage |
34
|
|
|
image={nodeStaff?.relationships?.field_image?.localFile?.childImageSharp?.gatsbyImageData} |
35
|
|
|
alt={`${nodeStaff.field_firstname} ${nodeStaff.field_lastname}`} |
36
|
|
|
/> |
37
|
|
|
) |
38
|
|
|
|
39
|
|
|
return ( |
40
|
|
|
<Layout> |
41
|
|
|
<div className="player__details__top"> |
42
|
|
|
<header className="page_header__wrapper player__header__wrapper"> |
43
|
|
|
<div className="page_header page_header--max player__header"> |
44
|
|
|
<div className="player__header__inner"> |
45
|
|
|
<div className="player__header__inner_text"> |
46
|
|
|
<h1 className={`player__detail__name`}> |
47
|
|
|
<span className={`player__detail__name_first`}>{nodeStaff.field_firstname}</span> |
48
|
|
|
<span className={`player__detail__name_last`}>{nodeStaff.field_lastname}</span> |
49
|
|
|
</h1> |
50
|
|
|
<p |
51
|
|
|
className={`player__detail__shirt_number`} |
52
|
|
|
aria-hidden="true" |
53
|
|
|
title={nodeStaff.field_position_staff || ``} |
54
|
|
|
> |
55
|
|
|
{nodeStaff?.field_position_short || ``} |
56
|
|
|
</p> |
57
|
|
|
</div> |
58
|
|
|
<div className="player__header__inner_image"> |
59
|
|
|
{picture || ( |
60
|
|
|
<StaticImage |
61
|
|
|
src={`../images/kcvv-player-bg.png`} |
62
|
|
|
alt={`${nodeStaff.field_firstname} ${nodeStaff.field_lastname}`} |
63
|
|
|
placeholder={`tracedSVG`} |
64
|
|
|
/> |
65
|
|
|
)} |
66
|
|
|
</div> |
67
|
|
|
</div> |
68
|
|
|
</div> |
69
|
|
|
</header> |
70
|
|
|
</div> |
71
|
|
|
<main className="player__details__middle"> |
72
|
|
|
{renderMeta(nodeStaff)} |
73
|
|
|
{cleanBody && <div dangerouslySetInnerHTML={{ __html: cleanBody }} className="player__details__intro" />} |
74
|
|
|
</main> |
75
|
|
|
{/* <PlayerDetail player={nodePlayer} /> */} |
76
|
|
|
</Layout> |
77
|
|
|
) |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
export const Head = ({ data: { nodeStaff } }: StaffQuery) => { |
81
|
|
|
const pathUrl = nodeStaff?.path?.alias || `` |
82
|
|
|
const heroImage = nodeStaff?.relationships?.field_image?.localFile?.childImageSharp?.gatsbyImageData |
83
|
|
|
|
84
|
|
|
const ogImage = heroImage && { |
85
|
|
|
src: getSrc(heroImage) || ``, |
86
|
|
|
width: heroImage.width, |
87
|
|
|
height: heroImage.height, |
88
|
|
|
} |
89
|
|
|
return ( |
90
|
|
|
<Seo |
91
|
|
|
title={nodeStaff?.title || ``} |
92
|
|
|
path={pathUrl} |
93
|
|
|
image={ogImage} |
94
|
|
|
description={nodeStaff?.title + ` - Staflid van KCVV Elewijt`} |
95
|
|
|
/> |
96
|
|
|
) |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
export default Staff |
100
|
|
|
|
101
|
|
|
const renderMeta = (nodeStaff: Queries.node__staff) => { |
102
|
|
|
return ( |
103
|
|
|
<div className="player__details__meta"> |
104
|
|
|
<div className="player__details__meta__item player__details__meta__item--birthdate"> |
105
|
|
|
<span className="player__details__meta__item__label">Geboortedatum</span> |
106
|
|
|
<span className="player__details__meta__item__data">{nodeStaff.field_birth_date || `Onbekend`}</span> |
107
|
|
|
</div> |
108
|
|
|
<div className="player__details__meta__item player__details__meta__item--position"> |
109
|
|
|
<span className="player__details__meta__item__data">{nodeStaff.field_position_staff}</span> |
110
|
|
|
<span className="player__details__meta__item__label"> |
111
|
|
|
{nodeStaff?.relationships?.node__team && ( |
112
|
|
|
<Link to={nodeStaff?.relationships?.node__team[0]?.path?.alias || ``}> |
113
|
|
|
{nodeStaff?.relationships?.node__team[0]?.title} |
114
|
|
|
</Link> |
115
|
|
|
)} |
116
|
|
|
</span> |
117
|
|
|
</div> |
118
|
|
|
<div className="player__details__meta__item player__details__meta__item--joindate"> |
119
|
|
|
<span className="player__details__meta__item__label">Aangesloten bij KCVV sinds</span> |
120
|
|
|
<span className="player__details__meta__item__data">{nodeStaff.field_join_date || `Onbekend`}</span> |
121
|
|
|
</div> |
122
|
|
|
</div> |
123
|
|
|
) |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
export const query = graphql` |
127
|
|
|
query StaffQuery($slug: String!) { |
128
|
|
|
nodeStaff(path: { alias: { eq: $slug } }) { |
129
|
|
|
path { |
130
|
|
|
alias |
131
|
|
|
} |
132
|
|
|
body { |
133
|
|
|
processed |
134
|
|
|
} |
135
|
|
|
title |
136
|
|
|
field_join_date |
137
|
|
|
field_lastname |
138
|
|
|
field_position_staff |
139
|
|
|
field_firstname |
140
|
|
|
field_birth_date |
141
|
|
|
field_position_short |
142
|
|
|
relationships { |
143
|
|
|
node__article { |
144
|
|
|
title |
145
|
|
|
path { |
146
|
|
|
alias |
147
|
|
|
} |
148
|
|
|
timestamp: created(formatString: "x") |
149
|
|
|
relationships { |
150
|
|
|
field_media_article_image { |
151
|
|
|
...ArticleImage |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
node__team { |
156
|
|
|
title |
157
|
|
|
relationships { |
158
|
|
|
field_media_article_image { |
159
|
|
|
...ArticleImage |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
path { |
163
|
|
|
alias |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
field_image { |
167
|
|
|
localFile { |
168
|
|
|
...KCVVFixedPlayerTeaser |
169
|
|
|
} |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
` |
175
|
|
|
|