import React, { useState, useEffect } from "react"; import Layout from "../core/Layout"; import { isAuthenticated } from "../auth"; import { Link } from "react-router-dom"; import { getPurchaseHistory } from "./apiUser"; import moment from "moment"; const Dashboard = () => { const [history, setHistory] = useState([]); const { user: { _id, name, email, role } } = isAuthenticated(); const token = isAuthenticated().token; const init = (userId, token) => { getPurchaseHistory(userId, token).then(data => { if (data.error) { console.log(data.error); } else { setHistory(data); } }); }; useEffect(() => { init(_id, token); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const userLinks = () => { return (

User Links

); }; const userInfo = () => { return (

User Information

); }; const purchaseHistory = history => { return (

Purchase history

); }; return (
{userLinks()}
{userInfo()} {purchaseHistory(history)}
); }; export default Dashboard;