From 8f047a6d1810553d61b30cb540bebf48f533509f Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 23 Dec 2024 00:15:40 -0500 Subject: [PATCH] Product grid tweaks --- dashboard/src/App.jsx | 2 +- .../src/components/dashboard/ProductGrid.jsx | 115 +++++++++++------- 2 files changed, 72 insertions(+), 45 deletions(-) diff --git a/dashboard/src/App.jsx b/dashboard/src/App.jsx index e5b8c0a..9834078 100644 --- a/dashboard/src/App.jsx +++ b/dashboard/src/App.jsx @@ -104,7 +104,7 @@ const DashboardLayout = () => {
-
+
diff --git a/dashboard/src/components/dashboard/ProductGrid.jsx b/dashboard/src/components/dashboard/ProductGrid.jsx index b746bab..39f2946 100644 --- a/dashboard/src/components/dashboard/ProductGrid.jsx +++ b/dashboard/src/components/dashboard/ProductGrid.jsx @@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react"; import axios from "axios"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"; import { ScrollArea } from "@/components/ui/scroll-area"; -import { Loader2, ArrowUpDown, AlertCircle, Package, Settings2, Search } from "lucide-react"; +import { Loader2, ArrowUpDown, AlertCircle, Package, Settings2, Search, X } from "lucide-react"; import { Table, TableBody, @@ -46,6 +46,7 @@ const ProductGrid = ({ direction: "desc", }); const [searchQuery, setSearchQuery] = useState(""); + const [isSearchVisible, setIsSearchVisible] = useState(false); useEffect(() => { fetchProducts(); @@ -163,41 +164,67 @@ const ProductGrid = ({ return ( -
-
- {title} - {description && ( - {description} - )} -
-
- {!error && ( -
- - setSearchQuery(e.target.value)} - className="pl-8 h-9 w-[200px]" - /> -
- )} - +
+
+
+ {title} + {description && ( + {description} + )} +
+
+ {!error && ( + + )} + +
+ {isSearchVisible && !error && ( +
+ + setSearchQuery(e.target.value)} + className="pl-9 pr-9 h-9 w-full" + autoFocus + /> + {searchQuery && ( + + )} +
+ )}
@@ -225,39 +252,39 @@ const ProductGrid = ({ - - - -
- + + + + +