added success toast

This commit is contained in:
plebbitor
2023-03-15 17:34:31 +01:00
parent 92e34fa5e8
commit 59cffb9dfc
5 changed files with 35 additions and 15 deletions
+1
View File
@@ -38,6 +38,7 @@ const StyledContainer = styled(ToastContainer)`
font-size: 11pt; font-size: 11pt;
animation-duration: 0s; animation-duration: 0s;
border: 1px solid #fee9cd; border: 1px solid #fee9cd;
color: #c5c8c6;
} }
`; `;
+6 -5
View File
@@ -8,6 +8,7 @@ import { useFeed, useAccountsActions } from '@plebbit/plebbit-react-hooks';
import InfiniteScroll from 'react-infinite-scroller'; import InfiniteScroll from 'react-infinite-scroller';
import { Tooltip } from 'react-tooltip'; import { Tooltip } from 'react-tooltip';
import onError from '../utils/onError'; import onError from '../utils/onError';
import onSuccess from '../utils/onSuccess';
import getDate from '../utils/getDate'; import getDate from '../utils/getDate';
import renderComments from '../utils/renderComments'; import renderComments from '../utils/renderComments';
import SettingsModal from './SettingsModal'; import SettingsModal from './SettingsModal';
@@ -169,11 +170,11 @@ const Board = ({ setBodyStyle }) => {
const onChallengeVerification = (challengeVerification) => { const onChallengeVerification = (challengeVerification) => {
if (challengeVerification.challengeSuccess === true) { if (challengeVerification.challengeSuccess === true) {
console.log('challenge success', {publishedCid: challengeVerification.publication.cid}) onSuccess('challenge success', {publishedCid: challengeVerification.publication.cid})
} }
else if (challengeVerification.challengeSuccess === false) { else if (challengeVerification.challengeSuccess === false) {
console.error('challenge failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); onError('challenge failed', {reason: challengeVerification.reason, errors: challengeVerification.errors});
alert("Error: You seem to have mistyped the CAPTCHA. Please try again."); onError("Error: You seem to have mistyped the CAPTCHA. Please try again.");
} }
} }
@@ -184,7 +185,7 @@ const Board = ({ setBodyStyle }) => {
challengeAnswers = await getChallengeAnswersFromUser(challenges) challengeAnswers = await getChallengeAnswersFromUser(challenges)
} }
catch (error) { catch (error) {
console.log(error); onError(error);
} }
if (challengeAnswers) { if (challengeAnswers) {
await comment.publishChallengeAnswers(challengeAnswers) await comment.publishChallengeAnswers(challengeAnswers)
@@ -217,7 +218,7 @@ const Board = ({ setBodyStyle }) => {
}; };
challengeImg.onerror = () => { challengeImg.onerror = () => {
reject(new Error('Could not load challenge image')); reject(onError('Could not load challenge image'));
}; };
}); });
}; };
+6 -5
View File
@@ -8,6 +8,7 @@ import { useFeed, useAccountsActions } from '@plebbit/plebbit-react-hooks';
import ImageBanner from './ImageBanner'; import ImageBanner from './ImageBanner';
import CaptchaModal from './CaptchaModal'; import CaptchaModal from './CaptchaModal';
import onError from '../utils/onError'; import onError from '../utils/onError';
import onSuccess from '../utils/onSuccess';
import InfiniteScroll from 'react-infinite-scroller'; import InfiniteScroll from 'react-infinite-scroller';
@@ -140,11 +141,11 @@ const Catalog = ({ setBodyStyle }) => {
const onChallengeVerification = (challengeVerification) => { const onChallengeVerification = (challengeVerification) => {
if (challengeVerification.challengeSuccess === true) { if (challengeVerification.challengeSuccess === true) {
console.log('challenge success', {publishedCid: challengeVerification.publication.cid}) onSuccess('challenge success', {publishedCid: challengeVerification.publication.cid})
} }
else if (challengeVerification.challengeSuccess === false) { else if (challengeVerification.challengeSuccess === false) {
console.error('challenge failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); onError('challenge failed', {reason: challengeVerification.reason, errors: challengeVerification.errors});
alert("Error: You seem to have mistyped the CAPTCHA. Please try again."); onError("Error: You seem to have mistyped the CAPTCHA. Please try again.");
} }
} }
@@ -155,7 +156,7 @@ const Catalog = ({ setBodyStyle }) => {
challengeAnswers = await getChallengeAnswersFromUser(challenges) challengeAnswers = await getChallengeAnswersFromUser(challenges)
} }
catch (error) { catch (error) {
console.log(error); onError(error);
} }
if (challengeAnswers) { if (challengeAnswers) {
await comment.publishChallengeAnswers(challengeAnswers) await comment.publishChallengeAnswers(challengeAnswers)
@@ -188,7 +189,7 @@ const Catalog = ({ setBodyStyle }) => {
}; };
challengeImg.onerror = () => { challengeImg.onerror = () => {
reject(new Error('Could not load challenge image')); reject(onError('Could not load challenge image'));
}; };
}); });
}; };
+6 -5
View File
@@ -8,6 +8,7 @@ import ImageBanner from './ImageBanner';
import CaptchaModal from './CaptchaModal'; import CaptchaModal from './CaptchaModal';
import { Tooltip } from 'react-tooltip'; import { Tooltip } from 'react-tooltip';
import onError from '../utils/onError'; import onError from '../utils/onError';
import onSuccess from '../utils/onSuccess';
import getDate from '../utils/getDate'; import getDate from '../utils/getDate';
import renderThreadComments from '../utils/renderThreadComments'; import renderThreadComments from '../utils/renderThreadComments';
@@ -136,11 +137,11 @@ const Thread = ({ setBodyStyle }) => {
const onChallengeVerification = (challengeVerification) => { const onChallengeVerification = (challengeVerification) => {
if (challengeVerification.challengeSuccess === true) { if (challengeVerification.challengeSuccess === true) {
console.log('challenge success', {publishedCid: challengeVerification.publication.cid}) onSuccess('challenge success', {publishedCid: challengeVerification.publication.cid})
} }
else if (challengeVerification.challengeSuccess === false) { else if (challengeVerification.challengeSuccess === false) {
console.error('challenge failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); onError('challenge failed', {reason: challengeVerification.reason, errors: challengeVerification.errors});
alert("Error: You seem to have mistyped the CAPTCHA. Please try again."); onError("Error: You seem to have mistyped the CAPTCHA. Please try again.");
} }
} }
@@ -151,7 +152,7 @@ const Thread = ({ setBodyStyle }) => {
challengeAnswers = await getChallengeAnswersFromUser(challenges) challengeAnswers = await getChallengeAnswersFromUser(challenges)
} }
catch (error) { catch (error) {
console.log(error); onError(error);
} }
if (challengeAnswers) { if (challengeAnswers) {
await comment.publishChallengeAnswers(challengeAnswers) await comment.publishChallengeAnswers(challengeAnswers)
@@ -184,7 +185,7 @@ const Thread = ({ setBodyStyle }) => {
}; };
challengeImg.onerror = () => { challengeImg.onerror = () => {
reject(new Error('Could not load challenge image')); reject(onError('Could not load challenge image'));
}; };
}); });
}; };
+16
View File
@@ -0,0 +1,16 @@
import { toast } from 'react-toastify';
const onSuccess = (success) => {
return toast.success(success.toString(), {
position: "top-right",
autoClose: 3000,
hideProgressBar: false,
closeOnClick: false,
pauseOnHover: true,
draggable: false,
progress: undefined,
theme: "dark",
});
};
export default onSuccess;