1import React, { useCallback, useEffect, useState } from 'react';
2import cn from 'classnames';
3import { Just } from 'folktale/maybe';
4import { Grid, Flex, Button } from 'indigo-react';
5import { Icon, Row } from '@tlon/indigo-react';
6import { azimuth } from 'azimuth-js';
8import { usePointCursor } from 'store/pointCursor';
9import { useWallet } from 'store/wallet';
10import { isL2, useRollerStore } from 'store/roller';
12import View from 'components/View';
13import Greeting from 'components/Greeting';
14import Passport from 'components/Passport';
15import Blinky from 'components/Blinky';
16import BarGraph from 'components/BarGraph';
17import Chip from 'components/Chip';
18import InviteSigilList from 'components/InviteSigilList';
19import { ForwardButton } from 'components/Buttons';
20import L2PointHeader from 'components/L2/Headers/L2PointHeader';
21import LayerIndicator from 'components/L2/LayerIndicator';
22import Card from 'components/L2/Card';
24import * as need from 'lib/need';
25import useInvites from 'lib/useInvites';
26import { useSyncExtras } from 'lib/useSyncPoints';
27import useCurrentPermissions from 'lib/useCurrentPermissions';
28import { useLocalRouter } from 'lib/LocalRouter';
29import Inviter from 'views/Invite/Inviter';
30import useRoller from 'lib/useRoller';
46 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
47 const _pendingInvites = pendingPoints.getOrElse([]).length;
51 <Grid.Item cols={[1, 11]}>
57 className={cn('t-right underline pointer-hover', {
58 gray4: sentInvites.getOrElse(0) === 0,
67 {acceptedInvites.getOrElse(0)} / {_totalInvites}
69 {_pendingInvites > 0 && (
70 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
71 {_pendingInvites} pending
82 available={availableInvites}
84 accepted={acceptedInvites}
89 pendingPoints={pendingPoints}
90 acceptedPoints={acceptedPoints}
96 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
97 <div className="p4 pv8 t-center gray4">
98 Start your invite group by adding members
103 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
109 onClick={() => setShowInviteForm(true)}>
113 {showInviteForm && <Inviter />}
114 <Grid.Item full className="mb2" />
119export default function Point() {
120 const { pop, push, names } = useLocalRouter();
121 const { wallet, authToken } = useWallet();
122 const { pointCursor } = usePointCursor();
123 const point = need.point(pointCursor);
125 const { api, getInvites } = useRoller();
131 setPendingTransactions,
132 } = useRollerStore();
134 const [loaded, setLoaded] = useState(false);
137 const loadL2Info = async () => {
138 const getTransactions = async () => {
139 const pointInfo = await api.getPoint(Number(point));
140 setCurrentPoint(pointInfo);
142 getInvites(isL2(pointInfo.dominion));
152 }, [api, point, authToken, setPendingTransactions, loaded]); // eslint-disable-line
154 const { isParent, canManage, canSpawn, canVote } = useCurrentPermissions();
157 const l1Invites = useInvites(point);
166 const showInvites = !(
167 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
170 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
172 const loadedInvites = Just.hasInstance(availableInvites);
174 // availableInvites.getOrElse(0) === 0
176 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
178 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
180 const goUrbitOS = useCallback(() => push(names.URBIT_OS), [push, names]);
182 const goUrbitID = useCallback(() => push(names.URBIT_ID), [push, names]);
184 const goResidents = useCallback(() => push(names.RESIDENTS), [push, names]);
186 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
191 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
193 const [showInviteForm, setShowInviteForm] = useState(false);
195 const senateButton = (() => {
196 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
213 // sync the current cursor
214 useSyncExtras([point]);
216 const address = need.addressFromWallet(wallet);
217 const numPending = pendingTransactions.length;
225 <L2PointHeader hideTimer={!!numPending} numInvites={invites.length} />
227 <Greeting point={point} />
229 <div className="transaction">
230 <Row className="title-row">
231 <div className="title">
232 {numPending} Planet{numPending > 1 ? 's' : ''} Spawned
234 <div className="rollup-timer">{nextRoll}</div>
236 <Row className="info-row">
237 <LayerIndicator layer={2} size="sm" />
238 <div className="date"></div>
244 address={Just(address)}
245 animationMode={'slide'}
249 <Grid.Item full as={Flex} justify="between">
252 subtitle="Manage peers that you service"
253 onClick={goResidents}
257 {isPlanet && hasInvites && (
259 showInviteForm={showInviteForm}
260 setShowInviteForm={setShowInviteForm}
261 acceptedInvites={acceptedInvites}
262 acceptedPoints={acceptedPoints}
263 availableInvites={availableInvites}
265 pendingPoints={pendingPoints}
266 sentInvites={sentInvites}
267 showInvites={showInvites}
270 {!loadedInvites && isPlanet && (
271 <Grid.Item className="mv2" full>
272 Invite Group <Blinky />
275 {/* {inviteButton} */}
276 <Grid.Item full as={Flex} justify="between">
279 subtitle="Identity and security settings"
280 icon={<Icon icon="User" />}
282 disabled={!canManage}
285 <Grid.Item full as={Flex} justify="between">
288 subtitle="Urbit OS Settings"
289 icon={<Icon icon="Server" />}
291 disabled={!canManage}
300 onClick={goIssuePoint}>
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