on master help sign in
refactor: re-structure the /Invite folder, move InvitesSend to InviteEmail, etc
commit7f63306ff4cc3cf2edc2e8af17d9f87edca0377d authorMatt Condon (shrugs) <mattgcondon@gmail.com> dateWed 19 Jun 2019, 20:02 (7 years ago) parent6542dce
6 files changed+70−64
src/components/Highlighted.js+5 src/lib/loadingCharacter.js+5 src/views/Invite.js+12−51 src/views/InvitesSend.js → src/views/Invite/InviteEmail.js+12−12 src/views/Invite/InviteUrl.js+35 src/views/Landing.js+1−1
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';
22import * as need from 'lib/need';
3−import { Grid, H5, Text, Button } from 'indigo-react';
3+import { Grid, H5, Text } from 'indigo-react';
44
55import { usePointCursor } from 'store/pointCursor';
6+import { useHistory } from 'store/history';
67// import { usePointCache } from 'store/pointCache';
78
89import View from 'components/View';
@@ -11,12 +12,12 @@ import Crumbs from 'components/Crumbs';
1112import useInvites from 'lib/useInvites';
1213import useSyncPoint from 'lib/useSyncPoint';
1314import useCurrentPointName from 'lib/useCurrentPointName';
14−
15−import { useHistory } from 'store/history';
16−import { ForwardButton } from 'components/Buttons';
17−import FooterButton from 'components/FooterButton';
1815import 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';
2021
2122const kInviteNames = {
2223 URL: 'URL',
@@ -25,49 +26,9 @@ const kInviteNames = {
2526
2627const kInviteViews = {
2728 URL: InviteUrl,
28− EMAIL: InvitesSend,
29+ EMAIL: InviteEmail,
2930};
3031
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−
7132export default function Invite() {
7233 const history = useHistory();
7334 const { Route, ...routeProps } = useRouter({
@@ -84,9 +45,9 @@ export default function Invite() {
8445
8546 // fetch the invites for the current cursor
8647 const { availableInvites, sentInvites, acceptedInvites } = useInvites(point);
87− const availableInvitesText = valOrLoading(availableInvites);
88− const sentInvitesText = valOrLoading(sentInvites);
89− const acceptedInvitesText = valOrLoading(acceptedInvites);
48+ const availableInvitesText = loadingCharacter(availableInvites);
49+ const sentInvitesText = loadingCharacter(sentInvites);
50+ const acceptedInvitesText = loadingCharacter(acceptedInvites);
9051
9152 return (
9253 <View>
src/views/InvitesSend.js → src/views/Invite/InviteEmail.jsrenamed+12−12
@@ -1,13 +1,13 @@
11import { Just, Nothing } from 'folktale/maybe';
22import React from 'react';
33import * as azimuth from 'azimuth-js';
4−import * as need from '../lib/need';
4+import * as need from 'lib/need';
55
6−import { hasReceived, sendMail } from '../lib/inviteMail';
7−import { Button, Input, H3, Warning } from '../components/old/Base';
6+import { hasReceived, sendMail } from 'lib/inviteMail';
7+import { Button, Input, H3, Warning } from 'components/old/Base';
88
99// for wallet generation
10−import * as wg from '../_walletgen/lib/lib';
10+import * as wg from '_walletgen/lib/lib';
1111
1212// for transaction generation and signing
1313import {
@@ -17,12 +17,12 @@ import {
1717 hexify,
1818 fromWei,
1919 toWei,
20−} from '../lib/txn';
21−import * as tank from '../lib/tank';
22−import { withNetwork } from '../store/network';
23−import { compose } from '../lib/lib';
24−import { withWallet } from '../store/wallet';
25−import { withPointCursor } from '../store/pointCursor';
20+} from 'lib/txn';
21+import * as tank from 'lib/tank';
22+import { withNetwork } from 'store/network';
23+import { compose } from 'lib/lib';
24+import { withWallet } from 'store/wallet';
25+import { withPointCursor } from 'store/pointCursor';
2626import View from 'components/View';
2727
2828const GAS_PRICE_GWEI = 20; // we pay the premium for faster ux
@@ -45,7 +45,7 @@ const EMAIL_STATUS = {
4545 FAIL: '×',
4646};
4747
48−class InvitesSend extends React.Component {
48+class InviteEmail extends React.Component {
4949 constructor(props) {
5050 super(props);
5151
@@ -498,4 +498,4 @@ export default compose(
498498 withNetwork,
499499 withWallet,
500500 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 @@
11import React from 'react';
2−import { H1, P, HelpText } from 'indigo-react';
2+import { H1, P } from 'indigo-react';
33
44import { ROUTE_NAMES } from '../lib/routeNames';
55import { useHistory } from '../store/history';