on master help sign in
fix incorrect error reporting on url invite
f83b9a5Liam Fitzgerald
src/views/Invite/Url.js+9−3
@@ -1,6 +1,7 @@
1import React, { useCallback, useState } from 'react';
1import React, { useCallback, useState } from 'react';
2import { Grid, ErrorText } from 'indigo-react';
2import { Grid, ErrorText } from 'indigo-react';
3import { get } from 'lodash';
3import { get } from 'lodash';
4+import { FORM_ERROR } from 'final-form';
4
5
5import useCopiable from 'lib/useCopiable';
6import useCopiable from 'lib/useCopiable';
6import useInviter from 'lib/useInviter';
7import useInviter from 'lib/useInviter';
@@ -10,7 +11,7 @@ import { ForwardButton } from 'components/Buttons';
10import NeedFundsNotice from 'components/NeedFundsNotice';
11import NeedFundsNotice from 'components/NeedFundsNotice';
11
12
12import { hasErrors } from 'form/validators';
13import { hasErrors } from 'form/validators';
13−
14+import { WARNING } from 'form/helpers';
14const STATUS = {
15const STATUS = {
15 INPUT: 'INPUT',
16 INPUT: 'INPUT',
16 SENDING: 'SENDING',
17 SENDING: 'SENDING',
@@ -24,7 +25,7 @@ const InviteUrl = () => {
24 const [error, setError] = useState();
25 const [error, setError] = useState();
25
26
26 const generateInvite = useCallback(async () => {
27 const generateInvite = useCallback(async () => {
27− const errors = await generateInvites(1);
28+ const { errors } = await generateInvites(1);
28 if (hasErrors(errors)) {
29 if (hasErrors(errors)) {
29 setError(errors);
30 setError(errors);
30 }
31 }
@@ -91,7 +92,12 @@ const InviteUrl = () => {
91 )}
92 )}
92 {invites.length === 0 && renderGenerateButton()}
93 {invites.length === 0 && renderGenerateButton()}
93 {needFunds && <Grid.Item full as={NeedFundsNotice} {...needFunds} />}
94 {needFunds && <Grid.Item full as={NeedFundsNotice} {...needFunds} />}
95+ {error[FORM_ERROR] ||
96+ (error[WARNING] && (
94− {error && <Grid.Item as={ErrorText}>{JSON.stringify(error)}</Grid.Item>}
97+ <Grid.Item as={ErrorText}>
98+ {error[FORM_ERROR] || error[WARNING]}
99+ </Grid.Item>
100+ ))}
95 </Grid.Item>
101 </Grid.Item>
96 );
102 );
97};
103};