diff --git a/src/pages/customers/CustomerList.jsx b/src/pages/customers/CustomerList.jsx index ebd8340..b9d3d4f 100644 --- a/src/pages/customers/CustomerList.jsx +++ b/src/pages/customers/CustomerList.jsx @@ -6,6 +6,7 @@ import { useAuth } from '../../context/AuthContext'; const CustomerList = () => { const { token } = useAuth(); + const [filter, setFilter] = useState('all'); const [searchTerm, setSearchTerm] = useState(''); const [customers, setCustomers] = useState([]); const [loading, setLoading] = useState(true); @@ -15,10 +16,13 @@ const CustomerList = () => { const fetchCustomers = async () => { try { setLoading(true); - // Include search query parameter if any - const url = searchTerm - ? `${API_BASE_URL}/customers/?search=${encodeURIComponent(searchTerm)}` - : `${API_BASE_URL}/customers/`; + let url = `${API_BASE_URL}/customers/`; + const params = []; + if (searchTerm) params.push(`search=${encodeURIComponent(searchTerm)}`); + if (filter !== 'all') params.push(`status=${filter}`); + if (params.length > 0) { + url += `?${params.join('&')}`; + } const res = await fetch(url, { headers: { @@ -36,21 +40,34 @@ const CustomerList = () => { }; fetchCustomers(); - }, [searchTerm, token]); + }, [searchTerm, filter, token]); return (

Customer Management

-
+
setSearchTerm(e.target.value)} /> +
+ {['all', 'active', 'banned'].map((status) => ( + + ))} +
{loading ? ( diff --git a/src/pages/products/ProductList.jsx b/src/pages/products/ProductList.jsx index b633d6b..8113b6f 100644 --- a/src/pages/products/ProductList.jsx +++ b/src/pages/products/ProductList.jsx @@ -6,6 +6,8 @@ import { useAuth } from '../../context/AuthContext'; const ProductList = () => { const { token } = useAuth(); const [searchTerm, setSearchTerm] = useState(''); + const [productFilter, setProductFilter] = useState('all'); + const [sellerFilter, setSellerFilter] = useState('all'); const [products, setProducts] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); @@ -14,7 +16,15 @@ const ProductList = () => { const fetchProducts = async () => { try { setLoading(true); - const res = await fetch(`${API_BASE_URL}/products/`, { + let url = `${API_BASE_URL}/products/`; + const params = []; + if (productFilter !== 'all') params.push(`status=${productFilter}`); + if (sellerFilter !== 'all') params.push(`seller_status=${sellerFilter}`); + if (params.length > 0) { + url += `?${params.join('&')}`; + } + + const res = await fetch(url, { headers: { 'Authorization': `Bearer ${token}` } @@ -31,7 +41,7 @@ const ProductList = () => { useEffect(() => { fetchProducts(); - }, [token]); + }, [productFilter, sellerFilter, token]); const handleStatusChange = async (prodId, action) => { try { @@ -78,14 +88,53 @@ const ProductList = () => {

Product Review & Management

-
- setSearchTerm(e.target.value)} - /> + {/* Search and Filters row */} +
+
+ setSearchTerm(e.target.value)} + /> +
+ +
+ {/* Product Status Filter */} +
+ Product Status: +
+ {['all', 'pending', 'approved', 'hold', 'rejected'].map((status) => ( + + ))} +
+
+ + {/* Seller Status Filter */} +
+ Seller Status: +
+ {['all', 'unverified', 'pending_approval', 'approved', 'rejected', 'suspended'].map((status) => ( + + ))} +
+
+
{loading ? ( diff --git a/src/pages/sellers/SellerList.jsx b/src/pages/sellers/SellerList.jsx index 5bdd6d4..6588743 100644 --- a/src/pages/sellers/SellerList.jsx +++ b/src/pages/sellers/SellerList.jsx @@ -61,7 +61,7 @@ const SellerList = () => { onChange={(e) => setSearchTerm(e.target.value)} />
- {['all', 'pending_approval', 'approved', 'suspended', 'banned'].map((status) => ( + {['all', 'unverified', 'pending_approval', 'approved', 'rejected', 'suspended'].map((status) => (