on eb070bb help sign in
bridge/src/views/Release.js
86 lines 2.1 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 NavHeader from 'components/NavHeader';
20const NAMES = {
21 ACTIVE: 'ACTIVE',
22 LOCKED: 'LOCKED',
23};
25const VIEWS = {
26 [NAMES.ACTIVE]: Active,
27 [NAMES.LOCKED]: Locked,
28};
29const OPTIONS = [
30 { text: 'Active', value: NAMES.ACTIVE },
31 { text: 'Locked', value: NAMES.LOCKED },
32];
33export default function ReleaseView() {
34 const { pop, push, names } = useHistory();
35 const { wallet } = useWallet();
37 const { setPointCursor } = usePointCursor();
39 const goPoint = useCallback(
40 point => {
41 setPointCursor(Just(point));
43 push(names.POINT);
44 },
45 [push, names, setPointCursor]
46 );
47 // inputs
48 const [currentTab, setCurrentTab] = useState(NAMES.ACTIVE);
50 const goActive = useCallback(() => {
51 setCurrentTab(NAMES.ACTIVE);
52 }, [setCurrentTab]);
54 const address = need.addressFromWallet(wallet);
56 return (
57 <View pop={pop} inset>
58 <NavHeader>
59 <CopiableAddress
60 className="f6 mono gray4 us-none pointer"
61 text={address}>
62 {address}
63 </CopiableAddress>
64 </NavHeader>
65 <Grid>
66 <Grid.Item full as={H1}></Grid.Item>
68 <Grid.Item
69 full
70 as={Tabs}
71 className="mt1"
72 // Tabs
73 views={VIEWS}
74 options={OPTIONS}
75 currentTab={currentTab}
76 onTabChange={setCurrentTab}
77 // Tab extra
78 goPoint={goPoint}
79 goActive={goActive}
80 //
81 //
82 />
83 </Grid>
84 </View>
85 );