on 8ca8b8a help sign in
bridge/src/views/Point.js
67 lines 1.9 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 { useHistory } from 'store/history';
9import View from 'components/View';
10import Passport from 'components/Passport';
11import { ForwardButton } from 'components/Buttons';
12import FooterButton from 'components/FooterButton';
13import { matchBlinky } from 'components/Blinky';
15import useInvites from 'lib/useInvites';
16import { useSyncOwnedPoints } from 'lib/useSyncPoints';
17import { ROUTE_NAMES } from 'lib/routeNames';
19import Actions from './Point/Actions';
20import { useWallet } from 'store/wallet';
22export default function Point() {
23 const history = useHistory();
24 const { pointCursor } = usePointCursor();
25 const { wallet } = useWallet();
27 const point = need.point(pointCursor);
29 // fetch the invites for the current cursor
30 const { availableInvites } = useInvites(point);
31 const availableInvitesText = matchBlinky(availableInvites);
33 const showActions = Maybe.Just.hasInstance(wallet);
35 const goInvite = useCallback(() => history.push(ROUTE_NAMES.INVITE), [
36 history,
37 ]);
39 // sync the current cursor
40 useSyncOwnedPoints([point]);
42 return (
43 <View>
44 <Passport point={Maybe.Just(point)} />
45 <Grid className="pt2">
46 <Grid.Item full>
47 <ForwardButton disabled>Admin</ForwardButton>
48 </Grid.Item>
49 <Grid.Divider />
50 <Grid.Item full>
51 <ForwardButton detail="Boot your computer" disabled>
52 Boot Arvo
53 </ForwardButton>
54 </Grid.Item>
55 {showActions && (
56 <Grid.Item full>
57 <Actions />
58 </Grid.Item>
59 )}
60 </Grid>
62 <FooterButton onClick={goInvite}>
63 Invite <sup>{availableInvitesText}</sup>
64 </FooterButton>
65 </View>
66 );