on master help sign in
Make transfer action work
aa70a4aFang
src/views/Admin.js+20−2
@@ -1,19 +1,29 @@
1import React, { useCallback } from 'react';
1import React, { useCallback } from 'react';
2import { Just } from 'folktale/maybe';
2import { Just } from 'folktale/maybe';
3import { Grid } from 'indigo-react';
3import { Grid } from 'indigo-react';
4+import * as need from 'lib/need';
4
5
5import View from 'components/View';
6import View from 'components/View';
6import { ForwardButton } from 'components/Buttons';
7import { ForwardButton } from 'components/Buttons';
7
8
8import { ROUTE_NAMES } from 'lib/routeNames';
9import { ROUTE_NAMES } from 'lib/routeNames';
10+import { eqAddr } from 'lib/wallet';
9
11
10import { useHistory } from 'store/history';
12import { useHistory } from 'store/history';
11import { useWallet } from 'store/wallet';
13import { useWallet } from 'store/wallet';
14+import { usePointCursor } from 'store/pointCursor';
15+import { usePointCache } from 'store/pointCache';
12import FooterButton from 'components/FooterButton';
16import FooterButton from 'components/FooterButton';
13
17
14export default function Admin() {
18export default function Admin() {
15 const history = useHistory();
19 const history = useHistory();
16− const { urbitWallet } = useWallet();
20+ const { urbitWallet, wallet } = useWallet();
21+ const { pointCursor } = usePointCursor();
22+ const { pointCache } = usePointCache();
23+
24+ const point = need.point(pointCursor);
25+ const pointDetails = need.fromPointCache(pointCache, point);
26+ const userAddress = need.wallet(wallet).address;
17
27
18 const goRedownload = useCallback(() => history.push(ROUTE_NAMES.REDOWNLOAD), [
28 const goRedownload = useCallback(() => history.push(ROUTE_NAMES.REDOWNLOAD), [
19 history,
29 history,
@@ -27,7 +37,12 @@ export default function Admin() {
27 history,
37 history,
28 ]);
38 ]);
29
39
40+ const goTransfer = useCallback(() => history.push(ROUTE_NAMES.TRANSFER), [
41+ history,
42+ ]);
43+
30 const canDownloadPassport = Just.hasInstance(urbitWallet);
44 const canDownloadPassport = Just.hasInstance(urbitWallet);
45+ const isOwner = eqAddr(userAddress, pointDetails.owner);
31
46
32 return (
47 return (
33 <View>
48 <View>
@@ -57,7 +72,10 @@ export default function Admin() {
57 </Grid.Item>
72 </Grid.Item>
58 </Grid>
73 </Grid>
59
74
75+ <FooterButton
60− <FooterButton detail="Transfer this identity to a new owner" disabled>
76+ detail="Transfer this identity to a new owner"
77+ disabled={!isOwner}
78+ onClick={goTransfer}>
61 Transfer
79 Transfer
62 </FooterButton>
80 </FooterButton>
63 </View>
81 </View>