on master help sign in
- use ternaries for conditional logic
ed7b91bChris Johnson
src/bridge/components/Header.js+15−22
@@ -11,13 +11,8 @@ const Crumbs = (props) => {
11 // FIXME probably more straightforward to render them normally and just
11 // FIXME probably more straightforward to render them normally and just
12 // return the reversed array of renders
12 // return the reversed array of renders
13 const rendered = history.map((route, idx) => {
13 const rendered = history.map((route, idx) => {
14−
15 return (
14 return (
16 <div className={'flex items-center'} key={ `history-${idx}` }>
15 <div className={'flex items-center'} key={ `history-${idx}` }>
17−
18−
19−
20−
21 <Button
16 <Button
22 prop-type={'link'}
17 prop-type={'link'}
23 prop-size={'sm'}
18 prop-size={'sm'}
@@ -31,8 +26,6 @@ const Crumbs = (props) => {
31 ? <div />
26 ? <div />
32 : <Chevron className={'h-4 mh-2'} />
27 : <Chevron className={'h-4 mh-2'} />
33 }
28 }
34−
35−
36 </div>
29 </div>
37 )
30 )
38 })
31 })
@@ -41,21 +34,21 @@ const Crumbs = (props) => {
41}
34}
42
35
43const Header = (props) => {
36const Header = (props) => {
44− if (props.showCrumbs) {
37+ const crumbs = (
45− return (
46− <div className={'flex items-center h-10'}>
38+ <div className={'flex items-center h-10'}>
47− <Crumbs
39+ <Crumbs
48− routeCrumbs={ props.routeCrumbs }
40+ routeCrumbs={ props.routeCrumbs }
49− skipRoute={ props.skipRoute }
41+ skipRoute={ props.skipRoute }
50− networkType={ props.networkType }
42+ networkType={ props.networkType }
51− wallet={ props.wallet }
43+ wallet={ props.wallet }
52− pointCursor={ props.pointCursor }
44+ pointCursor={ props.pointCursor }
53− />
45+ />
54− </div>
46+ </div>
55− )
47+ )
56− } else {
48+
57− return <h2 className="mt-9 clickable" onClick={() => props.skipRoute(1)}>Bridge</h2>
49+ const noCrumbs = <h2 className="mt-9 clickable" onClick={() => props.skipRoute(1)}>Bridge</h2>
58− }
50+
51+ return props.showCrumbs ? crumbs : noCrumbs
59}
52}
60
53
61export default Header
54export default Header
src/bridge/components/Passport.js+13−18
@@ -50,9 +50,7 @@ class Passport extends React.Component {
50
50
51 getCurrentDate() {
51 getCurrentDate() {
52 let date = new Date()
52 let date = new Date()
53− var fil = function(n) {
54−     return n >= 10 ? n : "0" + n;
53+ const fil = n => n >= 10 ? n : `0${n}`
55−   };
56 let fmtDate = `${date.getUTCFullYear()}.` +
54 let fmtDate = `${date.getUTCFullYear()}.` +
57   `${(date.getUTCMonth() + 1)}.` +
55   `${(date.getUTCMonth() + 1)}.` +
58   `${fil(date.getUTCDate())}`
56   `${fil(date.getUTCDate())}`
@@ -104,14 +102,15 @@ class Passport extends React.Component {
104 let stateElems = walletStates.map(state => {
102 let stateElems = walletStates.map(state => {
105 if (state === WALLET_STATES.DOWNLOADED) return null
103 if (state === WALLET_STATES.DOWNLOADED) return null
106
104
107− let lastIndex = walletStates.indexOf(state) === walletStates.length - 1
105+ const lastIndex = walletStates.indexOf(state) === walletStates.length - 1
106+ const checkmark = lastIndex
107+ ? <div className="text-700 text-sm lh-6 green-dark">✓</div>
108+ : null
108
109
109 return (
110 return (
110 <div className="flex justify-between">
111 <div className="flex justify-between">
111 <div className="text-mono text-sm lh-6 green-dark">{state}</div>
112 <div className="text-mono text-sm lh-6 green-dark">{state}</div>
112− {(!lastIndex) &&
113+ { checkmark }
113− <div className="text-700 text-sm lh-6 green-dark">✓</div>
114− }
115 </div>
114 </div>
116 )
115 )
117 })
116 })
@@ -124,8 +123,6 @@ class Passport extends React.Component {
124 }
123 }
125
124
126 render() {
125 render() {
127− let sigil = null
128−
129 let patp = this.props.point.matchWith({
126 let patp = this.props.point.matchWith({
130 Just: p => ob.patp(p.value),
127 Just: p => ob.patp(p.value),
131 Nothing: () => ''
128 Nothing: () => ''
@@ -141,15 +138,13 @@ class Passport extends React.Component {
141 Nothing: () => null
138 Nothing: () => null
142 })
139 })
143
140
144− if (patp !== '') {
141+ const sigil = patp !== ''
145− sigil = pour({
142+ ? pour({
146− patp: patp,
143+ patp: patp,
147− renderer: ReactSVGComponents,
144+ renderer: ReactSVGComponents,
148− size: 128
145+ size: 128
149− })
146+ })
150− } else {
151− sigil = <div className="passport-sigil-blank"></div>
147+ : <div className="passport-sigil-blank"></div>
152− }
153
148
154 let currentDate = this.getCurrentDate()
149 let currentDate = this.getCurrentDate()
155 let walletStates = this.getWalletStates()
150 let walletStates = this.getWalletStates()
src/bridge/lib/invite.js+2−1
@@ -86,6 +86,7 @@ const TRANSACTION_STATES = {
86 },
86 },
87}
87}
88
88
89+//TODO should be moved to lib/walletgen
89async function generateWallet(point) {
90async function generateWallet(point) {
90 const makeTicket = point => {
91 const makeTicket = point => {
91
92
@@ -140,7 +141,7 @@ async function generateWallet(point) {
140 return wallet;
141 return wallet;
141}
142}
142
143
143−//TODO pulled from walletgen/views/Generate and Download, put into lib
144+//TODO should be moved to lib/walletgen
144async function downloadWallet(paper) {
145async function downloadWallet(paper) {
145 return new Promise((resolve, reject) => {
146 return new Promise((resolve, reject) => {
146 const zip = new JSZip();
147 const zip = new JSZip();
src/bridge/views/InviteTicket.js+11−3
@@ -89,7 +89,9 @@ class InviteTicket extends React.Component {
89 uhdw.meta.passphrase
89 uhdw.meta.passphrase
90 ).matchWith({
90 ).matchWith({
91 Just: w => w.value,
91 Just: w => w.value,
92− Nothing: () => null
92+ Nothing: () => {
93+ throw BRIDGE_ERROR.MISSING_WALLET
94+ }
93 });
95 });
94
96
95 const addr = addressFromSecp256k1Public(inviteWallet.publicKey);
97 const addr = addressFromSecp256k1Public(inviteWallet.publicKey);
@@ -146,9 +148,15 @@ class InviteTicket extends React.Component {
146 let handler = isLogin ? this.handleInviteTicketInput : this.handleVerifyTicketInput
148 let handler = isLogin ? this.handleInviteTicketInput : this.handleVerifyTicketInput
147 let label = isLogin ? 'Activation code' : 'ticket'
149 let label = isLogin ? 'Activation code' : 'ticket'
148
150
151+ // if realWallet is Just, then VerifyTicketInput appropriate contents; if Nothing, remain Nothing
152+ const Verified = this.state.realWallet.map(realWallet =>
153+ VerifyTicketInput(realWallet.ticket)
154+ )
155+
156+ // Verified.getOrElse(TicketInput) falls back to TicketInput if Verified is Nothing
149 const TicketElem =
157 const TicketElem =
150− isVerify && !Nothing.hasInstance(this.state.realWallet)
158+ isVerify
151− ? VerifyTicketInput(this.state.realWallet.value.ticket)
159+ ? Verified.getOrElse(TicketInput)
152 : TicketInput
160 : TicketInput
153
161
154 return (
162 return (