1import React, { useCallback, useState, useEffect } 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 } from 'components/Buttons';
14import Blinky, { matchBlinky } from 'components/Blinky';
15import BarGraph from 'components/BarGraph';
16import Chip from 'components/Chip';
17import InviteSigilList from 'components/InviteSigilList';
18import { ForwardButton, HostingButton } from 'components/Buttons';
19import CopyButton from 'components/CopyButton';
20import { matchBlinky } from 'components/Blinky';
21import DownloadSigilButton from 'components/DownloadSigilButton';
23import * as need from 'lib/need';
24import useInvites from 'lib/useInvites';
25import { useSyncOwnedPoints } from 'lib/useSyncPoints';
26import useCurrentPermissions from 'lib/useCurrentPermissions';
27import { useLocalRouter } from 'lib/LocalRouter';
28import { useResidents } from 'lib/useResidents';
30import Inviter from 'views/Invite/Inviter';
32export default function Point() {
33 const { pop, push, names } = useLocalRouter();
34 const { pointCursor } = usePointCursor();
36 const { wallet } = useWallet();
37 const point = need.point(pointCursor);
39 const { residentCount } = useResidents(point);
47 } = useCurrentPermissions();
49 // fetch the invites for the current cursor
50 const invites = useInvites(point);
59 const showInvites = !(
60 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
63 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
66 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
67 const _pendingInvites = pendingPoints.getOrElse([]).length;
69 const loadedInvites = Just.hasInstance(availableInvites);
71 // availableInvites.getOrElse(0) === 0
73 const goAdmin = useCallback(() => push(names.ADMIN), [push, names]);
75 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
77 const goSigil = useCallback(() => push(names.SIGIL_GENERATOR), [push, names]);
79 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
81 const goUrbitOS = useCallback(() => push(names.URBIT_OS), [push, names]);
83 const goUrbitID = useCallback(() => push(names.URBIT_ID), [push, names]);
85 const goResidents = useCallback(() => push(names.RESIDENTS), [push, names]);
87 const goPartiesSetPoolSize = useCallback(
88 () => push(names.PARTY_SET_POOL_SIZE),
92 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
97 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
99 const [showInviteForm, setShowInviteForm] = useState(false);
101 const goBoot = useCallback(() => push(names.BOOT), [push, names]);
102 const goHosting = useCallback(() => push(names.HOSTING), [push, names]);
104 const inviteButton = (() => {
105 if (azimuth.getPointSize(point) === azimuth.PointSize.Star) {
111 disabled={!isActiveOwner}
112 onClick={goPartiesSetPoolSize}>
123 const senateButton = (() => {
124 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
141 // sync the current cursor
142 useSyncOwnedPoints([point]);
144 const address = need.addressFromWallet(wallet);
146 const InviteForm = useCallback(() => {
149 <Grid.Item cols={[1, 11]}>
155 className={cn('t-right underline pointer-hover', {
156 gray4: sentInvites.getOrElse(0) === 0,
163 <Flex align="center">
165 {acceptedInvites.getOrElse(0)} / {_totalInvites}
167 {_pendingInvites > 0 && (
168 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
169 {_pendingInvites} pending
180 available={availableInvites}
182 accepted={acceptedInvites}
187 pendingPoints={pendingPoints}
188 acceptedPoints={acceptedPoints}
194 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
195 <div className="p4 pv8 t-center gray4">
196 Start your invite group by adding members
201 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
207 onClick={() => setShowInviteForm(true)}>
211 {showInviteForm && <Inviter />}
212 <Grid.Item full className="mb2" />
217 console.log(residentCount);
220 <View pop={pop} inset>
221 <Greeting point={point} />
224 address={Just(address)}
225 animationMode={'slide'}
229 <Grid.Item full as={Flex} justify="between" onClick={goResidents}>
232 <span className="gray3">{matchBlinky(residentCount)}</span>
234 <Flex.Item>N/A</Flex.Item>
237 {isPlanet && hasInvites && <InviteForm />}
238 {!loadedInvites && isPlanet && (
239 <Grid.Item className="mv2" full>
240 Invite Group <Blinky />
244 <Grid className="pt2">
250 disabled={!canManage}
253 detail="Identity and security settings">
260 disabled={!canManage}
262 detail="Urbit OS Settings"
273 onClick={goIssuePoint}>
283 detail="Boot your computer"
288 <Grid.Item full as={HostingButton} onClick={goHosting} />
294 accessory={code && <CopyButton text={code} />}
295 detail={code || notice}
297 detailClassName="mono">
301 <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