Skip to content

Commit

Permalink
summary bug fixed & develop merged
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiolalombardim committed Feb 15, 2023
2 parents 859b217 + 6a7af36 commit b9e7d72
Show file tree
Hide file tree
Showing 21 changed files with 3,396 additions and 22,822 deletions.
19,891 changes: 0 additions & 19,891 deletions package-lock.json

This file was deleted.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
"source-map-explorer": "2.5.2",
"typescript": "^4.2.3"
},
"resolutions": {
"@types/react": "~17.0.3"
},
"eslintConfig": {
"extends": [
"react-app"
Expand Down
4 changes: 2 additions & 2 deletions src/models/Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const SUPPORTED_MIME_TYPES = [
] as const
export const SUPPORTED_MEDIA_TYPES = ["image", "audio", "video"] as const

export type NFTMimeType = typeof SUPPORTED_MIME_TYPES[number] | "unknown"
export type NFTMediaType = typeof SUPPORTED_MEDIA_TYPES[number] | "unknown"
export type NFTMimeType = (typeof SUPPORTED_MIME_TYPES)[number] | "unknown"
export type NFTMediaType = (typeof SUPPORTED_MEDIA_TYPES)[number] | "unknown"

interface NFTParams extends TokenParams {
description: string
Expand Down
3 changes: 1 addition & 2 deletions src/modules/common/WarningFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Box, Grid, IconButton, Typography } from "@material-ui/core"
import { styled } from "@material-ui/styles"
import { Box, Grid, IconButton, Typography, styled } from "@material-ui/core"
import React, { useEffect, useState } from "react"
import { ReactComponent as WarningIcon } from "assets/logos/warning.svg"
import CloseIcon from "@material-ui/icons/Close"
Expand Down
5 changes: 4 additions & 1 deletion src/modules/creator/state/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const reducer = (state: CreatorState, action: CreatorAction): CreatorStat
}
return state
case ActionTypes.UPDATE_ORGANIZATION_SETTINGS:
localStorage.setItem("creator-started", "true")
state = {
...state,
data: {
Expand Down Expand Up @@ -142,6 +143,7 @@ export const reducer = (state: CreatorState, action: CreatorAction): CreatorStat
return state
case ActionTypes.CLEAR_CACHE:
window.localStorage.removeItem(LOCAL_STORAGE_KEY)
window.localStorage.removeItem("creator-started")
state = {
...INITIAL_STATE,
deploymentStatus: {
Expand Down Expand Up @@ -169,10 +171,11 @@ const updateInitialState = (network: string, values: MigrationParams) => {

const CreatorProvider: React.FC = ({ children }) => {
const [data, updateCache] = useLocalStorage<MigrationParams>(LOCAL_STORAGE_KEY, INITIAL_STATE.data)
const isCreatorStarted = localStorage.getItem("creator-started")

const { network } = useTezos()

const updatedData = updateInitialState(network, data)
const updatedData = isCreatorStarted ? data : updateInitialState(network, data)

const stateWithCache = {
...INITIAL_STATE,
Expand Down
17 changes: 4 additions & 13 deletions src/modules/creator/steps/Governance.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { Grid, Paper, styled, Typography, Slider, withStyles, withTheme, Box, Tooltip } from "@material-ui/core"
import { TextField } from "formik-material-ui"
import React, { useContext, useEffect, useState } from "react"
Expand Down Expand Up @@ -342,14 +341,10 @@ const GovernanceForm = ({ submitForm, values, setFieldValue, errors, touched, se
})

useEffect(() => {
values.votingBlocks = periodBlocks
values.proposalFlushBlocks = flushBlocks
values.proposalExpiryBlocks = expiryBlocks

// setTimeout(() => {
// validateForm(values)
// }, 1000)
}, [periodBlocks, flushBlocks, expiryBlocks])
setFieldValue("votingBlocks", periodBlocks)
setFieldValue("proposalFlushBlocks", flushBlocks)
setFieldValue("proposalExpiryBlocks", expiryBlocks)
}, [values, periodBlocks, flushBlocks, expiryBlocks, setFieldValue])

useEffect(() => {
;(async () => {
Expand Down Expand Up @@ -858,11 +853,7 @@ export const Governance: React.FC = () => {
const { dispatch, state, updateCache } = useContext(CreatorContext)
const { votingSettings } = state.data
const history = useHistory()

const saveStepInfo = (values: VotingSettings, { setSubmitting }: any) => {
values.proposalExpiryBlocks = Number(values.proposalExpiryBlocks)
values.proposalFlushBlocks = Number(values.proposalFlushBlocks)
values.votingBlocks = Number(values.votingBlocks)
const newState = {
...state.data,
votingSettings: values
Expand Down
16 changes: 12 additions & 4 deletions src/modules/explorer/components/NavigationMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ReactComponent as TreasuryIcon } from "assets/logos/treasury.svg"
import { ReactComponent as RegistryIcon } from "assets/logos/list.svg"
import { ReactComponent as UserIcon } from "assets/logos/user.svg"
import { ReactComponent as NFTIcon } from "assets/logos/nft.svg"
import { ReactComponent as ConfigIcon } from "assets/logos/config.svg"
import React, { useEffect, useState } from "react"
import { useDAOID } from "../pages/DAO/router"
import { useDAO } from "services/indexer/dao/hooks/useDAO"
Expand Down Expand Up @@ -81,7 +82,8 @@ const IconContainer = styled("span")(({ theme, isSelected }: { theme: Theme; isS
"justifyContent": "center",

"& > svg > *": {
fill: isSelected ? theme.palette.secondary.main : theme.palette.text.primary
fill: isSelected ? theme.palette.secondary.main : theme.palette.text.primary,
stroke: isSelected ? theme.palette.secondary.main : theme.palette.text.primary
}
}))

Expand Down Expand Up @@ -134,10 +136,16 @@ const getPages = (daoId: string): Page[] => [
name: "User",
icon: UserIcon,
href: `/explorer/dao/${daoId}/user`
},
{
pathId: "config",
name: "Config",
icon: ConfigIcon,
href: `/explorer/dao/${daoId}/config`
}
]

const StyledBottomBar = styled(Grid)(({ theme, visible }: { theme: Theme; visible: boolean }) => ({
const StyledBottomBar = styled(Grid)(({ theme }: { theme: Theme }) => ({
position: "fixed",
height: 55,
width: "100%",
Expand Down Expand Up @@ -173,7 +181,7 @@ const BottomNavBar: React.FC = ({ children }) => {
}, [prevScrollPos, visible])

return (
<StyledBottomBar container direction={"row"} visible={visible}>
<StyledBottomBar container direction={"row"}>
<BottomBarItems container>{children}</BottomBarItems>
</StyledBottomBar>
)
Expand Down Expand Up @@ -225,7 +233,7 @@ export const NavigationMenu: React.FC<{ disableMobileMenu?: boolean }> = ({ disa
) : (
<BottomNavBar>
{pages.map((page, i) => (
<PageItem key={`page-${i}`} isSelected={pathId === page.pathId} item alignItems="center">
<PageItem key={`page-${i}`} isSelected={pathId === page.pathId} container item alignItems="center">
<Link to={page.href}>
<Grid container alignItems="center" justifyContent="center">
<Grid item>
Expand Down
4 changes: 2 additions & 2 deletions src/modules/explorer/components/ResponsiveDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const ResponsiveDialog: React.FC<{
<BottomSheet open={open} onDismiss={onClose}>
<Content container direction="column" style={{ gap: 46 }}>
<Grid item container direction="row" wrap="nowrap" justifyContent="space-between">
<Grid item>{Boolean(onGoBack) ? <BackButton onGoBack={onGoBack} /> : null}</Grid>
<Grid item>{onGoBack ? <BackButton onGoBack={onGoBack} /> : null}</Grid>
<Grid item>
<TitleText>{title}</TitleText>
</Grid>
Expand All @@ -54,7 +54,7 @@ export const ResponsiveDialog: React.FC<{
<CustomDialog open={open} onClose={onClose} maxWidth={template ? "md" : "sm"}>
<Content container direction="column" style={{ gap: 30 }}>
<Grid item container direction="row" wrap="nowrap" justifyContent="space-between">
<Grid item>{Boolean(onGoBack) ? <BackButton onGoBack={onGoBack} /> : null}</Grid>
<Grid item>{onGoBack ? <BackButton onGoBack={onGoBack} /> : null}</Grid>
<Grid item>
<TitleText color="textPrimary">{title}</TitleText>
</Grid>
Expand Down
4 changes: 2 additions & 2 deletions src/modules/explorer/components/StatusBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ const statusColors = (status: ProposalStatus) => {
}

const Badge = styled(Grid)(({ status }: { status: ProposalStatus; theme: Theme }) => ({
borderRadius: 4,
borderRadius: 50,
textAlign: "center",
minHeight: 24,
minWidth: 105,
padding: "2px 5px",
padding: "2px 8px",
background: statusColors(status).background,
color: statusColors(status).color,
whiteSpace: "nowrap"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/explorer/components/UsersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const TableText = styled(Typography)({
}
})

const titleDataMatcher = (title: typeof titles[number], rowData: RowData) => {
const titleDataMatcher = (title: (typeof titles)[number], rowData: RowData) => {
switch (title) {
case "Rank":
return rowData.address
Expand Down
177 changes: 177 additions & 0 deletions src/modules/explorer/pages/Config/components/DAOInfoTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
import { styled, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Typography } from "@material-ui/core"
import React from "react"
import { useDAO } from "services/indexer/dao/hooks/useDAO"
import { useDAOID } from "../../DAO/router"
import BigNumber from "bignumber.js"

const RowValue = styled(Typography)({
fontWeight: 300,
fontSize: 18
})

const TableTitle = styled(Typography)({
fontWeight: 500,
fontSize: 18
})

const CustomTableContainer = styled(TableContainer)(({ theme }) => ({
[theme.breakpoints.down("sm")]: {
maxWidth: 390
}
}))

export const DaoInfoTables: React.FC = () => {
const daoId = useDAOID()
const { data: dao } = useDAO(daoId)

return (
<>
<CustomTableContainer>
<Table style={{ marginTop: 32 }} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell colSpan={2}>
<TableTitle>Proposal & Voting Settings</TableTitle>
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{dao ? (
<>
<TableRow>
<TableCell component="th" scope="row">
<Typography variant="body1">Voting Period Duration</Typography>
</TableCell>
<TableCell align="right">
<RowValue>{dao.data.period} blocks</RowValue>
</TableCell>
</TableRow>
<TableRow>
<TableCell component="th" scope="row">
<Typography variant="body1">Flush Delay Duration</Typography>
</TableCell>
<TableCell align="right">
<RowValue>
{new BigNumber(dao.data.proposal_flush_level).toNumber() -
2 * new BigNumber(dao.data.period).toNumber()}{" "}
blocks
</RowValue>
</TableCell>
</TableRow>
<TableRow>
<TableCell component="th" scope="row">
<Typography variant="body1">Proposal Blocks to Expire</Typography>
</TableCell>
<TableCell align="right">
<RowValue>
{new BigNumber(dao.data.proposal_expired_level).toNumber() -
new BigNumber(dao.data.proposal_flush_level).toNumber()}{" "}
blocks
</RowValue>
</TableCell>
</TableRow>
<TableRow>
<TableCell component="th" scope="row">
<Typography variant="body1">Stake Required to Propose</Typography>
</TableCell>
<TableCell align="right">
<RowValue>
{new BigNumber(dao.data.extra.frozen_extra_value).toNumber()} locked {dao.data.token.symbol}
</RowValue>
</TableCell>
</TableRow>
<TableRow>
<TableCell component="th" scope="row">
<Typography variant="body1">Stake Returned if Rejected</Typography>
</TableCell>
<TableCell align="right">
<RowValue>
{dao.data.extra.returnedPercentage}% of locked {dao.data.token.symbol}
</RowValue>
</TableCell>
</TableRow>
<TableRow>
<TableCell component="th" scope="row">
<Typography variant="body1">Transfer Maximum XTZ Amount</Typography>
</TableCell>
<TableCell align="right">
<RowValue>{new BigNumber(dao.data.extra.max_xtz_amount).div(10 ** 6).toNumber()} XTZ</RowValue>
</TableCell>
</TableRow>
<TableRow>
<TableCell component="th" scope="row">
<Typography variant="body1">Transfer Minimum XTZ Amount</Typography>
</TableCell>
<TableCell align="right">
<RowValue>{new BigNumber(dao.data.extra.min_xtz_amount).div(10 ** 6).toNumber()} XTZ</RowValue>
</TableCell>
</TableRow>
</>
) : null}
</TableBody>
</Table>
</CustomTableContainer>

<CustomTableContainer>
<Table style={{ marginTop: 32 }} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell colSpan={2}>
<TableTitle>Quorum Settings</TableTitle>
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{dao ? (
<>
<TableRow>
<TableCell component="th" scope="row">
<Typography variant="body1">Quorum Threshold</Typography>
</TableCell>
<TableCell align="right">
<RowValue>
{dao.data.quorum_threshold.toNumber()} {dao.data.token.symbol}
</RowValue>
</TableCell>
</TableRow>
<TableRow>
<TableCell component="th" scope="row">
<Typography variant="body1">Quorum Min Amount</Typography>
</TableCell>
<TableCell align="right">
<RowValue>{new BigNumber(dao.data.min_quorum_threshold).div(10000).toNumber()}%</RowValue>
</TableCell>
</TableRow>
<TableRow>
<TableCell component="th" scope="row">
<Typography variant="body1">Quorum Max Amount</Typography>
</TableCell>
<TableCell align="right">
<RowValue>{new BigNumber(dao.data.max_quorum_threshold).div(10000).toNumber()}%</RowValue>
</TableCell>
</TableRow>
<TableRow>
<TableCell component="th" scope="row">
<Typography variant="body1">Quorum Change</Typography>
</TableCell>
<TableCell align="right">
<RowValue>{new BigNumber(dao.data.quorum_change).div(10000).toNumber()}%</RowValue>
</TableCell>
</TableRow>
<TableRow>
<TableCell component="th" scope="row">
<Typography variant="body1">Quorum Max Change</Typography>
</TableCell>
<TableCell align="right">
<RowValue>{new BigNumber(dao.data.max_quorum_change).div(10000).toNumber()}%</RowValue>
</TableCell>
</TableRow>
</>
) : null}
</TableBody>
</Table>
</CustomTableContainer>
</>
)
}
Loading

0 comments on commit b9e7d72

Please sign in to comment.