on aee35bb help sign in
bridge/src/views/ViewPoint.js
62 lines 1.6 kB history raw
1import React, { useState } from 'react';
2import Maybe from 'folktale/maybe';
3import * as ob from 'urbit-ob';
5import { H1, P } from '../components/old/Base';
7import { useHistory } from 'store/history';
8import { usePointCursor } from 'store/pointCursor';
10import { ROUTE_NAMES } from 'lib/routeNames';
12import View from 'components/View';
13import { ForwardButton } from 'components/Buttons';
14import { PointInput } from 'components/Inputs';
15import InputSigil from 'components/InputSigil';
17export default function ViewPoint() {
18 const history = useHistory();
19 const { setPointCursor } = usePointCursor();
20 const [pointName, setPointName] = useState('');
21 const [pass, setPass] = useState(false);
22 const [error, setError] = useState();
23 const [focused, setFocused] = useState(true);
25 return (
26 <View>
27 <H1>{'View a Point'}</H1>
29 <P>{'Enter a point name to view its public information.'}</P>
31 <PointInput
32 name="point"
33 label="Point Name"
34 onValue={setPointName}
35 onPass={setPass}
36 onError={setError}
37 onFocus={setFocused}
38 autoFocus
39 />
41 <InputSigil
42 patp={pointName}
43 size={68}
44 margin={8}
45 pass={pass}
46 focused={focused}
47 error={error}
48 />
50 <ForwardButton
51 disabled={!pass}
52 onClick={() => {
53 setPointCursor(Maybe.Just(parseInt(ob.patp2dec(pointName), 10)));
54 // ^ pointCursor expects native number type, not string
55 history.popAndPush(ROUTE_NAMES.POINT);
56 }}
57 solid>
58 Continue
59 </ForwardButton>
60 </View>
61 );