Created
February 21, 2019 04:01
-
-
Save wayanjimmy/3ca5dc95919edf9e7058005812ca1741 to your computer and use it in GitHub Desktop.
HistoryPanel
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, {Component} from "react" | |
const dateTimeFormat = "DD/MM/YYYY h:mm:ss a" | |
function HistoryRows({histories}) { | |
return histories.map((data, index) => ( | |
<tr key={index}> | |
<td>{data.message}</td> | |
<td>{moment(data.createdAt).format(dateTimeFormat)}</td> | |
<td>{data.createdBy}</td> | |
</tr> | |
)) | |
} | |
function HistoryPanel(props) { | |
return ( | |
<div className="table-fluid"> | |
<table className="table table-striped"> | |
<colgroup> | |
<col className="col-md-8" /> | |
<col className="col-md-2" /> | |
<col className="col-md-2" /> | |
</colgroup> | |
<thead> | |
<tr> | |
<th scope="col">Message</th> | |
<th scope="col">Date</th> | |
<th scope="col">User</th> | |
</tr> | |
</thead> | |
<tbody> | |
{(props.histories.length) ? <HistoryRows histories={props.histories}/> : ( | |
<tr> | |
<td colSpan={3}> | |
<div className="text-center">Empty</div> | |
</td> | |
</tr> | |
)} | |
</tbody> | |
</table> | |
</div> | |
) | |
} | |
export default HistoryPanel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment