Skip to content

Commit

Permalink
add clear escrow form
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsayo committed Dec 24, 2024
1 parent b179af2 commit a3a3465
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { AddressType, CHAIN_ID } from 'src/typings'

import { BuilderTransaction, useProposalStore } from '../../stores'
import { prepareProposalTransactions } from '../../utils/prepareTransactions'
import { useEscrowFormStore } from '../TransactionForm/Escrow/EscrowUtils'
import { Transactions } from './Transactions'
import { ERROR_CODE, FormValues, validationSchema } from './fields'

Expand Down Expand Up @@ -69,6 +70,7 @@ export const ReviewProposalForm = ({
const [simulating, setSimulating] = useState<boolean>(false)
const [simulations, setSimulations] = useState<Array<Simulation>>([])
const [proposing, setProposing] = useState<boolean>(false)
const { clear: clearEscrowForm } = useEscrowFormStore()

const { data: votes, isLoading } = useContractRead({
address: addresses?.token as AddressType,
Expand Down Expand Up @@ -178,6 +180,7 @@ export const ReviewProposalForm = ({
.then(() => {
setProposing(false)
clearProposal()
clearEscrowForm()
})
} catch (err: any) {
setProposing(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface EscrowFormState {
formValues: EscrowFormValues
setFormValues: (values: EscrowFormValues) => void
resetForm: () => void
clear: () => void
}

export interface EscrowFormProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const EscrowForm: React.FC<EscrowFormProps> = ({

const { formValues, setFormValues } = useEscrowFormStore()
const {
addresses: { multiSig, governor, treasury },
addresses: { multiSig, treasury },
} = useDaoStore()

const handleSubmit = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ const useEscrowFormStore = create(
formValues: initialState,
setFormValues: (values) => set({ formValues: values }),
resetForm: () => set({ formValues: initialState }),
clear: () => {
set({ formValues: initialState })
localStorage.removeItem('escrow-form-storage')
},
}),
{
name: 'escrow-form-storage',
Expand Down

0 comments on commit a3a3465

Please sign in to comment.