-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/dOrgTech/homebase-app in…
…to develop
- Loading branch information
Showing
22 changed files
with
4,976 additions
and
24,172 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,140 @@ | ||
import { Collapse, Grid, IconButton, Typography } from "@material-ui/core" | ||
import { styled } from "@material-ui/styles" | ||
import { ProposalItem } from "modules/explorer/pages/User" | ||
import React, { useCallback, useEffect, useMemo, useState } from "react" | ||
import { Link } from "react-router-dom" | ||
import { Proposal, ProposalStatus } from "services/indexer/dao/mappers/proposal/types" | ||
import { ContentContainer } from "./ContentContainer" | ||
import { Dropdown } from "./Dropdown" | ||
|
||
const TableContainer = styled(ContentContainer)({ | ||
width: "100%" | ||
}) | ||
|
||
const TableHeader = styled(Grid)({ | ||
padding: "16px 46px", | ||
minHeight: 34 | ||
}) | ||
|
||
const ProposalsFooter = styled(Grid)({ | ||
padding: "16px 46px", | ||
borderTop: ".6px solid rgba(125,140,139, 0.2)", | ||
minHeight: 34 | ||
}) | ||
|
||
interface Props { | ||
currentLevel: number | ||
proposals: Proposal[] | ||
title: string | ||
showFooter?: boolean | ||
rightItem?: (proposal: Proposal) => React.ReactElement | ||
} | ||
|
||
export const AllProposalsList: React.FC<Props> = ({ currentLevel, proposals, title, showFooter, rightItem }) => { | ||
const [filteredProposal, setFilteredProposals] = useState(proposals) | ||
const [filter, setFilter] = useState("All") | ||
|
||
const filterProposals = useCallback( | ||
(status?: any) => { | ||
if (status === "All") { | ||
return setFilteredProposals(proposals) | ||
} else if (status !== "All" && status !== undefined) { | ||
const filtered = proposals.filter(proposal => proposal["cachedStatus"]?.status === status) | ||
setFilteredProposals(filtered) | ||
} else { | ||
return setFilteredProposals(proposals) | ||
} | ||
}, | ||
[proposals] | ||
) | ||
|
||
useEffect(() => { | ||
filterProposals(filter) | ||
}, [filter, filterProposals]) | ||
|
||
useEffect(() => { | ||
setFilteredProposals(proposals) | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []) | ||
|
||
const filterProposalByStatus = (status: any) => { | ||
setFilter(status) | ||
} | ||
|
||
return ( | ||
<TableContainer item> | ||
<Grid container direction="column" wrap={"nowrap"}> | ||
<TableHeader item container justifyContent="space-between" alignItems="center"> | ||
<Grid item> | ||
<Typography variant="body1" style={{ fontWeight: "500" }} color="textPrimary"> | ||
{title} | ||
</Typography> | ||
</Grid> | ||
{proposals.length ? ( | ||
<Grid item> | ||
<IconButton aria-label="expand row" size="small"> | ||
<Dropdown | ||
options={[ | ||
{ name: "All", value: "All" }, | ||
{ name: ProposalStatus.ACTIVE, value: ProposalStatus.ACTIVE }, | ||
{ name: ProposalStatus.DROPPED, value: ProposalStatus.DROPPED }, | ||
{ name: ProposalStatus.EXECUTABLE, value: ProposalStatus.EXECUTABLE }, | ||
{ name: ProposalStatus.EXECUTED, value: ProposalStatus.EXECUTED }, | ||
{ name: ProposalStatus.EXPIRED, value: ProposalStatus.EXPIRED }, | ||
{ name: ProposalStatus.NO_QUORUM, value: ProposalStatus.NO_QUORUM }, | ||
{ name: ProposalStatus.PASSED, value: ProposalStatus.PASSED }, | ||
{ name: ProposalStatus.PENDING, value: ProposalStatus.PENDING }, | ||
{ name: ProposalStatus.REJECTED, value: ProposalStatus.REJECTED } | ||
]} | ||
value={"All"} | ||
onSelected={filterProposalByStatus} | ||
/>{" "} | ||
</IconButton> | ||
</Grid> | ||
) : null} | ||
</TableHeader> | ||
{filteredProposal.length ? ( | ||
<Grid | ||
item | ||
container | ||
wrap={"nowrap"} | ||
component={Collapse} | ||
in={true} | ||
timeout="auto" | ||
unmountOnExit | ||
direction="column" | ||
> | ||
{filteredProposal.map((p, i) => ( | ||
<Grid item key={`proposal-${i}`}> | ||
<Link to={`proposal/${p.id}`}> | ||
<ProposalItem proposal={p} status={p.getStatus(currentLevel).status}> | ||
{rightItem ? rightItem(p) : null} | ||
</ProposalItem> | ||
</Link> | ||
</Grid> | ||
))} | ||
</Grid> | ||
) : ( | ||
<ProposalsFooter item container direction="column" justifyContent="center"> | ||
<Grid item> | ||
<Typography color="textPrimary" align="center"> | ||
No items | ||
</Typography> | ||
</Grid> | ||
</ProposalsFooter> | ||
)} | ||
{showFooter && ( | ||
<ProposalsFooter item container direction="column" justifyContent="center"> | ||
<Grid item> | ||
<Link to="proposals"> | ||
<Typography color="secondary" variant="body2" align="center"> | ||
View All Proposals | ||
</Typography> | ||
</Link> | ||
</Grid> | ||
</ProposalsFooter> | ||
)} | ||
</Grid> | ||
</TableContainer> | ||
) | ||
} |
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,66 @@ | ||
import React, { useEffect, useState } from "react" | ||
import { Select, SelectProps, MenuItem, makeStyles, Theme } from "@material-ui/core" | ||
interface DropdownProps extends SelectProps { | ||
options: { name: string; value: string | undefined }[] | ||
value?: string | undefined | ||
onSelected?: (item: string | undefined) => void | ||
isFirst?: boolean | ||
} | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ | ||
icon: { | ||
left: 0 | ||
}, | ||
iconOpen: { | ||
transform: "none" | ||
}, | ||
selectSelect: { | ||
[theme.breakpoints.down("sm")]: { | ||
fontSize: 16 | ||
}, | ||
paddingLeft: 10, | ||
paddingTop: 0, | ||
paddingBottom: 0, | ||
minHeight: 24 | ||
}, | ||
option: { | ||
"padding": 8, | ||
"fontFamily": "Roboto Mono", | ||
"cursor": "pointer", | ||
"text-transform": "capitalize", | ||
"&:hover": { | ||
background: "rgba(129, 254, 183, .4)" | ||
} | ||
} | ||
})) | ||
|
||
export const Dropdown: React.FC<DropdownProps> = ({ options, value, onSelected }) => { | ||
const classes = useStyles() | ||
const [selected, setSelected] = useState<string | undefined>(value) | ||
|
||
useEffect(() => { | ||
setSelected(value) | ||
}, [value]) | ||
|
||
const handleSelected = (event: any) => { | ||
setSelected(event.target.value) | ||
if (onSelected) onSelected(event.target.value) | ||
} | ||
|
||
return ( | ||
<Select | ||
// native | ||
value={selected} | ||
onChange={handleSelected} | ||
classes={{ | ||
select: classes.selectSelect | ||
}} | ||
> | ||
{options.map(({ name, value }, index) => ( | ||
<option value={value} key={`${name}-${index}`} className={classes.option}> | ||
{name} | ||
</option> | ||
))} | ||
</Select> | ||
) | ||
} |
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
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
Oops, something went wrong.