@vixoniccom/footbal-score 1.3.0 → 1.4.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.github/workflows/sonarqube.yml +30 -0
  2. package/CHANGELOG.md +20 -0
  3. package/build/index.html +1 -0
  4. package/build/main.js +2 -0
  5. package/build/main.js.LICENSE.txt +59 -0
  6. package/build/test/downloads/4a9bcc4e-f398-4317-9f0f-afa8bcef1a4f.png +0 -0
  7. package/build/test/downloads/7953953c-7029-4730-ae4d-cff4abd5288f.ttf +0 -0
  8. package/build/test/downloads/Roboto-Bold.ttf +0 -0
  9. package/build/test/downloads/Spring in May.ttf +0 -0
  10. package/build/test/downloads/c705a739-312e-4334-9231-e73a05e9d382.ttf +0 -0
  11. package/build/test/downloads/cumples.png +0 -0
  12. package/build/test/downloads/d1093778-f3c9-42c8-9b07-9f8736390aeb/Foto prueba.jpg +0 -0
  13. package/build/test/downloads/d1093778-f3c9-42c8-9b07-9f8736390aeb/foto1.jpg +0 -0
  14. package/build/test/downloads/d1093778-f3c9-42c8-9b07-9f8736390aeb.zip +0 -0
  15. package/build/test/downloads/fondopasto.jpg +0 -0
  16. package/build/test/parameters.json +9 -0
  17. package/build.zip +0 -0
  18. package/configuration/appearanceGroup/appearanceInputs.ts +24 -0
  19. package/configuration/appearanceGroup/index.ts +8 -0
  20. package/configuration/dataGroup/dataInputs.ts +101 -0
  21. package/configuration/dataGroup/index.ts +8 -0
  22. package/configuration/index.ts +8 -0
  23. package/configuration/styleGroup/index.ts +8 -0
  24. package/configuration/styleGroup/styleInputs.ts +56 -0
  25. package/configuration/utils.ts +31 -0
  26. package/configuration.json +139 -132
  27. package/package.json +11 -17
  28. package/sonar-project.properties +1 -0
  29. package/src/App.tsx +39 -53
  30. package/src/components/FontLoader/index.tsx +7 -7
  31. package/src/components/FormattedText/index.tsx +34 -34
  32. package/src/components/Table/components/Results.tsx +10 -11
  33. package/src/components/Table/components/Row.tsx +34 -73
  34. package/src/components/Table/components/Status.tsx +8 -10
  35. package/src/components/Table/components/Time.tsx +7 -8
  36. package/src/components/Table/index.tsx +5 -16
  37. package/src/helpers/getFixture.ts +16 -9
  38. package/src/helpers/translateTeams.ts +48 -93
  39. package/src/index.html +12 -9
  40. package/src/parameters.d.ts +102 -103
  41. package/src/style.css +446 -434
  42. package/src/test/parameters.json +4 -2
  43. package/tsconfig.json +8 -18
  44. /package/src/{main.tsx → main.ts} +0 -0
package/src/App.tsx CHANGED
@@ -9,24 +9,24 @@ export type Props = {
9
9
  start: boolean
10
10
  }
11
11
 
