import React, { useState, useEffect } from 'react'; import { withRouter, useParams } from 'react-router-dom'; import axios from "axios"; import M from "materialize-css"; import './Flow.css'; import { formatMoney, timestampToDate } from "../common/formatting"; const Flow = (props) => { const { homie_id } = useParams(); const [flow, setFlow] = useState([]); useEffect( () => { (async () => { try { const response = await axios.get(`/api/money_moves?homie_id=${parseInt(homie_id)}`); if (response.status === 200 && response.data){ setFlow(response.data); } } catch (e) { M.toast({ html: "Yo! It ain't workin'" }); } })(); }, [homie_id]); const dateBlock = (timestamp) => { timestampToDate(timestamp) } const flowData = flow.map( (singleFlowData, index) => (