1import { Nothing, Just } from 'folktale/maybe';
2import React, { useState } from 'react';
3import * as azimuth from 'azimuth-js';
5import { H1 } from 'indigo-react';
6import View from 'components/View';
7import Tabs from 'components/Tabs';
9import Ticket from './Login/Ticket';
10import Mnemonic from './Login/Mnemonic';
11import Advanced from './Login/Advanced';
13import useLifecycle from 'lib/useLifecycle';
14import * as need from 'lib/need';
15import { ROUTE_NAMES } from 'lib/routeNames';
17import { useHistory } from 'store/history';
18import { useNetwork } from 'store/network';
19import { useWallet } from 'store/wallet';
20import { usePointCursor } from 'store/pointCursor';
23 TICKET: Symbol('TICKET'),
24 MNEMONIC: Symbol('MNEMONIC'),
25 ADVANCED: Symbol('ADVANCED'),
29 [TABS.TICKET]: Ticket,
30 [TABS.MNEMONIC]: Mnemonic,
31 [TABS.ADVANCED]: Advanced,
35 { title: 'Ticket', value: TABS.TICKET },
36 { title: 'Mnemonic', value: TABS.MNEMONIC },
37 { title: 'Advanced', value: TABS.ADVANCED },
40export default function Login() {
42 const history = useHistory();
43 const { contracts } = useNetwork();
44 const { wallet, resetWallet } = useWallet();
45 const { pointCursor, setPointCursor } = usePointCursor();
48 const [currentTab, setCurrentTab] = useState(TABS.TICKET);
55 const doContinue = async () => {
56 const _wallet = need.wallet(wallet);
57 const _contracts = need.contracts(contracts);
59 // if no point cursor set by login logic, try to deduce it
60 let deduced = pointCursor;
61 if (Nothing.hasInstance(deduced)) {
62 const owned = await azimuth.azimuth.getOwnedPoints(
66 if (owned.length === 1) {
67 deduced = Just(owned[0]);
68 } else if (owned.length === 0) {
69 const canOwn = await azimuth.azimuth.getTransferringFor(
73 if (canOwn.length === 1) {
74 deduced = Just(canOwn[0]);
79 // if we have a deduced point or one in the global context,
80 // navigate to that specific point, otherwise navigate to list of points
81 if (Just.hasInstance(deduced)) {
82 setPointCursor(deduced);
83 history.popAndPush(ROUTE_NAMES.POINTS);
84 history.push(ROUTE_NAMES.POINT);
86 history.popAndPush(ROUTE_NAMES.POINTS);
96 tabOptions={tabOptions}
97 currentTab={currentTab}
98 onTabChange={setCurrentTab}
100 loginCompleted={doContinue}
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list