Connect search component to monitor table

This commit is contained in:
Alex Holliday committed 2024-09-19 11:07:38 +08:00
1 parent b8d2dd834a
commit 07190f82d5
4 files changed
+42 -9

No files matched your search

@@ -108,7 +108,7 @@ TablePaginationActions.propTypes = {
onPageChange: PropTypes.func.isRequired,
};
const MonitorTable = ({ isAdmin }) => {
const MonitorTable = ({ isAdmin, filter }) => {
const theme = useTheme();
const navigate = useNavigate();
const dispatch = useDispatch();
@@ -155,7 +155,7 @@ const MonitorTable = ({ isAdmin }) => {
normalize: true,
page: page,
rowsPerPage: rowsPerPage,
filter: null,
filter: filter,
field: sort.field,
order: sort.order,
});
@@ -166,7 +166,7 @@ const MonitorTable = ({ isAdmin }) => {
}
};
fetchPage();
}, [updateTrigger, authState, page, rowsPerPage]);
}, [updateTrigger, authState, page, rowsPerPage, filter, sort]);
/**
* Helper function to calculate the range of displayed rows.
@@ -406,6 +406,7 @@ const MonitorTable = ({ isAdmin }) => {
MonitorTable.propTypes = {
isAdmin: PropTypes.bool,
filter: PropTypes.string,
};
const MemoizedMonitorTable = memo(MonitorTable);
+4 -2
View File
@@ -13,6 +13,7 @@ import Breadcrumbs from "../../../Components/Breadcrumbs";
import Greeting from "../../../Utils/greeting";
import MonitorTable from "./MonitorTable";
import Search from "../../../Components/Inputs/Search";
import useDebounce from "../../../Utils/debounce";
const Monitors = ({ isAdmin }) => {
const theme = useTheme();
@@ -21,6 +22,7 @@ const Monitors = ({ isAdmin }) => {
const authState = useSelector((state) => state.auth);
const [search, setSearch] = useState("");
const dispatch = useDispatch({});
const debouncedFilter = useDebounce(search, 500);
useEffect(() => {
dispatch(getUptimeMonitorsByTeamId(authState.authToken));
@@ -122,11 +124,11 @@ const Monitors = ({ isAdmin }) => {
options={monitorState?.monitorsSummary.monitors}
filteredBy="name"
value={search}
handleChange={setSearch}
handleInputChange={setSearch}
/>
</Box>
</Stack>
<MonitorTable isAdmin={isAdmin} />
<MonitorTable isAdmin={isAdmin} filter={debouncedFilter} />
</Box>
</>
)}