MCPcopy Create free account
hub / github.com/GreatStackDev/gocart / OrderItem

Function OrderItem

components/OrderItem.jsx:9–91  ·  view source on GitHub ↗
({ order })

Source from the content-addressed store, hash-verified

7import RatingModal from "./RatingModal";
8
9const OrderItem = ({ order }) => {
10
11 const currency = process.env.NEXT_PUBLIC_CURRENCY_SYMBOL || '$';
12 const [ratingModal, setRatingModal] = useState(null);
13
14 const { ratings } = useSelector(state => state.rating);
15
16 return (
17 <>
18 <tr className="text-sm">
19 <td className="text-left">
20 <div className="flex flex-col gap-6">
21 {order.orderItems.map((item, index) => (
22 <div key={index} className="flex items-center gap-4">
23 <div className="w-20 aspect-square bg-slate-100 flex items-center justify-center rounded-md">
24 <Image
25 className="h-14 w-auto"
26 src={item.product.images[0]}
27 alt="product_img"
28 width={50}
29 height={50}
30 />
31 </div>
32 <div className="flex flex-col justify-center text-sm">
33 <p className="font-medium text-slate-600 text-base">{item.product.name}</p>
34 <p>{currency}{item.price} Qty : {item.quantity} </p>
35 <p className="mb-1">{new Date(order.createdAt).toDateString()}</p>
36 <div>
37 {ratings.find(rating => order.id === rating.orderId && item.product.id === rating.productId)
38 ? <Rating value={ratings.find(rating => order.id === rating.orderId && item.product.id === rating.productId).rating} />
39 : <button onClick={() => setRatingModal({ orderId: order.id, productId: item.product.id })} className={`text-green-500 hover:bg-green-50 transition ${order.status !== "DELIVERED" && 'hidden'}`}>Rate Product</button>
40 }</div>
41 {ratingModal && <RatingModal ratingModal={ratingModal} setRatingModal={setRatingModal} />}
42 </div>
43 </div>
44 ))}
45 </div>
46 </td>
47
48 <td className="text-center max-md:hidden">{currency}{order.total}</td>
49
50 <td className="text-left max-md:hidden">
51 <p>{order.address.name}, {order.address.street},</p>
52 <p>{order.address.city}, {order.address.state}, {order.address.zip}, {order.address.country},</p>
53 <p>{order.address.phone}</p>
54 </td>
55
56 <td className="text-left space-y-2 text-sm max-md:hidden">
57 <div
58 className={`flex items-center justify-center gap-1 rounded-full p-1 ${order.status === 'confirmed'
59 ? 'text-yellow-500 bg-yellow-100'
60 : order.status === 'delivered'
61 ? 'text-green-500 bg-green-100'
62 : 'text-slate-500 bg-slate-100'
63 }`}
64 >
65 <DotIcon size={10} className="scale-250" />
66 {order.status.split('_').join(' ').toLowerCase()}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected