added option todos to filter
This commit is contained in:
@@ -49,13 +49,15 @@ export default function Reporte() {
|
||||
const [sistemasOperativos, setSistemasOperativos] = useState<SoOption[]>([])
|
||||
const [soSeleccionado, setSoSeleccionado] = useState<SoOption[]>([])
|
||||
|
||||
const [usos, setUsos] = useState<UsoOption[]>([])
|
||||
const [usos, setUsos] = useState<UsoOption[]>([{ id_uso: "0", tipo_uso: "Todos" }])
|
||||
const [usoSeleccionado, setUsoSeleccionado] = useState<UsoOption[]>([])
|
||||
|
||||
const [antiguedad, setAntiguedad] = useState<AntiguedadOption[]>([{ antiguedad: "Menor a 2 años" }, { antiguedad: "Entre 2 y 3 años" }, { antiguedad: "Entre 4 y 5 años" }, { antiguedad: "Mayor a 6 años" }])
|
||||
const [antiguedad, setAntiguedad] = useState<AntiguedadOption[]>([{ antiguedad: "Todos" }, { antiguedad: "Menor a 2 años" }, { antiguedad: "Entre 2 y 3 años" }, { antiguedad: "Entre 4 y 5 años" }, { antiguedad: "Mayor a 6 años" }])
|
||||
const [antiguedadSeleccionada, setAntiguedadSeleccionada] = useState<AntiguedadOption[]>([])
|
||||
|
||||
const [filtros, setFiltros] = useState<any>(null)
|
||||
const [filtrosTable, setFiltrosTable] = useState<any>(null)
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
const cargarDatos = async () => {
|
||||
@@ -73,11 +75,25 @@ export default function Reporte() {
|
||||
axios.get(`${api_url}/equipos/sistemas-operativos`, { headers }),
|
||||
])
|
||||
|
||||
setAdscripciones(adscripcionRes.data)
|
||||
setProcesadores(procesadorRes.data)
|
||||
setUsos(usoRes.data)
|
||||
setSistemasOperativos(soRes.data)
|
||||
setAdscripciones([
|
||||
{ id_adscripcion: "0", adscripcion: "Todos" },
|
||||
...adscripcionRes.data
|
||||
])
|
||||
|
||||
setProcesadores([
|
||||
{ id_procesador: "0", procesador: "Todos" },
|
||||
...procesadorRes.data
|
||||
])
|
||||
|
||||
setUsos([
|
||||
{ id_uso: "0", tipo_uso: "Todos" },
|
||||
...usoRes.data
|
||||
])
|
||||
|
||||
setSistemasOperativos([
|
||||
{ id_sistema_operativo: "0", sistema_operativo: "Todos" },
|
||||
...soRes.data
|
||||
])
|
||||
}
|
||||
|
||||
cargarDatos()
|
||||
@@ -106,7 +122,12 @@ export default function Reporte() {
|
||||
|
||||
const generarReporte = () => {
|
||||
|
||||
const filtros = {
|
||||
const limpiar = (arr: string[]) => {
|
||||
if (arr.includes("0")) return []
|
||||
return arr
|
||||
}
|
||||
|
||||
const filtrosTable = {
|
||||
adscripciones: adscripcionesSeleccionadas.map(a => String(a.id_adscripcion)),
|
||||
procesadores: procesadorSeleccionado.map(p => String(p.id_procesador)),
|
||||
sistemas: soSeleccionado.map(s => String(s.id_sistema_operativo)),
|
||||
@@ -114,7 +135,16 @@ export default function Reporte() {
|
||||
antiguedad: antiguedadSeleccionada.map(u => String(u.antiguedad))
|
||||
}
|
||||
|
||||
const filtros = {
|
||||
adscripciones: limpiar(adscripcionesSeleccionadas.map(a => String(a.id_adscripcion))),
|
||||
procesadores: limpiar(procesadorSeleccionado.map(p => String(p.id_procesador))),
|
||||
sistemas: limpiar(soSeleccionado.map(s => String(s.id_sistema_operativo))),
|
||||
usos: limpiar(usoSeleccionado.map(u => String(u.id_uso))),
|
||||
antiguedad: limpiar(antiguedadSeleccionada.map(a => String(a.antiguedad)))
|
||||
}
|
||||
|
||||
setFiltros(filtros)
|
||||
setFiltrosTable(filtrosTable)
|
||||
|
||||
}
|
||||
|
||||
@@ -351,8 +381,8 @@ export default function Reporte() {
|
||||
filtros={filtros}
|
||||
/>
|
||||
|
||||
<TableAntiguedad filtros={filtros} count={true}/>
|
||||
<TableAntiguedad filtros={filtros} count={false}/>
|
||||
<TableAntiguedad filtros={filtros} count={true} />
|
||||
<TableAntiguedad filtros={filtrosTable} count={false} />
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user