on bf5080e help sign in
bridge/src/views/ViewPoint.js
88 lines 2.0 kB history raw
1import Maybe from 'folktale/maybe'
2import React from 'react'
3import * as ob from 'urbit-ob'
5import { Button } from '../components/Base'
6import { Row, Col, H1, P } from '../components/Base'
7import { InnerLabel, PointInput, ValidatedSigil } from '../components/Base'
9import { ROUTE_NAMES } from '../lib/router'
11class ViewPoint extends React.Component {
12 constructor(props) {
13 super(props)
15 this.state = {
16 pointName: ''
17 }
19 this.handlePointInput = this.handlePointInput.bind(this)
20 }
22 handlePointInput = (pointName) => {
23 if (pointName.length < 15) {
24 this.setState({ pointName })
25 }
26 }
28 render() {
29 const { pointName } = this.state
30 const { popRoute, pushRoute, setPointCursor } = this.props
32 // NB (jtobin):
33 //
34 // could use a better patp parser in urbit-ob
35 let valid
36 try {
37 valid = ob.isValidPatp(pointName)
38 } catch(err) {
39 valid = false
40 }
42 return (
43 <Row>
44 <Col>
45 <H1>{ 'View a Point' }</H1>
47 <P>
48 { "Enter a point name to view its public information." }
49 </P>
51 <PointInput
52 autoFocus
53 prop-size='lg'
54 prop-format='innerLabel'
55 className='mono'
56 placeholder='e.g. ~zod'
57 onChange={ this.handlePointInput }
58 value={pointName}>
59 <InnerLabel>{'Point Name'}</InnerLabel>
60 <ValidatedSigil
61 className={'tr-0 mt-05 mr-0 abs'}
62 patp={pointName}
63 show
64 size={68}
65 margin={8} />
66 </PointInput>
68 <Button
69 className={'mt-8'}
70 disabled={ valid === false }
71 onClick={
72 () => {
73 setPointCursor(Maybe.Just(ob.patp2dec(pointName)))
74 popRoute()
75 pushRoute(ROUTE_NAMES.SHIP)
76 }
77 }
78 >
79 { 'Continue →' }
80 </Button>
81 </Col>
82 </Row>
83 )
84 }
88export default ViewPoint