12
- export const App = ({ data, start }: Props) => {
12
+ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
13
13
  const [dataFixture, setDataFixture] = useState<any[]>([])
14
14
  const [league, setLeague] = useState<string>('')
15
15
  const { parameters, downloadsPath } = data
16
16
  const { backgroundImage, padding, msj0 = '', updateTime } = parameters
17
- const backgroundImageState = backgroundImage && backgroundImage.filename
17
+ const backgroundImageState = backgroundImage?.filename
18
18
  ? `url("${downloadsPath}/${backgroundImage.filename}")`
19
19
  : ''
20
20
 
21
21
  const getData = async () => {
22
22
  const dataLocal: any = await getLocalData()
23
- const momentLocalStorage: any = dataLocal ? moment().diff(dataLocal.date, 'millisecond') : undefined
23
+ const momentLocalStorage = dataLocal ? moment().diff(dataLocal.date, 'millisecond') : undefined
24
24
  const timeNowFormat = moment().format('h:mma')
25
25
  const timeNow = moment(timeNowFormat, 'h:mma')
26
- const horaInicio = moment(parameters.timeStart, 'h:mma')
27
- const horaFin = moment(parameters.timeEnd, 'h:mma')
26
+ const startTime = moment(parameters.timeStart, 'h:mma')
27
+ const endTime = moment(parameters.timeEnd, 'h:mma')
28
28
 
29
- if (momentLocalStorage == undefined || (timeNow.isBetween(horaInicio, horaFin) && momentLocalStorage > updateTime!)) {
29
+ if (momentLocalStorage == undefined || (timeNow.isBetween(startTime, endTime) && momentLocalStorage > updateTime!)) {
30
30
  const dataRequest = await getFixture(parameters.league!, parameters.matchesYesterday, parameters.matchesTomorrow)
31
31
  setDataLocal(dataRequest)
32
32
  setDataFixture(dataRequest)
@@ -52,74 +52,60 @@ export const App = ({ data, start }: Props) => {
52
52
 
53
53
  //Request data every 5 minutes
54
54
  useEffect(() => {
55
- let interval = setInterval(() => {
55
+ const interval = setInterval(() => {
56
56
  getData()
57
57
  }, updateTime! || 300000);
58
58
  return () => clearInterval(interval)
59
59
  }, [updateTime, data])
60
60
 
61
- const setDataLocal = (data: any) => {
61
+ const setDataLocal = async (data: any) => {
62
62
  localforage.config({ name: 'request_api_football' })
63
- localforage.setItem('football-score', {
64
- date: Date.now(),
65
- data: data
66
- }, (err) => { if (err) console.log('err', err) })
63
+ try {
64
+ await localforage.setItem('football-score', { date: Date.now(), data })
65
+ } catch (err) {
66
+ console.log('err', err)
67
+ }
67
68
  }
68
69
 
69
70
  const getLocalData = async () => {
70
- let dataLocal = await localforage.getItem('football-score')
71
+ const dataLocal = await localforage.getItem('football-score')
71
72
  return dataLocal
72
73
  }
73
74
 
74
75
  return (
75
76
  dataFixture.length > 0 ?
76
- <div
77
- style={{
78
- position: 'absolute',
79
- top: 0,
80
- bottom: 0,
81
- left: 0,
82
- right: 0,
83
- backgroundImage: backgroundImageState,
84
- backgroundSize: '100% 100%',
85
- padding: padding
86
- }}
87
- >
77
+ <div style={{
78
+ position: 'absolute',
79
+ top: 0,
80
+ bottom: 0,
81
+ left: 0,
82
+ right: 0,
83
+ backgroundImage: backgroundImageState,
84
+ backgroundSize: '100% 100%',
85
+ padding: padding
86
+ }}>
88
87
  <FontLoader paths={['nameFormat.font', 'statusFormat.font', 'timeFormat.font', 'titleFormat.font', 'descriptionFormat.font', 'dateDayFormat.font', 'dateMonthFormat.font', 'goalsFormat.font']} parameters={parameters} downloadsPath={downloadsPath} />
89
- {
90
- parameters.titleEnabled &&
91
- <div style={{
92
- display: 'flex',
93
- position: 'relative',
94
- flex: '1 1 0%',
95
- flexDirection: 'column',
96
- }}>
88
+ {parameters.titleEnabled &&
89
+ <div style={{ display: 'flex', position: 'relative', flex: '1 1 0%', flexDirection: 'column' }}>
97
90
  <FormattedText text={parameters.title0 || 'Partidos Mundial'} format={parameters.titleFormat} />
98
91
  </div>
99
92
  }
100
93
  <Table dataFixture={dataFixture} parameters={parameters} />
101
94
  </div> :
102
- <div
103
- style={{
104
- position: 'absolute',
105
- top: 0,
106
- bottom: 0,
107
- left: 0,
108
- right: 0,
109
- backgroundImage: backgroundImageState,
110
- backgroundSize: '100% 100%',
111
- padding: padding,
112
- display: 'flex',
113
- alignItems: parameters.alignVerticalMsj,
114
- }}
115
- >
95
+ <div style={{
96
+ position: 'absolute',
97
+ top: 0,
98
+ bottom: 0,
99
+ left: 0,
100
+ right: 0,
101
+ backgroundImage: backgroundImageState,
102
+ backgroundSize: '100% 100%',
103
+ padding: padding,
104
+ display: 'flex',
105
+ alignItems: parameters.alignVerticalMsj
106
+ }}>
116
107
  <FontLoader paths={['nameFormat.font', 'descriptionFormat.font', 'dateDayFormat.font', 'dateMonthFormat.font', 'formatMjs.font']} parameters={parameters} downloadsPath={downloadsPath} />
117
- <div style={{
118
- display: 'flex',
119
- position: 'relative',
120
- flex: '1 1 0%',
121
- flexDirection: 'column',
122
- }}>
108
+ <div style={{ display: 'flex', position: 'relative', flex: '1 1 0%', flexDirection: 'column' }}>
123
109
  <FormattedText text={msj0 || 'Sin partidos'} format={parameters.formatMjs} />
124
110
  </div>
125
111
  </div>
@@ -1,13 +1,13 @@
1
1
  import React from 'react'
2
2
 
3
- type Props = {
4
- parameters: VixonicParameters
3
+ interface Props {
4
+ paths: Array<string>
5
+ parameters: any
5
6
  downloadsPath: string
6
- paths: string[]
7
7
  }
8
8
 
9
- export const FontLoader = ({ parameters, downloadsPath, paths }: Props) => {
10
- const _getValueByPath = (path: any, obj: any): any => {
9
+ export const FontLoader: React.FunctionComponent<Props> = ({ paths, parameters, downloadsPath }) => {
10
+ const _getValueByPath = (path: string, obj: any): any => {
11
11
  const pathsArray = path.split('.')
12
12
  const propertyName = pathsArray[0]
13
13
  if (pathsArray.length === 1) return obj[propertyName]
@@ -26,8 +26,8 @@ export const FontLoader = ({ parameters, downloadsPath, paths }: Props) => {
26
26
  }
27
27
  return `
28
28
  @font-face {
29
- font-family: "${font.family}";
30
- src: url("${font.src}");
29
+ font-family: '${font.family}';
30
+ src: url('${font.src}');
31
31
  }
32
32
  `
33
33
  } catch (err) {
@@ -1,5 +1,4 @@
1
1
  import React from 'react'
2
- import { isNumber } from 'lodash'
3
2
 
4
3
  const alignments = {
5
4
  center: 'center',
@@ -7,35 +6,34 @@ const alignments = {
7
6
  right: 'flex-end'
8
7
  }
9
8
 
10
- type aligment = {
9
+ type Aligment = {
11
10
  horizontal: keyof typeof alignments,
12
11
  vertical: keyof typeof alignments
13
12
  }
14
13
 
15
14
  interface Props {
16
15
  format?: any
17
- lineHeight: number
16
+ lineHeight?: number
18
17
  maxChar?: number
19
- style?: number
18
+ style?: React.CSSProperties
20
19
  text: string
21
- unit: string
20
+ unit?: string
22
21
  paddingBottom?: string
23
22
  paddingTop?: string
24
23
  }
25
24
 
26
- export const FormattedText = ({ text, format, maxChar, lineHeight, style, unit, paddingBottom, paddingTop }: Props) => {
27
- const trimText = (text: any, maxChar: any) => {
28
- const isValid = maxChar && isNumber(maxChar) && maxChar >= 3
29
- if (isValid && (text && text.length > maxChar) || false) {
30
- let returnText = text.substring(0, maxChar - 3)
31
- returnText.substr(-1, 3)
25
+ export const FormattedText: React.FunctionComponent<Props> = ({ text, format, maxChar, lineHeight, style, unit, paddingBottom, paddingTop }) => {
26
+ const trimText = (text: string, maxChar?: number) => {
27
+ const isValid = maxChar && maxChar >= 3
28
+ if (isValid && text.length > maxChar) {
29
+ const returnText = text.substring(0, maxChar - 3)
32
30
  return `${returnText.trim()}...`
33
31
  }
34
32
  return text
35
33
  }
36
34
 
37
- const checkNested = (obj: any, path: any): any => {
38
- let arr = path.split('.')
35
+ const checkNested = (obj: any, path: string): any => {
36
+ const arr = path.split('.')
39
37
  if (arr.length > 0) {
40
38
  if (obj.hasOwnProperty(arr[0])) {
41
39
  if (arr.length > 1) return checkNested(obj[arr[0]], arr.splice(1).join('.'))
@@ -44,32 +42,34 @@ export const FormattedText = ({ text, format, maxChar, lineHeight, style, unit,
44
42
  }
45
43
  }
46
44
 
47
- const getHorizontalAlignment = (alignment: aligment) => {
48
- if (alignment) {
49
- let hA = alignment.horizontal
50
- return alignments.hasOwnProperty(hA) ? alignments[alignment.horizontal] : 'flex-start'
51
- }
52
- return 'flex-start'
45
+ const getHorizontalAlignment = (alignment?: Aligment) => {
46
+ if (!alignment) return 'flex-start'
47
+
48
+ const hA = alignment.horizontal
49
+ return alignments.hasOwnProperty(hA) ? alignments[hA] : 'flex-start'
53
50
  }
54
51
 
55
52
  const renderText = maxChar ? trimText(text, maxChar) : text
56
- let containerStyle = Object.assign({
53
+ let containerStyle = {
57
54
  display: 'inline-flex',
58
- justifyContent: getHorizontalAlignment(format.alignment)
59
- }, style)
55
+ justifyContent: getHorizontalAlignment(format.alignment),
56
+ ...style
57
+ }
60
58
 
61
- return <div style={containerStyle}>
62
- <span style={{
63
- color: format?.fontColor,
64
- fontFamily: checkNested(format, 'font.filename') ? `"${format?.font?.filename?.replace('.', '-')}"` : '',
65
- fontSize: `${format?.fontSize}${unit}`,
66
- textAlign: checkNested(format, 'alignment.horizontal') ? format?.alignment?.horizontal : 'left',
67
- lineHeight: lineHeight,
68
- paddingBottom: paddingBottom,
69
- paddingTop: paddingTop,
70
- display: 'inline-flex'
71
- }}>{renderText}</span>
72
- </div>
59
+ return (
60
+ <div style={containerStyle}>
61
+ <span style={{
62
+ color: format?.fontColor,
63
+ fontFamily: checkNested(format, 'font.filename') ? `'${format?.font?.filename?.replace('.', '-')}'` : '',
64
+ fontSize: `${format?.fontSize}${unit}`,
65
+ textAlign: checkNested(format, 'alignment.horizontal') ? format?.alignment?.horizontal : 'left',
66
+ lineHeight: lineHeight,
67
+ paddingBottom: paddingBottom,
68
+ paddingTop: paddingTop,
69
+ display: 'inline-flex'
70
+ }}>{renderText}</span>
71
+ </div>
72
+ )
73
73
  }
74
74
 
75
75
  FormattedText.defaultProps = {
@@ -2,21 +2,20 @@ import React from 'react'
2
2
  import { FormattedText } from '../../FormattedText'
3
3
  import { isNumber } from 'lodash'
4
4
 
5
- export const Results = ({ parameters, goals, score }: any) => {
5
+ interface Props {
6
+ parameters: VixonicParameters
7
+ goals: any
8
+ score: any
9
+ }
10
+
11
+ export const Results: React.FunctionComponent<Props> = ({ parameters, goals, score }) => {
6
12
  return (
7
- <div style={{
8
- display: 'flex',
9
- justifyContent: 'center',
10
- }}>
11
- {
12
- isNumber(score.penalty.home) ? <FormattedText text={`(${score.penalty.home})`} format={parameters.goalsFormat} /> : ''
13
- }
13
+ <div style={{ display: 'flex', justifyContent: 'center' }}>
14
+ {isNumber(score.penalty.home) ? <FormattedText text={`(${score.penalty.home})`} format={parameters.goalsFormat} /> : ''}
14
15
  <FormattedText text={goals.home ? goals.home : 0} format={parameters.goalsFormat} />
15
16
  <FormattedText text={'-'} format={parameters.goalsFormat} />
16
17
  <FormattedText text={goals.away ? goals.away : 0} format={parameters.goalsFormat} />
17
- {
18
- isNumber(score.penalty.away) ? <FormattedText text={`(${score.penalty.away})`} format={parameters.goalsFormat} /> : ''
19
- }
18
+ {isNumber(score.penalty.away) ? <FormattedText text={`(${score.penalty.away})`} format={parameters.goalsFormat} /> : ''}
20
19
  </div>
21
20
  )
22
21
  }
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react'
2
- import { Results, Status, Time } from './'
2
+ import { Results, Status, Time } from './'
3
3
  import { FormattedText } from '../../'
4
4
  import { translateTeams } from '../../../helpers/translateTeams'
5
5
 
@@ -8,15 +8,18 @@ type Props = {
8
8
  parameters: VixonicParameters
9
9
  }
10
10
 
11
- export const Row = ({ item, parameters }: Props) => {
11
+ if (!process.env.RESULTS_FLAG_IMG) console.warn('Flag image asset is not defined')
12
+ const FLAG_IMG = process.env.RESULTS_FLAG_IMG
13
+
14
+ export const Row: React.FunctionComponent<Props> = ({ item, parameters }) => {
12
15
  const { fixture, teams, goals, score } = item
13
16
  const [homeTeam, setHomeTeam] = useState(false)
14
17
  const [awayTeam, setAwayTeam] = useState(false)
18
+ const imageSize = `${parameters.imageSize ?? 100}%`
15
19
  const {
16
20
  descriptionEnabled,
17
21
  widthDescription,
18
22
  descriptionFormat,
19
- imageSize,
20
23
  widthImage,
21
24
  widthScore,
22
25
  columnGap,
@@ -47,7 +50,6 @@ export const Row = ({ item, parameters }: Props) => {
47
50
  } catch (error) {
48
51
  console.log(error)
49
52
  setAwayTeam(false)
50
-
51
53
  }
52
54
  }
53
55
 
@@ -57,87 +59,46 @@ export const Row = ({ item, parameters }: Props) => {
57
59
  }, [])
58
60
 
59
61
  return (
60
- <div
61
- style={{
62
- display: 'grid',
63
- gridTemplateColumns: `${gridColumns}`,
64
- columnGap: `${columnGap || '10px'}`,
65
- width: '100%',
66
- height: '100%',
67
- alignItems: 'center',
68
- placeContent: 'center',
69
- padding: `${rowGap || '30px'} 0px`,
70
- justifyContent: 'center'
71
- }}
72
- >
73
- <div
74
- style={{
75
- display: 'flex',
76
- justifyContent: 'flex-end',
77
- }}
78
- >
62
+ <div style={{
63
+ display: 'grid',
64
+ gridTemplateColumns: `${gridColumns}`,
65
+ columnGap: `${columnGap || '10px'}`,
66
+ width: '100%',
67
+ height: '100%',
68
+ alignItems: 'center',
69
+ placeContent: 'center',
70
+ padding: `${rowGap || '30px'} 0px`,
71
+ justifyContent: 'center'
72
+ }}>
73
+ <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
79
74
  <Time time={Number(fixture.timestamp)} parameters={parameters} />
80
75
  </div>
81
- <div
82
- style={{
83
- display: 'flex',
84
- justifyContent: 'flex-end',
85
- }}
86
- >
76
+ <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
87
77
  <Status status={fixture.status.short} parameters={parameters} />
88
78
  </div>
89
- {
90
- descriptionEnabled &&
91
- <div style={{
92
- display: 'flex',
93
- justifyContent: 'flex-end',
94
- marginRight: '10px'
95
- }}>
79
+ {descriptionEnabled && (
80
+ <div style={{ display: 'flex', justifyContent: 'flex-end', marginRight: '10px' }}>
96
81
  <FormattedText text={nameHome} format={descriptionFormat} />
97
82
  </div>
98
- }
99
- <div style={{
100
- display: 'flex',
101
- justifyContent: 'center',
102
- width: '100%',
103
- alignItems: 'center',
104
- marginLeft: '5px'
105
- }}>
106
- {
107
- homeTeam ?
108
- <img src={`${teams.home.logo}`} style={{ width: `${imageSize ? imageSize : 100}%`, objectFit: 'contain' }} /> :
109
- <img src={`https://storage.googleapis.com/vixoniccom-emails/results_flags/0000.png`} style={{ width: `${imageSize ? imageSize : 100}%`, objectFit: 'contain' }} />
110
-
83
+ )}
84
+ <div style={{ display: 'flex', justifyContent: 'center', width: '100%', alignItems: 'center', marginLeft: '5px' }}>
85
+ {homeTeam ?
86
+ <img src={`${teams.home.logo}`} alt={`${nameHome} logo`} style={{ width: imageSize, objectFit: 'contain' }} /> :
87
+ <img src={FLAG_IMG} alt={`${nameHome} logo`} style={{ width: imageSize, objectFit: 'contain' }} />
111
88
  }
112
89
  </div>
113
90
  <Results goals={goals} score={score} parameters={parameters} />
114
- <div
115
- style={{
116
- display: 'flex',
117
- justifyContent: 'flex-start',
118
- width: '100%',
119
- alignItems: 'center',
120
- marginRight: '5px'
121
- }}
122
- >
123
- {
124
- awayTeam ?
125
- <img src={`${teams.away.logo}`} style={{ width: `${imageSize ? imageSize : 100}%`, objectFit: 'contain' }} />
126
- : <img src={`https://storage.googleapis.com/vixoniccom-emails/results_flags/0000.png`} style={{ width: `${imageSize ? imageSize : 100}%`, objectFit: 'contain' }} />
91
+ <div style={{ display: 'flex', justifyContent: 'flex-start', width: '100%', alignItems: 'center', marginRight: '5px' }} >
92
+ {awayTeam ?
93
+ <img src={`${teams.away.logo}`} alt={`${nameAway} logo`} style={{ width: imageSize, objectFit: 'contain' }} />
94
+ : <img src={FLAG_IMG} alt={`${nameAway} logo`} style={{ width: imageSize, objectFit: 'contain' }} />
127
95
  }
128
96
  </div>
129
- {
130
- descriptionEnabled &&
131
- <div
132
- style={{
133
- display: 'flex',
134
- justifyContent: 'flex-start',
135
- marginLeft: '10px',
136
- }}
137
- >
97
+ {descriptionEnabled && (
98
+ <div style={{ display: 'flex', justifyContent: 'flex-start', marginLeft: '10px' }}>
138
99
  <FormattedText text={nameAway} format={descriptionFormat} />
139
100
  </div>
140
- }
141
- </div >
101
+ )}
102
+ </div>
142
103
  )
143
104
  }
@@ -1,7 +1,11 @@
1
- import React from 'react'
2
1
  import { FormattedText } from '../../'
3
2
 
4
- export const Status = ({ status, parameters }: { status: string, parameters: VixonicParameters }) => {
3
+ interface Props {
4
+ status: string
5
+ parameters: VixonicParameters
6
+ }
7
+
8
+ export const Status: React.FunctionComponent<Props> = ({ status, parameters }) => {
5
9
  let translateStatus: string = ''
6
10
  switch (status) {
7
11
  case 'NS':
@@ -16,26 +20,20 @@ export const Status = ({ status, parameters }: { status: string, parameters: Vix
16
20
  case '2H':
17
21
  translateStatus = 'Segundo tiempo'
18
22
  break
19
- case 'FT':
20
- translateStatus = 'Finalizado'
21
- break
22
23
  case 'P':
23
24
  translateStatus = 'Penales'
24
25
  break
25
26
  case 'LIVE':
26
27
  translateStatus = 'En vivo'
27
28
  break
29
+ case 'FT':
28
30
  default:
29
31
  translateStatus = 'Finalizado'
30
32
  break
31
33
  }
32
34
 
33
35
  return (
34
- <div style={{
35
- display: 'flex',
36
- justifyContent: 'center',
37
- alignItems: 'center',
38
- }}>
36
+ <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
39
37
  <FormattedText text={translateStatus} format={parameters.statusFormat} />
40
38
  </div>
41
39
  )
@@ -2,15 +2,14 @@ import moment from 'moment'
2
2
  import React from 'react'
3
3
  import { FormattedText } from '../../'
4
4
 
5
- export const Time = ({ time, parameters }: { time: number, parameters: VixonicParameters }) => {
6
- return (
7
- <div style={{
8
- display: 'flex',
9
- flexDirection: 'column',
10
- alignItems: 'center',
11
- justifyContent: 'center',
5
+ interface Props {
6
+ time: number
7
+ parameters: VixonicParameters
8
+ }
12
9
 
13
- }}>
10
+ export const Time: React.FunctionComponent<Props> = ({ time, parameters }) => {
11
+ return (
12
+ <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', }}>
14
13
  <FormattedText text={moment.unix(time).format('DD-MM')} format={parameters.timeFormat} />
15
14
  <FormattedText text={moment.unix(time).format('h:mm a')} format={parameters.timeFormat} />
16
15
  </div>
@@ -6,7 +6,7 @@ type Props = {
6
6
  parameters: VixonicParameters
7
7
  }
8
8
 
9
- export const Table = ({ dataFixture, parameters }: Props) => {
9
+ export const Table: React.FunctionComponent<Props> = ({ dataFixture, parameters }) => {
10
10
  const { itemsPerPage, durationPerPage } = parameters
11
11
  const rows = Number(itemsPerPage || 4)
12
12
  const orderedData = dataFixture.sort((a, b) => a.fixture.timestamp - b.fixture.timestamp)
@@ -31,20 +31,9 @@ export const Table = ({ dataFixture, parameters }: Props) => {
31
31
  setPage(newPage)
32
32
  }
33
33
 
34
- return <div
35
- style={{
36
- display: 'flex',
37
- width: '100%',
38
- height: '100%',
39
- justifyContent: 'center',
40
- alignItems: 'center',
41
- flexDirection: 'column'
42
- }}
43
- >
44
- {
45
- items.map((item: any) => (
46
- <Row item={item} parameters={parameters} />
47
- ))
48
- }
34
+ return <div style={{ display: 'flex', width: '100%', height: '100%', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }}>
35
+ {items.map((item: any, index: number) => (
36
+ <Row key={item.fixture.id || `${item.fixture.timestamp}-${index}`} item={item} parameters={parameters} />
37
+ ))}
49
38
  </div>
50
39
  }
@@ -1,21 +1,28 @@
1
1
  import moment from 'moment'
2
2
  import axios from 'axios'
3
3
 
4
+ if (!process.env.FOOTBALL_API_KEY || !process.env.FOOTBALL_API_HOST || !process.env.FOOTBALL_API_URL)
5
+ console.warn('Missing API credentials')
6
+ const FOOTBALL_API_KEY = process.env.FOOTBALL_API_KEY
7
+ const FOOTBALL_API_HOST = process.env.FOOTBALL_API_HOST
8
+ const FOOTBALL_API_URL = process.env.FOOTBALL_API_URL
9
+
4
10
  export const getFixture = async (league: string, yesterday?: boolean, tomorrow?: boolean) => {
5
11
  const today = moment().format('YYYY-MM-DD')
6
- const year = moment().format('YYYY')
7
- const from = yesterday ? moment(Date.now() - 24 * 60 * 60 * 1000).format('YYYY-MM-DD') : today
8
- const to = tomorrow ? moment(Date.now() + 24 * 60 * 60 * 1000).format('YYYY-MM-DD') : today
12
+ let year = moment().format('YYYY')
13
+ year = '2023'
14
+ let from = yesterday ? moment(Date.now() - 24 * 60 * 60 * 1000).format('YYYY-MM-DD') : today
15
+ from = '2023-12-05'
16
+ let to = tomorrow ? moment(Date.now() + 24 * 60 * 60 * 1000).format('YYYY-MM-DD') : today
17
+ to = '2023-12-10'
9
18
 
10
19
  const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
20
+
11
21
  const options = {
12
22
  method: 'GET',
13
- url: 'https://v3.football.api-sports.io/fixtures',
14
- params: { from, to, league, season: `${year}`, timezone: `${timezone}` },
15
- headers: {
16
- 'X-RapidAPI-Key': '235e7dfd2220cd2347e61c8a53643fcc',
17
- 'X-RapidAPI-Host': 'api-football-v1.p.rapidapi.com'
18
- }
23
+ url: FOOTBALL_API_URL,
24
+ params: { from, to, league, season: year, timezone },
25
+ headers: { 'X-RapidAPI-Key': FOOTBALL_API_KEY, 'X-RapidAPI-Host': FOOTBALL_API_HOST },
19
26
  }
20
27
 
21
28
  try {