on master help sign in
feat: implement manage invites for parties view
abbbcbcMatt Condon (shrugs)
src/components/DownloadKeyfileButton.js−7
@@ -1,10 +1,7 @@
1import React from 'react';
1import React from 'react';
2import { Flex, B } from 'indigo-react';
2import { Flex, B } from 'indigo-react';
3
3
4−import { usePointCursor } from 'store/pointCursor';
5−
6import useKeyfileGenerator from 'lib/useKeyfileGenerator';
4import useKeyfileGenerator from 'lib/useKeyfileGenerator';
7−import * as need from 'lib/need';
8
5
9import { DownloadButton } from 'components/Buttons';
6import { DownloadButton } from 'components/Buttons';
10
7
@@ -13,11 +10,7 @@ export default function DownloadKeyfileButton({
13 className,
10 className,
14 ...rest
11 ...rest
15}) {
12}) {
16− const { pointCursor } = usePointCursor();
17− const _point = need.point(pointCursor);
18−
19 const { generating, available, downloaded, download } = useKeyfileGenerator(
13 const { generating, available, downloaded, download } = useKeyfileGenerator(
20− _point,
21 networkSeed
14 networkSeed
22 );
15 );
23
16
src/lib/routeNames.js+1
@@ -28,4 +28,5 @@ export const ROUTE_NAMES = {
28 TRANSFER: Symbol('TRANSFER'),
28 TRANSFER: Symbol('TRANSFER'),
29 SENT_TRANSACTION: Symbol('SENT_TRANSACTION'),
29 SENT_TRANSACTION: Symbol('SENT_TRANSACTION'),
30 GEN_KEYFILE: Symbol('GEN_KEYFILE'),
30 GEN_KEYFILE: Symbol('GEN_KEYFILE'),
31+ PARTY_SET_POOL_SIZE: Symbol('PARTY_SET_POOL_SIZE'),
31};
32};
src/lib/router.js+3
@@ -22,6 +22,7 @@ import Invite from 'views/Invite';
22import Activate from 'views/Activate';
22import Activate from 'views/Activate';
23
23
24import { ROUTE_NAMES } from './routeNames';
24import { ROUTE_NAMES } from './routeNames';
25+import PartySetPoolSize from 'views/Party/PartySetPoolSize';
25
26
26export const ROUTES = {
27export const ROUTES = {
27 [ROUTE_NAMES.LANDING]: Landing,
28 [ROUTE_NAMES.LANDING]: Landing,
@@ -44,4 +45,6 @@ export const ROUTES = {
44 [ROUTE_NAMES.SET_KEYS]: SetKeys,
45 [ROUTE_NAMES.SET_KEYS]: SetKeys,
45 [ROUTE_NAMES.TRANSFER]: Transfer,
46 [ROUTE_NAMES.TRANSFER]: Transfer,
46 [ROUTE_NAMES.SENT_TRANSACTION]: SentTransaction,
47 [ROUTE_NAMES.SENT_TRANSACTION]: SentTransaction,
48+ [ROUTE_NAMES.PARTY_SET_POOL_SIZE]: PartySetPoolSize,
49+ // TODO: nest this route under the Party.js router
47};
50};
src/lib/transformers.js+9−7
@@ -1,6 +1,14 @@
1// import { fill } from './lib'
1// import { fill } from './lib'
2
2
3−const prependSig = s => (s.charAt(0) !== '~' ? `~${s}` : s);
3+export const prependSig = s => (s.charAt(0) !== '~' ? `~${s}` : s);
4+
5+export const convertToNumber = s => {
6+ try {
7+ return parseInt(s, 10);
8+ } catch {
9+ return 0;
10+ }
11+};
4
12
5// const hideAllButLast = s => {
13// const hideAllButLast = s => {
6// const ll = s[s.length -1];
14// const ll = s[s.length -1];
@@ -9,9 +17,3 @@ const prependSig = s => (s.charAt(0) !== '~' ? `~${s}` : s);
9// };
17// };
10//
18//
11// const hideAll = s => fill(s.length, '•');
19// const hideAll = s => fill(s.length, '•');
12−
13−export {
14− prependSig,
15− // hideAllButLast,
16− // hideAll,
17−};
src/lib/useCurrentPermissions.jsnew file+17
@@ -0,0 +1,17 @@
1+import usePermissionsForPoint from './usePermissionsForPoint';
2+import { useWallet } from 'store/wallet';
3+import { usePointCursor } from 'store/pointCursor';
4+
5+export default function useCurrentPermissions() {
6+ const { wallet } = useWallet();
7+ const { pointCursor } = usePointCursor();
8+
9+ const _address = wallet.matchWith({
10+ Nothing: () => '',
11+ Just: p => p.value.address,
12+ });
13+
14+ const _point = pointCursor.getOrElse(null);
15+
16+ return usePermissionsForPoint(_address, _point);
17+}
src/lib/useInputs.js+19−1
@@ -16,8 +16,9 @@ import {
16 validateMaximumPatpByteLength,
16 validateMaximumPatpByteLength,
17 validateEthereumAddress,
17 validateEthereumAddress,
18 validateNotNullAddress,
18 validateNotNullAddress,
19+ validateGreaterThan,
19} from 'lib/validators';
20} from 'lib/validators';
20−import { prependSig } from 'lib/transformers';
21+import { prependSig, convertToNumber } from 'lib/transformers';
21
22
22import InputSigil from 'components/InputSigil';
23import InputSigil from 'components/InputSigil';
23
24
@@ -232,6 +233,23 @@ export function useAddressInput({ ...rest }) {
232 );
233 );
233}
234}
234
235
236+const kNumberTransformers = [convertToNumber];
237+const kNumberValidators = [validateGreaterThan(0)];
238+export function useNumberInput({ ...rest }) {
239+ return useFirstOf(
240+ useForm([
241+ {
242+ type: 'number',
243+ label: 'Number',
244+ autoComplete: 'off',
245+ transformers: kNumberTransformers,
246+ validators: kNumberValidators,
247+ ...rest,
248+ },
249+ ])
250+ );
251+}
252+
235const kEmailValidators = [validateEmail, validateNotEmpty];
253const kEmailValidators = [validateEmail, validateNotEmpty];
236export const buildEmailInputConfig = extra => ({
254export const buildEmailInputConfig = extra => ({
237 type: 'email',
255 type: 'email',
src/lib/useKeyfileGenerator.js+12−13
@@ -14,24 +14,23 @@ import {
14 deriveNetworkKeys,
14 deriveNetworkKeys,
15 compileNetworkingKey,
15 compileNetworkingKey,
16} from './keys';
16} from './keys';
17−import usePermissionsForPoint from './usePermissionsForPoint';
17+import useCurrentPermissions from './useCurrentPermissions';
18+import { usePointCursor } from 'store/pointCursor';
18
19
19−export default function useKeyfileGenerator(point, manualNetworkSeed) {
20+export default function useKeyfileGenerator(manualNetworkSeed) {
20 const { getDetails } = usePointCache();
21 const { getDetails } = usePointCache();
21 const { urbitWallet, wallet, authMnemonic } = useWallet();
22 const { urbitWallet, wallet, authMnemonic } = useWallet();
23+ const { pointCursor } = usePointCursor();
22
24
23 const [downloaded, setDownloaded] = useState(false);
25 const [downloaded, setDownloaded] = useState(false);
24 const [generating, setGenerating] = useState(true);
26 const [generating, setGenerating] = useState(true);
25 const [keyfile, setKeyfile] = useState(false);
27 const [keyfile, setKeyfile] = useState(false);
26
28
27− const _address = need.wallet(wallet).address;
29+ const _point = need.point(pointCursor);
28− const _details = need.details(getDetails(point));
30+ const _details = need.details(getDetails(_point));
29
31
30 const networkRevision = parseInt(_details.keyRevisionNumber, 10);
32 const networkRevision = parseInt(_details.keyRevisionNumber, 10);
31− const { isOwner, isManagementProxy } = usePermissionsForPoint(
33+ const { isOwner, isManagementProxy } = useCurrentPermissions();
32− _address,
33− point
34− );
35
34
36 const hasNetworkingKeys = networkRevision > 0;
35 const hasNetworkingKeys = networkRevision > 0;
37 const available =
36 const available =
@@ -68,16 +67,16 @@ export default function useKeyfileGenerator(point, manualNetworkSeed) {
68 return;
67 return;
69 }
68 }
70
69
71− setKeyfile(compileNetworkingKey(pair, point, networkRevision));
70+ setKeyfile(compileNetworkingKey(pair, _point, networkRevision));
72 setGenerating(false);
71 setGenerating(false);
73 }, [
72 }, [
73+ networkRevision,
74 manualNetworkSeed,
74 manualNetworkSeed,
75 urbitWallet,
75 urbitWallet,
76 wallet,
76 wallet,
77 authMnemonic,
77 authMnemonic,
78 _details,
78 _details,
79− networkRevision,
79+ _point,
80− point,
81 ]);
80 ]);
82
81
83 const download = useCallback(() => {
82 const download = useCallback(() => {
@@ -85,11 +84,11 @@ export default function useKeyfileGenerator(point, manualNetworkSeed) {
85 new Blob([keyfile], {
84 new Blob([keyfile], {
86 type: 'text/plain;charset=utf-8',
85 type: 'text/plain;charset=utf-8',
87 }),
86 }),
88− `${ob.patp(point).slice(1)}-${networkRevision}.key`
87+ `${ob.patp(_point).slice(1)}-${networkRevision}.key`
89 // TODO: ^ unifiy "remove tilde" calls
88 // TODO: ^ unifiy "remove tilde" calls
90 );
89 );
91 setDownloaded(true);
90 setDownloaded(true);
92− }, [keyfile, point, networkRevision]);
91+ }, [_point, keyfile, networkRevision]);
93
92
94 useEffect(() => {
93 useEffect(() => {
95 generate();
94 generate();
src/lib/usePermissionsForPoint.js+15
@@ -1,6 +1,9 @@
1import { azimuth } from 'azimuth-js';
1import { azimuth } from 'azimuth-js';
2
2
3import { usePointCache } from 'store/pointCache';
3import { usePointCache } from 'store/pointCache';
4+import { useNetwork } from 'store/network';
5+
6+import * as need from 'lib/need';
4
7
5import { eqAddr, ETH_ZERO_ADDR } from './wallet';
8import { eqAddr, ETH_ZERO_ADDR } from './wallet';
6
9
@@ -23,6 +26,8 @@ const NULL_PERMISSIONS = {
23 canTransfer: false,
26 canTransfer: false,
24 canSpawn: false,
27 canSpawn: false,
25 canVote: false,
28 canVote: false,
29+ //
30+ spawnIsDelegatedSending: false,
26};
31};
27
32
28/**
33/**
@@ -31,10 +36,13 @@ const NULL_PERMISSIONS = {
31 */
36 */
32export default function usePermissionsForPoint(address, point) {
37export default function usePermissionsForPoint(address, point) {
33 const { getDetails } = usePointCache();
38 const { getDetails } = usePointCache();
39+ const { contracts } = useNetwork();
34
40
35 return getDetails(point).matchWith({
41 return getDetails(point).matchWith({
36 Nothing: () => NULL_PERMISSIONS,
42 Nothing: () => NULL_PERMISSIONS,
37 Just: ({ value: details }) => {
43 Just: ({ value: details }) => {
44+ const _contracts = need.contracts(contracts);
45+
38 const pointSize = azimuth.getPointSize(point);
46 const pointSize = azimuth.getPointSize(point);
39 const isPlanet = pointSize === azimuth.PointSize.Planet;
47 const isPlanet = pointSize === azimuth.PointSize.Planet;
40 const isStar = pointSize === azimuth.PointSize.Star;
48 const isStar = pointSize === azimuth.PointSize.Star;
@@ -60,6 +68,11 @@ export default function usePermissionsForPoint(address, point) {
60 const canSpawn = (isStar || isGalaxy) && (isOwner || isSpawnProxy);
68 const canSpawn = (isStar || isGalaxy) && (isOwner || isSpawnProxy);
61 const canVote = isGalaxy && (isOwner || isVotingProxy);
69 const canVote = isGalaxy && (isOwner || isVotingProxy);
62
70
71+ const spawnIsDelegatedSending = eqAddr(
72+ _contracts.delegatedSending.address,
73+ details.spawnProxy
74+ );
75+
63 return {
76 return {
64 isPlanet,
77 isPlanet,
65 isStar,
78 isStar,
@@ -79,6 +92,8 @@ export default function usePermissionsForPoint(address, point) {
79 canTransfer,
92 canTransfer,
80 canSpawn,
93 canSpawn,
81 canVote,
94 canVote,
95+ //
96+ spawnIsDelegatedSending,
82 };
97 };
83 },
98 },
84 });
99 });
src/lib/validators.js+8−1
@@ -74,7 +74,7 @@ export const validateNotEmpty = m =>
74 prevMessage: m,
74 prevMessage: m,
75 validator: d => {
75 validator: d => {
76 try {
76 try {
77− return d.length > 1;
77+ return d.length > 0;
78 } catch {
78 } catch {
79 return false;
79 return false;
80 }
80 }
@@ -237,6 +237,13 @@ export const validateMaximumLength = l => m =>
237 error: `Must be ${l} characters or fewer.`,
237 error: `Must be ${l} characters or fewer.`,
238 });
238 });
239
239
240+export const validateGreaterThan = l => m =>
241+ simpleValidatorWrapper({
242+ prevMessage: m,
243+ validator: d => d > l,
244+ error: `Must be at least ${l}`,
245+ });
246+
240export const validatePatpByteLength = byteLength => {
247export const validatePatpByteLength = byteLength => {
241 return validateLength(patpStringLength(byteLength));
248 return validateLength(patpStringLength(byteLength));
242};
249};
src/views/Admin/AdminEditPermissions.js+9−12
@@ -1,30 +1,28 @@
1import React, { useCallback } from 'react';
1import React, { useCallback } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
2import { Just, Nothing } from 'folktale/maybe';
3−import * as need from 'lib/need';
4import { Grid } from 'indigo-react';
3import { Grid } from 'indigo-react';
5import { azimuth } from 'azimuth-js';
4import { azimuth } from 'azimuth-js';
6
5
7−import { ForwardButton } from 'components/Buttons';
8−import { matchBlinkyDate } from 'components/Blinky';
9−
10−import { ETH_ZERO_ADDR } from 'lib/wallet';
11−
12import { useNetwork } from 'store/network';
6import { useNetwork } from 'store/network';
13−import { useWallet } from 'store/wallet';
14import { usePointCursor } from 'store/pointCursor';
7import { usePointCursor } from 'store/pointCursor';
15import { usePointCache } from 'store/pointCache';
8import { usePointCache } from 'store/pointCache';
16−import ViewHeader from 'components/ViewHeader';
9+
17−import usePermissionsForPoint from 'lib/usePermissionsForPoint';
10+import * as need from 'lib/need';
11+import { ETH_ZERO_ADDR } from 'lib/wallet';
18import { PROXY_TYPE, proxyTypeToHuman } from 'lib/proxy';
12import { PROXY_TYPE, proxyTypeToHuman } from 'lib/proxy';
19import { useLocalRouter } from 'lib/LocalRouter';
13import { useLocalRouter } from 'lib/LocalRouter';
20import capitalize from 'lib/capitalize';
14import capitalize from 'lib/capitalize';
21import { eqAddr } from 'lib/wallet';
15import { eqAddr } from 'lib/wallet';
16+import useCurrentPermissions from 'lib/useCurrentPermissions';
17+
18+import ViewHeader from 'components/ViewHeader';
19+import { ForwardButton } from 'components/Buttons';
20+import { matchBlinkyDate } from 'components/Blinky';
22import MiniBackButton from 'components/MiniBackButton';
21import MiniBackButton from 'components/MiniBackButton';
23
22
24export default function AdminEditPermissions() {
23export default function AdminEditPermissions() {
25 const { pop, push, names } = useLocalRouter();
24 const { pop, push, names } = useLocalRouter();
26 const { contracts } = useNetwork();
25 const { contracts } = useNetwork();
27− const { wallet } = useWallet();
28 const { pointCursor } = usePointCursor();
26 const { pointCursor } = usePointCursor();
29 const { getDetails, getRekeyDate } = usePointCache();
27 const { getDetails, getRekeyDate } = usePointCache();
30
28
@@ -34,11 +32,10 @@ export default function AdminEditPermissions() {
34 const pointSize = azimuth.getPointSize(point);
32 const pointSize = azimuth.getPointSize(point);
35 const isParent = pointSize !== azimuth.PointSize.Planet;
33 const isParent = pointSize !== azimuth.PointSize.Planet;
36 const isSenate = pointSize === azimuth.PointSize.Galaxy;
34 const isSenate = pointSize === azimuth.PointSize.Galaxy;
37− const address = need.wallet(wallet).address;
38
35
39 const details = need.details(getDetails(point));
36 const details = need.details(getDetails(point));
40 const networkRevision = parseInt(details.keyRevisionNumber, 10);
37 const networkRevision = parseInt(details.keyRevisionNumber, 10);
41− const { canManage, isOwner } = usePermissionsForPoint(address, point);
38+ const { canManage, isOwner } = useCurrentPermissions();
42
39
43 const goSetProxy = useCallback(
40 const goSetProxy = useCallback(
44 proxyType => push(names.SET_PROXY, { proxyType }),
41 proxyType => push(names.SET_PROXY, { proxyType }),
src/views/Admin/AdminHome.js+3−12
@@ -1,31 +1,22 @@
1import React, { useCallback } from 'react';
1import React, { useCallback } from 'react';
2import { Just } from 'folktale/maybe';
2import { Just } from 'folktale/maybe';
3import { Grid, B } from 'indigo-react';
3import { Grid, B } from 'indigo-react';
4−import * as need from 'lib/need';
5
4
6import { ForwardButton } from 'components/Buttons';
5import { ForwardButton } from 'components/Buttons';
7
6
8import { useWallet } from 'store/wallet';
7import { useWallet } from 'store/wallet';
9−import { usePointCursor } from 'store/pointCursor';
10−
11−import usePermissionsForPoint from 'lib/usePermissionsForPoint';
12
8
13import ViewHeader from 'components/ViewHeader';
9import ViewHeader from 'components/ViewHeader';
14import { useLocalRouter } from 'lib/LocalRouter';
10import { useLocalRouter } from 'lib/LocalRouter';
15import DownloadKeyfileButton from 'components/DownloadKeyfileButton';
11import DownloadKeyfileButton from 'components/DownloadKeyfileButton';
16import MiniBackButton from 'components/MiniBackButton';
12import MiniBackButton from 'components/MiniBackButton';
13+import useCurrentPermissions from 'lib/useCurrentPermissions';
17
14
18export default function AdminHome() {
15export default function AdminHome() {
19 const { push, names, pop } = useLocalRouter();
16 const { push, names, pop } = useLocalRouter();
20− const { urbitWallet, wallet } = useWallet();
17+ const { urbitWallet } = useWallet();
21− const { pointCursor } = usePointCursor();
22
18
23− const point = need.point(pointCursor);
24− const address = need.addressFromWallet(wallet);
25− const { isOwner, canTransfer, isTransferProxySet } = usePermissionsForPoint(
19+ const { isOwner, canTransfer, isTransferProxySet } = useCurrentPermissions();
26− address,
27− point
28− );
29
20
30 const goRedownload = useCallback(() => push(names.REDOWNLOAD), [push, names]);
21 const goRedownload = useCallback(() => push(names.REDOWNLOAD), [push, names]);
31 const goReticket = useCallback(() => push(names.RETICKET), [push, names]);
22 const goReticket = useCallback(() => push(names.RETICKET), [push, names]);
src/views/Party/PartySetPoolSize.jsnew file+145
@@ -0,0 +1,145 @@
1+import React, { useCallback, useEffect } from 'react';
2+import cn from 'classnames';
3+import { Grid, Text, Input } from 'indigo-react';
4+import * as azimuth from 'azimuth-js';
5+
6+import { useNetwork } from 'store/network';
7+import { usePointCursor } from 'store/pointCursor';
8+import { usePointCache } from 'store/pointCache';
9+
10+import * as need from 'lib/need';
11+import { usePointInput, useNumberInput } from 'lib/useInputs';
12+import useEthereumTransaction from 'lib/useEthereumTransaction';
13+import { GAS_LIMITS } from 'lib/constants';
14+
15+import ViewHeader from 'components/ViewHeader';
16+import MiniBackButton from 'components/MiniBackButton';
17+import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
18+import patp2dec from 'lib/patp2dec';
19+import { useHistory } from 'store/history';
20+import View from 'components/View';
21+import useCurrentPermissions from 'lib/useCurrentPermissions';
22+import WarningBox from 'components/WarningBox';
23+
24+function useSetPoolSize() {
25+ const { contracts } = useNetwork();
26+ const { pointCursor } = usePointCursor();
27+ const { syncOwnedPoint } = usePointCache();
28+
29+ const _contracts = need.contracts(contracts);
30+ const _point = need.point(pointCursor);
31+
32+ const {
33+ construct: _construct,
34+ confirmed,
35+ inputsLocked,
36+ bind,
37+ } = useEthereumTransaction(GAS_LIMITS.DEFAULT);
38+ // TODO: GAS_LIMITS.SET_POOL_SIZE
39+
40+ const construct = useCallback(
41+ (poolOwner, poolSize) =>
42+ _construct(
43+ azimuth.delegatedSending.setPoolSize(
44+ _contracts,
45+ _point,
46+ poolOwner,
47+ poolSize
48+ )
49+ ),
50+ [_construct, _contracts, _point]
51+ );
52+
53+ // sync point details after success
54+ useEffect(() => {
55+ if (confirmed) {
56+ syncOwnedPoint(_point);
57+ }
58+ }, [_point, confirmed, syncOwnedPoint]);
59+
60+ return {
61+ construct,
62+ confirmed,
63+ inputsLocked,
64+ bind,
65+ };
66+}
67+
68+export default function PartySetPoolSize() {
69+ const { pop } = useHistory();
70+ const { contracts } = useNetwork();
71+
72+ const _contracts = need.contracts(contracts);
73+
74+ const { spawnIsDelegatedSending } = useCurrentPermissions();
75+
76+ const { construct, confirmed, inputsLocked, bind } = useSetPoolSize();
77+
78+ const [poolOwnerInput, { pass: validPoint, data: poolOwner }] = usePointInput(
79+ {
80+ name: 'point',
81+ label: 'Point',
82+ disabled: inputsLocked,
83+ }
84+ );
85+
86+ const [
87+ poolSizeInput,
88+ { pass: validPoolSize, data: poolSize },
89+ ] = useNumberInput({
90+ name: 'poolsize',
91+ label: 'Pool Size',
92+ initialValue: 5,
93+ disabled: inputsLocked,
94+ });
95+
96+ useEffect(() => {
97+ if (validPoint && validPoolSize) {
98+ construct(patp2dec(poolOwner), poolSize);
99+ }
100+ }, [poolOwner, construct, validPoint, validPoolSize, poolSize]);
101+
102+ return (
103+ <View inset>
104+ <Grid>
105+ <Grid.Item full as={MiniBackButton} onClick={() => pop()} />
106+ <Grid.Item full as={ViewHeader}>
107+ Set Pool Size
108+ </Grid.Item>
109+ {!spawnIsDelegatedSending && (
110+ <Grid.Item full as={WarningBox} className="mb4">
111+ The spawn proxy must be set to{' '}
112+ <code className="mono f6">
113+ {_contracts.delegatedSending.address}
114+ </code>{' '}
115+ for invitations to be available.
116+ </Grid.Item>
117+ )}
118+ <Grid.Item
119+ full
120+ as={Text}
121+ className={cn('f5', {
122+ green3: confirmed,
123+ })}>
124+ {confirmed
125+ ? `${poolSize} invites have been allocated to ${poolOwner}`
126+ : `Allocate invites to a child point.`}
127+ </Grid.Item>
128+
129+ {!confirmed && (
130+ <>
131+ <Grid.Item full as={Input} {...poolOwnerInput} className="mt4" />
132+ <Grid.Item full as={Input} {...poolSizeInput} className="mb4" />
133+ </>
134+ )}
135+
136+ <Grid.Item
137+ full
138+ as={InlineEthereumTransaction}
139+ {...bind}
140+ onReturn={() => pop()}
141+ />
142+ </Grid>
143+ </View>
144+ );
145+}
src/views/Point.js+10−26
@@ -15,40 +15,27 @@ import { matchBlinky } from 'components/Blinky';
15
15
16import useInvites from 'lib/useInvites';
16import useInvites from 'lib/useInvites';
17import { useSyncOwnedPoints } from 'lib/useSyncPoints';
17import { useSyncOwnedPoints } from 'lib/useSyncPoints';
18−
18+import useCurrentPermissions from 'lib/useCurrentPermissions';
19−import Actions from './Point/Actions';
20−import { useWallet } from 'store/wallet';
21−import usePermissionsForPoint from 'lib/usePermissionsForPoint';
22
19
23export default function Point() {
20export default function Point() {
24 const { push, names } = useHistory();
21 const { push, names } = useHistory();
25 const { pointCursor } = usePointCursor();
22 const { pointCursor } = usePointCursor();
26− const { wallet } = useWallet();
27
23
28 const point = need.point(pointCursor);
24 const point = need.point(pointCursor);
29
25
30− const { isActiveOwner, canManage } = usePermissionsForPoint(
26+ const { isActiveOwner, canManage } = useCurrentPermissions();
31− // using empty string should be ok here
32− wallet.matchWith({
33− Nothing: () => '',
34− Just: p => p.value.address,
35− }),
36− point
37− );
38
27
39 // fetch the invites for the current cursor
28 // fetch the invites for the current cursor
40 const { availableInvites } = useInvites(point);
29 const { availableInvites } = useInvites(point);
41
30
42− const showActions = Just.hasInstance(wallet);
43−
44 const goAdmin = useCallback(() => push(names.ADMIN), [push, names]);
31 const goAdmin = useCallback(() => push(names.ADMIN), [push, names]);
45
32
46 const goInvite = useCallback(() => push(names.INVITE), [push, names]);
33 const goInvite = useCallback(() => push(names.INVITE), [push, names]);
47
34
48− const goParties = useCallback(() => push(names.INVITES_MANAGE), [
35+ const goPartiesSetPoolSize = useCallback(
49− push,
36+ () => push(names.PARTY_SET_POOL_SIZE),
50− names,
37+ [push, names]
51− ]);
38+ );
52
39
53 const inviteButton = (() => {
40 const inviteButton = (() => {
54 switch (azimuth.getPointSize(point)) {
41 switch (azimuth.getPointSize(point)) {
@@ -62,8 +49,10 @@ export default function Point() {
62 //
49 //
63 case azimuth.PointSize.Star:
50 case azimuth.PointSize.Star:
64 return (
51 return (
52+ <FooterButton
65− <FooterButton disabled={!isActiveOwner} onClick={goParties}>
53+ disabled={!isActiveOwner}
54+ onClick={goPartiesSetPoolSize}>
66− Manage parties
55+ Manage Parties
67 </FooterButton>
56 </FooterButton>
68 );
57 );
69 //
58 //
@@ -88,11 +77,6 @@ export default function Point() {
88 </Grid.Item>
77 </Grid.Item>
89 <Grid.Divider />
78 <Grid.Divider />
90 <Grid.Item full as={BootArvoButton} disabled />
79 <Grid.Item full as={BootArvoButton} disabled />
91− {showActions && (
92− <Grid.Item full>
93− <Actions />
94− </Grid.Item>
95− )}
96 </Grid>
80 </Grid>
97
81
98 {inviteButton}
82 {inviteButton}