From d523c7f0f3c49ac3afb763e87af283babb5b8e0a Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 15 Jun 2022 12:35:37 +0100 Subject: [PATCH 1/2] Retry failed transactions during publish (#1511) * allow multiple runs of handleSubmit * collect what we need in local state for reuse after method has run * run each step conditionally * split up handleSubmit * switch submit button text * empty values.feedback fix * error copy * tiny logic fix for consistency * code comments * submit button fixes * add loader during submission * add new white loader style * button style override fixes --- .../@shared/atoms/Button/index.module.css | 9 - .../@shared/atoms/Loader/index.module.css | 5 + src/components/@shared/atoms/Loader/index.tsx | 5 +- .../Publish/Actions/index.module.css | 1 + src/components/Publish/Actions/index.tsx | 17 +- src/components/Publish/Submission/index.tsx | 4 - src/components/Publish/index.tsx | 236 +++++++++++------- 7 files changed, 168 insertions(+), 109 deletions(-) diff --git a/src/components/@shared/atoms/Button/index.module.css b/src/components/@shared/atoms/Button/index.module.css index e187b43cf..63a509ea2 100644 --- a/src/components/@shared/atoms/Button/index.module.css +++ b/src/components/@shared/atoms/Button/index.module.css @@ -20,15 +20,6 @@ text-align: center; } -.button:first-child { - margin-left: 0; -} - -.button:last-child { - margin-right: 0; - min-width: auto; -} - .button:hover, .button:focus { color: var(--brand-white); diff --git a/src/components/@shared/atoms/Loader/index.module.css b/src/components/@shared/atoms/Loader/index.module.css index 8519d8f1a..319ab7dfb 100644 --- a/src/components/@shared/atoms/Loader/index.module.css +++ b/src/components/@shared/atoms/Loader/index.module.css @@ -23,6 +23,11 @@ margin-left: calc(var(--spacer) / 4); } +.loader.white { + border-color: rgba(255 255 255 / 0.3); + border-top-color: var(--brand-white); +} + @keyframes loader { to { transform: rotate(360deg); diff --git a/src/components/@shared/atoms/Loader/index.tsx b/src/components/@shared/atoms/Loader/index.tsx index b8a97987f..57c6070b3 100644 --- a/src/components/@shared/atoms/Loader/index.tsx +++ b/src/components/@shared/atoms/Loader/index.tsx @@ -3,12 +3,13 @@ import styles from './index.module.css' export interface LoaderProps { message?: string + white?: boolean } -export default function Loader({ message }: LoaderProps): ReactElement { +export default function Loader({ message, white }: LoaderProps): ReactElement { return (
- + {message && {message}}
) diff --git a/src/components/Publish/Actions/index.module.css b/src/components/Publish/Actions/index.module.css index 6d7145403..74ebd03bd 100644 --- a/src/components/Publish/Actions/index.module.css +++ b/src/components/Publish/Actions/index.module.css @@ -7,6 +7,7 @@ .actions button { margin: 0 calc(var(--spacer) / 2); + min-height: 40px; } .infoIcon { diff --git a/src/components/Publish/Actions/index.tsx b/src/components/Publish/Actions/index.tsx index 339a264f9..ee0160559 100644 --- a/src/components/Publish/Actions/index.tsx +++ b/src/components/Publish/Actions/index.tsx @@ -10,6 +10,7 @@ import { useRouter } from 'next/router' import Tooltip from '@shared/atoms/Tooltip' import AvailableNetworks from 'src/components/Publish/AvailableNetworks' import Info from '@images/info.svg' +import Loader from '@shared/atoms/Loader' export default function Actions({ scrollToRef, @@ -24,8 +25,7 @@ export default function Actions({ values, errors, isValid, - isSubmitting, - setFieldValue + isSubmitting }: FormikContextType = useFormikContext() const { connect, accountId } = useWeb3() @@ -60,6 +60,11 @@ export default function Actions({ (values.user.stepCurrent === 2 && errors.services !== undefined) || (values.user.stepCurrent === 3 && errors.pricing !== undefined) + const hasSubmitError = + values.feedback?.[1].status === 'error' || + values.feedback?.[2].status === 'error' || + values.feedback?.[3].status === 'error' + return (