Skip to content

Commit

Permalink
Add clear button to wipe proposals.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Nov 8, 2023
1 parent 6ec9577 commit 3752bb9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
7 changes: 7 additions & 0 deletions packages/stateful/components/dao/CreateDaoProposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ export const CreateDaoProposal = () => {
),
})

// Reset form to defaults and clear latest proposal save.
const clear = useCallback(() => {
formMethods.reset(makeDefaultNewProposalForm())
setLatestProposalSave({})
}, [formMethods, makeDefaultNewProposalForm, setLatestProposalSave])

const [proposalCreatedCardProps, setProposalCreatedCardProps] =
useRecoilState(proposalCreatedCardPropsAtom)

Expand Down Expand Up @@ -311,6 +317,7 @@ export const CreateDaoProposal = () => {
return (
<FormProvider {...formMethods}>
<CreateProposal
clear={clear}
newProposal={
<SuspenseLoader
fallback={<PageLoader />}
Expand Down
27 changes: 24 additions & 3 deletions packages/stateless/pages/CreateProposal.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import { Clear } from '@mui/icons-material'
import { ReactNode } from 'react'
import { useTranslation } from 'react-i18next'

import { DaoTabId } from '@dao-dao/types'

import { PageHeaderContent, RightSidebarContent } from '../components'
import {
IconButton,
PageHeaderContent,
RightSidebarContent,
Tooltip,
} from '../components'

export interface CreateProposalProps {
export type CreateProposalProps = {
newProposal: ReactNode
clear?: () => void
rightSidebarContent: ReactNode
}

export const CreateProposal = ({
newProposal,
clear,
rightSidebarContent,
}: CreateProposalProps) => {
const { t } = useTranslation()
Expand All @@ -31,7 +39,20 @@ export const CreateProposal = ({
/>

<div className="mx-auto flex max-w-5xl flex-col items-stretch gap-6">
<p className="title-text text-text-body">{t('title.newProposal')}</p>
<div className="flex flex-row items-center justify-between gap-4">
<p className="title-text text-text-body">{t('title.newProposal')}</p>

{clear && (
<Tooltip title={t('button.clear')}>
<IconButton
Icon={Clear}
circular
onClick={clear}
variant="ghost"
/>
</Tooltip>
)}
</div>

{newProposal}
</div>
Expand Down

0 comments on commit 3752bb9

Please sign in to comment.