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

pc/modals: Disable submit buttons on when Formik isSubmitting #2401

Merged
Merged
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ The types of changes are:

* Home screen header scaling and responsiveness issues [#2200](https://github.com/ethyca/fides/pull/2277)
* Added a feature flag for the recent dataset classification UX changes [#2335](https://github.com/ethyca/fides/pull/2335)
* Privacy Center identity inputs validate even when they are optional. [#2308](https://github.com/ethyca/fides/pull/2308)
* Privacy Center
* Identity inputs validate even when they are optional. [#2308](https://github.com/ethyca/fides/pull/2308)
* Submit buttons show loading state and disable while submitting. [#2401](https://github.com/ethyca/fides/pull/2401)
* Phone inputs no longer request country SVGs from external domain. [#2378](https://github.com/ethyca/fides/pull/2378)
* Input validation errors no longer change the height of modals. [#2379](https://github.com/ethyca/fides/pull/2379)
* Patch masking strategies to better handle null and non-string inputs [#2307](https://github.com/ethyca/fides/pull/2377)

### Security
Expand Down
11 changes: 5 additions & 6 deletions clients/privacy-center/components/modals/VerificationForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useEffect } from "react";
import {
Button,
chakra,
Expand Down Expand Up @@ -40,7 +40,6 @@ const useVerificationForm = ({
verificationType: VerificationType;
successHandler: () => void;
}) => {
const [isLoading, setIsLoading] = useState(false);
const toast = useToast();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [verificationCode, setVerificationCode] = useLocalStorage(
Expand All @@ -56,8 +55,6 @@ const useVerificationForm = ({
code: "",
},
onSubmit: async (values) => {
setIsLoading(true);

const body = {
code: values.code,
};
Expand Down Expand Up @@ -123,7 +120,7 @@ const useVerificationForm = ({
},
});

return { ...formik, isLoading, resetVerificationProcess };
return { ...formik, resetVerificationProcess };
};

type VerificationFormProps = {
Expand Down Expand Up @@ -153,6 +150,7 @@ const VerificationForm: React.FC<VerificationFormProps> = ({
touched,
values,
isValid,
isSubmitting,
dirty,
resetForm,
resetVerificationProcess,
Expand Down Expand Up @@ -209,7 +207,8 @@ const VerificationForm: React.FC<VerificationFormProps> = ({
_hover={{ bg: "primary.400" }}
_active={{ bg: "primary.500" }}
colorScheme="primary"
disabled={!(isValid && dirty)}
isLoading={isSubmitting}
isDisabled={isSubmitting || !(isValid && dirty)}
size="sm"
>
Submit code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useEffect } from "react";
import {
Button,
chakra,
Expand Down Expand Up @@ -42,16 +42,13 @@ const useConsentRequestForm = ({
}) => {
const identityInputs =
config.consent?.identity_inputs ?? defaultIdentityInput;
const [isLoading, setIsLoading] = useState(false);
const toast = useToast();
const formik = useFormik({
initialValues: {
email: "",
phone: "",
},
onSubmit: async (values) => {
setIsLoading(true);

const body = {
email: values.email,
phone_number: values.phone,
Expand Down Expand Up @@ -116,7 +113,7 @@ const useConsentRequestForm = ({
}),
});

return { ...formik, isLoading, identityInputs };
return { ...formik, identityInputs };
};

type ConsentRequestFormProps = {
Expand Down Expand Up @@ -144,6 +141,7 @@ const ConsentRequestForm: React.FC<ConsentRequestFormProps> = ({
touched,
values,
isValid,
isSubmitting,
dirty,
setFieldValue,
resetForm,
Expand Down Expand Up @@ -225,7 +223,8 @@ const ConsentRequestForm: React.FC<ConsentRequestFormProps> = ({
_hover={{ bg: "primary.400" }}
_active={{ bg: "primary.500" }}
colorScheme="primary"
disabled={!(isValid && dirty)}
isLoading={isSubmitting}
isDisabled={isSubmitting || !(isValid && dirty)}
size="sm"
>
Continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Text,
useToast,
} from "@fidesui/react";
import React, { useEffect, useState } from "react";
import React, { useEffect } from "react";
import { useFormik } from "formik";
import * as Yup from "yup";
import { Headers } from "headers-polyfill";
Expand Down Expand Up @@ -44,7 +44,6 @@ const usePrivacyRequestForm = ({
isVerificationRequired: boolean;
}) => {
const identityInputs = action?.identity_inputs ?? defaultIdentityInput;
const [isLoading, setIsLoading] = useState(false);
const toast = useToast();
const formik = useFormik({
initialValues: {
Expand All @@ -58,8 +57,6 @@ const usePrivacyRequestForm = ({
return;
}

setIsLoading(true);

const body = [
{
identity: {
Expand Down Expand Up @@ -143,7 +140,7 @@ const usePrivacyRequestForm = ({
}),
});

return { ...formik, isLoading, identityInputs };
return { ...formik, identityInputs };
};

type PrivacyRequestFormProps = {
Expand Down Expand Up @@ -176,6 +173,7 @@ const PrivacyRequestForm: React.FC<PrivacyRequestFormProps> = ({
touched,
values,
isValid,
isSubmitting,
dirty,
resetForm,
identityInputs,
Expand Down Expand Up @@ -276,7 +274,8 @@ const PrivacyRequestForm: React.FC<PrivacyRequestFormProps> = ({
_hover={{ bg: "primary.400" }}
_active={{ bg: "primary.500" }}
colorScheme="primary"
disabled={!(isValid && dirty)}
isLoading={isSubmitting}
isDisabled={isSubmitting || !(isValid && dirty)}
size="sm"
>
Continue
Expand Down