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 { 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';
33import { isL2 } from 'lib/utils/roller';
47 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
48 const _pendingInvites = pendingPoints.getOrElse([]).length;
52 <Grid.Item cols={[1, 11]}>
58 className={cn('t-right underline pointer-hover', {
59 gray4: sentInvites.getOrElse(0) === 0,
68 {acceptedInvites.getOrElse(0)} / {_totalInvites}
70 {_pendingInvites > 0 && (
71 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
72 {_pendingInvites} pending
83 available={availableInvites}
85 accepted={acceptedInvites}
90 pendingPoints={pendingPoints}
91 acceptedPoints={acceptedPoints}
97 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
98 <div className="p4 pv8 t-center gray4">
99 Start your invite group by adding members
104 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
110 onClick={() => setShowInviteForm(true)}>
114 {showInviteForm && <Inviter />}
115 <Grid.Item full className="mb2" />
120export default function Point() {
121 const { pop, push, names } = useLocalRouter();
122 const { wallet, authToken } = useWallet();
123 const { pointCursor } = usePointCursor();
124 const point = need.point(pointCursor);
126 const { api, getInvites } = useRoller();
132 setPendingTransactions,
133 } = useRollerStore();
135 const [loaded, setLoaded] = useState(false);
138 const loadL2Info = async () => {
139 const getTransactions = async () => {
140 const pointInfo = await api.getPoint(Number(point));
141 setCurrentPoint(pointInfo);
143 getInvites(isL2(pointInfo.dominion));
153 }, [api, point, authToken, setPendingTransactions, loaded]); // eslint-disable-line
155 const { isParent, canManage, canSpawn, canVote } = useCurrentPermissions();
158 const l1Invites = useInvites(point);
167 const showInvites = !(
168 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
171 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
173 const loadedInvites = Just.hasInstance(availableInvites);
175 // availableInvites.getOrElse(0) === 0
177 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
179 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
181 const goUrbitOS = useCallback(() => push(names.URBIT_OS), [push, names]);
183 const goUrbitID = useCallback(() => push(names.URBIT_ID), [push, names]);
185 const goResidents = useCallback(() => push(names.RESIDENTS), [push, names]);
187 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
192 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
194 const [showInviteForm, setShowInviteForm] = useState(false);
196 const senateButton = (() => {
197 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
214 // sync the current cursor
215 useSyncExtras([point]);
217 const address = need.addressFromWallet(wallet);
218 const numPending = pendingTransactions.length;
226 <L2PointHeader hideTimer={!!numPending} numInvites={invites.length} />
228 <Greeting point={point} />
230 <div className="transaction">
231 <Row className="title-row">
232 <div className="title">
233 {numPending} Planet{numPending > 1 ? 's' : ''} Spawned
235 <div className="rollup-timer">{nextRoll}</div>
237 <Row className="info-row">
238 <LayerIndicator layer={2} size="sm" />
239 <div className="date"></div>
245 address={Just(address)}
246 animationMode={'slide'}
250 <Grid.Item full as={Flex} justify="between">
253 subtitle="Manage peers that you service"
254 onClick={goResidents}
258 {isPlanet && hasInvites && (
260 showInviteForm={showInviteForm}
261 setShowInviteForm={setShowInviteForm}
262 acceptedInvites={acceptedInvites}
263 acceptedPoints={acceptedPoints}
264 availableInvites={availableInvites}
266 pendingPoints={pendingPoints}
267 sentInvites={sentInvites}
268 showInvites={showInvites}
271 {!loadedInvites && isPlanet && (
272 <Grid.Item className="mv2" full>
273 Invite Group <Blinky />
276 {/* {inviteButton} */}
277 <Grid.Item full as={Flex} justify="between">
280 subtitle="Identity and security settings"
281 icon={<Icon icon="User" />}
283 disabled={!canManage}
286 <Grid.Item full as={Flex} justify="between">
289 subtitle="Urbit OS Settings"
290 icon={<Icon icon="Server" />}
292 disabled={!canManage}
301 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