1import { Nothing, Just } from 'folktale/maybe';
2import React, { useState, useEffect } 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 * as need from '../lib/need';
14import { ROUTE_NAMES } from '../lib/routeNames';
16import { useHistory } from '../store/history';
17import { useNetwork } from '../store/network';
18import { useWallet } from '../store/wallet';
19import { usePointCursor } from '../store/pointCursor';
22 TICKET: Symbol('TICKET'),
23 MNEMONIC: Symbol('MNEMONIC'),
24 ADVANCED: Symbol('ADVANCED'),
27export default function Login() {
29 const history = useHistory();
30 const { contracts } = useNetwork();
31 const { wallet, setUrbitWallet } = useWallet();
32 const { pointCursor, setPointCursor } = usePointCursor();
35 const [currentTab, setCurrentTab] = useState(TABS.TICKET);
39 setUrbitWallet(Nothing());
40 setPointCursor(Nothing());
46 const doContinue = async () => {
47 const realWallet = need.wallet(wallet);
48 const realContracts = need.contracts(contracts);
50 // if no point cursor set by login logic, try to deduce it
51 let deduced = Nothing();
52 if (Nothing.hasInstance(pointCursor)) {
53 const owned = await azimuth.azimuth.getOwnedPoints(
57 if (owned.length === 1) {
58 deduced = Just(owned[0]);
59 } else if (owned.length === 0) {
60 const canOwn = await azimuth.azimuth.getTransferringFor(
64 if (canOwn.length === 1) {
65 deduced = Just(canOwn[0]);
70 if (Just.hasInstance(deduced)) {
71 setPointCursor(deduced);
72 history.popAndPush(ROUTE_NAMES.POINT_HOME);
73 } else if (Just.hasInstance(pointCursor)) {
74 history.popAndPush(ROUTE_NAMES.POINT_HOME);
76 //TODO to new overview (maybe should be merged into point home?)
77 history.popAndPush(ROUTE_NAMES.POINTS);
82 [TABS.TICKET]: Ticket,
83 [TABS.MNEMONIC]: Mnemonic,
84 [TABS.ADVANCED]: Advanced,
88 { title: 'Ticket', value: TABS.TICKET },
89 { title: 'Mnemonic', value: TABS.MNEMONIC },
90 { title: 'Advanced', value: TABS.ADVANCED },
99 tabOptions={tabOptions}
100 currentTab={currentTab}
101 onTabChange={setCurrentTab}
103 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