diff --git a/packages/frontend/src/components/SearchBar.tsx b/packages/frontend/src/components/SearchBar.tsx index 6587825d..473da86a 100644 --- a/packages/frontend/src/components/SearchBar.tsx +++ b/packages/frontend/src/components/SearchBar.tsx @@ -3,7 +3,7 @@ import React, { ChangeEventHandler, forwardRef } from 'react'; import { Input } from '@material-tailwind/react'; interface SearchBarProps { - onChange: ChangeEventHandler; + onChange?: ChangeEventHandler; value?: string; placeholder?: string; } @@ -15,7 +15,6 @@ const SearchBar: React.ForwardRefRenderFunction< return (
{ + const [searchedBranch, setSearchedBranch] = useState(''); + + const filteredDeployments = useMemo(() => { + if (searchedBranch) { + return deploymentData.filter((deployment) => + deployment.branch.toLowerCase().includes(searchedBranch.toLowerCase()), + ); + } + + return deploymentData; + }, [searchedBranch]); + + const handleResetFilters = useCallback(() => { + setSearchedBranch(''); + }, []); + return (
- setSearchedBranch(event.target.value)} />
@@ -37,9 +56,25 @@ const DeploymentsTabPanel = () => {
- {deploymentDetails.map((deployment, key) => { - return ; - })} + {Boolean(filteredDeployments.length) ? ( + filteredDeployments.map((deployment, key) => { + return ; + }) + ) : ( +
+
+
No deployments found
+

Please change your search query or filters

+ +
+
+ )}
);