on master help sign in
refactor: re-structure the /Invite folder, move InvitesSend to InviteEmail, etc
7f63306Matt Condon (shrugs)
src/components/Highlighted.jsnew file+5
@@ -0,0 +1,5 @@
1+import React from 'react';
2+
3+export default function Highlighted(props) {
4+ return <span className="red3" {...props} />;
5+}
src/lib/loadingCharacter.jsnew file+5
@@ -0,0 +1,5 @@
1+export default val =>
2+ val.matchWith({
3+ Nothing: () => '▓',
4+ Just: p => p.value,
5+ });
src/views/Invite.js+12−51
@@ -1,8 +1,9 @@
1−import React, { useCallback } from 'react';
1+import React from 'react';
2import * as need from 'lib/need';
2import * as need from 'lib/need';
3−import { Grid, H5, Text, Button } from 'indigo-react';
3+import { Grid, H5, Text } from 'indigo-react';
4
4
5import { usePointCursor } from 'store/pointCursor';
5import { usePointCursor } from 'store/pointCursor';
6+import { useHistory } from 'store/history';
6// import { usePointCache } from 'store/pointCache';
7// import { usePointCache } from 'store/pointCache';
7
8
8import View from 'components/View';
9import View from 'components/View';
@@ -11,12 +12,12 @@ import Crumbs from 'components/Crumbs';
11import useInvites from 'lib/useInvites';
12import useInvites from 'lib/useInvites';
12import useSyncPoint from 'lib/useSyncPoint';
13import useSyncPoint from 'lib/useSyncPoint';
13import useCurrentPointName from 'lib/useCurrentPointName';
14import useCurrentPointName from 'lib/useCurrentPointName';
14−
15−import { useHistory } from 'store/history';
16−import { ForwardButton } from 'components/Buttons';
17−import FooterButton from 'components/FooterButton';
18import useRouter from 'lib/useRouter';
15import useRouter from 'lib/useRouter';
19−import InvitesSend from './InvitesSend';
16+import loadingCharacter from 'lib/loadingCharacter';
17+
18+import InviteUrl from './Invite/InviteUrl';
19+import InviteEmail from './Invite/InviteEmail';
20+import Highlighted from 'components/Highlighted';
20
21
21const kInviteNames = {
22const kInviteNames = {
22 URL: 'URL',
23 URL: 'URL',
@@ -25,49 +26,9 @@ const kInviteNames = {
25
26
26const kInviteViews = {
27const kInviteViews = {
27 URL: InviteUrl,
28 URL: InviteUrl,
28− EMAIL: InvitesSend,
29+ EMAIL: InviteEmail,
29};
30};
30
31
31−const valOrLoading = val =>
32− val.matchWith({
33− Nothing: () => '▓',
34− Just: p => p.value,
35− });
36−
37−function Highlighted(props) {
38− return <span className="red3" {...props} />;
39−}
40−
41−function InviteUrl({ names, push }) {
42− const pushEmail = useCallback(() => push(names.EMAIL), [push, names]);
43−
44− return (
45− <>
46− <Grid className="mt3">
47− <Grid.Divider />
48− <Grid.Item
49− as={Button}
50− detail="Generate a URL to send to one guest"
51− full
52− disabled>
53− Generate Invite
54− </Grid.Item>
55− <Grid.Divider />
56− <Grid.Item
57− as={ForwardButton}
58− onClick={pushEmail}
59− detail="Send invitation to your guest's email"
60− full>
61− Send Invite via Email
62− </Grid.Item>
63− </Grid>
64− <FooterButton detail="i.e. Ethereum Address, Text File" disabled>
65− Advanced
66− </FooterButton>
67− </>
68− );
69−}
70−
71export default function Invite() {
32export default function Invite() {
72 const history = useHistory();
33 const history = useHistory();
73 const { Route, ...routeProps } = useRouter({
34 const { Route, ...routeProps } = useRouter({
@@ -84,9 +45,9 @@ export default function Invite() {
84
45
85 // fetch the invites for the current cursor
46 // fetch the invites for the current cursor
86 const { availableInvites, sentInvites, acceptedInvites } = useInvites(point);
47 const { availableInvites, sentInvites, acceptedInvites } = useInvites(point);
87− const availableInvitesText = valOrLoading(availableInvites);
48+ const availableInvitesText = loadingCharacter(availableInvites);
88− const sentInvitesText = valOrLoading(sentInvites);
49+ const sentInvitesText = loadingCharacter(sentInvites);
89− const acceptedInvitesText = valOrLoading(acceptedInvites);
50+ const acceptedInvitesText = loadingCharacter(acceptedInvites);
90
51
91 return (
52 return (
92 <View>
53 <View>
src/views/InvitesSend.js → src/views/Invite/InviteEmail.jsrenamed+12−12
@@ -1,13 +1,13 @@
1import { Just, Nothing } from 'folktale/maybe';
1import { Just, Nothing } from 'folktale/maybe';
2import React from 'react';
2import React from 'react';
3import * as azimuth from 'azimuth-js';
3import * as azimuth from 'azimuth-js';
4−import * as need from '../lib/need';
4+import * as need from 'lib/need';
5
5
6−import { hasReceived, sendMail } from '../lib/inviteMail';
6+import { hasReceived, sendMail } from 'lib/inviteMail';
7−import { Button, Input, H3, Warning } from '../components/old/Base';
7+import { Button, Input, H3, Warning } from 'components/old/Base';
8
8
9// for wallet generation
9// for wallet generation
10−import * as wg from '../_walletgen/lib/lib';
10+import * as wg from '_walletgen/lib/lib';
11
11
12// for transaction generation and signing
12// for transaction generation and signing
13import {
13import {
@@ -17,12 +17,12 @@ import {
17 hexify,
17 hexify,
18 fromWei,
18 fromWei,
19 toWei,
19 toWei,
20−} from '../lib/txn';
20+} from 'lib/txn';
21−import * as tank from '../lib/tank';
21+import * as tank from 'lib/tank';
22−import { withNetwork } from '../store/network';
22+import { withNetwork } from 'store/network';
23−import { compose } from '../lib/lib';
23+import { compose } from 'lib/lib';
24−import { withWallet } from '../store/wallet';
24+import { withWallet } from 'store/wallet';
25−import { withPointCursor } from '../store/pointCursor';
25+import { withPointCursor } from 'store/pointCursor';
26import View from 'components/View';
26import View from 'components/View';
27
27
28const GAS_PRICE_GWEI = 20; // we pay the premium for faster ux
28const GAS_PRICE_GWEI = 20; // we pay the premium for faster ux
@@ -45,7 +45,7 @@ const EMAIL_STATUS = {
45 FAIL: '×',
45 FAIL: '×',
46};
46};
47
47
48−class InvitesSend extends React.Component {
48+class InviteEmail extends React.Component {
49 constructor(props) {
49 constructor(props) {
50 super(props);
50 super(props);
51
51
@@ -498,4 +498,4 @@ export default compose(
498 withNetwork,
498 withNetwork,
499 withWallet,
499 withWallet,
500 withPointCursor
500 withPointCursor
501−)(InvitesSend);
501+)(InviteEmail);
src/views/Invite/InviteUrl.jsnew file+35
@@ -0,0 +1,35 @@
1+import React, { useCallback } from 'react';
2+import { Grid, Button } from 'indigo-react';
3+
4+import { ForwardButton } from 'components/Buttons';
5+import FooterButton from 'components/FooterButton';
6+
7+export default function InviteUrl({ names, push }) {
8+ const pushEmail = useCallback(() => push(names.EMAIL), [push, names]);
9+
10+ return (
11+ <>
12+ <Grid className="mt3">
13+ <Grid.Divider />
14+ <Grid.Item
15+ as={Button}
16+ detail="Generate a URL to send to one guest"
17+ full
18+ disabled>
19+ Generate Invite
20+ </Grid.Item>
21+ <Grid.Divider />
22+ <Grid.Item
23+ as={ForwardButton}
24+ onClick={pushEmail}
25+ detail="Send invitation to your guest's email"
26+ full>
27+ Send Invite via Email
28+ </Grid.Item>
29+ </Grid>
30+ <FooterButton detail="i.e. Ethereum Address, Text File" disabled>
31+ Advanced
32+ </FooterButton>
33+ </>
34+ );
35+}
src/views/Landing.js+1−1
@@ -1,5 +1,5 @@
1import React from 'react';
1import React from 'react';
2−import { H1, P, HelpText } from 'indigo-react';
2+import { H1, P } from 'indigo-react';
3
3
4import { ROUTE_NAMES } from '../lib/routeNames';
4import { ROUTE_NAMES } from '../lib/routeNames';
5import { useHistory } from '../store/history';
5import { useHistory } from '../store/history';