Skip to content

Commit

Permalink
fix: back button navigate (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
terran6 authored and mwmerz committed May 26, 2023
1 parent 52f4b3d commit 4f90330
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/auth/modules/create/RecoverWalletPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const RecoverWalletPage = () => {
const { t } = useTranslation()

return (
<Page title={t("Import from seed phrase")} backButton small>
<Page title={t("Import from seed phrase")} backButtonPath="/" small>
<Card>
<RecoverWalletForm />
</Card>
Expand Down
8 changes: 5 additions & 3 deletions src/components/layout/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Props extends QueryState {
small?: boolean
sub?: boolean // used as a page in a page
invisible?: boolean // used as a page in a page with no margin
backButton?: boolean
backButtonPath?: string
}

const Page = (props: PropsWithChildren<Props>) => {
Expand All @@ -29,7 +29,7 @@ const Page = (props: PropsWithChildren<Props>) => {
sub,
invisible,
mainClassName,
backButton,
backButtonPath,
} = props

return (
Expand All @@ -43,7 +43,9 @@ const Page = (props: PropsWithChildren<Props>) => {
{title && (
<header className={styles.header}>
<div className={styles.titleWrapper}>
{backButton && <ArrowBack onClick={() => navigate(-1)} />}
{backButtonPath && (
<ArrowBack onClick={() => navigate(backButtonPath)} />
)}
<h1 className={styles.title}>{title}</h1>
</div>
{extra}
Expand Down
11 changes: 6 additions & 5 deletions src/pages/gov/ProposalDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ const ProposalDetails = () => {

useGoBackOnError(state)

const render = () => {
if (!proposal) return null

const { status } = proposal
if (!proposal) {
return null
}
const { status } = proposal

const render = () => {
return (
<Col>
<Row>
Expand Down Expand Up @@ -70,7 +71,7 @@ const ProposalDetails = () => {
{...state}
title={t("Proposal details")}
extra={proposal && <ProposalActions proposal={proposal} />}
backButton
backButtonPath={`/gov#${status}`}
>
{render()}
</Page>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/multisig/SignMultisigTxPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const SignMultisigTxPage = () => {
}

return (
<Page backButton title={t("Sign a multisig tx")}>
<Page backButtonPath="/" title={t("Sign a multisig tx")}>
{render()}
</Page>
)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/stake/ValidatorDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ValidatorDetails = () => {
}

return (
<Page {...state} title={t("Validator details")} backButton>
<Page {...state} title={t("Validator details")} backButtonPath="/stake">
{render()}
</Page>
)
Expand Down
2 changes: 1 addition & 1 deletion src/txs/gov/DepositTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const DepositTx = () => {
const { data: proposal, ...state } = useProposal(id, chain)

return (
<Page title={t("Deposit")} backButton>
<Page title={t("Deposit")} backButtonPath={`/proposal/${chain}/${id}`}>
<Auto
columns={[
<Card inputCard>
Expand Down
2 changes: 1 addition & 1 deletion src/txs/gov/SubmitProposalTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const SubmitProposalTx = () => {
}

return (
<Page backButton title={t("New proposal")} small>
<Page backButtonPath="/gov" title={t("New proposal")} small>
<ChainFilter outside>{(chain) => render(chain)}</ChainFilter>
</Page>
)
Expand Down
2 changes: 1 addition & 1 deletion src/txs/gov/VoteTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const VoteTx = () => {
const { data: proposal, ...state } = useProposal(id, chain)

return (
<Page backButton title={t("Vote")}>
<Page backButtonPath={`/proposal/${chain}/${id}`} title={t("Vote")}>
<Auto
columns={[
<Card inputCard>
Expand Down
2 changes: 1 addition & 1 deletion src/txs/stake/StakeTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const StakeTx = () => {
}

return (
<Page {...state} title={t("Delegate")} backButton>
<Page {...state} title={t("Delegate")} backButtonPath="/stake">
<Auto
columns={[
<Tabs
Expand Down
7 changes: 6 additions & 1 deletion src/txs/stake/WithdrawRewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ const WithdrawRewards = () => {
}

return (
<Page {...state} backButton title={t("Withdraw rewards")} small>
<Page
{...state}
backButtonPath="/stake"
title={t("Withdraw rewards")}
small
>
{render()}
</Page>
)
Expand Down
2 changes: 1 addition & 1 deletion src/txs/wasm/InstantiateContractTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const InstantiateContractTx = () => {
const { t } = useTranslation()

return (
<Page title={t("Instantiate a code")} small backButton>
<Page title={t("Instantiate a code")} small backButtonPath="/contract">
<ChainFilter>
{(chainID) => (
<IBCHelperContext>
Expand Down
2 changes: 1 addition & 1 deletion src/txs/wasm/StoreCodeTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const StoreCodeTx = () => {
const { t } = useTranslation()

return (
<Page title={t("Upload a wasm file")} small backButton>
<Page title={t("Upload a wasm file")} small backButtonPath="/contract">
<ChainFilter>
{(chainID) => <StoreCodeForm chainID={chainID ?? ""} />}
</ChainFilter>
Expand Down

0 comments on commit 4f90330

Please sign in to comment.