added hcas diagnostic choice

This commit is contained in:
2022-06-14 17:08:11 +01:00
parent b588927e20
commit cb9995da75
4 changed files with 176 additions and 53 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ export function Textfield(props) {
// console.log(parentField, showIfHasParentShowValue); // console.log(parentField, showIfHasParentShowValue);
// console.log(parentField, formProps, form); // console.log(parentField, formProps, form);
//console.log("validation props:", validation); console.log("validation props:", validation);
return ( return (
<div className="govuk-form-group"> <div className="govuk-form-group">
+12 -9
View File
@@ -239,6 +239,8 @@ let AboutYou = (props) => {
...custom ...custom
}) => { }) => {
let { t } = useTranslation(); let { t } = useTranslation();
const required = (value) => (value ? undefined : "Required");
return ( return (
<> <>
<div <div
@@ -298,6 +300,7 @@ let AboutYou = (props) => {
type="radio" type="radio"
className="govuk-radios__input" className="govuk-radios__input"
value={options[key].split("|")[0]} value={options[key].split("|")[0]}
validate={[required]}
// checked={ // checked={
// value == // value ==
// parseInt(options[key].split("|")[0]) // parseInt(options[key].split("|")[0])
@@ -393,12 +396,12 @@ let AboutYou = (props) => {
label={label} label={label}
options={fieldOptions} options={fieldOptions}
id={name} id={name}
//validate={[required]} validate={[required]}
errorMsg="Select an option" errorMsg="Select an option"
component={RenderRadio} component={RenderRadio}
inline={props.inline} inline={props.inline}
hint={props.hint} hint={props.hint}
validate={eval(validation)} //validate={eval(validation)}
requiredDocumentLabel={props.requiredDocumentLabel} requiredDocumentLabel={props.requiredDocumentLabel}
requiredDocumentValue={props.requiredDocumentValue} requiredDocumentValue={props.requiredDocumentValue}
setDocumentsList={props.setDocumentsList} setDocumentsList={props.setDocumentsList}
@@ -412,12 +415,12 @@ let AboutYou = (props) => {
label={label} label={label}
options={fieldOptions} options={fieldOptions}
id={name} id={name}
//validate={[required]} validate={[required]}
errorMsg="Select an option" errorMsg="Select an option"
component={RenderRadio} component={RenderRadio}
inline={props.inline} inline={props.inline}
hint={props.hint} hint={props.hint}
validate={eval(validation)} //validate={eval(validation)}
requiredDocumentLabel={props.requiredDocumentLabel} requiredDocumentLabel={props.requiredDocumentLabel}
requiredDocumentValue={props.requiredDocumentValue} requiredDocumentValue={props.requiredDocumentValue}
setDocumentsList={props.setDocumentsList} setDocumentsList={props.setDocumentsList}
@@ -504,7 +507,7 @@ let AboutYou = (props) => {
options="[846040000|newappeal:about-you-who-are-you-label-appellant,846040001|newappeal:about-you-who-are-you-label-agent]" options="[846040000|newappeal:about-you-who-are-you-label-appellant,846040001|newappeal:about-you-who-are-you-label-agent]"
id={"pinswg_appellantagent"} id={"pinswg_appellantagent"}
className="govuk-radios__input" className="govuk-radios__input"
//validate={[required]} validate={"[required]"}
errorMsg="Select an option" errorMsg="Select an option"
/> />
@@ -579,7 +582,7 @@ let AboutYou = (props) => {
options="[846040000|newappeal:about-you-agent-contact-preferences-value-email,846040001|newappeal:about-you-agent-contact-preferences-value-post]" options="[846040000|newappeal:about-you-agent-contact-preferences-value-email,846040001|newappeal:about-you-agent-contact-preferences-value-post]"
id={"pinswg_contactprefs"} id={"pinswg_contactprefs"}
className="govuk-radios__input" className="govuk-radios__input"
validate={[required]} validate={"[required]"}
errorMsg="Select an option" errorMsg="Select an option"
/> />
<Radiofield <Radiofield
@@ -591,8 +594,8 @@ let AboutYou = (props) => {
options="[846040000|newappeal:about-you-agent-language-preferences-value-english,846040001|newappeal:about-you-agent-language-preferences-value-welsh]" options="[846040000|newappeal:about-you-agent-language-preferences-value-english,846040001|newappeal:about-you-agent-language-preferences-value-welsh]"
id={"pinswg_languagepreference"} id={"pinswg_languagepreference"}
className="govuk-radios__input" className="govuk-radios__input"
validate={[required]} validate={"[required]"}
errorMsg="Select an option" errorMsg="Select an optionqqq"
/> />
</> </>
)} )}
@@ -749,7 +752,7 @@ let AboutYou = (props) => {
id={"pinswg_languagepreference"} id={"pinswg_languagepreference"}
className="govuk-radios__input" className="govuk-radios__input"
validate={[required]} validate={[required]}
errorMsg="Select an option" errorMsg="Select an optionwww"
/> />
</> </>
)} )}
+162 -43
View File
@@ -156,7 +156,7 @@ let CreateCase = (props) => {
className="govuk-select" className="govuk-select"
id="appealTypes" id="appealTypes"
name={name} name={name}
onChange={(e) => props.onChangeSelectAppealType(e)} //onChange={(e) => props.onChangeSelectAppealType(e)}
> >
<option value="" disabled defaultValue> <option value="" disabled defaultValue>
{t("common:drop-down-select")} {t("common:drop-down-select")}
@@ -210,7 +210,7 @@ let CreateCase = (props) => {
); );
}; };
const RenderYesNo = ({ const RenderRadio = ({
datafieldname, datafieldname,
name, name,
label, label,
@@ -221,6 +221,9 @@ let CreateCase = (props) => {
meta: { touched, error }, meta: { touched, error },
...custom ...custom
}) => { }) => {
let { t } = useTranslation();
const required = (value) => (value ? undefined : "Required");
console.log(custom.hint);
return ( return (
<> <>
<div <div
@@ -232,14 +235,14 @@ let CreateCase = (props) => {
> >
<fieldset <fieldset
className="govuk-fieldset" className="govuk-fieldset"
aria-describedby={id + "_label"} aria-describedby={datafieldname + "-hint"}
> >
<legend className="govuk-fieldset__legend govuk-fieldset__legend--s govuk-!-font-weight-regular"> <legend className="govuk-fieldset__legend govuk-fieldset__legend--s govuk-!-font-weight-regular">
<label <label
className="govuk-fieldset__heading govuk-body-m" className="govuk-fieldset__heading govuk-body-m"
id={id + "_label"} id={id + "_label"}
> >
{FieldsTranslations(label)} {label}
</label> </label>
</legend> </legend>
{touched && error && ( {touched && error && (
@@ -260,10 +263,9 @@ let CreateCase = (props) => {
: "govuk-radios govuk-radios--inline govuk-radios--small" : "govuk-radios govuk-radios--inline govuk-radios--small"
} }
> >
{custom.hint != false && ( {" "}
<div className="govuk-hint"> {custom.hint != undefined && (
{t(custom.hint)} <div className="govuk-hint">{custom.hint}</div>
</div>
)} )}
{Object.keys(options).map((key, index) => ( {Object.keys(options).map((key, index) => (
<div <div
@@ -276,20 +278,22 @@ let CreateCase = (props) => {
name={id} name={id}
component="input" component="input"
type="radio" type="radio"
hint={custom.hint}
className="govuk-radios__input" className="govuk-radios__input"
value={options[key]} value={options[key].split("|")[0]}
//checked={value == options[key]} validate={[required]}
// checked={
// value ==
// parseInt(options[key].split("|")[0])
// }
onChange={(e) => { onChange={(e) => {
let docListObj = let docListObj =
custom.documentList; custom.documentList;
if ( if (
custom.requiredDocumentValue == custom.requiredDocumentValue ==
"Yes" || "Yes"
custom.requiredDocumentValue ==
"Ydw"
) { ) {
e.target.value == "Ydw" || e.target.value != "846040000"
e.target.value == "Yes"
? (docListObj = ? (docListObj =
Object.assign( Object.assign(
docListObj, docListObj,
@@ -303,7 +307,6 @@ let CreateCase = (props) => {
"documentCheckList_" + "documentCheckList_" +
id id
]; ];
console.log(docListObj);
custom.setDocumentsList( custom.setDocumentsList(
docListObj docListObj
); );
@@ -314,7 +317,7 @@ let CreateCase = (props) => {
className="govuk-label govuk-radios__label" className="govuk-label govuk-radios__label"
htmlFor={id + "_" + index} htmlFor={id + "_" + index}
> >
{options[key]} {t(options[key].split("|")[1])}
</label> </label>
</div> </div>
))} ))}
@@ -324,6 +327,91 @@ let CreateCase = (props) => {
</> </>
); );
}; };
function Radiofield(props) {
const {
name,
label,
datafieldname,
parentField,
form,
formProps,
parentFieldShowOnValue,
validation,
} = props;
const router = useRouter();
const required = (value) => (value ? undefined : "Required");
// console.log(props.options);
const fieldOptions = props.options
.slice(1, props.options.length - 1)
.split(",");
//parentFieldShowOnValue
var showIfHasParentShowValue = parentField != false;
//debugger;
// parentField != false &&
// !_.isEmpty(formProps[form]) &&
// _.has(formProps[form].values, parentField) &&
// parentFieldShowOnValue.indexOf(
// formProps[form].values[parentField].toString()
// ) > -1;
(showIfHasParentShowValue == parentField) != false &&
showIfHasParentShowValue;
// console.log(
// datafieldname,
// showIfHasParentShowValue,
// formProps[form].values[parentField]
// );
return (
<>
{parentField != false ? (
showIfHasParentShowValue && (
<Field
name={name}
datafieldname={datafieldname}
label={label}
options={fieldOptions}
id={name}
validate={[required]}
errorMsg="Select an option"
component={RenderRadio}
inline={props.inline}
hint={props.hint}
//validate={eval(validation)}
requiredDocumentLabel={props.requiredDocumentLabel}
requiredDocumentValue={props.requiredDocumentValue}
setDocumentsList={props.setDocumentsList}
documentList={props.documentList}
/>
)
) : (
<Field
name={name}
datafieldname={datafieldname}
label={label}
options={fieldOptions}
id={name}
validate={[required]}
errorMsg="Select an option"
component={RenderRadio}
inline={props.inline}
hint={props.hint}
//validate={eval(validation)}
requiredDocumentLabel={props.requiredDocumentLabel}
requiredDocumentValue={props.requiredDocumentValue}
setDocumentsList={props.setDocumentsList}
documentList={props.documentList}
/>
)}
</>
);
}
const required = (value) => (value ? undefined : "Required"); const required = (value) => (value ? undefined : "Required");
const [formStep, setFormStep] = useState(0); const [formStep, setFormStep] = useState(0);
@@ -333,13 +421,33 @@ let CreateCase = (props) => {
var appTypeCollection = values.appealTypes; var appTypeCollection = values.appealTypes;
appTypeCollection = getFormCollectionByID(appTypeCollection);
formStep == 0 && setFormStep(1); formStep == 0 && setFormStep(1);
// console.log(values); whichAppealType =
values.appealTypes == "846040004" && values.confirmHASCAS == "true"
? "846040004"
: values.appealTypes == "846040004" &&
values.confirmHASCAS == "false"
? "846040000"
: values.appealTypes;
// console.log(props.loggedInUser); var whichAppealType = whichAppealType;
appTypeCollection = getFormCollectionByID(whichAppealType);
console.log(
"/newappeal" +
"/" +
appTypeCollection.UrlName +
"?lpa=" +
values.lpaTypes +
"&apt=" +
whichAppealType +
"&id=" //+
// data.incidentid
);
delete values.confirmHASCAS;
createNewCase( createNewCase(
appTypeCollection.appealTypeID, appTypeCollection.appealTypeID,
@@ -355,7 +463,7 @@ let CreateCase = (props) => {
"?lpa=" + "?lpa=" +
values.lpaTypes + values.lpaTypes +
"&apt=" + "&apt=" +
values.appealTypes.split(",")[0] + whichAppealType +
"&id=" + "&id=" +
data.incidentid data.incidentid
); );
@@ -364,6 +472,7 @@ let CreateCase = (props) => {
.catch(({ err }) => { .catch(({ err }) => {
console.log(err); console.log(err);
}); });
// router.replace( // router.replace(
// "/newappeal" + // "/newappeal" +
// "/" + // "/" +
@@ -380,6 +489,22 @@ let CreateCase = (props) => {
}; };
const yesNo = router.locale == "cy" ? ["Ydw", "Na"] : ["Yes", "No"]; const yesNo = router.locale == "cy" ? ["Ydw", "Na"] : ["Yes", "No"];
var parentField = "appealTypes",
formProps = props.whichForm,
form = "caseForm",
parentFieldShowOnValue = "846040004";
var showIfHasParentShowValue =
parentField != false &&
!_.isEmpty(formProps[form]) &&
_.has(formProps[form].values, parentField) &&
parentFieldShowOnValue.indexOf(
formProps[form].values[parentField].toString()
) > -1;
(showIfHasParentShowValue == parentField) != false &&
showIfHasParentShowValue;
return ( return (
<> <>
{formStep == 0 ? ( {formStep == 0 ? (
@@ -404,28 +529,22 @@ let CreateCase = (props) => {
"newappeal:select-appeal-type-label-error-msg" "newappeal:select-appeal-type-label-error-msg"
)} )}
/> />
{}
<Field
name={"confirmHASCAS"}
datafieldname={"confirmHASCAS"}
label={"Confirm HAS/CAS appeal is required"}
options={yesNo}
id={"confirmHASCAS"}
//validate={[required]}
errorMsg="Select an option"
component={RenderYesNo}
inline={true}
hint={
"This appeal route is only applicable if your application relates the refusal of planning permission, orthe refusal of an application to vary or remove a condition attached to a previous permision. All other applications will be submitted via a Section 78 Planning Appeal"
}
validate={[]}
requiredDocumentLabel={props.requiredDocumentLabel}
requiredDocumentValue={props.requiredDocumentValue}
setDocumentsList={props.setDocumentsList}
documentList={props.documentList}
/>
{showIfHasParentShowValue && (
<Radiofield
name={"confirmHASCAS"}
datafieldname={"confirmHASCAS"}
label={"Confirm HAS/CAS appeal is required"}
hint={
"This appeal route is only applicable if your application relates the refusal of planning permission, orthe refusal of an application to vary or remove a condition attached to a previous permision. All other applications will be submitted via a Section 78 Planning Appeal"
}
options="[true|Yes,false|No]"
id={"confirmHASCAS"}
className="govuk-radios__input"
validate={"[required]"}
errorMsg="Select an option"
/>
)}
<button <button
type="submit" type="submit"
className="govuk-button" className="govuk-button"
+1
View File
@@ -117,6 +117,7 @@ const Home = (props) => {
LPAData={props.LPAData} LPAData={props.LPAData}
appealType={props.setAppealType} appealType={props.setAppealType}
loggedInUser={props.accountDetails.loggedinUserId} loggedInUser={props.accountDetails.loggedinUserId}
whichForm={props.form}
/> />
</main> </main>
</div> </div>