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();
44 } = useCurrentPermissions();
46 // fetch the invites for the current cursor
47 const invites = useInvites(point);
56 const showInvites = !(
57 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
60 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
63 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
64 const _pendingInvites = pendingPoints.getOrElse([]).length;
66 const loadedInvites = Just.hasInstance(availableInvites);
68 // availableInvites.getOrElse(0) === 0
70 const goAdmin = useCallback(() => push(names.ADMIN), [push, names]);
72 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
74 const goSigil = useCallback(() => push(names.SIGIL_GENERATOR), [push, names]);
76 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
78 const goPartiesSetPoolSize = useCallback(
79 () => push(names.PARTY_SET_POOL_SIZE),
83 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
88 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
90 const [showInviteForm, setShowInviteForm] = useState(false);
92 const inviteButton = (() => {
93 if (azimuth.getPointSize(point) === azimuth.PointSize.Star) {
99 disabled={!isActiveOwner}
100 onClick={goPartiesSetPoolSize}>
111 const senateButton = (() => {
112 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
129 // sync the current cursor
130 useSyncOwnedPoints([point]);
132 const address = need.addressFromWallet(wallet);
135 <View pop={pop} inset>
136 <Greeting point={point} />
139 address={Just(address)}
140 animationMode={'slide'}
143 {isPlanet && hasInvites && (
145 <Grid.Item cols={[1, 11]}>
151 className={cn('t-right underline pointer-hover', {
152 gray4: sentInvites.getOrElse(0) === 0,
159 <Flex align="center">
161 {acceptedInvites.getOrElse(0)} / {_totalInvites}
163 {_pendingInvites > 0 && (
164 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
165 {_pendingInvites} pending
176 available={availableInvites}
178 accepted={acceptedInvites}
183 pendingPoints={pendingPoints}
184 acceptedPoints={acceptedPoints}
190 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
191 <div className="p4 pv8 t-center gray4">
192 Start your invite group by adding members
197 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
203 onClick={() => setShowInviteForm(true)}>
207 {showInviteForm && <Inviter />}
208 <Grid.Item full className="mb2" />
211 {!loadedInvites && isPlanet && (
212 <Grid.Item className="mv2" full>
213 Invite Group <Blinky />
217 <Grid className="pt2">
219 <Grid.Item full as={ForwardButton} onClick={goSigil}>
226 disabled={!canManage}
238 onClick={goIssuePoint}>
245 <Grid.Item full as={BootUrbitOSButton} />
250 accessory={code && <CopyButton text={code} />}
251 detail={code || notice}
253 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