From 200c5fa52329f74cd3651b582ccc11141b2c8b96 Mon Sep 17 00:00:00 2001 From: Daniel Cojocea Date: Wed, 18 Sep 2024 17:22:58 -0400 Subject: [PATCH] Hooked up search to state --- Client/src/Components/Inputs/Search/index.jsx | 22 ++++++++----------- Client/src/Pages/Monitors/Home/index.jsx | 10 ++++++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Client/src/Components/Inputs/Search/index.jsx b/Client/src/Components/Inputs/Search/index.jsx index ab6586119..b8eaf89b6 100644 --- a/Client/src/Components/Inputs/Search/index.jsx +++ b/Client/src/Components/Inputs/Search/index.jsx @@ -3,25 +3,21 @@ import { Box, ListItem, Autocomplete, TextField } from "@mui/material"; import { useTheme } from "@emotion/react"; import SearchIcon from "../../../assets/icons/search.svg?react"; -const options = [ - "Google", - "Material UI", - "Alias", - "Twitter", - "Discord", - "YouTube", -]; - -const Search = ({ id, sx }) => { +const Search = ({ id, options, value, handleChange, sx }) => { const theme = useTheme(); return ( { + handleChange(newValue); + }} fullWidth freeSolo disableClearable options={options} + getOptionLabel={(option) => option.name} renderInput={(params) => ( { )} filterOptions={(options, { inputValue }) => { const filtered = options.filter((option) => - option.toLowerCase().includes(inputValue.toLowerCase()) + option.name.toLowerCase().includes(inputValue.toLowerCase()) ); if (filtered.length === 0) { - return [{ label: "No monitors found", noOptions: true }]; + return [{ name: "No monitors found", noOptions: true }]; } return filtered; }} @@ -84,7 +80,7 @@ const Search = ({ id, sx }) => { : {} } > - {option.noOptions ? option.label : option} + {option.name} ); }} diff --git a/Client/src/Pages/Monitors/Home/index.jsx b/Client/src/Pages/Monitors/Home/index.jsx index a6518f56b..36921d1f5 100644 --- a/Client/src/Pages/Monitors/Home/index.jsx +++ b/Client/src/Pages/Monitors/Home/index.jsx @@ -1,5 +1,5 @@ import "./index.css"; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import { useSelector, useDispatch } from "react-redux"; import { getUptimeMonitorsByTeamId } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice"; import { useNavigate } from "react-router-dom"; @@ -19,6 +19,7 @@ const Monitors = ({ isAdmin }) => { const navigate = useNavigate(); const monitorState = useSelector((state) => state.uptimeMonitors); const authState = useSelector((state) => state.auth); + const [search, setSearch] = useState(""); const dispatch = useDispatch({}); useEffect(() => { @@ -28,7 +29,6 @@ const Monitors = ({ isAdmin }) => { monitorState?.isLoading && monitorState?.monitorsSummary?.monitors?.length === 0; - console.log(monitorState.monitorsSummary.monitors); return ( {loading ? ( @@ -118,7 +118,11 @@ const Monitors = ({ isAdmin }) => { {monitorState?.monitorsSummary?.monitorCounts?.total || 0} - +