Skip to content

Commit

Permalink
distinguish between FileError and ServerError
Browse files Browse the repository at this point in the history
  • Loading branch information
dsamojlenko committed Oct 8, 2024
1 parent 1d37bef commit 5ac18e3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions components/clientComponents/forms/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
import { filterShownElements, filterValuesByShownElements } from "@lib/formContext";
import { formHasGroups } from "@lib/utils/form-builder/formHasGroups";
import { showReviewPage } from "@lib/utils/form-builder/showReviewPage";
import { t } from "i18next";

interface SubmitButtonProps {
numberOfRequiredQuestions: number;
Expand Down Expand Up @@ -170,7 +169,12 @@ const InnerForm: React.FC<InnerFormProps> = (props) => {
const errorList = props.errors ? getErrorList(props) : null;
const errorId = "gc-form-errors";
const serverErrorId = `${errorId}-server`;
const formStatusError = props.status === "Error" ? props.errors.form || t("server-error") : null;
const formStatusError =
props.status === "FileError"
? t("input-validation.file-submission")
: props.status === "Error"
? t("server-error")
: null;

// If there are errors on the page, set focus the first error field
useEffect(() => {
Expand Down Expand Up @@ -391,12 +395,7 @@ export const Form = withFormik<FormProps, Responses>({
);

if (result.error) {
formikBag.setStatus("Error");
if (result.error.message.includes("FileValidationResult")) {
formikBag.setErrors({
form: t("input-validation.file-submission"),
});
}
formikBag.setStatus("FileError");
} else {
formikBag.props.onSuccess(result.id);
}
Expand Down

0 comments on commit 5ac18e3

Please sign in to comment.