Skip to content

Commit 8d4c775

Browse files
committed
fix(search): dataset count in database card
1 parent 3c4c2aa commit 8d4c775

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/components/DatasetDetailPage/MetaDataPanel.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const MetaDataPanel: React.FC<Props> = ({
106106
Modalities
107107
</Typography>
108108

109-
{(() => {
109+
{/* {(() => {
110110
const mods = Array.isArray(dbViewInfo?.rows?.[0]?.value?.modality)
111111
? [...new Set(dbViewInfo.rows[0].value.modality as string[])]
112112
: [];
@@ -149,10 +149,10 @@ const MetaDataPanel: React.FC<Props> = ({
149149
))}
150150
</Box>
151151
);
152-
})()}
153-
{/* <Typography sx={{ color: "text.secondary" }}>
152+
})()} */}
153+
<Typography sx={{ color: "text.secondary" }}>
154154
{dbViewInfo?.rows?.[0]?.value?.modality?.join(", ") ?? "N/A"}
155-
</Typography> */}
155+
</Typography>
156156
</Box>
157157
<Box>
158158
<Typography sx={{ color: Colors.darkPurple, fontWeight: "600" }}>

src/components/SearchPage/DatabaseCard.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import React from "react";
1414
import { useEffect } from "react";
1515
import { Link } from "react-router-dom";
1616
import { fetchDbInfo } from "redux/neurojson/neurojson.action";
17+
import { RootState } from "redux/store";
1718
import RoutesEnum from "types/routes.enum";
1819
import { 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

Comments
 (0)