1import React, { useCallback, useState } from 'react';
2import cn from 'classnames';
3import { Just } from 'folktale/maybe';
4import { Grid, Flex, Button } from 'indigo-react';
5import { azimuth } from 'azimuth-js';
7import { usePointCursor } from 'store/pointCursor';
8import { useWallet } from 'store/wallet';
10import View from 'components/View';
11import Greeting from 'components/Greeting';
12import Passport from 'components/Passport';
13import { ForwardButton, BootUrbitOSButton } from 'components/Buttons';
14import CopyButton from 'components/CopyButton';
15import Blinky, { matchBlinky } from 'components/Blinky';
16import BarGraph from 'components/BarGraph';
17import Chip from 'components/Chip';
18import InviteSigilList from 'components/InviteSigilList';
20import * as need from 'lib/need';
21import useInvites from 'lib/useInvites';
22import { useSyncOwnedPoints } from 'lib/useSyncPoints';
23import useCurrentPermissions from 'lib/useCurrentPermissions';
24import { useLocalRouter } from 'lib/LocalRouter';
25import useKeyfileGenerator from 'lib/useKeyfileGenerator';
27import Inviter from 'views/Invite/Inviter';
29export default function Point() {
30 const { pop, push, names } = useLocalRouter();
31 const { pointCursor } = usePointCursor();
33 const { wallet } = useWallet();
34 const point = need.point(pointCursor);
36 const { code, notice } = useKeyfileGenerator();
45 } = useCurrentPermissions();
47 // fetch the invites for the current cursor
48 const invites = useInvites(point);
57 const showInvites = !(
58 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
61 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
64 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
65 const _pendingInvites = pendingPoints.getOrElse([]).length;
67 const loadedInvites = Just.hasInstance(availableInvites);
69 // availableInvites.getOrElse(0) === 0
71 const goAdmin = useCallback(() => push(names.ADMIN), [push, names]);
73 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
75 const goSigil = useCallback(() => push(names.SIGIL_GENERATOR), [push, names]);
77 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
79 const goPartiesSetPoolSize = useCallback(
80 () => push(names.PARTY_SET_POOL_SIZE),
84 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
89 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
91 const [showInviteForm, setShowInviteForm] = useState(false);
93 const inviteButton = (() => {
94 if (azimuth.getPointSize(point) === azimuth.PointSize.Star) {
100 disabled={!isActiveOwner}
101 onClick={goPartiesSetPoolSize}>
112 const senateButton = (() => {
113 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
130 // sync the current cursor
131 useSyncOwnedPoints([point]);
133 const address = need.addressFromWallet(wallet);
136 <View pop={pop} inset>
137 <Greeting point={point} />
140 address={Just(address)}
141 animationMode={'slide'}
144 {isPlanet && hasInvites && (
146 <Grid.Item cols={[1, 11]}>
152 className={cn('t-right underline pointer-hover', {
153 gray4: sentInvites.getOrElse(0) === 0,
160 <Flex align="center">
162 {acceptedInvites.getOrElse(0)} / {_totalInvites}
164 {_pendingInvites > 0 && (
165 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
166 {_pendingInvites} pending
177 available={availableInvites}
179 accepted={acceptedInvites}
184 pendingPoints={pendingPoints}
185 acceptedPoints={acceptedPoints}
191 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
192 <div className="p4 pv8 t-center gray4">
193 Start your invite group by adding members
198 {!showInviteForm && availableInvites.getOrElse(0) > 0 && isOwner && (
204 onClick={() => setShowInviteForm(true)}>
208 {showInviteForm && <Inviter />}
209 <Grid.Item full className="mb2" />
212 {!loadedInvites && isPlanet && (
213 <Grid.Item className="mv2" full>
214 Invite Group <Blinky />
218 <Grid className="pt2">
220 <Grid.Item full as={ForwardButton} onClick={goSigil}>
227 disabled={!canManage}
239 onClick={goIssuePoint}>
246 <Grid.Item full as={BootUrbitOSButton} />
251 accessory={code && <CopyButton text={code} />}
252 detail={code || notice}
254 detailClassName="mono">
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list