on 46dbb79 help sign in
bridge/src/views/Admin.js
83 lines 2.4 kB history raw
1import React, { useCallback } from 'react';
2import { Just } from 'folktale/maybe';
3import { Grid } from 'indigo-react';
4import * as need from 'lib/need';
6import View from 'components/View';
7import { ForwardButton } from 'components/Buttons';
9import { ROUTE_NAMES } from 'lib/routeNames';
10import { eqAddr } from 'lib/wallet';
12import { useHistory } from 'store/history';
13import { useWallet } from 'store/wallet';
14import { usePointCursor } from 'store/pointCursor';
15import { usePointCache } from 'store/pointCache';
16import FooterButton from 'components/FooterButton';
18export default function Admin() {
19 const history = useHistory();
20 const { urbitWallet, wallet } = useWallet();
21 const { pointCursor } = usePointCursor();
22 const { pointCache } = usePointCache();
24 const point = need.point(pointCursor);
25 const pointDetails = need.fromPointCache(pointCache, point);
26 const userAddress = need.wallet(wallet).address;
28 const goRedownload = useCallback(() => history.push(ROUTE_NAMES.REDOWNLOAD), [
29 history,
30 ]);
32 const goReticket = useCallback(() => history.push(ROUTE_NAMES.RETICKET), [
33 history,
34 ]);
36 const goEditPerms = useCallback(() => history.push(ROUTE_NAMES.PERMISSIONS), [
37 history,
38 ]);
40 const goTransfer = useCallback(() => history.push(ROUTE_NAMES.TRANSFER), [
41 history,
42 ]);
44 const canDownloadPassport = Just.hasInstance(urbitWallet);
45 const isOwner = eqAddr(userAddress, pointDetails.owner);
47 return (
48 <View>
49 <Grid className="pt3">
50 <Grid.Item full>
51 <ForwardButton
52 disabled={!canDownloadPassport}
53 onClick={goRedownload}
54 detail="Re-download your paper wallet">
55 Download Passport
56 </ForwardButton>
57 </Grid.Item>
58 <Grid.Divider />
59 <Grid.Item full>
60 <ForwardButton
61 onClick={goReticket}
62 detail="//TODO disable if not logged in as owner">
63 Reticket
64 </ForwardButton>
65 </Grid.Item>
66 <Grid.Item full>
67 <ForwardButton
68 onClick={goEditPerms}
69 detail="Management, networking keys, etc.">
70 Edit permissions
71 </ForwardButton>
72 </Grid.Item>
73 </Grid>
75 <FooterButton
76 detail="Transfer this identity to a new owner"
77 disabled={!isOwner}
78 onClick={goTransfer}>
79 Transfer
80 </FooterButton>
81 </View>
82 );