From dcb8a0c6c68b80ce2a1c60538cfc1c2045223493 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 26 Nov 2021 10:11:25 +0000 Subject: [PATCH] fix `touched` overwrite, add pricing success condition --- .../Publish/Navigation/index.module.css | 4 +++ src/components/Publish/Navigation/index.tsx | 28 ++++++++++++++----- src/components/Publish/Pricing/Price.tsx | 16 ++--------- src/components/Publish/Services/index.tsx | 4 +-- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/components/Publish/Navigation/index.module.css b/src/components/Publish/Navigation/index.module.css index 8ffc67c12..75a1a4712 100644 --- a/src/components/Publish/Navigation/index.module.css +++ b/src/components/Publish/Navigation/index.module.css @@ -87,3 +87,7 @@ background: var(--brand-alert-green); border-color: transparent; } + +.success.current:before { + background: var(--font-color-heading); +} diff --git a/src/components/Publish/Navigation/index.tsx b/src/components/Publish/Navigation/index.tsx index 168351cd1..259167313 100644 --- a/src/components/Publish/Navigation/index.tsx +++ b/src/components/Publish/Navigation/index.tsx @@ -5,15 +5,31 @@ import { wizardSteps } from '../_constants' import styles from './index.module.css' export default function Navigation(): ReactElement { - const { values, errors, setFieldValue }: FormikContextType = - useFormikContext() + const { + values, + errors, + touched, + setFieldValue + }: FormikContextType = useFormikContext() function handleStepClick(step: number) { setFieldValue('user.stepCurrent', step) } - const isSuccessMetadata = errors.metadata === undefined - const isSuccessServices = errors.services === undefined + function getSuccessClass(step: number) { + const isSuccessMetadata = errors.metadata === undefined + const isSuccessServices = errors.services === undefined + const isSuccessPricing = + errors.pricing === undefined && touched.pricing?.price + const isSuccessPreview = false + + const isSuccess = + (step === 1 && isSuccessMetadata) || + (step === 2 && isSuccessServices) || + (step === 3 && isSuccessPricing) || + (step === 4 && isSuccessPreview) + return isSuccess ? styles.success : null + } return (