Skip to content

Commit

Permalink
Merge pull request #463 from dOrgTech/v2-develop
Browse files Browse the repository at this point in the history
Merge v2-develop to v2
  • Loading branch information
Man-Jain authored Jan 18, 2023
2 parents 9cc0d9e + 8d005bb commit f68ad9a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 27 deletions.
61 changes: 38 additions & 23 deletions src/modules/explorer/components/NewTreasuryProposalDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const DAOBalanceText = styled(Typography)({
marginRight: 10
})

const CustomErrorText = styled(ErrorText)({
textTransform: "capitalize"
})

const AutoCompletePaper = styled(Paper)({
background: "#24282B"
})
Expand Down Expand Up @@ -161,6 +165,7 @@ export const NewTreasuryProposalDialog: React.FC<{ open: boolean }> = ({ open })

const recipientError = (errors.transferForm?.transfers?.[activeTransfer - 1] as any)?.recipient
const amountError = (errors.transferForm?.transfers?.[activeTransfer - 1] as any)?.amount
const assetsError = (errors.transferForm?.transfers?.[activeTransfer - 1] as any)?.asset

const { transfers } = watch("transferForm")

Expand Down Expand Up @@ -216,32 +221,35 @@ export const NewTreasuryProposalDialog: React.FC<{ open: boolean }> = ({ open })
(field, index) =>
index === activeTransfer - 1 && (
<>
<ProposalFormInput label={"Recipient"}>
<Controller
key={field.id}
name={`transferForm.transfers.${index}.recipient`}
control={control}
render={({ field }) => (
<TextField
{...field}
type="string"
InputProps={{ disableUnderline: true }}
placeholder="Type an Address Here"
/>
)}
/>

{recipientError && touched.transferForm?.transfers?.[activeTransfer - 1]?.recipient ? (
<ErrorText>{recipientError}</ErrorText>
<Grid container direction="column">
<ProposalFormInput label={"Recipient"}>
<Controller
key={field.id}
name={`transferForm.transfers.${index}.recipient`}
control={control}
rules={{ required: true }}
render={({ field }) => (
<TextField
{...field}
type="string"
InputProps={{ disableUnderline: true }}
placeholder="Type an Address Here"
/>
)}
/>
</ProposalFormInput>
{recipientError && errors.transferForm?.transfers?.[activeTransfer - 1]?.recipient ? (
<CustomErrorText>{recipientError.type}</CustomErrorText>
) : null}
</ProposalFormInput>
<Grid container alignItems="center" style={{ gap: 26 }}>
</Grid>
<Grid container style={{ gap: 26 }}>
<Grid item xs={isMobileSmall ? 12 : 6}>
<ProposalFormInput label={"Asset"}>
<Controller
key={field.id}
name={`transferForm.transfers.${index}.asset`}
control={control}
rules={{ required: true }}
render={({ field: { onChange, ...props } }) => (
<AutoCompleteField
options={assetOptions || []}
Expand Down Expand Up @@ -276,6 +284,9 @@ export const NewTreasuryProposalDialog: React.FC<{ open: boolean }> = ({ open })
)}
/>
</ProposalFormInput>
{assetsError && errors.transferForm?.transfers?.[activeTransfer - 1]?.asset ? (
<CustomErrorText>{assetsError.type}</CustomErrorText>
) : null}
</Grid>

<Grid item xs={isMobileSmall ? 12 : true}>
Expand All @@ -297,6 +308,11 @@ export const NewTreasuryProposalDialog: React.FC<{ open: boolean }> = ({ open })
key={field.id}
name={`transferForm.transfers.${index}.amount`}
control={control}
rules={{
validate: () => {
return getValues(`transferForm.transfers.${index}.amount`) > 0
}
}}
render={({ field }) => (
<TextField
{...field}
Expand All @@ -321,11 +337,10 @@ export const NewTreasuryProposalDialog: React.FC<{ open: boolean }> = ({ open })
/>
)}
/>

{amountError && touched.transferForm?.transfers?.[activeTransfer - 1]?.amount ? (
<ErrorText>{amountError}</ErrorText>
) : null}
</ProposalFormInput>
{amountError && errors.transferForm?.transfers?.[activeTransfer - 1]?.amount ? (
<ErrorText>{"Must be greater than zero"}</ErrorText>
) : null}
</Grid>
<DaoBalance container direction="row" alignItems="center" justifyContent="space-between">
<Grid item xs={6}>
Expand Down
20 changes: 19 additions & 1 deletion src/modules/explorer/components/ProposalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ import { Token } from "models/Token"
import { useDAOID } from "../pages/DAO/router"
import { ProposalFormInput } from "./ProposalFormInput"
import { ProposalFormResponsiveDialog } from "./ResponsiveDialog"
import CloseButton from "modules/common/CloseButton"

const CustomContainer = styled(Grid)({
padding: "42px 54px 0px 54px"
})

const DialogTitle = styled(Typography)({
fontSize: 20,
fontWeight: 500,
textTransform: "capitalize"
})

type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>
Expand Down Expand Up @@ -170,7 +181,14 @@ export const ProposalFormContainer: React.FC<Props> = ({ open, handleClose, defa
<ProposalFormResponsiveDialog open={open} onClose={handleClose}>
{dao && daoHoldings && (
<>
<AppTabBar value={selectedTab} setValue={setSelectedTab} labels={forms.map(form => form.label)} />
<CustomContainer container direction="row" justifyContent="space-between" alignItems="center">
<Grid item>
<DialogTitle>{forms[selectedTab].label.toLowerCase()}</DialogTitle>
</Grid>
<Grid item>
<CloseButton onClose={handleClose} />
</Grid>
</CustomContainer>
{forms.map((form, i) => (
<TabPanel key={`tab-${i}`} value={selectedTab} index={i}>
<form.component open={open} />
Expand Down
1 change: 0 additions & 1 deletion src/modules/explorer/pages/DAO/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export const DAO: React.FC = () => {
</Grid>
</Grid>
</HeroContainer>
<UserBalancesBox daoId={daoId} />
<DAOStatsRow />

{data && cycleInfo && activeProposals && (
Expand Down
1 change: 0 additions & 1 deletion src/modules/explorer/pages/Proposals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export const Proposals: React.FC = () => {
</Grid>
</Grid>
</HeroContainer>
<DAOStatsRow />

{data && cycleInfo && activeProposals && (
<ProposalsList title={"Active Proposals"} currentLevel={cycleInfo.currentLevel} proposals={activeProposals} />
Expand Down
2 changes: 1 addition & 1 deletion src/modules/explorer/pages/Treasury/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const Treasury: React.FC = () => {
<TransfersTable isInbound={false} transfers={outboundTransfers} />
</Grid>
</Grid>
<ProposalFormContainer open={openTransfer} handleClose={onCloseTransfer} defaultTab={1} />
<ProposalFormContainer open={openTransfer} handleClose={onCloseTransfer} defaultTab={0} />
<DelegationChangeProposalForm open={openDelegationChange} handleClose={() => setOpenDelegationChange(false)} />
</>
)
Expand Down

0 comments on commit f68ad9a

Please sign in to comment.