on 4c8c607 help sign in
bridge/src/views/Release.js
90 lines 2.2 kB history raw
1import React, { useState, useCallback } from 'react';
2import { H1, Grid } from 'indigo-react';
3import { Just } from 'folktale/maybe';
5import * as need from 'lib/need';
7import { useHistory } from 'store/history';
8import { useWallet } from 'store/wallet';
9import { usePointCursor } from 'store/pointCursor';
11import View from 'components/View';
12import Tabs from 'components/Tabs';
13import Crumbs from 'components/Crumbs';
14import CopiableAddress from 'components/CopiableAddress';
16import Active from 'views/Release/Active';
17import Locked from 'views/Release/Locked';
18import Transfer from 'views/Release/Transfer';
19import NavHeader from 'components/NavHeader';
21const NAMES = {
22 ACTIVE: 'ACTIVE',
23 LOCKED: 'LOCKED',
24 TRANSFER: 'TRANSFER',
25};
27const VIEWS = {
28 [NAMES.ACTIVE]: Active,
29 [NAMES.LOCKED]: Locked,
30 [NAMES.TRANSFER]: Transfer,
31};
32const OPTIONS = [
33 { text: 'Active', value: NAMES.ACTIVE },
34 { text: 'Locked', value: NAMES.LOCKED },
35 { text: 'Transfer', value: NAMES.TRANSFER },
36];
37export default function ReleaseView() {
38 const { pop, push, names } = useHistory();
39 const { wallet } = useWallet();
41 const { setPointCursor } = usePointCursor();
43 const goPoint = useCallback(
44 point => {
45 setPointCursor(Just(point));
47 push(names.POINT);
48 },
49 [push, names, setPointCursor]
50 );
51 // inputs
52 const [currentTab, setCurrentTab] = useState(NAMES.ACTIVE);
54 const goActive = useCallback(() => {
55 setCurrentTab(NAMES.ACTIVE);
56 }, [setCurrentTab]);
58 const address = need.addressFromWallet(wallet);
60 return (
61 <View pop={pop} inset>
62 <NavHeader>
63 <CopiableAddress
64 className="f6 mono gray4 us-none pointer"
65 text={address}>
66 {address}
67 </CopiableAddress>
68 </NavHeader>
69 <Grid>
70 <Grid.Item full as={H1}></Grid.Item>
72 <Grid.Item
73 full
74 as={Tabs}
75 className="mt1"
76 // Tabs
77 views={VIEWS}
78 options={OPTIONS}
79 currentTab={currentTab}
80 onTabChange={setCurrentTab}
81 // Tab extra
82 goPoint={goPoint}
83 goActive={goActive}
84 //
85 //
86 />
87 </Grid>
88 </View>
89 );