MCPcopy Create free account
hub / github.com/basir/node-react-ecommerce / OrderScreen

Function OrderScreen

frontend/src/screens/OrderScreen.js:6–87  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

4import { createOrder, detailsOrder, payOrder } from '../actions/orderActions';
5import PaypalButton from '../components/PaypalButton';
6function OrderScreen(props) {
7
8 const orderPay = useSelector(state => state.orderPay);
9 const { loading: loadingPay, success: successPay, error: errorPay } = orderPay;
10 const dispatch = useDispatch();
11 useEffect(() => {
12 if (successPay) {
13 props.history.push("/profile");
14 } else {
15 dispatch(detailsOrder(props.match.params.id));
16 }
17 return () => {
18 };
19 }, [successPay]);
20
21 const handleSuccessPayment = (paymentResult) => {
22 dispatch(payOrder(order, paymentResult));
23 }
24
25 const orderDetails = useSelector(state => state.orderDetails);
26 const { loading, order, error } = orderDetails;
27
28 return loading ? <div>Loading ...</div> : error ? <div>{error}</div> :
29
30 <div>
31 <div className="placeorder">
32 <div className="placeorder-info">
33 <div>
34 <h3>
35 Shipping
36 </h3>
37 <div>
38 {order.shipping.address}, {order.shipping.city},
39 {order.shipping.postalCode}, {order.shipping.country},
40 </div>
41 <div>
42 {order.isDelivered ? "Delivered at " + order.deliveredAt : "Not Delivered."}
43 </div>
44 </div>
45 <div>
46 <h3>Payment</h3>
47 <div>
48 Payment Method: {order.payment.paymentMethod}
49 </div>
50 <div>
51 {order.isPaid ? "Paid at " + order.paidAt : "Not Paid."}
52 </div>
53 </div>
54 <div>
55 <ul className="cart-list-container">
56 <li>
57 <h3>
58 Shopping Cart
59 </h3>
60 <div>
61 Price
62 </div>
63 </li>

Callers

nothing calls this directly

Calls 1

detailsOrderFunction · 0.90

Tested by

no test coverage detected