on 8ca8b8a help sign in
bridge/src/views/ViewPoint.js
49 lines 1.3 kB history raw
1import React, { useCallback } from 'react';
2import Maybe from 'folktale/maybe';
3import { Input } from 'indigo-react';
5import { H1, P } from '../components/old/Base';
7import { useHistory } from 'store/history';
8import { usePointCursor } from 'store/pointCursor';
10import { ROUTE_NAMES } from 'lib/routeNames';
11import patp2dec from 'lib/patp2dec';
13import View from 'components/View';
14import { ForwardButton } from 'components/Buttons';
15import { usePointInput } from 'components/Inputs';
17export default function ViewPoint() {
18 const history = useHistory();
19 const { setPointCursor } = usePointCursor();
20 const pointInput = usePointInput({
21 name: 'point',
22 autoFocus: true,
23 });
24 const { data: pointName, pass } = pointInput;
26 const disabled = !pass;
27 const goForward = useCallback(() => {
28 setPointCursor(Maybe.Just(patp2dec(pointName)));
29 history.popAndPush(ROUTE_NAMES.POINT);
30 }, [setPointCursor, history, pointName]);
32 return (
33 <View>
34 <H1>View a Point</H1>
36 <P>Enter a point name to view its public information.</P>
38 <Input {...pointInput} onEnter={goForward} />
40 <ForwardButton
41 className="mt3"
42 disabled={disabled}
43 onClick={goForward}
44 solid>
45 Continue
46 </ForwardButton>
47 </View>
48 );