refactor wallet area

This commit is contained in:
Jeremy Kauffman 2017-08-17 16:19:29 -04:00
parent 6d6f70ed46
commit 1cbc96533b
14 changed files with 96 additions and 43 deletions

View file

@ -51,7 +51,7 @@ let daemonStopRequested = false;
let readyToQuit = false; let readyToQuit = false;
// If we receive a URI to open from an external app but there's no window to // If we receive a URI to open from an external app but there's no window to
// send it to, it's cached in this variable. // sendCredits it to, it's cached in this variable.
let openUri = null; let openUri = null;
function processRequestedUri(uri) { function processRequestedUri(uri) {

View file

@ -4,7 +4,9 @@ import HelpPage from "page/help";
import ReportPage from "page/report.js"; import ReportPage from "page/report.js";
import StartPage from "page/start.js"; import StartPage from "page/start.js";
import WalletPage from "page/wallet"; import WalletPage from "page/wallet";
import ShowPage from "page/showPage"; import ReceiveCreditsPage from "page/receiveCredits";
import SendCreditsPage from "page/sendCredits";
import ShowPage from "page/show";
import PublishPage from "page/publish"; import PublishPage from "page/publish";
import DiscoverPage from "page/discover"; import DiscoverPage from "page/discover";
import DeveloperPage from "page/developer.js"; import DeveloperPage from "page/developer.js";
@ -35,11 +37,11 @@ const Router = props => {
help: <HelpPage params={params} />, help: <HelpPage params={params} />,
publish: <PublishPage params={params} />, publish: <PublishPage params={params} />,
published: <FileListPublished params={params} />, published: <FileListPublished params={params} />,
receive: <WalletPage params={params} />, receive: <ReceiveCreditsPage params={params} />,
report: <ReportPage params={params} />, report: <ReportPage params={params} />,
rewards: <RewardsPage params={params} />, rewards: <RewardsPage params={params} />,
search: <SearchPage params={params} />, search: <SearchPage params={params} />,
send: <WalletPage params={params} />, send: <SendCreditsPage params={params} />,
settings: <SettingsPage params={params} />, settings: <SettingsPage params={params} />,
show: <ShowPage params={params} />, show: <ShowPage params={params} />,
start: <StartPage params={params} />, start: <StartPage params={params} />,

View file

@ -0,0 +1,15 @@
import React from "react";
import { connect } from "react-redux";
import { doNavigate } from "actions/app";
import { selectBalance } from "selectors/wallet";
import WalletBalance from "./view";
const select = state => ({
balance: selectBalance(state),
});
const perform = dispatch => ({
navigate: path => dispatch(doNavigate(path)),
});
export default connect(select, perform)(WalletBalance);

View file

@ -0,0 +1,28 @@
import React from "react";
import Link from "component/link";
import { CreditAmount } from "component/common";
const WalletBalance = props => {
const { balance, navigate } = props;
return (
<section className="card">
<div className="card__title-primary">
<h3>{__("Balance")}</h3>
</div>
<div className="card__content">
{balance && <CreditAmount amount={balance} precision={8} />}
</div>
<div className="card__content">
<div className="help">
<Link
onClick={() => navigate("/backup")}
label={__("Backup Your Wallet")}
/>
</div>
</div>
</section>
);
};
export default WalletBalance;

View file

@ -0,0 +1,5 @@
import React from "react";
import { connect } from "react-redux";
import ReceiveCreditsPage from "./view";
export default connect(null, null)(ReceiveCreditsPage);

View file

@ -0,0 +1,16 @@
import React from "react";
import SubHeader from "component/subHeader";
import WalletBalance from "component/walletBalance";
import WalletAddress from "component/walletAddress";
const ReceiveCreditsPage = props => {
return (
<main className="main--single-column">
<SubHeader />
<WalletBalance />
<WalletAddress />
</main>
);
};
export default ReceiveCreditsPage;

View file

@ -0,0 +1,5 @@
import React from "react";
import { connect } from "react-redux";
import SendCreditsPage from "./view";
export default connect(null, null)(SendCreditsPage);

View file

@ -0,0 +1,16 @@
import React from "react";
import SubHeader from "component/subHeader";
import WalletBalance from "component/walletBalance";
import WalletSend from "component/walletSend";
const SendCreditsPage = props => {
return (
<main className="main--single-column">
<SubHeader />
<WalletBalance />
<WalletSend />
</main>
);
};
export default SendCreditsPage;

View file

@ -2,7 +2,7 @@ import React from "react";
import lbryuri from "lbryuri"; import lbryuri from "lbryuri";
import { BusyMessage } from "component/common"; import { BusyMessage } from "component/common";
import ChannelPage from "page/channel"; import ChannelPage from "page/channel";
import FilePage from "page/filePage"; import FilePage from "page/file";
class ShowPage extends React.PureComponent { class ShowPage extends React.PureComponent {
componentWillMount() { componentWillMount() {

View file

@ -1,17 +1,5 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { doNavigate } from "actions/app";
import { selectCurrentPage } from "selectors/app";
import { selectBalance } from "selectors/wallet";
import WalletPage from "./view"; import WalletPage from "./view";
const select = state => ({ export default connect(null, null)(WalletPage);
currentPage: selectCurrentPage(state),
balance: selectBalance(state),
});
const perform = dispatch => ({
navigate: path => dispatch(doNavigate(path)),
});
export default connect(select, perform)(WalletPage);

View file

@ -1,36 +1,14 @@
import React from "react"; import React from "react";
import SubHeader from "component/subHeader"; import SubHeader from "component/subHeader";
import WalletBalance from "component/walletBalance";
import TransactionList from "component/transactionList"; import TransactionList from "component/transactionList";
import WalletAddress from "component/walletAddress";
import WalletSend from "component/walletSend";
import Link from "component/link";
import { CreditAmount } from "component/common";
const WalletPage = props => { const WalletPage = props => {
const { balance, currentPage, navigate } = props;
return ( return (
<main className="main--single-column"> <main className="main--single-column">
<SubHeader /> <SubHeader />
<section className="card"> <WalletBalance />
<div className="card__title-primary"> <TransactionList />
<h3>{__("Balance")}</h3>
</div>
<div className="card__content">
<CreditAmount amount={balance} precision={8} />
</div>
<div className="card__content">
<div className="help">
<Link
onClick={() => navigate("/backup")}
label={__("Backup Your Wallet")}
/>
</div>
</div>
</section>
{currentPage === "wallet" ? <TransactionList {...props} /> : ""}
{currentPage === "send" ? <WalletSend {...props} /> : ""}
{currentPage === "receive" ? <WalletAddress /> : ""}
</main> </main>
); );
}; };