on master help sign in
invites: display errors correctly

Instead of passing in some invites object, pass in error strings.

commit5fc55cb495a120d0f62cc2e46feaabe69f5fccc3 authorFang <git@fang.io> dateTue 21 Jul 2020, 23:30 (6 years ago) parent059ed84
1 file changed+13−5
src/lib/useInviter.js+13−5
src/lib/useInviter.js+13−5
@@ -159,7 +159,7 @@ const useInviter = () => {
159159 () => setNeedFunds(undefined)
160160 );
161161
162− let unsentInvites = [];
162+ let inviteErrors = [];
163163 let confirmedInvites = [];
164164 const txAndMailings = signedInvites.map(async invite => {
165165 try {
@@ -172,8 +172,12 @@ const useInviter = () => {
172172 await waitForTransactionConfirm(_web3, txHash);
173173 confirmedInvites.push(invite);
174174 } catch (error) {
175− console.error(error);
176− unsentInvites.push(invite);
175+ console.error('Error sending invite tx:', error);
176+ if (typeof error === 'string') {
177+ inviteErrors.push(error);
178+ } else if (typeof error === 'object' && error.message) {
179+ inviteErrors.push(error.message);
180+ }
177181 return;
178182 }
179183 });
@@ -183,8 +187,12 @@ const useInviter = () => {
183187 setTxStatus(STATUS.SUCCESS);
184188 setInvites(confirmedInvites);
185189
186− if (unsentInvites.length > 0) {
187− return { errors: { [FORM_ERROR]: unsentInvites } };
190+ if (inviteErrors.length > 0) {
191+ return {
192+ errors: {
193+ [FORM_ERROR]: ['Error sending invites: ', ...inviteErrors],
194+ },
195+ };
188196 }
189197
190198 if (errorCount > 0) {