cleared debug, updated new appeal add about you

This commit is contained in:
2022-05-31 10:15:03 +01:00
parent 55a9a15a57
commit f2e71c0b54
49 changed files with 161396 additions and 500 deletions
+80 -39
View File
@@ -3,6 +3,8 @@ import useTranslation from "next-translate/useTranslation";
import { useRouter } from "next/router";
import { connect } from "react-redux";
import { Field, formValueSelector, reduxForm } from "redux-form";
import { useState } from "react";
import transLookup from "../../data/lookuptranslations.json";
import {
setAppealLPA,
@@ -12,6 +14,7 @@ import {
import { getFormCollectionByID } from "../utils";
import FileUpload from "./fileupload";
import Aboutyou from "./aboutyou";
import { createNewCase } from "../../actions";
let CreateCase = (props) => {
// useEffect(() => {
@@ -208,6 +211,8 @@ let CreateCase = (props) => {
const required = (value) => (value ? undefined : "Required");
const [formStep, setFormStep] = useState(0);
const onHandleSubmit = (values) => {
event.preventDefault();
@@ -215,48 +220,84 @@ let CreateCase = (props) => {
appTypeCollection = getFormCollectionByID(appTypeCollection);
router.replace(
"/newappeal" +
"/" +
appTypeCollection.UrlName +
"?lpa=" +
values.lpaTypes +
"&apt=" +
values.appealTypes.split(",")[0],
null,
{
shallow: true,
}
);
formStep == 0 && setFormStep(1);
// console.log(values);
// console.log(props.loggedInUser);
createNewCase(
appTypeCollection.appealTypeID,
values.lpaTypes,
props.loggedInUser,
values
)
.then((data) => {
router.replace(
"/newappeal" +
"/" +
appTypeCollection.UrlName +
"?lpa=" +
values.lpaTypes +
"&apt=" +
values.appealTypes.split(",")[0] +
"&id=" +
data.incidentid
);
return data;
})
.catch(({ err }) => {
console.log(err);
});
// router.replace(
// "/newappeal" +
// "/" +
// appTypeCollection.UrlName +
// "?lpa=" +
// values.lpaTypes +
// "&apt=" +
// values.appealTypes.split(",")[0],
// null,
// {
// shallow: true,
// }
// );
};
return (
<form onSubmit={handleSubmit(onHandleSubmit)}>
{/* <Aboutyou /> */}
<Field
name="lpaTypes"
component={RenderLPAList}
optionsObj={lpaOptionsObj}
validate={[required]}
label={t("newappeal:select-lpa-label")}
errorMsg={t("newappeal:select-lpa-label-error-msg")}
/>
<Field
name="appealTypes"
component={RenderAppealTypeList}
optionsObj={appealOptionsObj}
validate={[required]}
label={t("newappeal:select-appeal-type-label")}
errorMsg={t("newappeal:select-appeal-type-label-error-msg")}
/>
<button
type="submit"
className="govuk-button"
data-module="govuk-button"
>
{t("common:continue-button")}
</button>
</form>
<>
{formStep == 0 ? (
<Aboutyou setFormStep={setFormStep} />
) : (
<form onSubmit={handleSubmit(onHandleSubmit)}>
<Field
name="lpaTypes"
component={RenderLPAList}
optionsObj={lpaOptionsObj}
validate={[required]}
label={t("newappeal:select-lpa-label")}
errorMsg={t("newappeal:select-lpa-label-error-msg")}
/>
<Field
name="appealTypes"
component={RenderAppealTypeList}
optionsObj={appealOptionsObj}
validate={[required]}
label={t("newappeal:select-appeal-type-label")}
errorMsg={t(
"newappeal:select-appeal-type-label-error-msg"
)}
/>
<button
type="submit"
className="govuk-button"
data-module="govuk-button"
>
{t("common:continue-button")}
</button>
</form>
)}
</>
);
};