import React, { useState, useEffect } from 'react' import axios from 'axios'; import { isAuthenticated } from '../utils/auth' import catchErrors from '../utils/catchErrors'; import { Card, Row, Col, Button, Alert } from 'react-bootstrap'; import { Link } from 'react-router-dom'; function PaymentCompleted() { const user = isAuthenticated() const [error, setError] = useState() const [order, setOrder] = useState([]) const [total, setTotal] = useState(0) const [receiverInfo, setReceiverInfo] = useState({}) const [num, setNum] = useState('') useEffect(() => { getOrder() }, [user]) async function getOrder() { try { setError('') const response = await axios.get(`/api/order/showorder/${user}`) console.log(response.data) setNum(response.data._id) setOrder(response.data.products) setTotal(response.data.total) setReceiverInfo(response.data.receiverInfo) } catch (error) { catchErrors(error, setError) } } return (