on master help sign in
Make transfer action work
commitaa70a4a645e3c827bab3c7f1fee5a4d3801bfea1 authorFang <git@fang.io> dateTue 2 Jul 2019, 22:29 (7 years ago) parentc17dcfd
1 file changed+20−2
src/views/Admin.js+20−2
src/views/Admin.js+20−2
@@ -1,19 +1,29 @@
11import React, { useCallback } from 'react';
22import { Just } from 'folktale/maybe';
33import { Grid } from 'indigo-react';
4+import * as need from 'lib/need';
45
56import View from 'components/View';
67import { ForwardButton } from 'components/Buttons';
78
89import { ROUTE_NAMES } from 'lib/routeNames';
10+import { eqAddr } from 'lib/wallet';
911
1012import { useHistory } from 'store/history';
1113import { useWallet } from 'store/wallet';
14+import { usePointCursor } from 'store/pointCursor';
15+import { usePointCache } from 'store/pointCache';
1216import FooterButton from 'components/FooterButton';
1317
1418export default function Admin() {
1519 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;
1727
1828 const goRedownload = useCallback(() => history.push(ROUTE_NAMES.REDOWNLOAD), [
1929 history,
@@ -27,7 +37,12 @@ export default function Admin() {
2737 history,
2838 ]);
2939
40+ const goTransfer = useCallback(() => history.push(ROUTE_NAMES.TRANSFER), [
41+ history,
42+ ]);
43+
3044 const canDownloadPassport = Just.hasInstance(urbitWallet);
45+ const isOwner = eqAddr(userAddress, pointDetails.owner);
3146
3247 return (
3348 <View>
@@ -57,7 +72,10 @@ export default function Admin() {
5772 </Grid.Item>
5873 </Grid>
5974
60− <FooterButton detail="Transfer this identity to a new owner" disabled>
75+ <FooterButton
76+ detail="Transfer this identity to a new owner"
77+ disabled={!isOwner}
78+ onClick={goTransfer}>
6179 Transfer
6280 </FooterButton>
6381 </View>