on df0c310 help sign in
bridge/src/views/Login.tsx
104 lines 2.7 kB history raw
1import React, { useCallback } from 'react';
2import { Grid, Text, Flex } from 'indigo-react';
4import { versionLabel } from 'lib/flags';
6import { useHistory } from 'store/history';
8import { COMMANDS, FlowType, useFlowCommand } from 'lib/flowCommand';
10import View from 'components/View';
11import Footer from 'components/Footer';
13import Other from './Login/Other';
15import './Login.scss';
17export default function Login() {
18 // globals
19 const { push, names }: any = useHistory();
20 const flow: any = useFlowCommand();
22 const goHome = useCallback(() => {
23 if (!flow) {
24 push(names.POINTS);
25 } else {
26 switch (flow.kind) {
27 case COMMANDS.TAKE_LOCKUP:
28 push(names.ACCEPT_LOCKUP);
29 break;
30 //
31 case COMMANDS.BITCOIN:
32 push(names.BITCOIN);
33 break;
34 //
35 case COMMANDS.XPUB:
36 push(names.BITCOIN);
37 break;
38 //
39 default:
40 throw new Error('unimplemented flow ' + flow.kind);
41 }
42 }
43 }, [flow, push, names]);
45 const flowDescription = (command: FlowType) => {
46 if (!command) {
47 return null;
48 }
50 switch (command.kind) {
51 case COMMANDS.TAKE_LOCKUP:
52 //TODO kind of want "sign in as 0xabc.." here...
53 return <>To accept a star lockup batch, please sign in.</>;
54 //
55 case COMMANDS.BITCOIN:
56 return <>To sign a Bitcoin transaction, please sign in.</>;
57 //
58 case COMMANDS.XPUB:
59 return <>To view your Bitcoin extended public key, please sign in.</>;
60 //
61 default:
62 return <>Flow: {command.kind}</>;
63 }
64 };
66 return (
67 <View inset hideBack>
68 <Grid>
69 <Grid.Item
70 full
71 as={Text}
72 className="flex justify-center mt9 mb7 w-max-mobile">
73 <Grid.Item as={Text}>Bridge /&nbsp;</Grid.Item>
74 <Grid.Item className="fw-bold" as={Text}>
75 Log In
76 </Grid.Item>
77 </Grid.Item>
78 {flow && (
79 <Grid.Item full as={Text} className="t-center mb4">
80 {flowDescription(flow)}
81 </Grid.Item>
82 )}
83 <Grid.Item
84 full
85 as={Other}
86 goHome={goHome}
87 className="login-selector w-max-mobile"
88 />
89 </Grid>
91 <Footer>
92 <Flex className="mb8 f6" justify="between">
93 <Flex.Item
94 as="a"
95 href="https://github.com/urbit/bridge/releases"
96 className="us-none pointer">
97 <span className="underline">Offline</span> ↗
98 </Flex.Item>
99 <Flex.Item className="gray4">v{versionLabel}</Flex.Item>
100 </Flex>
101 </Footer>
102 </View>
103 );