on 616e621 help sign in
bridge/src/views/ViewPoint.js
90 lines 2.1 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, Form } 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 <Form>
52 <PointInput
53 autoFocus
54 prop-size='lg'
55 prop-format='innerLabel'
56 className='mono'
57 placeholder='e.g. ~zod'
58 onChange={ this.handlePointInput }
59 value={pointName}>
60 <InnerLabel>{'Point Name'}</InnerLabel>
61 <ValidatedSigil
62 className={'tr-0 mt-05 mr-0 abs'}
63 patp={pointName}
64 show
65 size={68}
66 margin={8} />
67 </PointInput>
69 <Button
70 className={'mt-8'}
71 disabled={ valid === false }
72 onClick={
73 () => {
74 setPointCursor(Maybe.Just(ob.patp2dec(pointName)))
75 popRoute()
76 pushRoute(ROUTE_NAMES.SHIP)
77 }
78 }
79 >
80 { 'Continue →' }
81 </Button>
82 </Form>
83 </Col>
84 </Row>
85 )
86 }
90export default ViewPoint