Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of undefined (reading 'path') #62

Open
nilabhjaiswal opened this issue Jun 16, 2023 · 0 comments
Open

Comments

@nilabhjaiswal
Copy link

nilabhjaiswal commented Jun 16, 2023

import React,{ Fragment, useEffect } from 'react';
import {useDispatch, useSelector } from "react-redux";
import { useAlert } from "react-alert";
import { Link, useMatch } from "react-router-dom";
import { Typography } from "@mui/material";
import "./OrderDetails.css";
import Loader from "../layout/Loader/Loader";
import MetaData from "../layout/MetaData";
import { getOrderDetails, clearErrors } from "../../actions/orderAction";

const OrderDetails = () => {
const { order, error, loading } = useSelector((state) => state.orderDetails);

const match = useMatch();
const dispatch = useDispatch();
const alert = useAlert();

useEffect(() => {
if (error) {
alert.error(error);
dispatch(clearErrors());
}

dispatch(getOrderDetails(match.params.id));

}, [dispatch, alert, error, match.params.id]);
return (

{loading ? (

) : (





Order #{order && order._id}

Shipping Info


Name:


{order.user && order.user.name}


Phone:



{order.shippingInfo && order.shippingInfo.phoneNo}



Address:



{order.shippingInfo &&
${order.shippingInfo.address}, ${order.shippingInfo.city}, ${order.shippingInfo.state}, ${order.shippingInfo.pinCode}, ${order.shippingInfo.country}}



Payment


<p
className={
order.paymentInfo &&
order.paymentInfo.status === "succeeded"
? "greenColor"
: "redColor"
}
>
{order.paymentInfo &&
order.paymentInfo.status === "succeeded"
? "PAID"
: "NOT PAID"}


            <div>
              <p>Amount:</p>
              <span>{order && order.totalPrice}</span>
            </div>
          </div>

          <Typography>Order Status</Typography>
          <div className="orderDetailsContainerBox">
            <div>
              <p
                className={
                  order.orderStatus && order.orderStatus === "Delivered"
                    ? "greenColor"
                    : "redColor"
                }
              >
                {order && order.orderStatus}
              </p>
            </div>
          </div>
        </div>

        <div className="orderDetailsCartItems">
          <Typography>Order Items:</Typography>
          <div className="orderDetailsCartItemsContainer">
            {order.orderItems &&
              order.orderItems.map((item) => (
                <div key={item.product}>
                  <img src={item.image} alt="Product" />
                  <Link to={`/product/${item.product}`}>
                    {item.name}
                  </Link>{" "}
                  <span>
                    {item.quantity} X ₹{item.price} ={" "}
                    <b>₹{item.price * item.quantity}</b>
                  </span>
                </div>
              ))}
          </div>
        </div>
      </div>
    </Fragment>
  )}
</Fragment>

)
}

export default OrderDetails

@nilabhjaiswal nilabhjaiswal changed the title TypeError: params.getValue is not a function - at Object.cellClassName TypeError: Cannot read properties of undefined (reading 'path') Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant