@@ -14,6 +14,7 @@ import React from "react";
1414import { useEffect } from "react" ;
1515import { Link } from "react-router-dom" ;
1616import { fetchDbInfo } from "redux/neurojson/neurojson.action" ;
17+ import { RootState } from "redux/store" ;
1718import RoutesEnum from "types/routes.enum" ;
1819import { modalityValueToEnumLabel } from "utils/SearchPageFunctions/modalityLabels" ;
1920
@@ -37,9 +38,13 @@ const DatabaseCard: React.FC<Props> = ({
3738 onChipClick,
3839} ) => {
3940 const dispatch = useAppDispatch ( ) ;
40- const { loading, error, data, limit } = useAppSelector (
41- ( state ) => state . neurojson
42- ) ;
41+ const dbInfo = useAppSelector ( ( state : RootState ) => state . neurojson . dbInfo ) ;
42+ console . log ( "dbInfo" , dbInfo ) ;
43+ useEffect ( ( ) => {
44+ if ( dbId ) {
45+ dispatch ( fetchDbInfo ( dbId . toLowerCase ( ) ) ) ;
46+ }
47+ } , [ dbId , dispatch ] ) ;
4348 const databaseLink = `${ RoutesEnum . DATABASES } /${ dbId } ` ;
4449 // keyword hightlight functional component
4550 const highlightKeyword = ( text : string , keyword ?: string ) => {
@@ -50,12 +55,6 @@ const DatabaseCard: React.FC<Props> = ({
5055 const regex = new RegExp ( `(${ keyword } )` , "gi" ) ; // for case-insensitive and global
5156 const parts = text . split ( regex ) ;
5257
53- useEffect ( ( ) => {
54- if ( dbId ) {
55- dispatch ( fetchDbInfo ( dbId . toLowerCase ( ) ) ) ;
56- }
57- } , [ dbId , dispatch ] ) ;
58-
5958 return (
6059 < >
6160 { parts . map ( ( part , i ) =>
@@ -195,8 +194,9 @@ const DatabaseCard: React.FC<Props> = ({
195194
196195 < Stack direction = "row" spacing = { 1 } flexWrap = "wrap" gap = { 1 } >
197196 < Typography variant = "body2" mt = { 1 } >
198- { /* <strong>Datasets:</strong> {datasets ?? "N/A"} */ }
199- < strong > Datasets:</ strong > { limit ?? "N/A" }
197+ < strong > Datasets:</ strong > { datasets ?? "N/A" }
198+ { /* <strong>Datasets:</strong>{" "}
199+ {dbInfo?.doc_count != null ? dbInfo.doc_count - 1 : "N/A"} */ }
200200 </ Typography >
201201 </ Stack >
202202 </ Stack >
0 commit comments