Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User search bars #853

Merged
merged 14 commits into from
Oct 29, 2024
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
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"svg.preview.background": "black",
"cSpell.words": [
"offchain"
]
}
],
"editor.autoClosingBrackets": "always",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Sending XTZ directly to DAO address
- Delegating DAO's XTZ to baker
- Changing DAO configuration parameters
- Added Searchbar on Treasury Page

## [1.0.6] - 2022-01-05
### Added
Expand Down Expand Up @@ -72,4 +73,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Treasury page style

### Breaking changes
- Upgraded BaseDAO contracts to [v0.4](https://github.com/tezos-commons/baseDAO/tree/b3aa7886950d4f1eb65816ed726ce69e77e14472) - DAOs created prior to this upgrade are deprecated
- Upgraded BaseDAO contracts to [v0.4](https://github.com/tezos-commons/baseDAO/tree/b3aa7886950d4f1eb65816ed726ce69e77e14472) - DAOs created prior to this upgrade are deprecated
1 change: 0 additions & 1 deletion src/modules/explorer/components/FiltersDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useEffect, useState } from "react"
import { ResponsiveDialog } from "./ResponsiveDialog"
import { Grid, styled } from "@material-ui/core"
import { Typography } from "@mui/material"
import { Dropdown } from "./Dropdown"
import { ProposalStatus } from "services/services/dao/mappers/proposal/types"
import { SmallButton } from "modules/common/SmallButton"
import { Order, ProposalType } from "./FiltersUserDialog"
Expand Down
135 changes: 135 additions & 0 deletions src/modules/explorer/components/FiltersTokensDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import React, { useEffect, useState } from "react"
import { Grid, TextField, Typography, styled, withStyles } from "@material-ui/core"
import { ResponsiveDialog } from "./ResponsiveDialog"
import { SmallButton } from "modules/common/SmallButton"
import { TokensFilters } from "../pages/Treasury"

interface Props {
currentFilters: TokensFilters | undefined
open: boolean
handleClose: () => void
saveFilters: (options: TokensFilters) => void
}

const SectionTitle = styled(Typography)({
fontSize: "18px !important",
fontWeight: 600
})

const Container = styled(Grid)({
marginTop: 6,
gap: 24
})

const CustomTextField = withStyles({
root: {
"& .MuiInput-root": {
fontWeight: 300,
textAlign: "initial"
},
"& .MuiInputBase-input": {
textAlign: "initial",
background: "#2F3438",
borderRadius: 8,
padding: 16
},
"& .MuiInputBase-root": {
textWeight: 300
},
"& .MuiInput-underline": {
borderBottom: "none !important"
},
"& .MuiInput-underline:before": {
borderBottom: "none !important"
},
"& .MuiInput-underline:hover:before": {
borderBottom: "none !important"
},
"& .MuiInput-underline:after": {
borderBottom: "none !important"
},
"& .MuiInput-underline:hover:not(.Mui-disabled):before": {
borderBottom: "none !important"
}
}
})(TextField)

export const FilterTokenDialog: React.FC<Props> = ({ open, handleClose, saveFilters, currentFilters }) => {
const [token, setToken] = useState<string | null>("")
const [balanceMin, setBalanceMin] = useState<string | undefined>()
const [balanceMax, setBalanceMax] = useState<string | undefined>()

const ariaLabel = { "aria-label": "description" }

useEffect(() => {
if (currentFilters) {
setToken(currentFilters?.token)
setBalanceMin(currentFilters.balanceMin)
setBalanceMax(currentFilters.balanceMax)
}
}, [currentFilters])

const showFilters = () => {
const filterObject: TokensFilters = {
token: token,
balanceMin: balanceMin,
balanceMax: balanceMax
}
saveFilters(filterObject)
handleClose()
}

return (
<>
<ResponsiveDialog open={open} onClose={handleClose} title={"Filter"} template="sm">
<Container container direction="column">
<Grid item>
<SectionTitle>Token</SectionTitle>
</Grid>
<Grid item>
<CustomTextField
onChange={event => setToken(event.target.value)}
style={{ width: "40%" }}
name="test"
value={token}
placeholder="Token"
inputProps={ariaLabel}
/>
</Grid>

<Grid item>
<SectionTitle>Balance</SectionTitle>
</Grid>
<Grid item container direction="row" justifyContent="space-between" spacing={2}>
<Grid item xs={6}>
<CustomTextField
onChange={event => setBalanceMin(event.target.value)}
name="test"
value={balanceMin}
placeholder="Min"
inputProps={ariaLabel}
type="number"
/>
</Grid>
<Grid item xs={6}>
<CustomTextField
onChange={event => setBalanceMax(event.target.value)}
name="test"
value={balanceMax}
placeholder="Min"
type="number"
inputProps={ariaLabel}
/>
</Grid>
</Grid>
</Container>

<Container container direction="row" justifyContent="flex-end">
<SmallButton color="secondary" variant="contained" onClick={showFilters}>
Apply
</SmallButton>
</Container>
</ResponsiveDialog>
</>
)
}
205 changes: 205 additions & 0 deletions src/modules/explorer/components/FiltersTransactionsDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
import React, { useEffect, useState } from "react"
import { Grid, TextField, Typography, styled, withStyles } from "@material-ui/core"
import { ResponsiveDialog } from "./ResponsiveDialog"
import { SmallButton } from "modules/common/SmallButton"
import { TransactionsFilters } from "../pages/Treasury"

export enum TransactionStatus {
COMPLETED = "applied",
PENDING = "pending",
FAILED = "failed"
}

interface Props {
currentFilters: TransactionsFilters | undefined
open: boolean
handleClose: () => void
saveFilters: (options: TransactionsFilters) => void
}

const SectionTitle = styled(Typography)({
fontSize: "18px !important",
fontWeight: 600
})

const Container = styled(Grid)({
marginTop: 6,
gap: 24
})

const CustomTextField = withStyles({
root: {
"& .MuiInput-root": {
fontWeight: 300,
textAlign: "initial"
},
"& .MuiInputBase-input": {
textAlign: "initial",
background: "#2F3438",
borderRadius: 8,
padding: 16
},
"& .MuiInputBase-root": {
textWeight: 300
},
"& .MuiInput-underline": {
borderBottom: "none !important"
},
"& .MuiInput-underline:before": {
borderBottom: "none !important"
},
"& .MuiInput-underline:hover:before": {
borderBottom: "none !important"
},
"& .MuiInput-underline:after": {
borderBottom: "none !important"
},
"& .MuiInput-underline:hover:not(.Mui-disabled):before": {
borderBottom: "none !important"
}
}
})(TextField)

const StatusButton = styled(Grid)(({ theme }) => ({
"background": theme.palette.primary.main,
"padding": "8px 16px",
"borderRadius": 50,
"marginRight": 16,
"marginBottom": 16,
"cursor": "pointer",
"textTransform": "capitalize",
"&:hover": {
background: "rgba(129, 254, 183, .4)"
}
}))

interface StatusOption {
label: string
}

export const FilterTransactionsDialog: React.FC<Props> = ({ open, handleClose, saveFilters, currentFilters }) => {
const [status, setStatus] = useState<StatusOption[]>([])
const [token, setToken] = useState<string | null>("")
const [sender, setSender] = useState<string | null>("")
const [receiver, setReceiver] = useState<string | null>("")

const [filters, setFilters] = useState<StatusOption>()
const ariaLabel = { "aria-label": "description" }

useEffect(() => {
setStatus([])
setStatusOptions()
if (currentFilters) {
setToken(currentFilters?.token)
setSender(currentFilters.sender)
setReceiver(currentFilters.receiver)
setFilters(currentFilters.status)
}
}, [currentFilters])

const setStatusOptions = () => {
const values = Object.values(TransactionStatus)
for (const item in values) {
const obj = {
label: values[item]
}
setStatus(oldArray => [...oldArray, obj])
}
}

const isSelected = (item: StatusOption) => {
return filters && filters.label === item.label ? true : false
}

const saveStatus = (status: StatusOption) => {
if (status.label === filters?.label) {
setFilters(undefined)
} else {
setFilters(status)
}
}

const showFilters = () => {
const filterObject: TransactionsFilters = {
token: token,
receiver: receiver,
sender: sender,
status: filters
}
saveFilters(filterObject)
handleClose()
}

return (
<>
<ResponsiveDialog open={open} onClose={handleClose} title={"Filter"} template="sm">
<Container container direction="column">
<Grid item>
<SectionTitle>Sort by</SectionTitle>
</Grid>
<Grid item>
<Grid item container direction="row">
{status.length > 0 &&
status.map((item, index) => {
return (
<StatusButton
item
key={`status-${index}`}
style={isSelected(item) ? { backgroundColor: "#fff", color: "#1c1f23" } : {}}
>
<Typography onClick={() => saveStatus(item)}>{item.label}</Typography>
</StatusButton>
)
})}
</Grid>
</Grid>
<Grid item>
<SectionTitle>Token</SectionTitle>
</Grid>
<Grid item>
<CustomTextField
onChange={event => setToken(event.target.value)}
style={{ width: "40%" }}
name="test"
value={token}
placeholder="Token"
inputProps={ariaLabel}
/>
</Grid>

<Grid item>
<SectionTitle>Receiving Address</SectionTitle>
</Grid>
<Grid item>
<CustomTextField
onChange={event => setReceiver(event.target.value)}
name="test"
value={receiver}
placeholder="Address"
inputProps={ariaLabel}
/>
</Grid>

<Grid item>
<SectionTitle>Sending Address</SectionTitle>
</Grid>
<Grid item>
<CustomTextField
onChange={event => setSender(event.target.value)}
name="test"
value={sender}
placeholder="Address"
inputProps={ariaLabel}
/>
</Grid>
</Container>

<Container container direction="row" justifyContent="flex-end">
<SmallButton color="secondary" variant="contained" onClick={showFilters}>
Apply
</SmallButton>
</Container>
</ResponsiveDialog>
</>
)
}
4 changes: 4 additions & 0 deletions src/modules/explorer/components/ProposalsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export const ProposalsList: React.FC<Props> = ({
setFilteredProposals(listOfProposals)
}, [])

useEffect(() => {
setFilteredProposals(listOfProposals)
}, [liteProposals, proposals])

useEffect(() => {
setFilteredProposals(listOfProposals)
}, [showFullList])
Expand Down
Loading
Loading