Skip to content

Commit

Permalink
0 results fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemma committed Jun 12, 2024
1 parent 4c06c74 commit ddd603a
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 139 deletions.
5 changes: 4 additions & 1 deletion frontend/src/components/Individuals/IndividualsResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,10 @@ function IndividualsResults (props) {
}

if (updatedArrayFilterVar.length === 0) {
beaconsList.push(res.data.response)
res.data.responses.forEach(element => {
beaconsList.push(element)
})

}

let variablePause = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ thead {
font-size: 14px;
font-family: sans-serif;
/* padding: 8px; */
text-align: center;

display: flex;
align-items: center;
width: 328px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CrossQueries from '../../CrossQueries/CrossQueries'
import { FaBars, FaEye, FaEyeSlash } from 'react-icons/fa' // Import icons from react-icons library
import { FiLayers, FiDownload } from 'react-icons/fi'

function TableResultsIndividuals (props) {
function TableResultsIndividuals(props) {
const [showDatsets, setShowDatasets] = useState(false)
const [showResults, setShowResults] = useState(false)
const [resultsSelected, setResultsSelected] = useState(props.results)
Expand Down Expand Up @@ -489,151 +489,155 @@ function TableResultsIndividuals (props) {

useEffect(() => {
setShowDatasets(true)

console.log(props.beaconsList)
}, [])

return (
<div className='containerBeaconResults'>
{showDatsets === true &&
props.beaconsList.map((result, beaconIndex) => {
return (
<table className='tableGranularity' key={beaconIndex}>
<thead className='theadGranularity'>
<tr id='trGranuHeader'>
<th className='thGranularityTitleBeacon'>Beacon</th>
<th className='thGranularityTitle'>Dataset</th>
<th className='thGranularityTitle'>Result</th>
</tr>
</thead>
<tbody className='tbodyGranu'>
{props.results.length > 0 &&
props.resultsPerDataset.map((dataset, index2) => {
const totalCount = dataset[3]
? dataset[3].reduce((acc, count) => acc + count, 0)
: 0
const allTrue = dataset[2]
? dataset[2].every(booleanElement => booleanElement)
: 'No, sorry'

return (
<React.Fragment key={index2}>
<tr
className='trGranuBeacon'
onClick={() => toggleRow(index2)}
>
<td className='tdGranuBeacon'>
{dataset[0]}
{expandedRows.includes(index2) ? (
<ion-icon name='chevron-down-outline'></ion-icon>
) : (
<ion-icon name='chevron-up-outline'></ion-icon>
<>
{beaconIndex === 0 && (
<table className='tableGranularity' key={beaconIndex}>
<thead className='theadGranularity'>
<tr id='trGranuHeader'>
<th className='thGranularityTitleBeacon'>Beacon</th>
<th className='thGranularityTitle'>Dataset</th>
<th className='thGranularityTitle'>Result</th>
</tr>
</thead>
<tbody className='tbodyGranu'>
{props.results.length > 0 &&
props.resultsPerDataset.map((dataset, index2) => {
const totalCount = dataset[3]
? dataset[3].reduce((acc, count) => acc + count, 0)
: 0
const allTrue = dataset[2]
? dataset[2].every(booleanElement => booleanElement)
: 'No, sorry'

return (
<React.Fragment key={index2}>
<tr
className='trGranuBeacon'
onClick={() => toggleRow(index2)}
>
<td className='tdGranuBeacon'>
{dataset[0]}
{expandedRows.includes(index2) ? (
<ion-icon name='chevron-down-outline'></ion-icon>
) : (
<ion-icon name='chevron-up-outline'></ion-icon>
)}
</td>
<td className='tdGranuBeacon'></td>
<td className='tdGranuBeacon'>
{props.show === 'boolean'
? allTrue
? 'YES'
: 'No, sorry'
: totalCount}
</td>
</tr>
{expandedRows.includes(index2) && (
<React.Fragment key={`expanded-${index2}`}>
{props.show === 'boolean' &&
dataset[2].map(
(booleanElement, booleanIndex) => (
<tr
className='trGranu'
key={`boolean-${booleanIndex}`}
>
<td className='tdGranu'></td>
<td
className={`tdGranu ${
booleanElement
? 'tdFoundDataset'
: 'tdNotFoundDataset'
}`}
>
{dataset[1][booleanIndex]}
</td>
<td
className={`tdGranu ${
booleanElement
? 'tdFound'
: 'tdNotFound'
}`}
>
{booleanElement ? 'YES' : 'No, sorry'}
</td>
</tr>
)
)}
{props.show === 'count' &&
dataset[3].map((countElement, countIndex) => (
<tr
className='trGranu'
key={`count-${countIndex}`}
>
<td className='tdGranu'></td>
<td
className={`tdGranu ${
countElement !== undefined &&
countElement !== null &&
countElement !== 0
? 'tdFoundDataset'
: 'tdNotFoundDataset'
}`}
>
{dataset[1][countIndex]}
</td>
<td
className={`tdGranu ${
countElement !== undefined &&
countElement !== null &&
countElement !== 0
? 'tdFound'
: 'tdNotFound'
}`}
>
{countElement}
</td>
</tr>
))}
</React.Fragment>
)}
</td>
<td className='tdGranuBeacon'></td>
<td className='tdGranuBeacon'>
{props.show === 'boolean'
? allTrue
? 'YES'
: 'No, sorry'
: totalCount}
</td>
</tr>
{expandedRows.includes(index2) && (
<React.Fragment key={`expanded-${index2}`}>
{props.show === 'boolean' &&
dataset[2].map((booleanElement, booleanIndex) => (
<tr
className='trGranu'
key={`boolean-${booleanIndex}`}
>
<td className='tdGranu'></td>
<td
className={`tdGranu ${
booleanElement
? 'tdFoundDataset'
: 'tdNotFoundDataset'
}`}
>
{dataset[1][booleanIndex]}
</td>
<td
className={`tdGranu ${
booleanElement ? 'tdFound' : 'tdNotFound'
}`}
>
{booleanElement ? 'YES' : 'No, sorry'}
</td>
</tr>
))}
{props.show === 'count' &&
dataset[3].map((countElement, countIndex) => (
<tr
className='trGranu'
key={`count-${countIndex}`}
>
<td className='tdGranu'></td>
<td
className={`tdGranu ${
countElement !== undefined &&
countElement !== null &&
countElement !== 0
? 'tdFoundDataset'
: 'tdNotFoundDataset'
}`}
>
{dataset[1][countIndex]}
</td>
<td
className={`tdGranu ${
countElement !== undefined &&
countElement !== null &&
countElement !== 0
? 'tdFound'
: 'tdNotFound'
}`}
>
{countElement}
</td>
</tr>
))}
</React.Fragment>
)}
</React.Fragment>
)
})}
{props.results.length === 0 &&
props.beaconsList.map((beacon, index2) => {
const totalCount = 0
const allTrue = 'No, sorry'

return (
<React.Fragment key={index2}>
<tr
className='trGranuBeacon'
onClick={() => toggleRow(index2)}
>
<td className='tdGranuBeacon'>
{beacon.id}
{expandedRows.includes(index2) ? (
<ion-icon name='chevron-down-outline'></ion-icon>
) : (
<ion-icon name='chevron-up-outline'></ion-icon>
)}
</td>
<td className='tdGranuBeacon'></td>
<td className='tdGranuBeacon'>
{props.show === 'boolean'
? allTrue
? 'YES'
: 'No, sorry'
: totalCount}
</td>
</tr>
</React.Fragment>
)
})}
</tbody>
</table>
)
})}
{props.results.length === 0 &&
props.beaconsList.map((beacon, index2) => {
const totalCount = 0
const allTrue = 'No, sorry'

return (
<React.Fragment key={index2}>
<tr
className='trGranuBeacon'
onClick={() => toggleRow(index2)}
>
<td className='tdGranuBeacon tdNotFoundDataset'>
{beacon.response.name}

</td>
<td className='tdGranuBeacon'></td>
<td className='tdGranuBeacon tdNotFoundDataset'>
{props.show === 'boolean'
? allTrue
? 'YES'
: 'No, sorry'
: totalCount}
</td>
</tr>
</React.Fragment>
)
})}
</tbody>
</table>
)}
</>
)
})}

Expand Down

0 comments on commit ddd603a

Please sign in to comment.