diff --git a/app/dashboard/applications/Applications.tsx b/app/dashboard/applications/Applications.tsx
index 62c1fb9..cd67711 100644
--- a/app/dashboard/applications/Applications.tsx
+++ b/app/dashboard/applications/Applications.tsx
@@ -213,7 +213,7 @@ export default function Dashboard() {
console.log(error.response.data);
}
};
-
+
const searchApplications = async () => {
try {
setIsSearching(true);
@@ -391,7 +391,6 @@ export default function Dashboard() {
onChange={(e) => setSearchTerm(e.target.value)}
/>
-
{!loading ? (
("");
const [editDisk, setEditDisk] = useState
("");
+ const [searchTerm, setSearchTerm] = useState("");
+ const [isSearching, setIsSearching] = useState(false);
+
useEffect(() => {
const savedLayout = Cookies.get('layoutPreference-servers');
setIsGridLayout(savedLayout === 'grid');
@@ -210,6 +213,33 @@ export default function Dashboard() {
}
}
+ const searchServers = async () => {
+ try {
+ setIsSearching(true);
+ const response = await axios.post<{ results: Server[] }>(
+ "/api/servers/search",
+ { searchterm: searchTerm }
+ );
+ setServers(response.data.results);
+ setIsSearching(false);
+ } catch (error: any) {
+ console.error("Search error:", error.response?.data);
+ setIsSearching(false);
+ }
+ };
+
+ useEffect(() => {
+ const delayDebounce = setTimeout(() => {
+ if (searchTerm.trim() === "") {
+ getServers();
+ } else {
+ searchServers();
+ }
+ }, 300);
+
+ return () => clearTimeout(delayDebounce);
+ }, [searchTerm]);
+
return (
@@ -345,6 +375,14 @@ export default function Dashboard() {
+
+ setSearchTerm(e.target.value)}
+ />
+
{!loading ?