Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
- Fixed Search Logic on Treasury Tokens
- Fixed icons in pagination for next and previous page
- Fixed a TS issue
- Added a button for clear filters
  • Loading branch information
ashutoshpw committed Oct 13, 2024
1 parent 878fc3c commit 39036ac
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ yarn-error.log*

.idea
.env.example
.cosine
.cosine
bun.lockb
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"cSpell.words": [
"offchain"
],
"editor.autoClosingBrackets": "always"
}
"editor.autoClosingBrackets": "always",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
6 changes: 5 additions & 1 deletion src/modules/explorer/components/VotersProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export const VotersProgress: React.FC<VotersData> = ({ showButton, daoId, propos
title: "Voting Details",
showTitle: false
})
const votesData = proposal ? proposal?.voters : []
const votesData =
proposal?.voters.map(voter => ({
...voter,
value: voter.value.toString()
})) || []
try {
const csv = generateCsv(csvConfig)(votesData)
download(csvConfig)(csv)
Expand Down
45 changes: 34 additions & 11 deletions src/modules/explorer/pages/Treasury/components/BalancesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { CopyButton } from "modules/common/CopyButton"
import ReactPaginate from "react-paginate"
import "../../DAOList/styles.css"
import FilterAltIcon from "@mui/icons-material/FilterAlt"
import CloseIcon from "@mui/icons-material/Close"
import NavigateNextIcon from "@mui/icons-material/NavigateNext"
import NavigateBeforeIcon from "@mui/icons-material/NavigateBefore"

import { SearchInput } from "../../DAOList/components/Searchbar"
import { TokensFilters } from ".."
import { FilterTokenDialog } from "modules/explorer/components/FiltersTokensDialog"
Expand Down Expand Up @@ -116,7 +120,7 @@ const BalancesList: React.FC<TableProps> = ({
}) => {
const [currentPage, setCurrentPage] = useState(0)
const [offset, setOffset] = useState(0)
const value = isMobileSmall ? 6 : 5
const value = 6
const [list, setList] = useState(rows)

useEffect(() => {
Expand Down Expand Up @@ -209,9 +213,9 @@ const BalancesList: React.FC<TableProps> = ({
))}
<Grid container direction="row" justifyContent="flex-end">
<ReactPaginate
previousLabel={"<"}
previousLabel={<NavigateBeforeIcon />}
breakLabel="..."
nextLabel=">"
nextLabel={<NavigateNextIcon />}
onPageChange={handlePageClick}
pageRangeDisplayed={2}
pageCount={pageCount}
Expand Down Expand Up @@ -239,10 +243,7 @@ export const BalancesTable: React.FC = () => {
const [openFiltersDialog, setOpenFiltersDialog] = useState(false)
const [searchText, setSearchText] = useState("")
const [filters, setFilters] = useState<TokensFilters>()

const filterByName = (text: string) => {
setSearchText(text.trim())
}
const filtersEnabled = Object.values(filters || {}).some(value => !!value)

const onCloseTransfer = () => {
setOpenTransfer(false)
Expand Down Expand Up @@ -336,9 +337,14 @@ export const BalancesTable: React.FC = () => {
}

if (searchText) {
holdings = holdings.filter(
holding => holding.token && holding.token.name.toLowerCase().includes(searchText.toLowerCase())
)
console.log({ holdings })
holdings = holdings.filter(holding => {
const query = searchText.toLowerCase()
if (holding.token?.name.toLowerCase().includes(query)) return true
if (holding.token?.id.toLowerCase().includes(query)) return true
if (holding.token?.symbol.toLowerCase().includes(query)) return true
return false
})
}

return holdings.map(createData)
Expand All @@ -359,8 +365,25 @@ export const BalancesTable: React.FC = () => {
<FilterAltIcon style={{ color: theme.palette.secondary.main, marginRight: 6 }} fontSize="small" />
<Typography color="secondary">Filter & Sort</Typography>
</FiltersContainer>
{filtersEnabled && (
<FiltersContainer
onClick={() => setFilters({ token: "", balanceMax: "", balanceMin: "" })}
xs={isSmall ? 12 : 2}
item
container
direction="row"
alignItems="center"
>
<CloseIcon style={{ color: theme.palette.secondary.main, marginRight: 6 }} fontSize="small" />
<Typography color="secondary">Clear Filters</Typography>
</FiltersContainer>
)}
<Grid item xs={4}>
<SearchInput search={filterByName} />
<SearchInput
search={(text: string) => {
setSearchText(text.trim())
}}
/>
</Grid>
</Grid>
<BalancesList
Expand Down

0 comments on commit 39036ac

Please sign in to comment.