on master help sign in
Actually render error messages

And prints tickets for invites that sent, but never went out over email.

commit510f315a87943b690badf847bbcb2e019db62ae8 authorFang <git@fang.io> dateMon 29 Jul 2019, 19:50 (7 years ago) parentd663652
1 file changed+22−18
src/views/Invite/InviteEmail.js+22−18
src/views/Invite/InviteEmail.js+22−18
@@ -322,7 +322,8 @@ export default function InviteEmail() {
322322 setStatus(STATUS.SENDING);
323323 clearReceipts();
324324
325− let errorCount = 0;
325+ let unsentInvites = [];
326+ let orphanedInvites = [];
326327 const txAndMailings = inputs.map(async input => {
327328 const invite = invites[input.name];
328329 try {
@@ -337,10 +338,7 @@ export default function InviteEmail() {
337338 if (!didConfirm) throw new Error();
338339 } catch (error) {
339340 console.error(error);
340− errorCount++;
341− addError({
342− [input.name]: `Transaction Failure for ${invite.email}`,
343− });
341+ unsentInvites.push(invite);
344342 return;
345343 }
346344
@@ -354,11 +352,7 @@ export default function InviteEmail() {
354352 if (!success) throw new Error('Failed to send mail');
355353 } catch (error) {
356354 console.error(error);
357− errorCount++;
358− //TODO make sure this actually gets displayed
359− addError({
360− [input.name]: `Mailing Failure for ${invite.email}, please send them this code manually: ${invite.ticket}`,
361− });
355+ orphanedInvites.push(invite);
362356 }
363357
364358 addReceipt({ [input.name]: true });
@@ -366,13 +360,24 @@ export default function InviteEmail() {
366360
367361 await Promise.all(txAndMailings);
368362 // if there are any receipt errors, throw a general error
369− if (errorCount > 0) {
370− throw new Error(
371− `There ${pluralize(errorCount, 'was', 'were')} ${pluralize(
372− errorCount,
373− 'error'
374− )} while sending transactions.`
375− );
363+ let errorString = '';
364+ if (orphanedInvites.length > 0) {
365+ errorString =
366+ 'Not all invite emails were sent. ' +
367+ 'Please send the following invite codes manually: ' +
368+ orphanedInvites.map(i => `${i.email}: ${i.ticket}`).join(', ') +
369+ '. ';
370+ }
371+ if (unsentInvites.length > 0) {
372+ errorString =
373+ errorString +
374+ 'Not all invites were created. ' +
375+ 'Did not send invites for: ' +
376+ unsentInvites.map(i => i.email).join(', ') +
377+ '.';
378+ }
379+ if (errorString !== '') {
380+ throw new Error(errorString);
376381 }
377382 }, [
378383 web3,
@@ -382,7 +387,6 @@ export default function InviteEmail() {
382387 invites,
383388 point,
384389 wallet,
385− addError,
386390 sendMail,
387391 ]);
388392