-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Address manage component to another route
- Loading branch information
1 parent
05df260
commit b519c98
Showing
7 changed files
with
126 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
packages/bierzo-wallet/src/routes/addressManage/index.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Address, ChainId } from "@iov/bcp"; | ||
import { action } from "@storybook/addon-actions"; | ||
import { linkTo } from "@storybook/addon-links"; | ||
import { storiesOf } from "@storybook/react"; | ||
import { ActionMenuItem } from "medulas-react-components"; | ||
import React from "react"; | ||
|
||
import { ChainAddressPairWithName } from "../../components/AddressesTable"; | ||
import DecoratedStorybook, { bierzoRoot } from "../../utils/storybook"; | ||
import { BwUsernameWithChainName } from "../addresses"; | ||
import { | ||
REGISTER_USERNAME_REGISTRATION_STORY_PATH, | ||
REGISTER_USERNAME_STORY_PATH, | ||
} from "../register/index.stories"; | ||
import ManageName from "./ManageName"; | ||
|
||
const chainAddresses: ChainAddressPairWithName[] = [ | ||
{ | ||
chainId: "local-iov-devnet" as ChainId, | ||
address: "tiov1dcg3fat5zrvw00xezzjk3jgedm7pg70y222af3" as Address, | ||
chainName: "IOV Devnet", | ||
}, | ||
{ | ||
chainId: "lisk-198f2b61a8" as ChainId, | ||
address: "1349293588603668134L" as Address, | ||
chainName: "Lisk Devnet", | ||
}, | ||
{ | ||
chainId: "ethereum-eip155-5777" as ChainId, | ||
address: "0xD383382350F9f190Bd2608D6381B15b4e1cec0f3" as Address, | ||
chainName: "Ganache", | ||
}, | ||
]; | ||
|
||
const username: BwUsernameWithChainName = { | ||
username: "test2*iov", | ||
addresses: [chainAddresses[0], chainAddresses[1]], | ||
}; | ||
|
||
const menuItems: readonly ActionMenuItem[] = [ | ||
{ | ||
title: "Renew", | ||
action: () => { | ||
action("Renew")(); | ||
}, | ||
}, | ||
{ | ||
title: "Transfer iovname", | ||
action: () => { | ||
action("Transfer iovname")(); | ||
}, | ||
}, | ||
{ | ||
title: "Delete iovname", | ||
action: () => { | ||
action("Delete iovname")(); | ||
}, | ||
}, | ||
]; | ||
|
||
storiesOf(`${bierzoRoot}/Address Manage`, module) | ||
.addParameters({ viewport: { defaultViewport: "responsive" } }) | ||
.add("Manage names", () => ( | ||
<DecoratedStorybook> | ||
<ManageName | ||
account={username} | ||
menuItems={menuItems} | ||
onRegisterUsername={linkTo(REGISTER_USERNAME_STORY_PATH, REGISTER_USERNAME_REGISTRATION_STORY_PATH)} | ||
/> | ||
</DecoratedStorybook> | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ActionMenuItem, Block } from "medulas-react-components"; | ||
import * as React from "react"; | ||
|
||
import { history } from ".."; | ||
import PageMenu from "../../components/PageMenu"; | ||
import { BwUsernameWithChainName } from "../addresses"; | ||
import { REGISTER_IOVNAME_ROUTE, REGISTER_STARNAME_ROUTE } from "../paths"; | ||
import ManageName from "./ManageName"; | ||
|
||
function onRegisterUsername(): void { | ||
history.push(REGISTER_IOVNAME_ROUTE); | ||
} | ||
|
||
function onRegisterStarname(): void { | ||
history.push(REGISTER_STARNAME_ROUTE); | ||
} | ||
|
||
const menuItems: readonly ActionMenuItem[] = [ | ||
{ title: "Renew", action: () => console.log("Renew") }, | ||
{ title: "Transfer iovname", action: () => console.log("Transfer iovname") }, | ||
{ title: "Delete iovname", action: () => console.log("Delete iovname") }, | ||
]; | ||
|
||
const AddressManage = (): JSX.Element => { | ||
const aadressToManage: BwUsernameWithChainName | undefined = history.location.state; | ||
|
||
if (!aadressToManage) { | ||
throw new Error("No address to manage provided, something wrong."); | ||
} | ||
|
||
return ( | ||
<PageMenu> | ||
<Block marginTop={4} display="flex" flexDirection="column" alignItems="center" justifyContent="center"> | ||
<ManageName menuItems={menuItems} account={aadressToManage} onRegisterUsername={onRegisterUsername} /> | ||
</Block> | ||
</PageMenu> | ||
); | ||
}; | ||
|
||
export default AddressManage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters