import React, { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import Sidebar from '../sidebar/Sidebar'; import axiosInstance from '../../api/axiosConfig'; const CustomerList = () => { const [customers, setCustomers] = useState([]); const navigate = useNavigate(); useEffect(() => { // Fetch the customers data from the JSON file getCustomers(); }, []); const getCustomers = async () => { try { const response = await axiosInstance.get('http://localhost:5000/customers'); let customers_data = response.data; // List of customers setCustomers(customers_data); } catch (error) { throw error; } }; const handleAddCustomer = () => { navigate('/add-customer'); }; return (

Customers List

Filter

Total Customers ({customers.length})

{customers.map((customer, index) => ( ))}
# customer id customer fullname
{index + 1} {customer.id} {customer.firstname} {customer.lastname}
); }; export default CustomerList;