on dffcebf help sign in
bridge/src/views/ViewPoint.js
48 lines 1.3 kB history raw
1import React, { useCallback } from 'react';
2import { Just } 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';
12import { usePointInput } from 'lib/useInputs';
14import View from 'components/View';
15import { ForwardButton } from 'components/Buttons';
17export default function ViewPoint() {
18 const history = useHistory();
19 const { setPointCursor } = usePointCursor();
20 const [pointInput, { data: pointName, pass }] = usePointInput({
21 name: 'point',
22 autoFocus: true,
23 });
25 const disabled = !pass;
26 const goForward = useCallback(() => {
27 setPointCursor(Just(patp2dec(pointName)));
28 history.popAndPush(ROUTE_NAMES.POINT);
29 }, [setPointCursor, history, pointName]);
31 return (
32 <View>
33 <H1>View a Point</H1>
35 <P>Enter a point name to view its public information.</P>
37 <Input {...pointInput} onEnter={goForward} />
39 <ForwardButton
40 className="mt3"
41 disabled={disabled}
42 onClick={goForward}
43 solid>
44 Continue
45 </ForwardButton>
46 </View>
47 );