welsh changes

This commit is contained in:
2024-12-05 16:34:48 +00:00
parent 8b349e7d3a
commit 19310b8145
12 changed files with 143 additions and 56 deletions
@@ -1228,7 +1228,7 @@ let Enforcement_Questionnaire = (props) => {
label={t("myrepresentations:enf-section-question-date")}
component={RenderDatePicker}
validate={[required]}
errorMsg="Select a date"
errorMsg={t("newappeal:select-a-date-label")}
dateStart="0"
dateEnd="1-y"
/>
+54 -35
View File
@@ -116,8 +116,6 @@ export function Textfield(props) {
maxFieldLength,
hint,
} = props;
// const required = (value) =>
// value ? undefined : t("newappeal:is-required-label");
const required = (value) => {
let errors;
@@ -239,7 +237,7 @@ export function Textfield(props) {
className="govuk-input govuk-input--width-20"
validate={eval(validation)}
label={props.label}
errorMsg="Is required"
errorMsg={t("newappeal:is-required-label")}
maxFieldLength={props.maxFieldLength}
/>
)}
@@ -319,14 +317,14 @@ export function MultiLinefield(props) {
// Check for the required field
if (!value) {
errors = "This field is required";
errors = t("newappeal:is-required-label");
} else {
// Check for emojis using a regular expression
const emojiRegex =
/[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{2300}-\u{23FF}\u{2B50}\u{1F004}-\u{1F0CF}\u{1F0A0}-\u{1F0A5}\u{1F170}-\u{1F251}]/gu;
if (emojiRegex.test(value)) {
errors = "Emojis are not allowed";
errors = t("newappeal:emojis-not-allowed-label");
}
}
@@ -492,7 +490,8 @@ export function RichMultiLinefield(props) {
validation,
maxFieldLength,
} = props;
const required = (value) => (value ? undefined : "Is required");
const required = (value) =>
value ? undefined : t("newappeal:is-required-label");
var showIfHasParentShowValue =
parentField != false &&
@@ -702,6 +701,7 @@ export function DateFieldPicker(props) {
dateStart,
dateEnd,
} = props;
let { t } = useTranslation();
const required = (value) => (value ? undefined : "Required");
var showIfHasParentShowValue =
@@ -720,7 +720,7 @@ export function DateFieldPicker(props) {
label={label}
component={RenderDatePicker}
validate={eval(validation)}
errorMsg="Select a date"
errorMsg={t("newappeal:select-a-date-label")}
dateStart={dateStart}
dateEnd={dateEnd}
hint={props.hint}
@@ -733,7 +733,7 @@ export function DateFieldPicker(props) {
label={label}
component={RenderDatePicker}
validate={eval(validation)}
errorMsg="Select a date"
errorMsg={t("newappeal:select-a-date-label")}
dateStart={dateStart}
dateEnd={dateEnd}
hint={props.hint}
@@ -1318,7 +1318,9 @@ const RenderPickList = ({
dropdownObj = dropdownObj[0];
const required = (value) => {
return value || value == 0 ? undefined : "Is required";
return value || value == 0
? undefined
: t("newappeal:is-required-label");
};
return (
@@ -1363,7 +1365,9 @@ export function PickList(props) {
const { name, label, datafieldname, hint } = props;
let { t } = useTranslation();
const required = (value) => {
return value || value == 0 ? undefined : "Is required";
return value || value == 0
? undefined
: t("newappeal:is-required-label");
};
return (
<Field
@@ -1374,7 +1378,7 @@ export function PickList(props) {
datafieldname={datafieldname}
picklistData={props.picklistData}
hint={props.hint}
errorMsg="Is required"
errorMsg={t("newappeal:is-required-label")}
validate={[required]}
/>
);
@@ -1391,12 +1395,19 @@ export function NumericField(props) {
parentField,
maxFieldLength,
} = props;
let { t } = useTranslation();
const required = (value) => {
return value || value == 0 ? undefined : "Is required";
return value || value == 0
? undefined
: t("newappeal:is-required-label");
};
const isNumber = (value) => {
const regex = /^\d*\.?\d{0,1}$/;
return regex.test(value) ? undefined : "Should be a number";
return regex.test(value)
? undefined
: t("newappeal:invalid-number-label");
};
const maxLength = (max) => (value) =>
@@ -1495,11 +1506,17 @@ export function DecimalField(props) {
parentField,
maxFieldLength,
} = props;
const required = (value) => (value ? undefined : "Is required");
let { t } = useTranslation();
const required = (value) =>
value ? undefined : t("newappeal:is-required-label");
const isNumber = (value) => {
const regex = /^\d*\.?\d{0,1}$/;
return regex.test(value) ? undefined : "Should be a number or decimal";
return regex.test(value)
? undefined
: t("newappeal:invalid-number-label");
};
const maxLength = (max) => (value) =>
@@ -1521,6 +1538,24 @@ export function DecimalField(props) {
//console.log("parentField:", parentField, showIfHasParentShowValue);
const normalizeDecimal = (value) => {
return value ? parseFloat(value) : value;
};
const validateDecimal = (value) => {
if (!value) return t("newappeal:is-required-label");
// Regex to match whole numbers or decimal numbers (up to 7 characters including decimal)
const regex = /^\d{1,6}(\.\d{1,2})?$/; // Up to 6 digits before the decimal, 2 after
// Check if the value matches the regex pattern
if (!regex.test(value)) {
return t("newappeal:invalid-decimal-label");
}
return undefined;
};
return (
<>
{parentField != false ? (
@@ -1557,7 +1592,7 @@ export function DecimalField(props) {
pattern="^\d*\.?\d+$"
// inputMode="numeric"
// parse={Number}
validate={validateDecimal}
validate={[validateDecimal]}
component={RenderDecimalField}
label={props.label}
maxFieldLength={props.maxFieldLength}
@@ -1569,24 +1604,6 @@ export function DecimalField(props) {
);
}
const normalizeDecimal = (value) => {
return value ? parseFloat(value) : value;
};
const validateDecimal = (value) => {
if (!value) return "This field is required";
// Regex to match whole numbers or decimal numbers (up to 7 characters including decimal)
const regex = /^\d{1,6}(\.\d{1,2})?$/; // Up to 6 digits before the decimal, 2 after
// Check if the value matches the regex pattern
if (!regex.test(value)) {
return "Invalid number (max 7 characters, 2 decimal places)";
}
return undefined;
};
const RenderDecimalField = ({
name,
id,
@@ -2010,7 +2027,9 @@ const RenderFileUpload = (field) => {
)}
</>
)}
{blobList.length > 0 && <h4>Previously added files</h4>}
{blobList.length > 0 && (
<h4>{t("newappeal:previously-added-files")}</h4>
)}
{blobList.map(
(blob, i) =>
blob.documentType == field.documentTypeCode && (
+2 -1
View File
@@ -96,7 +96,8 @@ export default function BuildField(props) {
);
break;
case "{4273EDBD-AC1D-40d3-9FB2-095C621B552D}":
const required = (value) => (value ? undefined : "Is required");
const required = (value) =>
value ? undefined : t("newappeal:is-required-label");
return (
<Textfield
+16 -5
View File
@@ -186,7 +186,7 @@ const BuildProgress = (props) => {
<ul className="govuk-list ">
<li className="at-nav__page">
<ol className="govuk-list govuk-list--bullet">
<li>Application form</li>
<li>{t("newappeal:application-form")}</li>
{props.props.props.form.hasOwnProperty(
"appealForm"
@@ -223,7 +223,9 @@ const BuildProgress = (props) => {
.values.pinswg_caseworkreason ==
"846040005" && (
<li>
Registration of Application letter
{t(
"newappeal:registration-of-application-letter"
)}
</li>
)
: ""}
@@ -255,7 +257,11 @@ const BuildProgress = (props) => {
].values.hasOwnProperty("pinswg_attachsoc")
? props.props.props.form["appealForm"]
.values.pinswg_attachsoc ==
"true" && <li>Statement of Case</li>
"true" && (
<li>
{t("newappeal:statement-of-case")}
</li>
)
: ""}
{props.props.props.form.hasOwnProperty(
@@ -272,7 +278,11 @@ const BuildProgress = (props) => {
? props.props.props.form["appealForm"]
.values
.pinswg_attachcostapplication ==
"true" && <li>Cost Application</li>
"true" && (
<li>
{t("newappeal:cost-application")}
</li>
)
: ""}
{props.props.props.form.hasOwnProperty(
@@ -303,7 +313,8 @@ const BuildProgress = (props) => {
return <li key={key}>{value}</li>;
}
)} */}
<li>Site Location Plan</li>
<li>{t("newappeal:site-location-plan")}</li>
</ol>
</li>
</ul>
+17 -5
View File
@@ -626,12 +626,14 @@ const mapStateToProps = (state, ownProps) => {
formData: state.formData,
appealType: state.appealType,
initialValues: state.appealType.caseReference.caseDetails,
currentView: state.currentView,
}
: {
search: state.search,
searchResultsObj: state.searchResultsObj,
formData: state.formData,
appealType: state.appealType,
currentView: state.currentView,
//form: state.form,
};
};
@@ -658,22 +660,28 @@ const mapDispatchToProps = (dispatch) => {
const selector = formValueSelector("appealForm"); // <-- same as form name
const validate = (values) => {
const validate = (values, props) => {
const errors = {};
const strippedHtml = (htmlStr) => {
return htmlStr.replace(/(<([^>]+)>)/gi, "").trim();
};
const locale = props.currentView.locale;
if (values.hasOwnProperty("pinswg_attachsoc")) {
if (values.pinswg_attachsoc == "false") {
if (values.hasOwnProperty("pinswg_statementofcase")) {
if (strippedHtml(values.pinswg_statementofcase).length == 0)
errors.pinswg_statementofcase =
"Submit your Statement of Case or select Yes to attach a separate Statement of Case Document";
locale != "cy"
? "Submit your Statement of Case or select Yes to attach a separate Statement of Case Document"
: "Cyflwynwch eich Datganiad Achos neu dewiswch Ie i atodi Dogfen Datganiad Achos ar wahân";
} else {
errors.pinswg_statementofcase =
"Submit your Statement of Case or select Yes to attach a separate Statement of Case Document";
locale != "cy"
? "Submit your Statement of Case or select Yes to attach a separate Statement of Case Document"
: "Cyflwynwch eich Datganiad Achos neu dewiswch Ie i atodi Dogfen Datganiad Achos ar wahân";
}
}
}
@@ -684,10 +692,14 @@ const validate = (values) => {
if (values.hasOwnProperty("pinswg_costapplication")) {
if (strippedHtml(values.pinswg_costapplication).length == 0)
errors.pinswg_costapplication =
"Submit a Costs application or select Yes to attach a separate Costs application";
locale != "cy"
? "Submit a Costs application or select Yes to attach a separate Costs application"
: "Cyflwyno cais Costau neu ddewis Ie i atodi cais Costau ar wahân";
} else {
errors.pinswg_costapplication =
"Submit a Costs application or select Yes to attach a separate Costs application";
locale != "cy"
? "Submit a Costs application or select Yes to attach a separate Costs application"
: "Cyflwyno cais Costau neu ddewis Ie i atodi cais Costau ar wahân";
}
}
}