on fbcd6b6 help sign in
bridge/src/views/Point.js
74 lines 2.2 kB history raw
1import React, { useCallback } from 'react';
2import Maybe from 'folktale/maybe';
3import * as need from 'lib/need';
4import { Grid } from 'indigo-react';
6import { usePointCursor } from 'store/pointCursor';
7import { usePointCache } from 'store/pointCache';
8import { useHistory } from 'store/history';
10import View from 'components/View';
11import Passport from 'components/Passport';
12import { ForwardButton } from 'components/Buttons';
13import FooterButton from 'components/FooterButton';
14import { matchBlinky } from 'components/Blinky';
16import useInvites from 'lib/useInvites';
17import { useSyncOwnedPoints } from 'lib/useSyncPoints';
18import { ROUTE_NAMES } from 'lib/routeNames';
20import Actions from './Point/Actions';
21import { useWallet } from 'store/wallet';
23export default function Point() {
24 const history = useHistory();
25 const { pointCursor } = usePointCursor();
26 const { pointCache } = usePointCache();
27 const { wallet } = useWallet();
29 const point = need.point(pointCursor);
30 const hasInCache = point in pointCache;
32 // fetch the invites for the current cursor
33 const { availableInvites } = useInvites(point);
34 const availableInvitesText = matchBlinky(availableInvites);
36 const showActions = Maybe.Just.hasInstance(wallet);
38 const goAdmin = useCallback(() => history.push(ROUTE_NAMES.ADMIN), [history]);
40 const goInvite = useCallback(() => history.push(ROUTE_NAMES.INVITE), [
41 history,
42 ]);
44 // sync the current cursor
45 useSyncOwnedPoints([point]);
47 return (
48 <View>
49 <Passport point={Maybe.Just(point)} />
50 <Grid className="pt2">
51 <Grid.Item full>
52 <ForwardButton disabled={!hasInCache} onClick={goAdmin}>
53 Admin
54 </ForwardButton>
55 </Grid.Item>
56 <Grid.Divider />
57 <Grid.Item full>
58 <ForwardButton detail="Boot your computer" disabled>
59 Boot Arvo
60 </ForwardButton>
61 </Grid.Item>
62 {showActions && (
63 <Grid.Item full>
64 <Actions />
65 </Grid.Item>
66 )}
67 </Grid>
69 <FooterButton onClick={goInvite}>
70 Invite <sup>{availableInvitesText}</sup>
71 </FooterButton>
72 </View>
73 );