Skip to content

Instantly share code, notes, and snippets.

@dhimasanb
Created June 25, 2019 16:36
Show Gist options
  • Save dhimasanb/3cb11b387e41305aac0daf9c4d3b4180 to your computer and use it in GitHub Desktop.
Save dhimasanb/3cb11b387e41305aac0daf9c4d3b4180 to your computer and use it in GitHub Desktop.
Table Result Index.js
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