@vixoniccom/footbal-score 1.4.0-dev.1 → 1.4.0-dev.3
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.
- package/CHANGELOG.md +14 -0
- package/build/main.js +1 -1
- package/build/test/parameters.json +2 -1
- package/build.zip +0 -0
- package/package.json +1 -2
- package/src/App.tsx +8 -8
- package/src/components/Table/components/Time.tsx +1 -1
- package/src/helpers/getFixture.ts +4 -7
- package/src/style.css +1 -1
- package/src/test/parameters.json +2 -1
package/build.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixoniccom/footbal-score",
|
|
3
3
|
"alias": "Resultados Deportivos",
|
|
4
|
-
"version": "1.4.0-dev.
|
|
4
|
+
"version": "1.4.0-dev.3",
|
|
5
5
|
"description": "Muestra resultados en vivo de fútbol.",
|
|
6
6
|
"main": "main.js",
|
|
7
7
|
"author": "",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"react-dom": "^18.3.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@types/node": "^12.20.37",
|
|
28
27
|
"@types/react": "^18.3.23",
|
|
29
28
|
"@types/react-dom": "^18.3.7",
|
|
30
29
|
"@vixoniccom/module-packager": "^2.13.0-dev.1",
|
package/src/App.tsx
CHANGED
|
@@ -11,9 +11,9 @@ export type Props = {
|
|
|
11
11
|
|
|
12
12
|
export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
13
13
|
const [dataFixture, setDataFixture] = useState<any[]>([])
|
|
14
|
-
const [
|
|
14
|
+
const [leagueState, setLeagueState] = useState<string>('')
|
|
15
15
|
const { parameters, downloadsPath } = data
|
|
16
|
-
const { backgroundImage, padding, msj0 = '', updateTime } = parameters
|
|
16
|
+
const { backgroundImage, padding, msj0 = '', updateTime = 300000, league = '9' } = parameters
|
|
17
17
|
const backgroundImageState = backgroundImage?.filename
|
|
18
18
|
? `url("${downloadsPath}/${backgroundImage.filename}")`
|
|
19
19
|
: ''
|
|
@@ -27,7 +27,7 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
27
27
|
const endTime = moment(parameters.timeEnd, 'h:mma')
|
|
28
28
|
|
|
29
29
|
if (momentLocalStorage == undefined || (timeNow.isBetween(startTime, endTime) && momentLocalStorage > updateTime!)) {
|
|
30
|
-
const dataRequest = await getFixture(
|
|
30
|
+
const dataRequest = await getFixture(league, parameters.matchesYesterday, parameters.matchesTomorrow)
|
|
31
31
|
setDataLocal(dataRequest)
|
|
32
32
|
setDataFixture(dataRequest)
|
|
33
33
|
} else {
|
|
@@ -37,24 +37,24 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
37
37
|
|
|
38
38
|
useEffect(() => {
|
|
39
39
|
if (start) {
|
|
40
|
-
|
|
40
|
+
setLeagueState(league)
|
|
41
41
|
getData()
|
|
42
42
|
}
|
|
43
43
|
}, [data])
|
|
44
44
|
|
|
45
45
|
useEffect(() => {
|
|
46
|
-
if (
|
|
47
|
-
|
|
46
|
+
if (leagueState !== league) {
|
|
47
|
+
setLeagueState(league)
|
|
48
48
|
localforage.clear()
|
|
49
49
|
getData()
|
|
50
50
|
}
|
|
51
|
-
}, [
|
|
51
|
+
}, [league])
|
|
52
52
|
|
|
53
53
|
//Request data every 5 minutes
|
|
54
54
|
useEffect(() => {
|
|
55
55
|
const interval = setInterval(() => {
|
|
56
56
|
getData()
|
|
57
|
-
}, updateTime
|
|
57
|
+
}, updateTime)
|
|
58
58
|
return () => clearInterval(interval)
|
|
59
59
|
}, [updateTime, data])
|
|
60
60
|
|
|
@@ -9,7 +9,7 @@ interface Props {
|
|
|
9
9
|
|
|
10
10
|
export const Time: React.FunctionComponent<Props> = ({ time, parameters }) => {
|
|
11
11
|
return (
|
|
12
|
-
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center'
|
|
12
|
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
|
|
13
13
|
<FormattedText text={moment.unix(time).format('DD-MM')} format={parameters.timeFormat} />
|
|
14
14
|
<FormattedText text={moment.unix(time).format('h:mm a')} format={parameters.timeFormat} />
|
|
15
15
|
</div>
|
|
@@ -6,16 +6,13 @@ if (!process.env.FOOTBALL_API_KEY || !process.env.FOOTBALL_API_HOST || !process.
|
|
|
6
6
|
const FOOTBALL_API_KEY = process.env.FOOTBALL_API_KEY
|
|
7
7
|
const FOOTBALL_API_HOST = process.env.FOOTBALL_API_HOST
|
|
8
8
|
const FOOTBALL_API_URL = process.env.FOOTBALL_API_URL
|
|
9
|
+
const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000
|
|
9
10
|
|
|
10
11
|
export const getFixture = async (league: string, yesterday?: boolean, tomorrow?: boolean) => {
|
|
11
12
|
const today = moment().format('YYYY-MM-DD')
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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'
|
|
18
|
-
|
|
13
|
+
const year = moment().format('YYYY')
|
|
14
|
+
const from = yesterday ? moment(Date.now() - MILLISECONDS_PER_DAY).format('YYYY-MM-DD') : today
|
|
15
|
+
const to = tomorrow ? moment(Date.now() + MILLISECONDS_PER_DAY).format('YYYY-MM-DD') : today
|
|
19
16
|
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
20
17
|
|
|
21
18
|
const options = {
|
package/src/style.css
CHANGED