-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added history and pending request page
- Loading branch information
1 parent
f92a6b2
commit 0b914e8
Showing
6 changed files
with
615 additions
and
3 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
92 changes: 92 additions & 0 deletions
92
instances/treasury-devdao.near/widget/components/Pagination.jsx
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,92 @@ | ||
const totalPages = props.totalPages ?? 12; // Assume you have 12 pages | ||
const maxVisiblePages = props.maxVisiblePages ?? 5; | ||
const onPageClick = props.onPageClick | ||
? props.onPageClick | ||
: () => console.log("clicked"); | ||
const pagesToShow = Math.min(totalPages, maxVisiblePages); | ||
const [selectedPage, setSelectedPage] = useState(props.selectedPage ?? 1); | ||
const totalPageSets = Math.ceil(totalPages / maxVisiblePages); | ||
const [currentPageSet, setCurrentPageSet] = useState(1); | ||
|
||
const Pagination = styled.div` | ||
display: flex; | ||
gap: 12px; | ||
div { | ||
display: flex; | ||
height: 30px; | ||
min-width: 30px; | ||
padding: 12px; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 10px; | ||
border-radius: 8px; | ||
transition: all 300ms; | ||
cursor: pointer; | ||
/* Other/Button_text */ | ||
font-size: 14px; | ||
font-style: normal; | ||
font-weight: 500; | ||
line-height: normal; | ||
&.selected, | ||
&:hover { | ||
background-color: #23242b; | ||
color: white; | ||
} | ||
&.arrow { | ||
border: 1px solid rgba(255, 255, 255, 0.2); | ||
} | ||
&.disabled { | ||
cursor: not-allowed; | ||
} | ||
} | ||
`; | ||
|
||
const handlePageClick = (pageNumber) => { | ||
onPageClick(pageNumber); | ||
}; | ||
|
||
const handleArrowClick = (direction) => { | ||
if (direction === "left") { | ||
setCurrentPageSet(Math.max(currentPageSet - 1, 1)); | ||
} else { | ||
setCurrentPageSet( | ||
Math.min(currentPageSet + 1, Math.ceil(totalPages / maxVisiblePages)) | ||
); | ||
} | ||
}; | ||
|
||
const getPageNumber = (index) => | ||
(currentPageSet - 1) * maxVisiblePages + index + 1; | ||
|
||
return ( | ||
<Pagination> | ||
<div | ||
className={`arrow ${currentPageSet === 1 ? "disabled" : undefined}`} | ||
onClick={() => handleArrowClick("left")} | ||
> | ||
<i className="bi bi-arrow-left"></i> | ||
</div> | ||
{Array.from({ length: pagesToShow }).map((_, index) => { | ||
const pageNumber = getPageNumber(index); | ||
return ( | ||
<div | ||
key={pageNumber} | ||
className={pageNumber === selectedPage ? "selected" : undefined} | ||
onClick={() => handlePageClick(pageNumber)} | ||
> | ||
{pageNumber} | ||
</div> | ||
); | ||
})} | ||
<div | ||
className={`arrow ${ | ||
currentPageSet === Math.ceil(totalPages / maxVisiblePages) | ||
? "disabled" | ||
: undefined | ||
}`} | ||
onClick={() => handleArrowClick("right")} | ||
> | ||
<i className="bi bi-arrow-right"></i> | ||
</div> | ||
</Pagination> | ||
); |
42 changes: 42 additions & 0 deletions
42
instances/treasury-devdao.near/widget/components/TokenAmount.jsx
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,42 @@ | ||
const address = props.address ?? ""; // Empty string for NEAR | ||
const amountWithDecimals = props.amountWithDecimals ?? 0; | ||
const amountWithoutDecimals = props.amountWithoutDecimals; // Automatically converted to the correct value | ||
|
||
const isNEAR = address === "" || address.toLowerCase() === "near"; | ||
|
||
let ftMetadata = { | ||
symbol: "NEAR", | ||
decimals: 24, | ||
}; | ||
if (!isNEAR) { | ||
ftMetadata = Near.view(address, "ft_metadata", {}); | ||
if (ftMetadata === null) return null; | ||
} | ||
let amount = amountWithDecimals; | ||
if (amountWithoutDecimals !== undefined) { | ||
amount = Big(amountWithoutDecimals) | ||
.div(Big(10).pow(ftMetadata.decimals ?? 1)) | ||
.toString(); | ||
} | ||
|
||
const Wrapper = styled.div` | ||
.amount { | ||
font-size: 14px; | ||
font-weight: 500; | ||
line-height: 1.15; | ||
} | ||
`; | ||
return ( | ||
<Wrapper className="d-flex gap-1 align-items-center"> | ||
<div> | ||
<img | ||
width="14px" | ||
height="14px" | ||
src={isNEAR ? "${REPL_NEAR_TOKEN_ICON}" : ftMetadata.icon} | ||
/> | ||
</div> | ||
<div className="d-flex gap-1 align-items-center"> | ||
<span className="amount">{amount}</span> | ||
</div> | ||
</Wrapper> | ||
); |
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,23 @@ | ||
function getApproversGroup(){ | ||
|
||
const daoPolicy = Near.view(treasuryDaoID, "get_policy", {}); | ||
const groupWithTransferPermission = (daoPolicy.roles ?? []).filter((role) => { | ||
const transferPermissions = [ | ||
"transfer:*", | ||
"transfer:VoteApprove", | ||
"transfer:VoteReject", | ||
"transfer:VoteRemove", | ||
]; | ||
return (role?.permissions ?? []).some((i) => transferPermissions.includes(i)); | ||
}); | ||
|
||
let approversGroup = []; | ||
groupWithTransferPermission.map( | ||
(i) => (approversGroup = approversGroup.concat(i.kind.Group)) | ||
); | ||
return approversGroup | ||
} | ||
|
||
return { | ||
getApproversGroup | ||
} |
Oops, something went wrong.