Skip to content

Commit d9e7dce

Browse files
committed
fix(search): correct dataset count on database card
1 parent c10f8ca commit d9e7dce

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/components/SearchPage/DatabaseCard.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ import {
88
Avatar,
99
} from "@mui/material";
1010
import { Colors } from "design/theme";
11+
import { useAppDispatch } from "hooks/useAppDispatch";
12+
import { useAppSelector } from "hooks/useAppSelector";
1113
import React from "react";
14+
import { useEffect } from "react";
1215
import { Link } from "react-router-dom";
16+
import { fetchDbInfo } from "redux/neurojson/neurojson.action";
1317
import RoutesEnum from "types/routes.enum";
1418
import { modalityValueToEnumLabel } from "utils/SearchPageFunctions/modalityLabels";
1519

@@ -32,6 +36,10 @@ const DatabaseCard: React.FC<Props> = ({
3236
keyword,
3337
onChipClick,
3438
}) => {
39+
const dispatch = useAppDispatch();
40+
const { loading, error, data, limit } = useAppSelector(
41+
(state) => state.neurojson
42+
);
3543
const databaseLink = `${RoutesEnum.DATABASES}/${dbId}`;
3644
// keyword hightlight functional component
3745
const highlightKeyword = (text: string, keyword?: string) => {
@@ -42,6 +50,12 @@ const DatabaseCard: React.FC<Props> = ({
4250
const regex = new RegExp(`(${keyword})`, "gi"); // for case-insensitive and global
4351
const parts = text.split(regex);
4452

53+
useEffect(() => {
54+
if (dbId) {
55+
dispatch(fetchDbInfo(dbId.toLowerCase()));
56+
}
57+
}, [dbId, dispatch]);
58+
4559
return (
4660
<>
4761
{parts.map((part, i) =>
@@ -181,7 +195,8 @@ const DatabaseCard: React.FC<Props> = ({
181195

182196
<Stack direction="row" spacing={1} flexWrap="wrap" gap={1}>
183197
<Typography variant="body2" mt={1}>
184-
<strong>Datasets:</strong> {datasets ?? "N/A"}
198+
{/* <strong>Datasets:</strong> {datasets ?? "N/A"} */}
199+
<strong>Datasets:</strong> {limit ?? "N/A"}
185200
</Typography>
186201
</Stack>
187202
</Stack>

0 commit comments

Comments
 (0)