hmm
This commit is contained in:
@@ -3,12 +3,14 @@ import { Edit, Trash, AlertTriangle, CheckCircle, AlertCircle } from "lucide-rea
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Product } from "@/models/products";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
|
||||
interface ProductTableProps {
|
||||
products: Product[];
|
||||
loading: boolean;
|
||||
onEdit: (product: Product) => void;
|
||||
onDelete: (productId: string) => void;
|
||||
onToggleEnabled: (productId: string, enabled: boolean) => void;
|
||||
getCategoryNameById: (categoryId: string) => string;
|
||||
}
|
||||
|
||||
@@ -17,6 +19,7 @@ const ProductTable = ({
|
||||
loading,
|
||||
onEdit,
|
||||
onDelete,
|
||||
onToggleEnabled,
|
||||
getCategoryNameById
|
||||
}: ProductTableProps) => {
|
||||
|
||||
@@ -47,6 +50,7 @@ const ProductTable = ({
|
||||
<TableHead className="text-center">Category</TableHead>
|
||||
<TableHead className="text-center">Unit</TableHead>
|
||||
<TableHead className="text-center">Stock</TableHead>
|
||||
<TableHead className="text-center">Enabled</TableHead>
|
||||
<TableHead className="text-right">Actions</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
@@ -59,6 +63,7 @@ const ProductTable = ({
|
||||
<TableCell>Loading...</TableCell>
|
||||
<TableCell>Loading...</TableCell>
|
||||
<TableCell>Loading...</TableCell>
|
||||
<TableCell>Loading...</TableCell>
|
||||
</TableRow>
|
||||
))
|
||||
) : sortedProducts.length > 0 ? (
|
||||
@@ -81,6 +86,12 @@ const ProductTable = ({
|
||||
<Badge variant="outline" className="text-xs">Not Tracked</Badge>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell className="text-center">
|
||||
<Switch
|
||||
checked={product.enabled !== false}
|
||||
onCheckedChange={(checked) => onToggleEnabled(product._id as string, checked)}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell className="text-right flex justify-end space-x-1">
|
||||
<Button variant="ghost" size="sm" onClick={() => onEdit(product)}>
|
||||
<Edit className="h-4 w-4" />
|
||||
@@ -98,7 +109,7 @@ const ProductTable = ({
|
||||
))
|
||||
) : (
|
||||
<TableRow>
|
||||
<TableCell colSpan={5} className="h-24 text-center">
|
||||
<TableCell colSpan={6} className="h-24 text-center">
|
||||
No products found.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
Reference in New Issue
Block a user