-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
802e892
commit 238bc31
Showing
8 changed files
with
683 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function getRelativeTime(timestamp) { | ||
const currentTimestamp = new Date().getTime(); | ||
const targetTimestamp = new Date(timestamp).getTime(); | ||
|
||
const differenceInMilliseconds = currentTimestamp - targetTimestamp; | ||
const differenceInDays = Math.floor( | ||
differenceInMilliseconds / (1000 * 60 * 60 * 24) | ||
); | ||
const differenceInHours = Math.floor( | ||
(differenceInMilliseconds % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) | ||
); | ||
|
||
if (differenceInDays > 0) { | ||
return `${differenceInDays} ${differenceInDays === 1 ? "day" : "days"} ago`; | ||
} else if (differenceInHours > 0) { | ||
return `${differenceInHours} ${ | ||
differenceInHours === 1 ? "hour" : "hours" | ||
} ago`; | ||
} else { | ||
return "Less than an hour ago"; | ||
} | ||
} | ||
|
||
return { getRelativeTime }; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
const { getRelativeTime } = VM.require( | ||
"${REPL_DEVHUB}/widget/core.lib.timeUtils" | ||
); | ||
|
||
getRelativeTime || (getRelativeTime = () => {}); | ||
|
||
const Container = styled.div` | ||
.text-grey { | ||
color: #b9b9b9 !important; | ||
} | ||
.text-dark-grey { | ||
color: #687076; | ||
} | ||
.text-grey-100 { | ||
background-color: #f5f5f5; | ||
} | ||
td { | ||
padding-inline: 1.5rem; | ||
color: inherit; | ||
} | ||
.overflow { | ||
overflow: auto; | ||
} | ||
.max-w-100 { | ||
max-width: 100%; | ||
} | ||
button { | ||
background-color: #04a46e; | ||
color: white; | ||
border: none; | ||
font-weight: 600; | ||
} | ||
`; | ||
|
||
const data = [ | ||
{ | ||
id: 1, | ||
summary: | ||
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibu", | ||
title: "Proposal 1 will deliver a new solution to improve th...", | ||
description: "", | ||
from: "megha19.near", | ||
to: "megha19.near", | ||
kycbVerified: true, | ||
token: "NEAR", | ||
amount: "1000", | ||
created: 1643468479000, | ||
}, | ||
{ | ||
id: 2, | ||
summary: | ||
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibu", | ||
title: "Proposal 2 will deliver a new solution to improve th...", | ||
description: "", | ||
from: "mefsdfdsfsdfsdfie urhfgiurehvbiubuihrbiuthvuerhtiuerhvniurhntiuheritheruthieurtheiutheritigha19.near", | ||
to: "megha19.near", | ||
kycbVerified: true, | ||
token: "NEAR", | ||
amount: "1000", | ||
created: 1643468479000, | ||
}, | ||
{ | ||
id: 3, | ||
summary: | ||
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibu", | ||
title: "Proposal 3 will deliver a new solution to improve th...", | ||
description: "", | ||
from: "megha19.near", | ||
to: "megha19.near", | ||
kycbVerified: false, | ||
token: "NEAR", | ||
amount: "1000.44", | ||
created: 1643468479000, | ||
}, | ||
]; | ||
|
||
const [expandSummaryIndex, setExpandSummary] = useState({}); | ||
|
||
return ( | ||
<Container className="d-flex flex-column gap-4"> | ||
<div className="d-flex flex-row gap-2 align-items-center"> | ||
<div className="h4 bold mb-0">Need Approvals</div> | ||
<i class="bi bi-info-circle"></i> | ||
</div> | ||
<div className="custom-card overflow"> | ||
<div className="card-body"> | ||
<table className="table"> | ||
<thead> | ||
<tr className="text-grey"> | ||
<td>ID</td> | ||
<td>PROPOSAL</td> | ||
<td>FROM</td> | ||
<td>TO</td> | ||
<td>KYC/B VERIFIED</td> | ||
<td>TOKEN</td> | ||
<td>AMOUNT</td> | ||
<td>CREATED</td> | ||
<td>PAY</td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{data?.map((item, index) => { | ||
return ( | ||
<tr | ||
className={expandSummaryIndex[index] ? "text-grey-100" : ""} | ||
> | ||
<td>{item.id}</td> | ||
<td className="d-flex flex-row justify-content-between"> | ||
<div | ||
className="d-flex flex-column gap-2 flex-wrap" | ||
style={{ maxWidth: 280 }} | ||
> | ||
<div className="h6 bold text-truncate max-w-100"> | ||
{item.title} | ||
</div> | ||
<div | ||
className={ | ||
"text-dark-grey max-w-100 " + | ||
(expandSummaryIndex[index] ? "" : "text-truncate") | ||
} | ||
> | ||
{item.summary} | ||
</div> | ||
</div> | ||
<div className="cursor"> | ||
<img | ||
src={ | ||
expandSummaryIndex[index] | ||
? "https://ipfs.near.social/ipfs/bafkreic35n4yddasdpl532oqcxjwore66jrjx2qc433hqdh5wi2ijy4ida" | ||
: "https://ipfs.near.social/ipfs/bafkreiaujwid7iigy6sbkrt6zkwmafz5umocvzglndugvofcz2fpw5ur3y" | ||
} | ||
onClick={() => | ||
setExpandSummary((prevState) => ({ | ||
...prevState, | ||
[index]: !prevState[index], | ||
})) | ||
} | ||
height={20} | ||
/> | ||
</div> | ||
</td> | ||
<td className="text-truncate" style={{ maxWidth: 150 }}> | ||
{item.from} | ||
</td> | ||
<td className="text-truncate" style={{ maxWidth: 150 }}> | ||
{item.to} | ||
</td> | ||
<td className="text-center"> | ||
{item.kycbVerified ? ( | ||
<img | ||
src="https://ipfs.near.social/ipfs/bafkreidqveupkcc7e3rko2e67lztsqrfnjzw3ceoajyglqeomvv7xznusm" | ||
height={30} | ||
/> | ||
) : ( | ||
"Need icon" | ||
)} | ||
</td> | ||
<td>{item.token}</td> | ||
<td>{parseFloat(item.amount).toLocaleString("en-US")}</td> | ||
<td className="text-grey">{getRelativeTime(item.created)}</td> | ||
<td> | ||
<button>Pay</button> | ||
</td> | ||
</tr> | ||
); | ||
})} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</Container> | ||
); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const { normalize } = VM.require("${REPL_DEVHUB}/widget/core.lib.stringUtils"); | ||
const { href } = VM.require("${REPL_DEVHUB}/widget/core.lib.url"); | ||
|
||
href || (href = () => {}); | ||
|
||
normalize || (normalize = () => {}); | ||
|
||
const { tab, ...passProps } = props; | ||
|
||
const NavUnderline = styled.ul` | ||
cursor: pointer; | ||
a { | ||
text-decoration: none; | ||
color: #939597; | ||
} | ||
a.active { | ||
font-weight: bolder; | ||
color: #151515; | ||
border-bottom: 3px solid black; | ||
} | ||
a:hover { | ||
color: #151515; | ||
} | ||
`; | ||
|
||
const tabs = [ | ||
{ | ||
title: "Need Approvals", | ||
view: "approvals", | ||
props: {}, | ||
}, | ||
{ | ||
title: "Payment History", | ||
view: "history", | ||
props: {}, | ||
}, | ||
{ | ||
title: "Treasury", | ||
view: "treasury", | ||
props: {}, | ||
}, | ||
]; | ||
|
||
if (!tab) { | ||
tab = normalize("Need Approvals"); | ||
} | ||
|
||
let currentTab = tabs.find((it) => normalize(it.title) === tab); | ||
|
||
return ( | ||
<div> | ||
<NavUnderline className="nav gap-4 my-4"> | ||
{tabs.map( | ||
({ title }) => | ||
title && ( | ||
<li className="nav-item" key={title}> | ||
<Link | ||
to={href({ | ||
widgetSrc: `${REPL_DEVHUB}/widget/app`, | ||
params: { | ||
page: "devDaoDashboard", | ||
tab: normalize(title), | ||
}, | ||
})} | ||
className={[ | ||
"d-inline-flex gap-2", | ||
tab === normalize(title) ? "nav-link active" : "nav-link", | ||
].join(" ")} | ||
> | ||
<span>{title}</span> | ||
</Link> | ||
</li> | ||
) | ||
)} | ||
</NavUnderline> | ||
{currentTab && ( | ||
<div className="w-100 h-100 mt-4" key={currentTab.title}> | ||
<Widget | ||
src={`${REPL_DEVHUB}/widget/devhub.entity.trustee.${currentTab.view}`} | ||
props={currentTab.props} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
); |
Oops, something went wrong.