Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.4 kB
1
Indexable
Never
// DeliveryPartnerTable.js
import { MantineReactTable, useMantineReactTable } from "mantine-react-table";
import { useEffect, useMemo, useState } from "react";

const DeliveryPartnerTable = (deliveryPartners, loading) => {
  const [newDeliveryPartner, setNewDeliveryPartner] = useState([])

  useEffect(() => {
    if (!loading) {
      setNewDeliveryPartner(deliveryPartners)
    }
  }, [deliveryPartners, loading])
  // const [orders, setOrders] = useState([]);
  // const [loading, setLoading] = useState(true); // Add loading state

  console.log('deliveryPartners 234', deliveryPartners);


  const columns = useMemo(
    () => [
      {
        accessorKey: "email",
        header: "Email Id",
      },
    ],
    []
  );

  const table = useMantineReactTable({
    columns,
    data: newDeliveryPartner,
  });

  if (loading) {
    // Show loading indicator
    return (
      <div className="flex items-center justify-center mt-16">
        <div className="flex">
          <span className="loading loading-bars loading-xs"></span>
          <span className="loading loading-bars loading-sm"></span>
          <span className="loading loading-bars loading-md"></span>
          <span className="loading loading-bars loading-lg"></span>
        </div>
      </div>
    );
  }


  return <MantineReactTable table={table} />;
};

export default DeliveryPartnerTable;
Leave a Comment