Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add addOwner route and open tx flow #2399

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/components/tx-flow/flows/AddOwner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@ export type AddOwnerFlowProps = {
threshold: number
}

const AddOwnerFlow = () => {
const { safe } = useSafeInfo()

const defaultValues: AddOwnerFlowProps = {
newOwner: {
address: '',
name: '',
},
threshold: safe.threshold,
}

const FlowInner = ({ defaultValues }: { defaultValues: AddOwnerFlowProps }) => {
const { data, step, nextStep, prevStep } = useTxStepper<AddOwnerFlowProps>(defaultValues)

const steps = [
Expand All @@ -52,4 +42,20 @@ const AddOwnerFlow = () => {
)
}

const AddOwnerFlow = ({ address }: { address?: string }) => {
const { safe, safeLoading, safeLoaded } = useSafeInfo()

const defaultValues: AddOwnerFlowProps = {
newOwner: {
address: address || '',
name: '',
},
threshold: safe.threshold,
}

if (!safeLoaded || safeLoading) return null

return <FlowInner defaultValues={defaultValues} />
}

export default AddOwnerFlow
32 changes: 32 additions & 0 deletions src/pages/addOwner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { NextPage } from 'next'
import Head from 'next/head'
import { useRouter } from 'next/router'
import { useContext, useEffect } from 'react'
import { TxModalContext } from '@/components/tx-flow'
import AddOwnerFlow from '@/components/tx-flow/flows/AddOwner'
import { AppRoutes } from '@/config/routes'

const AddOwner: NextPage = () => {
const router = useRouter()
const { address } = router.query
const ownerAddress = Array.isArray(address) ? address[0] : address
const { setTxFlow } = useContext(TxModalContext)

useEffect(() => {
router.push({ pathname: AppRoutes.settings.setup, query: router.query }).then(() => {
if (!ownerAddress) return

setTxFlow(<AddOwnerFlow address={ownerAddress} />)
})
}, [ownerAddress, router, setTxFlow])

return (
<>
<Head>
<title>{'Safe{Wallet} – Add Owner'}</title>
</Head>
</>
)
}

export default AddOwner
Loading