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