import React, { useEffect, useState } from "react"; import OrderButtons from "./OrderButtons"; import { FiChevronRight } from "react-icons/fi"; import OrderDetails from "./OrderDetails"; const OrderIndexItem = ({ order, collapseAll, expandAll, setCollapseAll, setExpandAll, }) => { // const { orderId, status } = order; // const idToShow = orderId.slice(-7).toUpperCase(); const [showDetails, setShowDetails] = useState(false); useEffect(() => { if (collapseAll) { setShowDetails(false); } if (expandAll) { setShowDetails(true); } setCollapseAll(false); setExpandAll(false); }, [showDetails, collapseAll, expandAll, setCollapseAll, setExpandAll]); if (!order.orderId) return null; const { orderId, status } = order; const idToShow = orderId.slice(-7).toUpperCase(); const handleDropDown = () => { setShowDetails(!showDetails); }; const actions = status === "FULFILLED" || status === "CANCELLED" ? (
{status}
) : ( ); return (
{`Order #: ${orderId}`}
{actions}
); }; export default OrderIndexItem;