show transactions on homie click

This commit is contained in:
Bilal
2020-09-11 12:34:15 +03:00
parent da35c0d9a7
commit 36968b234c
9 changed files with 268 additions and 34 deletions

View File

@@ -4,6 +4,7 @@ import './Cash.css';
import axios from 'axios';
import { MAKE_MONEY_MOVE } from '../RouteNames';
import { withRouter } from 'react-router-dom';
import { formatMoney } from '../common/formatting';
const Cash = (props) => {
const [homiesCash, setHomiesCash] = useState([]);
@@ -21,17 +22,11 @@ const Cash = (props) => {
getCashForHomies();
}, []);
const formatMoney = (amount) => {
const formatted = Number.parseFloat(amount).toFixed(2);
return `${formatted} KM`;
}
const cashTableBody = homiesCash.map( (homieLine) => {
return (
<tr key={homieLine.homie.id}>
<td className="cash-cell-left">
{ homieLine.homie.name }
<a href={`/homie/${homieLine.homie.id}/flow`}>{ homieLine.homie.name }</a>
</td>
<td className="cash-cell-right">
{ formatMoney(homieLine.amount) }
@@ -44,39 +39,39 @@ const Cash = (props) => {
});
return (
<div>
<div className="container">
<Table>
<thead>
<tr>
<th>
Homie
</th>
<th>
Cash
</th>
<th>
Actions
</th>
</tr>
</thead>
<tbody>
{ cashTableBody }
</tbody>
</Table>
<Table>
<thead>
<tr>
<th>
Homie
</th>
<th>
Cash
</th>
<th>
Actions
</th>
</tr>
</thead>
<tbody>
{ cashTableBody }
</tbody>
</Table>
<Button
<Button
floating
large
className="green"
fab={{direction: 'bottom'}}
waves="light"
icon="add"
icon="add"
onClick={
() => {
props.history.push(MAKE_MONEY_MOVE)
}
}/>
}
/>
</div>
);