on c262e73 help sign in
bridge/src/views/Admin.js
84 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 address = need.addressFromWallet(wallet);
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(address, pointDetails.owner);
47 return (
48 <View>
49 <Grid className="pt2">
50 <Grid.Item
51 full
52 as={ForwardButton}
53 disabled={!canDownloadPassport}
54 onClick={goRedownload}
55 detail="Re-download your paper wallet">
56 Download Passport
57 </Grid.Item>
58 <Grid.Divider />
59 <Grid.Item
60 full
61 as={ForwardButton}
62 disabled={!isOwner}
63 onClick={goReticket}
64 detail="Move to brand new wallet, re-setting all permissions">
65 Reticket
66 </Grid.Item>
67 <Grid.Item
68 full
69 as={ForwardButton}
70 onClick={goEditPerms}
71 detail="Management, networking keys, etc.">
72 Edit permissions
73 </Grid.Item>
74 </Grid>
76 <FooterButton
77 detail="Transfer this identity to a new owner"
78 disabled={!isOwner}
79 onClick={goTransfer}>
80 Transfer
81 </FooterButton>
82 </View>
83 );