11import { useState , useMemo } from 'react' ;
22import { useQuery } from '@tanstack/react-query' ;
3- import {
4- WarningCircle ,
5- List ,
6- GridFour ,
7- MagnifyingGlass ,
8- Database
9- } from '@phosphor-icons/react' ;
3+ import { WarningCircle , List , GridFour , MagnifyingGlass , Database } from '@phosphor-icons/react' ;
104
115import SourcesTableView from './SourcesTableView' ;
126import SourcesCardsView from './SourcesCardsView' ;
@@ -23,33 +17,28 @@ interface SourcesTableProps {
2317export default function SourcesTable ( { searchQuery = '' } : SourcesTableProps ) {
2418 const [ viewMode , setViewMode ] = useState < 'table' | 'cards' > ( 'table' ) ;
2519
26- const {
27- data,
28- isLoading : loading ,
29- error
30- } = useQuery (
31- createSourcesQuery ( ) ,
32- queryClient
33- ) ;
20+ const { data, isLoading : loading , error } = useQuery ( createSourcesQuery ( ) , queryClient ) ;
3421
3522 const dataSources = useMemo ( ( ) => {
36- const filteredGroups = data ?. filter ( ( dataSource ) => {
37- if ( ! searchQuery ) return true ;
38-
39- const searchLower = searchQuery . toLowerCase ( ) ;
40- return (
41- dataSource . dataset . toLowerCase ( ) . includes ( searchLower ) ||
42- generateDisplayName ( dataSource . dataset ) . toLowerCase ( ) . includes ( searchLower ) ||
43- dataSource . endpoints . some (
44- ( endpoint ) =>
45- endpoint . url . toLowerCase ( ) . includes ( searchLower ) ||
46- endpoint . modules . some ( module =>
47- module . name . toLowerCase ( ) . includes ( searchLower ) ||
48- module . label . toLowerCase ( ) . includes ( searchLower )
49- )
50- )
51- ) ;
52- } ) ?? [ ] ;
23+ const filteredGroups =
24+ data ?. filter ( ( dataSource ) => {
25+ if ( ! searchQuery ) return true ;
26+
27+ const searchLower = searchQuery . toLowerCase ( ) ;
28+ return (
29+ dataSource . dataset . toLowerCase ( ) . includes ( searchLower ) ||
30+ generateDisplayName ( dataSource . dataset ) . toLowerCase ( ) . includes ( searchLower ) ||
31+ dataSource . endpoints . some (
32+ ( endpoint ) =>
33+ endpoint . url . toLowerCase ( ) . includes ( searchLower ) ||
34+ endpoint . modules . some (
35+ ( module ) =>
36+ module . name . toLowerCase ( ) . includes ( searchLower ) ||
37+ module . label . toLowerCase ( ) . includes ( searchLower )
38+ )
39+ )
40+ ) ;
41+ } ) ?? [ ] ;
5342
5443 return filteredGroups . sort ( ( a , b ) => {
5544 if ( b . endpoints . length !== a . endpoints . length ) {
@@ -118,8 +107,8 @@ export default function SourcesTable({ searchQuery = '' }: SourcesTableProps) {
118107 < div className = "space-y-4" >
119108 < div className = "text-gGray-600 flex items-center justify-between text-sm" >
120109 < span >
121- { dataSources . length } data source{ dataSources . length !== 1 ? 's' : '' } •{ ' ' }
122- { totalModules } unique modules
110+ { dataSources . length } data source{ dataSources . length !== 1 ? 's' : '' } • { totalModules } { ' ' }
111+ unique modules
123112 </ span >
124113
125114 < div className = "flex items-center space-x-4" >
0 commit comments