Skip to content

Commit

Permalink
Basic Table for txnHistory added
Browse files Browse the repository at this point in the history
Signed-off-by: Kartikay <[email protected]>
  • Loading branch information
kartikaysaxena committed Dec 10, 2023
1 parent ac6f840 commit 07fd514
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/site/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,17 @@ const Index = () => {
const [txnHistory, setTxnHistory] = useState([]);

const milliToDate = (milli) => {
const monthNames = [
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
];

let numberString = milli.toString();
let result = numberString.slice(0, -3);
let resultNumber = parseFloat(result);
const date = new Date(resultNumber);
return date.toString()
const time = date.getDate() + " " + monthNames[date.getMonth()] + " " + date.getFullYear();
return time;
}

const handleOpen = () => {
Expand Down Expand Up @@ -579,7 +585,7 @@ const Index = () => {
onClick={handleGetAllTransactions}
style={{ backgroundColor: '#6F4CFF', color: 'white' }}
>
ACTIVITY
Transaction History
</Button>
<Dialog open={open} onClose={handleClose} maxWidth='md'>
<DialogContent >
Expand All @@ -589,7 +595,7 @@ const Index = () => {
<TableHead>
<TableRow>
<TableCell>Version</TableCell>
<TableCell>Sender</TableCell>
<TableCell>Hash</TableCell>
<TableCell>Value</TableCell>
<TableCell>Timestamp</TableCell>
{/* Add more table headers if needed */}
Expand All @@ -600,7 +606,7 @@ const Index = () => {
{txnHistory.map((txn, i) => (
<TableRow key={i}>
<TableCell>{txn.version}</TableCell>
<TableCell>{txn.sender}</TableCell>
<TableCell>{txn.hash}</TableCell>
<TableCell>{txn.events[0].data.amount}</TableCell>
<TableCell>{milliToDate(txn.timestamp)}</TableCell>
{/* Add more table cells with data */}
Expand Down

0 comments on commit 07fd514

Please sign in to comment.