Created
June 25, 2019 16:36
-
-
Save dhimasanb/3cb11b387e41305aac0daf9c4d3b4180 to your computer and use it in GitHub Desktop.
Table Result Index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import PropTypes from "prop-types"; | |
import { convertToRupiah } from "../../../../utils/helpers"; | |
import DataTable from "./components/dataTable"; | |
import AmountLeftTable from "./components/amountLeftTable"; | |
import "./index.css"; | |
const TableResult = ({ data, amountLeft }) => { | |
// Result data fractions | |
const dataSource = []; | |
let number = 0; | |
if (data && data.length > 0) { | |
data.map((value, index) => { | |
return dataSource.push({ | |
key: index, | |
no: (number += 1), | |
quantity: value.quantity, | |
rupiah: convertToRupiah(value.rupiah) | |
}); | |
}); | |
} | |
return ( | |
<div className="table-box"> | |
{/* Data Table */} | |
{data && data.length > 0 && ( | |
<div> | |
<DataTable dataSource={dataSource} /> | |
</div> | |
)} | |
{/* Amount Left Table */} | |
{amountLeft > 0 && ( | |
<div className="table-box"> | |
<AmountLeftTable amountLeft={amountLeft} /> | |
</div> | |
)} | |
</div> | |
); | |
}; | |
TableResult.propTypes = { | |
data: PropTypes.array, | |
amountLeft: PropTypes.any | |
}; | |
export default TableResult; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment