Skip to content

Commit

Permalink
Fixes with Contract Call, Registry Page and UI of other pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshpw committed Jan 14, 2025
1 parent 4aa3e89 commit 6a8d836
Show file tree
Hide file tree
Showing 18 changed files with 560 additions and 85 deletions.
10 changes: 10 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,14 @@ a {
.proposal-details a:hover {
text-decoration: underline;
/* border-bottom: 1px solid #81feb7; */
}

:root {
--rsbs-backdrop-bg: rgba(0, 0, 0, 0.6);
--rsbs-bg: #1c2024;
--rsbs-handle-bg: hsla(0, 0%, 0%, 0.14);
--rsbs-max-w: auto;
--rsbs-ml: env(safe-area-inset-left);
--rsbs-mr: env(safe-area-inset-right);
--rsbs-overlay-rounded: 16px;
}
4 changes: 2 additions & 2 deletions src/modules/etherlink/components/EvmDaoSettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export const EvmDaoSettingModal: React.FC<{
<Table aria-label="simple table">
<TableBody>
{daoSelected?.id &&
tableData.map((item: { key: string; value: string }) => (
<TableRow>
tableData.map((item: { key: string; value: string }, index: number) => (
<TableRow key={index}>
<CustomTableCell component="th" scope="row">
<Typography color="textPrimary" variant="body1">
{item.key}
Expand Down
169 changes: 169 additions & 0 deletions src/modules/etherlink/components/EvmRegistryTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import React, { useState } from "react"
import {
Button,
Grid,
styled,
Table,
TableBody,
TableCell,
TableHead,
TableRow,
Typography,
useMediaQuery,
useTheme
} from "@material-ui/core"
import dayjs from "dayjs"

import { ContentContainer } from "modules/explorer/components/ContentContainer"

const localizedFormat = require("dayjs/plugin/localizedFormat")
dayjs.extend(localizedFormat)

const titles = ["Registry Items", "Value", "Last Updated"]

interface RowData {
key: string
value: string
lastUpdated?: string
onClick: () => void
}

interface Props {
data: RowData[]
}

export const OverflowCell = styled(TableCell)({
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
maxWidth: 300
})

const MobileTableHeader = styled(Grid)({
width: "100%",
padding: 20,
borderBottom: "0.3px solid #3D3D3D"
})

const MobileTableRow = styled(Grid)({
padding: "30px",
borderBottom: "0.3px solid #3D3D3D"
})

const OverflowItem = styled(Grid)({
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
maxWidth: 300
})

const TableContainer = styled(ContentContainer)({
width: "100%"
})

const titleDataMatcher = (title: (typeof titles)[number], rowData: RowData) => {
switch (title) {
case "Registry Items":
return rowData.key
case "Value":
return rowData.value
case "Last Updated":
return rowData.lastUpdated || "-"
}
}

const MobileRegistryTable: React.FC<Props> = ({ data }) => {
return (
<Grid container direction="column" alignItems="center">
<MobileTableHeader item>
<Typography align="center" variant="h4" color="textPrimary">
Registry
</Typography>
</MobileTableHeader>
{data.map((rowData, i) => (
<MobileTableRow
key={`registryMobile-${i}`}
item
container
direction="column"
alignItems="center"
onClick={() => rowData.onClick()}
style={{ gap: 19 }}
>
{titles.map((title, j) => (
<OverflowItem item key={`registryMobileItem-${j}`}>
<Typography variant="h6" color="secondary" align="center">
{title === "Registry Items" ? "Proposal Key" : title}
</Typography>
<Typography variant="h6" color="textPrimary" align="center">
{titleDataMatcher(title, rowData)}
</Typography>
</OverflowItem>
))}
<Grid item>
<Button
variant="contained"
color="secondary"
onClick={e => {
e.stopPropagation()
rowData.onClick()
}}
>
Edit
</Button>
</Grid>
</MobileTableRow>
))}
</Grid>
)
}

const DesktopRegistryTable: React.FC<Props> = ({ data }) => {
return (
<Table>
<TableHead>
<TableRow>
{titles.map((title, i) => (
<TableCell key={`registrytitle-${i}`}>{title}</TableCell>
))}
</TableRow>
</TableHead>
<TableBody>
{data.map((rowData, i) => (
<TableRow key={`registryrow-${i}`} onClick={() => rowData.onClick()}>
<TableCell>{rowData.key.toUpperCase()}</TableCell>
<OverflowCell>{rowData.value}</OverflowCell>
<TableCell>{rowData.lastUpdated ? dayjs(rowData.lastUpdated).format("L") : "-"}</TableCell>
<TableCell align="right">
<Button
variant="contained"
color="secondary"
onClick={e => {
e.stopPropagation()
rowData.onClick()
}}
>
Edit
</Button>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
)
}

export const EvmRegistryTable: React.FC<{ data: RowData[] }> = ({ data }) => {
const theme = useTheme()
const isSmall = useMediaQuery(theme.breakpoints.down("sm"))
const [selectedItem, setSelectedItem] = useState<RowData>()
const [open, setOpen] = useState(false)

return (
<>
<TableContainer item>
{isSmall ? <MobileRegistryTable data={data} /> : <DesktopRegistryTable data={data} />}
</TableContainer>
</>
)
}
108 changes: 107 additions & 1 deletion src/modules/etherlink/creator/EvmDaoSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,79 @@
import { DescriptionText } from "components/ui/DaoCreator"
import { TitleBlock } from "modules/common/TitleBlock"
import React from "react"
import {
Grid,
styled,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Typography,
useMediaQuery,
useTheme
} from "@material-ui/core"
import useEvmDaoCreateStore from "services/contracts/etherlinkDAO/hooks/useEvmDaoCreateStore"
import { CopyAddress } from "modules/common/CopyAddress"
import { CopyButton } from "modules/common/CopyButton"

interface EvmDaoSummaryProps {
// Add props as needed
}
const CustomTableContainer = styled(TableContainer)(({ theme }) => ({
width: "inherit",
[theme.breakpoints.down("sm")]: {}
}))

const CustomTableCell = styled(TableCell)(({ theme }) => ({
[theme.breakpoints.down("sm")]: {
paddingBottom: 0,
paddingLeft: "16px !important",
textAlign: "end"
}
}))

const CustomTableCellValue = styled(TableCell)(({ theme }) => ({
[theme.breakpoints.down("sm")]: {
paddingTop: 0,
paddingRight: "16px !important",
textAlign: "end",
paddingBottom: 0
}
}))

const RowValue = styled(Typography)(({ theme }) => ({
fontWeight: 300,
fontSize: 18,
[theme.breakpoints.down("sm")]: {
fontSize: 16
}
}))

export const EvmDaoSummary: React.FC<EvmDaoSummaryProps> = () => {
const theme = useTheme()
const isMobileSmall = useMediaQuery(theme.breakpoints.down("sm"))
const { data } = useEvmDaoCreateStore()
const tableData = [
{ key: "Name", value: data?.name },
{ key: "Symbol", value: data?.governanceToken?.symbol },
{
key: "Total Members",
value: data?.members.length
},
{
key: "Total Supply",
value: data?.members.reduce(
(acc: number, member: { amountOfTokens: number }) => Number(acc) + Number(member.amountOfTokens),
0
)
},
{
key: "Quorum",
value: `${data?.quorum?.returnedTokenPercentage}%`
}
]
return (
<div className="evm-dao-summary">
<TitleBlock
Expand All @@ -16,7 +82,47 @@ export const EvmDaoSummary: React.FC<EvmDaoSummaryProps> = () => {
<DescriptionText variant="subtitle1">These settings will define the summary for your DAO.</DescriptionText>
}
/>
<div className="summary-content"></div>
<div className="summary-content">
<CustomTableContainer>
<Table aria-label="simple table">
<TableBody>
{tableData.map((item: { key: string; value: string }) => (
<TableRow>
<CustomTableCell component="th" scope="row">
<Typography style={{ color: "white", textAlign: "left" }}>{item.key}</Typography>
</CustomTableCell>
<CustomTableCellValue align="right">
{typeof item.value === "string" && item?.value?.startsWith("0x") ? (
<RowValue style={isMobileSmall ? { width: "max-content" } : {}}>
{isMobileSmall ? (
<CopyAddress address={item.value} />
) : (
<>
<Grid
container
style={{ color: "white" }}
direction="row"
alignItems="center"
justifyContent="flex-end"
>
{item.value}
<CopyButton text={item.value} />
</Grid>
</>
)}
</RowValue>
) : (
<RowValue style={isMobileSmall ? { width: "max-content" } : { color: "white" }}>
{item.value}
</RowValue>
)}
</CustomTableCellValue>
</TableRow>
))}
</TableBody>
</Table>
</CustomTableContainer>
</div>
</div>
)
}
2 changes: 1 addition & 1 deletion src/modules/etherlink/creator/EvmDaoTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import useEvmDaoCreateStore from "services/contracts/etherlinkDAO/hooks/useEvmDa
const LambdaCustomBox = styled(Grid)(({ theme }) => ({
"height": 273,
"marginTop": 30,
"background": "#2F3438",
"background": "#1c2024",
"borderRadius": 8,
"maxWidth": 342,
"width": "-webkit-fill-available",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { GridContainer } from "modules/common/GridContainer"
import { Button, Grid, TableRow, TableBody, Table, Typography, useMediaQuery, useTheme, TableCell } from "@mui/material"
import {
Button,
Grid,
TableRow,
TableBody,
Table,
Typography,
useMediaQuery,
useTheme,
TableCell,
IconButton
} from "@mui/material"
import { PageContainer } from "components/ui/DaoCreator"
import { useContext, useEffect, useState } from "react"
import { useParams } from "react-router-dom"
Expand All @@ -13,6 +24,7 @@ import { ThumbUpAlt } from "@mui/icons-material"
import { useNotification } from "modules/common/hooks/useNotification"
import { useEvmProposalOps } from "services/contracts/etherlinkDAO/hooks/useEvmProposalOps"
import { ProposalStatus } from "services/services/dao/mappers/proposal/types"
import { CopyButton } from "modules/common/CopyButton"

const RenderProposalAction = () => {
const { daoProposalSelected } = useContext(EtherlinkContext)
Expand Down Expand Up @@ -193,6 +205,8 @@ export const EvmProposalDetailsPage = () => {
<Grid container>
{daoProposalSelected?.proposalData?.map(
({ parameter, value }: { parameter: string; value: string }, idx: number) => {
console.log("callDataXYB", parameter, value)
const textValue = value?.length > 64 ? value.slice(0, 8) + "..." + value.slice(-4) : value
return (
<Grid key={idx}>
<Table
Expand All @@ -213,7 +227,15 @@ export const EvmProposalDetailsPage = () => {
<Typography style={{ color: "white" }}>Value</Typography>
</TableCell>
<TableCell>
<Typography style={{ color: "white" }}>{value}</Typography>
<div style={{ display: "flex", alignItems: "center" }}>
<Typography style={{ color: "white" }}>{textValue}</Typography>
<IconButton
onClick={() => navigator.clipboard.writeText(value)}
style={{ marginLeft: 8, padding: 4 }}
>
<CopyButton text={value} />
</IconButton>
</div>
</TableCell>
</TableRow>
</TableBody>
Expand Down
Loading

0 comments on commit 6a8d836

Please sign in to comment.