Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide error message when value changes #13640

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import { Formik } from "formik";
import {
Col,
Expand Down Expand Up @@ -31,6 +31,11 @@ const Checkout = ({ product, quantity, action }: Props) => {
const productCanBeTrialled = product?.canBeTrialled;
const canTrial = canBeTrialled(productCanBeTrialled, userCanTrial);
const initialValues = getInitialFormValues(product, canTrial, userInfo);
const [formChanged, setFormChanged] = useState({});

useEffect(() => {
error ? setError(null) : null;
}, [formChanged]);

if (!localStorage.getItem("gaEventTriggered")) {
localStorage.setItem("gaEventTriggered", "true");
Expand Down Expand Up @@ -65,6 +70,11 @@ const Checkout = ({ product, quantity, action }: Props) => {
</>
) : (
<Formik
innerRef={(formikActions) =>
formikActions && formikActions.errors
? setFormChanged(formikActions.values)
: setFormChanged({})
}
onSubmit={() => {}}
initialValues={initialValues}
enableReinitialize={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
queryClient.invalidateQueries("preview");
setIsButtonDisabled(false);
setIsEditing(false);
setError(null);

Check warning on line 93 in static/js/src/advantage/subscribe/checkout/components/UserInfoForm/UserInfoForm.tsx

View check run for this annotation

Codecov / codecov/patch

static/js/src/advantage/subscribe/checkout/components/UserInfoForm/UserInfoForm.tsx#L93

Added line #L93 was not covered by tests
},
onError: (error) => {
setFieldValue("Description", false);
Expand Down
32 changes: 16 additions & 16 deletions templates/account/checkout.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
endblock meta_copydoc %} {% block content %}

<div id="shop-checkout-app">
<div class="p-strip">
<div class="u-fixed-width">
<h1 class="p-heading--2">
Checkout
</h1>
</div>
<div class="p-strip">
<div class="u-fixed-width">
<h1 class="p-heading--2">
Checkout
</h1>
</div>
<div class="p-strip u-no-padding--top">
<div class="row">
<div class="u-no-margin--bottom p-card">
<div class="p-card__content">
<span class="p-text--default">
<i class="p-icon--spinner u-animation--spin"></i>
</span>
Loading…
</div>
</div>
</div>
<div class="p-strip u-no-padding--top">
<div class="row">
<div class="u-no-margin--bottom p-card">
<div class="p-card__content">
<span class="p-text--default">
<i class="p-icon--spinner u-animation--spin"></i>
</span>
Loading…
</div>
</div>
</div>
</div>
</div>

<script>
Expand Down
Loading