diff --git a/components/case/representation/representationCapacitySelection.js b/components/case/representation/representationCapacitySelection.js index 16ac04d6..e75265c4 100644 --- a/components/case/representation/representationCapacitySelection.js +++ b/components/case/representation/representationCapacitySelection.js @@ -61,7 +61,7 @@ let RepCapacitySelection = (props) => { options={capacityOptionsArr} id="representationCapacity" className="govuk-radios__input" - errorMsg="Select an option" + errorMsg={t("newappeal:select-an-option-label")} component={RenderRadioList} validate={[required]} /> diff --git a/components/elements/index.js b/components/elements/index.js index 42ef4ed4..8ddc18ab 100644 --- a/components/elements/index.js +++ b/components/elements/index.js @@ -108,7 +108,7 @@ export function Textfield(props) { // console.log(parentField, showIfHasParentShowValue); // console.log(parentField, formProps, form); - //console.log("validation props:", validation); + console.log("validation props:", validation); return (
@@ -621,6 +621,7 @@ const RenderYesNo = ({ export function YesNofield(props) { const router = useRouter(); + let { t } = useTranslation(); const { name, label, inline, validation } = props; const yesNo = router.locale == "cy" ? ["Ydw", "Na"] : ["Yes", "No"]; @@ -635,7 +636,7 @@ export function YesNofield(props) { id={props.name} className={"govuk-radios__input"} validate={eval(validation)} - errorMsg="Select an option" + errorMsg={t("newappeal:select-an-option-label")} component={RenderYesNo} inline={_.has(props, "inline") ? props.inline : "true"} requiredDocumentLabel={props.requiredDocumentLabel} @@ -773,6 +774,7 @@ export function Radiofield(props) { const router = useRouter(); const required = (value) => (value ? undefined : "Required"); // console.log(props.options); + let { t } = useTranslation(); const fieldOptions = props.options .slice(1, props.options.length - 1) @@ -807,7 +809,7 @@ export function Radiofield(props) { options={fieldOptions} id={name} //validate={[required]} - errorMsg="Select an option" + errorMsg={t("newappeal:select-an-option-label")} component={RenderRadio} inline={props.inline} hint={props.hint} @@ -826,7 +828,7 @@ export function Radiofield(props) { options={fieldOptions} id={name} //validate={[required]} - errorMsg="Select an option" + errorMsg={t("newappeal:select-an-option-label")} component={RenderRadio} inline={props.inline} hint={props.hint} @@ -930,7 +932,7 @@ export function CheckBoxfield(props) { id={props.id} className={props.className} //validate={[required]} - errorMsg="Select an option" + errorMsg={t("newappeal:select-an-option-label")} component={RenderCheckBox} /> ); @@ -996,51 +998,142 @@ export function PickList(props) { } export function NumericField(props) { - const { name, label, validation } = props; + const { + name, + label, + validation, + form, + formProps, + parentFieldShowOnValue, + parentField, + } = props; const required = (value) => (value ? undefined : "Required"); + //parentFieldShowOnValue + var showIfHasParentShowValue = + parentField != false && + !_.isEmpty(formProps[form]) && + _.has(formProps[form].values, parentField) && + parentFieldShowOnValue.indexOf( + formProps[form].values[parentField].toString() + ) > -1; + + (showIfHasParentShowValue == parentField) != false && + showIfHasParentShowValue; + + console.log("parentField:", parentField, showIfHasParentShowValue); + return ( -
- -
+ <> + {parentField != false ? ( + showIfHasParentShowValue && ( +
+ +
+ ) + ) : ( +
+ +
+ )} + ); } export function DecimalField(props) { - const { name, label, validation } = props; + const { + name, + label, + validation, + form, + formProps, + parentFieldShowOnValue, + parentField, + } = props; const required = (value) => (value ? undefined : "Required"); + //parentFieldShowOnValue + var showIfHasParentShowValue = + parentField != false && + !_.isEmpty(formProps[form]) && + _.has(formProps[form].values, parentField) && + parentFieldShowOnValue.indexOf( + formProps[form].values[parentField].toString() + ) > -1; + + (showIfHasParentShowValue == parentField) != false && + showIfHasParentShowValue; + + console.log("parentField:", parentField, showIfHasParentShowValue); + return ( -
- -
+ <> + {parentField != false ? ( + showIfHasParentShowValue && ( +
+ +
+ ) + ) : ( +
+ +
+ )} + ); } diff --git a/components/myportal/topthree.js b/components/myportal/topthree.js index c11546b0..0321b5dc 100644 --- a/components/myportal/topthree.js +++ b/components/myportal/topthree.js @@ -209,16 +209,17 @@ const TopThree = (props) => {
- {(topThreeType == "awaitingSubmission" || - topThreeType == "watchedCases") && ( -
- { - showTopThreeArr[key][ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] - } -
- )} + {/* {(topThreeType == "awaitingSubmission" || + topThreeType == "watchedCases") && ( */} +
+ Appeal type:{" "} + { + showTopThreeArr[key][ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ] + } +
+ {/* )} */} {/* {topThreeType != "awaitingSubmission" ? ( */}
{t("myportal:case-address")}:{" "} diff --git a/components/newappeal/aboutyou.js b/components/newappeal/aboutyou.js index 83d38979..f52596b6 100644 --- a/components/newappeal/aboutyou.js +++ b/components/newappeal/aboutyou.js @@ -239,6 +239,8 @@ let AboutYou = (props) => { ...custom }) => { let { t } = useTranslation(); + const required = (value) => (value ? undefined : "Required"); + return ( <>
{ type="radio" className="govuk-radios__input" value={options[key].split("|")[0]} + validate={[required]} // checked={ // value == // parseInt(options[key].split("|")[0]) @@ -393,12 +396,12 @@ let AboutYou = (props) => { label={label} options={fieldOptions} id={name} - //validate={[required]} - errorMsg="Select an option" + validate={[required]} + errorMsg={t("newappeal:select-an-option-label")} component={RenderRadio} inline={props.inline} hint={props.hint} - validate={eval(validation)} + //validate={eval(validation)} requiredDocumentLabel={props.requiredDocumentLabel} requiredDocumentValue={props.requiredDocumentValue} setDocumentsList={props.setDocumentsList} @@ -412,12 +415,12 @@ let AboutYou = (props) => { label={label} options={fieldOptions} id={name} - //validate={[required]} - errorMsg="Select an option" + validate={[required]} + errorMsg={t("newappeal:select-an-option-label")} component={RenderRadio} inline={props.inline} hint={props.hint} - validate={eval(validation)} + //validate={eval(validation)} requiredDocumentLabel={props.requiredDocumentLabel} requiredDocumentValue={props.requiredDocumentValue} setDocumentsList={props.setDocumentsList} @@ -504,8 +507,8 @@ let AboutYou = (props) => { options="[846040000|newappeal:about-you-who-are-you-label-appellant,846040001|newappeal:about-you-who-are-you-label-agent]" id={"pinswg_appellantagent"} className="govuk-radios__input" - //validate={[required]} - errorMsg="Select an option" + validate={"[required]"} + errorMsg={t("newappeal:select-an-option-label")} /> {appellantAgentValue == "846040000" && ( @@ -579,8 +582,8 @@ let AboutYou = (props) => { options="[846040000|newappeal:about-you-agent-contact-preferences-value-email,846040001|newappeal:about-you-agent-contact-preferences-value-post]" id={"pinswg_contactprefs"} className="govuk-radios__input" - validate={[required]} - errorMsg="Select an option" + validate={"[required]"} + errorMsg={t("newappeal:select-an-option-label")} /> { options="[846040000|newappeal:about-you-agent-language-preferences-value-english,846040001|newappeal:about-you-agent-language-preferences-value-welsh]" id={"pinswg_languagepreference"} className="govuk-radios__input" - validate={[required]} - errorMsg="Select an option" + validate={"[required]"} + errorMsg={t("newappeal:select-an-option-label")} /> )} @@ -737,7 +740,7 @@ let AboutYou = (props) => { id={"pinswg_contactprefs"} className="govuk-radios__input" validate={[required]} - errorMsg="Select an option" + errorMsg={t("newappeal:select-an-option-label")} /> { id={"pinswg_languagepreference"} className="govuk-radios__input" validate={[required]} - errorMsg="Select an option" + errorMsg={t("newappeal:select-an-option-label")} /> )} diff --git a/components/newappeal/buildfield.js b/components/newappeal/buildfield.js index 0f4e9a50..6244b143 100644 --- a/components/newappeal/buildfield.js +++ b/components/newappeal/buildfield.js @@ -149,7 +149,11 @@ export default function BuildField(props) { ); break; @@ -158,7 +162,11 @@ export default function BuildField(props) { ); break; diff --git a/components/newappeal/createCase.js b/components/newappeal/createCase.js index 2abd947b..b9aa1837 100644 --- a/components/newappeal/createCase.js +++ b/components/newappeal/createCase.js @@ -15,6 +15,7 @@ import { getFormCollectionByID } from "../utils"; import FileUpload from "./fileupload"; import Aboutyou from "./aboutyou"; import { createNewCase } from "../../actions"; +import { FieldsTranslations } from "../elements"; let CreateCase = (props) => { // useEffect(() => { @@ -26,7 +27,7 @@ let CreateCase = (props) => { const router = useRouter(); const { locale } = router; - const { LPAData, onSubmit, handleSubmit } = props; + const { LPAData, onSubmit, handleSubmit, formData } = props; const appealOptionsObj = _.isEmpty(props) ? [{}] @@ -209,6 +210,207 @@ let CreateCase = (props) => { ); }; + const RenderRadio = ({ + datafieldname, + name, + label, + id, + errorMsg, + options, + input: { onChange, value }, + meta: { touched, error }, + ...custom + }) => { + let { t } = useTranslation(); + const required = (value) => (value ? undefined : "Required"); + return ( + <> +
+
+ + + + {touched && error && ( + + + Error: + {" "} + {errorMsg} + + )} +
+ {" "} + {custom.hint != undefined && ( +
{custom.hint}
+ )} + {Object.keys(options).map((key, index) => ( +
+ { + let docListObj = + custom.documentList; + if ( + custom.requiredDocumentValue == + "Yes" + ) { + e.target.value != "846040000" + ? (docListObj = + Object.assign( + docListObj, + { + ["documentCheckList_" + + id]: + custom.requiredDocumentLabel, + } + )) + : delete docListObj[ + "documentCheckList_" + + id + ]; + custom.setDocumentsList( + docListObj + ); + } + }} + /> + +
+ ))} +
+
+
+ + ); + }; + + 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 && ( + + ) + ) : ( + + )} + + ); + } + const required = (value) => (value ? undefined : "Required"); const [formStep, setFormStep] = useState(0); @@ -218,13 +420,35 @@ let CreateCase = (props) => { var appTypeCollection = values.appealTypes; - appTypeCollection = getFormCollectionByID(appTypeCollection); - 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; + + console.log(appTypeCollection); createNewCase( appTypeCollection.appealTypeID, @@ -240,7 +464,7 @@ let CreateCase = (props) => { "?lpa=" + values.lpaTypes + "&apt=" + - values.appealTypes.split(",")[0] + + whichAppealType + "&id=" + data.incidentid ); @@ -249,6 +473,7 @@ let CreateCase = (props) => { .catch(({ err }) => { console.log(err); }); + // router.replace( // "/newappeal" + // "/" + @@ -263,6 +488,23 @@ let CreateCase = (props) => { // } // ); }; + 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 ( <> @@ -288,6 +530,20 @@ let CreateCase = (props) => { "newappeal:select-appeal-type-label-error-msg" )} /> + + {showIfHasParentShowValue && ( + + )}
diff --git a/styles/sass/welshgov/_application.scss b/styles/sass/welshgov/_application.scss index 93b67216..902d81d4 100644 --- a/styles/sass/welshgov/_application.scss +++ b/styles/sass/welshgov/_application.scss @@ -28,9 +28,11 @@ html { .govuk-breadcrumbs__link, .govuk-fieldset__legend--s, .govuk-input, +.govuk-textarea, .govuk-panel, .govuk-panel__title, .govuk-warning-text__text, +.govuk-hint, .app-cookie-banner, .govuk-error-message.govuk-form-group--error, h1,