@@ -1,7 +1,8 @@
1−import React, { useCallback } from 'react';
1+import React, { useCallback, useMemo } from 'react';
2import { Just } from 'folktale/maybe';
2import { Just } from 'folktale/maybe';
3import * as need from 'lib/need';
3import * as need from 'lib/need';
4import { Grid } from 'indigo-react';
4import { Grid } from 'indigo-react';
5+import { azimuth } from 'azimuth-js';
6import { usePointCursor } from 'store/pointCursor';
7import { usePointCursor } from 'store/pointCursor';
7import { useHistory } from 'store/history';
8import { useHistory } from 'store/history';
@@ -20,6 +21,9 @@ import Actions from './Point/Actions';
20import { useWallet } from 'store/wallet';
21import { useWallet } from 'store/wallet';
21import usePermissionsForPoint from 'lib/usePermissionsForPoint';
22import usePermissionsForPoint from 'lib/usePermissionsForPoint';
24+const isPlanet = point =>
25+ azimuth.getPointSize(point) === azimuth.PointSize.Planet;
23export default function Point() {
27export default function Point() {
24 const history = useHistory();
28 const history = useHistory();
25 const { pointCursor } = usePointCursor();
29 const { pointCursor } = usePointCursor();
@@ -27,7 +31,7 @@ export default function Point() {
28 const point = need.point(pointCursor);
32 const point = need.point(pointCursor);
30− const { canManage } = usePermissionsForPoint(
34+ const { isOwner, canManage } = usePermissionsForPoint(
31 // using empty string should be ok here
35 // using empty string should be ok here
32 wallet.matchWith({
36 wallet.matchWith({
33 Nothing: () => '',
37 Nothing: () => '',
@@ -38,7 +42,6 @@ export default function Point() {
39 // fetch the invites for the current cursor
43 // fetch the invites for the current cursor
40 const { availableInvites } = useInvites(point);
44 const { availableInvites } = useInvites(point);
41− const availableInvitesText = matchBlinky(availableInvites);
43 const showActions = Just.hasInstance(wallet);
46 const showActions = Just.hasInstance(wallet);
@@ -48,6 +51,30 @@ export default function Point() {
54+ const inviteButton = useMemo(() => {
55+ switch (azimuth.getPointSize(point)) {
56+ case azimuth.PointSize.Planet:
57+ const availableInvitesText = matchBlinky(availableInvites);
58+ const goInvite = () => history.push(ROUTE_NAMES.INVITE);
60+ <FooterButton disabled={!isOwner} onClick={goInvite}>
61+ Invite <sup>{availableInvitesText} available</sup>
65+ case azimuth.PointSize.Star:
66+ const goParties = () => history.push(ROUTE_NAMES.INVITES_MANAGE);
68+ <FooterButton disabled={!isOwner} onClick={goParties}>
76+ }, [point, history, isOwner, availableInvites]);
51 // sync the current cursor
78 // sync the current cursor
52 useSyncOwnedPoints([point]);
79 useSyncOwnedPoints([point]);
@@ -73,9 +100,7 @@ export default function Point() {
76− <FooterButton disabled={!canManage} onClick={goInvite}>
103+ {inviteButton}
77− Invite <sup>{availableInvitesText} available</sup>