on master help sign in
fix incorrect error reporting on url invite
commitf83b9a575f004f2c7f5645e2fbdfa01561fa7e1f authorLiam Fitzgerald <liam@urizen.co> dateThu 9 Jan 2020, 12:32 (7 years ago) parentaa8b19d
1 file changed+9−3
src/views/Invite/Url.js+9−3
src/views/Invite/Url.js+9−3
@@ -1,6 +1,7 @@
11import React, { useCallback, useState } from 'react';
22import { Grid, ErrorText } from 'indigo-react';
33import { get } from 'lodash';
4+import { FORM_ERROR } from 'final-form';
45
56import useCopiable from 'lib/useCopiable';
67import useInviter from 'lib/useInviter';
@@ -10,7 +11,7 @@ import { ForwardButton } from 'components/Buttons';
1011import NeedFundsNotice from 'components/NeedFundsNotice';
1112
1213import { hasErrors } from 'form/validators';
13−
14+import { WARNING } from 'form/helpers';
1415const STATUS = {
1516 INPUT: 'INPUT',
1617 SENDING: 'SENDING',
@@ -24,7 +25,7 @@ const InviteUrl = () => {
2425 const [error, setError] = useState();
2526
2627 const generateInvite = useCallback(async () => {
27− const errors = await generateInvites(1);
28+ const { errors } = await generateInvites(1);
2829 if (hasErrors(errors)) {
2930 setError(errors);
3031 }
@@ -91,7 +92,12 @@ const InviteUrl = () => {
9192 )}
9293 {invites.length === 0 && renderGenerateButton()}
9394 {needFunds && <Grid.Item full as={NeedFundsNotice} {...needFunds} />}
94− {error && <Grid.Item as={ErrorText}>{JSON.stringify(error)}</Grid.Item>}
95+ {error[FORM_ERROR] ||
96+ (error[WARNING] && (
97+ <Grid.Item as={ErrorText}>
98+ {error[FORM_ERROR] || error[WARNING]}
99+ </Grid.Item>
100+ ))}
95101 </Grid.Item>
96102 );
97103};