1import React, { useCallback, useState } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
3import { Grid, Flex } from 'indigo-react';
4import { azimuth } from 'azimuth-js';
6import { usePointCursor } from 'store/pointCursor';
7import { useWallet } from 'store/wallet';
9import View from 'components/View';
10import Greeting from 'components/Greeting';
11import Passport from 'components/Passport';
12import { ForwardButton, BootUrbitOSButton } from 'components/Buttons';
13import CopyButton from 'components/CopyButton';
14import { matchBlinky } from 'components/Blinky';
15import DownloadSigilButton from 'components/DownloadSigilButton';
16import BarGraph from 'components/BarGraph';
17import Chip from 'components/Chip';
18import MaybeSigil from 'components/MaybeSigil';
19import InviteSigilList from 'components/InviteSigilList';
21import * as need from 'lib/need';
22import useInvites from 'lib/useInvites';
23import { useSyncOwnedPoints } from 'lib/useSyncPoints';
24import useCurrentPermissions from 'lib/useCurrentPermissions';
25import { useLocalRouter } from 'lib/LocalRouter';
26import useKeyfileGenerator from 'lib/useKeyfileGenerator';
28import InviteCohort from 'views/Invite/Cohort';
30export default function Point() {
31 const { pop, push, names } = useLocalRouter();
32 const { pointCursor } = usePointCursor();
34 const { wallet } = useWallet();
35 const point = need.point(pointCursor);
37 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 // availableInvites.getOrElse(0) === 0
68 const goAdmin = useCallback(() => push(names.ADMIN), [push, names]);
70 const goInvite = useCallback(() => push(names.INVITE), [push, names]);
72 const goParty = useCallback(() => push(names.PARTY), [push, names]);
74 const goPartiesSetPoolSize = useCallback(
75 () => push(names.PARTY_SET_POOL_SIZE),
79 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
84 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
86 const [showInviteForm, setShowInviteForm] = useState(false);
88 const inviteButton = (() => {
89 switch (azimuth.getPointSize(point)) {
90 case azimuth.PointSize.Planet:
91 const availableInvitesText = matchBlinky(availableInvites);
97 disabled={!isActiveOwner}
99 Invite <sup>{availableInvitesText}</sup>
105 case azimuth.PointSize.Star:
111 disabled={!isActiveOwner}
112 onClick={goPartiesSetPoolSize}>
124 // sync the current cursor
125 useSyncOwnedPoints([point]);
127 const address = need.addressFromWallet(wallet);
130 <View pop={pop} inset>
131 <Greeting point={point} />
134 address={Just(address)}
135 animationMode={'slide'}
138 {isPlanet && hasInvites && (
140 <Grid.Item cols={[1, 11]}>
145 <Grid.Item className="t-right" onClick={goParty} cols={[11, 13]}>
149 <Flex align="center">
151 {acceptedInvites.getOrElse(0)} / {_totalInvites}
153 {_pendingInvites > 0 && (
154 <Flex.Item as={Chip} color="yellow">
155 {_pendingInvites.getOrElse([]).length} pending
166 available={availableInvites}
168 accepted={acceptedInvites}
173 pendingPoints={pendingPoints}
174 acceptedPoints={acceptedPoints}
180 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
181 <div className="p4 pv8 t-center gray4">
182 Start your invite group by adding members
187 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
192 onClick={() => setShowInviteForm(true)}>
196 {showInviteForm && <InviteCohort />}
200 <Grid className="pt2">
205 disabled={!canManage}
217 onClick={goIssuePoint}>
223 <Grid.Item full as={BootUrbitOSButton} />
228 accessory={code && <CopyButton text={code} />}
229 detail={code || notice}
231 detailClassName="mono">
235 <Grid.Item full as={DownloadSigilButton} point={point} />
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