1import React, { useCallback, useState } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
3import * as azimuth from 'azimuth-js';
5import { H4, Grid } from 'indigo-react';
7import Ticket from './Login/Ticket';
8import Mnemonic from './Login/Mnemonic';
9import Advanced from './Login/Advanced';
10import Hardware from './Login/Hardware';
12import * as need from 'lib/need';
14import { useHistory } from 'store/history';
15import { useNetwork } from 'store/network';
16import { useWallet } from 'store/wallet';
17import { usePointCursor } from 'store/pointCursor';
19import View from 'components/View';
20import Tabs from 'components/Tabs';
21import Crumbs from 'components/Crumbs';
22import Footer from 'components/Footer';
23import { ForwardButton, OfflineButton } from 'components/Buttons';
33 [NAMES.TICKET]: Ticket,
34 [NAMES.MNEMONIC]: Mnemonic,
35 [NAMES.HARDWARE]: Hardware,
36 [NAMES.ADVANCED]: Advanced,
40 { text: 'Master Ticket', value: NAMES.TICKET },
41 { text: 'Mnemonic', value: NAMES.MNEMONIC },
42 { text: 'Hardware', value: NAMES.HARDWARE },
43 { text: 'Advanced', value: NAMES.ADVANCED },
46export default function Login() {
48 const { push, replaceWith, names } = useHistory();
49 const { contracts } = useNetwork();
50 const { wallet } = useWallet();
51 const { pointCursor, setPointCursor } = usePointCursor();
54 const [currentTab, setCurrentTab] = useState(NAMES.TICKET);
56 const goToActivate = useCallback(
57 () => replaceWith([{ key: names.LANDING }, { key: names.ACTIVATE }]),
61 const goToPoints = useCallback(() => {
65 const goToPoint = useCallback(() => {
68 }, [goToPoints, push, names]);
70 const doContinue = useCallback(async () => {
71 const _wallet = need.wallet(wallet);
72 const _contracts = need.contracts(contracts);
74 // if no point cursor set by login logic, try to deduce it
75 let deduced = pointCursor;
76 if (Nothing.hasInstance(deduced)) {
77 const owned = await azimuth.azimuth.getOwnedPoints(
81 if (owned.length === 1) {
82 deduced = Just(owned[0]);
83 } else if (owned.length === 0) {
84 const canOwn = await azimuth.azimuth.getTransferringFor(
88 if (canOwn.length === 1) {
89 deduced = Just(canOwn[0]);
94 // if we have a deduced point or one in the global context,
95 // navigate to that specific point, otherwise navigate to list of points
96 if (Just.hasInstance(deduced)) {
97 setPointCursor(deduced);
102 }, [contracts, pointCursor, setPointCursor, wallet, goToPoint, goToPoints]);
107 <Grid.Item full as={Crumbs} routes={[{ text: 'Multipass' }]} />
108 <Grid.Item full as={H4} className="mt4">
118 currentTab={currentTab}
119 onTabChange={setCurrentTab}
127 disabled={Nothing.hasInstance(wallet)}
128 onClick={doContinue}>
136 <Grid.Item full as={ForwardButton} onClick={goToActivate}>
140 <Grid.Item full as={OfflineButton} />
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