Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
chore: disable filter
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchis committed May 1, 2024
1 parent b159b3d commit c860b21
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 59 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/schedule_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: deploy-latest-log
on:
schedule:
- cron: "0 */6 * * 1-5"
# schedule: desactivado ya no se actualiza mas
# - cron: "0 */6 * * 1-5"
workflow_dispatch:
jobs:
deploy:
Expand Down
59 changes: 2 additions & 57 deletions components/charts/NewInfectedChart.jsx
Original file line number Diff line number Diff line change
@@ -1,70 +1,15 @@
import { isBefore, parse, subDays, subMonths } from 'date-fns'
import React, { useState, useEffect } from 'react'
import React from 'react'
import { CartesianGrid, Legend, Line, LineChart, ResponsiveContainer, Tooltip, XAxis } from 'recharts'
import Select from '../ui/select'

function dateParse (date) {
return parse(date, 'dd/MM/yy', new Date())
}
const valuesFilter = [
{
name: 'Últimos 6 meses',
value: '6MONTHS',
filter: (data) => data.filter(obj => isBefore(subMonths(new Date(), 6), dateParse(obj.date)))
},
{
name: 'Últimos 3 meses',
value: '3MONTHS',
filter: (data) => data.filter(obj => isBefore(subMonths(new Date(), 3), dateParse(obj.date)))
},
{
name: 'Últimos 30 días',
value: '1MONTHS',
filter: (data) => data.filter(obj => isBefore(subDays(new Date(), 30), dateParse(obj.date)))
},
{
name: 'Últimos 15 días',
value: '15DAYS',
filter: (data) => data.filter(obj => isBefore(subDays(new Date(), 15), dateParse(obj.date)))
},
{
name: 'Desde inicio hasta ahora',
value: 'FOREVERNOW',
filter: (data) => data
}
]
const DEFAULT_FILTER = valuesFilter[1]
export default function NewInfectedChart ({ newInfected }) {
const [data, setData] = useState([])
const [filter, setFilter] = useState(DEFAULT_FILTER.value)

function onChangeFilter (event) {
const filterFn = valuesFilter.find(filter => filter.value === event.target.value).filter
setFilter(event.target.value)
setData(filterFn(newInfected))
}

useEffect(() => {
setData(DEFAULT_FILTER.filter(newInfected))
}, [newInfected])

return (
<>
<h2>Nuevos casos COVID</h2>
<p className='text-cursive'>
Número de positivos.
</p>
<Select
label='Filtro' style={{
margin: 'var(--size-8) 0 var(--size-8) 0'
}} value={filter} onChange={onChangeFilter}
>
{valuesFilter.map(val =>
<option key={val.name} value={val.value}>{val.name}</option>
)}
</Select>
<ResponsiveContainer height={500}>
<LineChart data={data} width={500} height={500}>
<LineChart data={newInfected} width={500} height={500}>
<CartesianGrid strokeDasharray='3 3' />
<XAxis dataKey='date' fontSize='12px' minTickGap={0} interval='preserveStartEnd' />
<Tooltip />
Expand Down

0 comments on commit c860b21

Please sign in to comment.