coe pair filter

This commit is contained in:
2026-05-27 11:29:02 -04:00
parent 8da5957024
commit 5996443f38
8 changed files with 221 additions and 7 deletions
+18 -3
View File
@@ -1,5 +1,4 @@
import { useState, useMemo } from 'react'
import { useQueryClient } from '@tanstack/react-query'
import { Settings } from 'lucide-react'
import { useStats } from './hooks/useStats'
import { useTests } from './hooks/useTests'
@@ -11,8 +10,19 @@ import FilterPanel from './components/FilterPanel'
import TestTable from './components/TestTable'
import ConfigModal from './components/ConfigModal'
function hasCoePairs(value) {
if (!value) return false
if (Array.isArray(value)) return value.length > 0
if (typeof value !== 'string') return false
try {
const parsed = JSON.parse(value)
return Array.isArray(parsed) && parsed.length > 0
} catch {
return false
}
}
export default function App() {
const queryClient = useQueryClient()
const [showConfig, setShowConfig] = useState(false)
const [filters, setFilters] = useState({})
@@ -32,6 +42,11 @@ export default function App() {
for (const f of strFields) {
if (filters[f] && t[f] !== filters[f]) return false
}
if (filters.coePair === 'yes' || filters.coePair === 'no') {
const paired = hasCoePairs(t.coe_pair)
if (filters.coePair === 'yes' && !paired) return false
if (filters.coePair === 'no' && paired) return false
}
return true
})
}, [allTests, filters])
@@ -125,7 +140,7 @@ export default function App() {
<p className="text-slate-500 text-xs">
Showing {filteredTests.length} of {allTests.length} tests
</p>
<TestTable tests={filteredTests} isLoading={testsLoading} />
<TestTable tests={filteredTests} allTests={allTests} isLoading={testsLoading} />
</div>
</main>