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 (
Total Customers ({customers.length})
# | customer id | customer fullname |
---|---|---|
{index + 1} | {customer.id} | {customer.firstname} {customer.lastname} |