validate required on submit not blur
This commit is contained in:
@@ -2,7 +2,7 @@ import useTranslation from "next-translate/useTranslation";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Field, reduxForm } from "redux-form";
|
import { Field, reduxForm, SubmissionError } from "redux-form";
|
||||||
import { sendGAEvent } from "@next/third-parties/google";
|
import { sendGAEvent } from "@next/third-parties/google";
|
||||||
|
|
||||||
const required = (errorMsg) => (value) =>
|
const required = (errorMsg) => (value) =>
|
||||||
@@ -84,15 +84,23 @@ let CaseSearch = (props) => {
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
const onHandleSubmit = (values) => {
|
const onHandleSubmit = (values) => {
|
||||||
//spinnerState();
|
if (Object.keys(values).length === 0) {
|
||||||
router.push({
|
console.log(props.error);
|
||||||
pathname:
|
|
||||||
router.locale == "cy"
|
throw new SubmissionError({
|
||||||
? "/fymhorth/canlyniadauchwilio"
|
basicSearch: t("myportal:searchcases-validation-required"),
|
||||||
: "/myportal/searchresults",
|
_error: "required",
|
||||||
query: { q: values.basicSearch },
|
});
|
||||||
shallow: true,
|
} else {
|
||||||
});
|
router.push({
|
||||||
|
pathname:
|
||||||
|
router.locale == "cy"
|
||||||
|
? "/fymhorth/canlyniadauchwilio"
|
||||||
|
: "/myportal/searchresults",
|
||||||
|
query: { q: values.basicSearch },
|
||||||
|
shallow: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -106,11 +114,6 @@ let CaseSearch = (props) => {
|
|||||||
|
|
||||||
<Field
|
<Field
|
||||||
validate={[
|
validate={[
|
||||||
required(
|
|
||||||
t(
|
|
||||||
"myportal:searchcases-validation-required"
|
|
||||||
)
|
|
||||||
),
|
|
||||||
minLength(
|
minLength(
|
||||||
t(
|
t(
|
||||||
"myportal:searchcases-validation-minlength"
|
"myportal:searchcases-validation-minlength"
|
||||||
|
|||||||
Reference in New Issue
Block a user