From cfe732f299f4db8904aa2d2dfc48db316b6e92ef Mon Sep 17 00:00:00 2001 From: robbond Date: Thu, 26 Feb 2026 13:04:28 +0000 Subject: [PATCH] included emdash in doc upload validation --- components/case/pagination.js | 25 ++-- .../representation/representationElements.js | 113 +++++++++--------- components/elements/index.js | 76 ++++++------ components/search/pagination.js | 25 ++-- pages/api/file/uploadsinglefile.js | 12 +- styles/sass/welshgov/_application.scss | 6 +- 6 files changed, 131 insertions(+), 126 deletions(-) diff --git a/components/case/pagination.js b/components/case/pagination.js index fa6e187d..86623631 100644 --- a/components/case/pagination.js +++ b/components/case/pagination.js @@ -13,7 +13,7 @@ const PaginationControl = (props) => { currentPage, spinnerState, getDocumentResults, - setCurrentPage, + setCurrentPage } = props; let { t } = useTranslation(); @@ -45,7 +45,7 @@ const PaginationControl = (props) => { const range = { start: Math.round(currentPage - delta / 2), - end: Math.round(currentPage + delta / 2), + end: Math.round(currentPage + delta / 2) }; if (range.start - 1 === 1 || range.end + 1 === pageCount) { @@ -89,7 +89,7 @@ const PaginationControl = (props) => { { - spinnerState(), + (spinnerState(), setCurrentPage( props.currentView.currentPage - 1 @@ -99,7 +99,7 @@ const PaginationControl = (props) => { 1, orderBy, fieldSort - ); + )); }} > {t("common:previous-link-button")} @@ -132,12 +132,12 @@ const PaginationControl = (props) => { key={i} onClick={() => { spinnerState(); - setCurrentPage(e), + (setCurrentPage(e), getDocumentResults( e, orderBy, fieldSort - ); + )); }} > {e} @@ -150,7 +150,7 @@ const PaginationControl = (props) => { { - spinnerState(), + (spinnerState(), setCurrentPage( props.currentView.currentPage + 1 @@ -160,7 +160,7 @@ const PaginationControl = (props) => { 1, orderBy, fieldSort - ); + )); }} > {t("common:next-link-button")} @@ -174,8 +174,9 @@ const PaginationControl = (props) => {
- {t("common:pages-label")} {currentPage}{" "} - {t("common:of-label")} {pagesCount} + {t("common:pages-label")}{" "} + {props.currentView.currentPage} {t("common:of-label")}{" "} + {pagesCount}
)} @@ -185,7 +186,7 @@ const PaginationControl = (props) => { const mapStateToProps = (state) => { return { - currentView: state.currentView, + currentView: state.currentView }; }; @@ -193,7 +194,7 @@ const mapDispatchToProps = (dispatch) => { return { setCurrentPage: (currentPage) => { dispatch(setCurrentPage(currentPage)); - }, + } }; }; diff --git a/components/case/representation/representationElements.js b/components/case/representation/representationElements.js index 94a577ce..a9dcff22 100644 --- a/components/case/representation/representationElements.js +++ b/components/case/representation/representationElements.js @@ -13,7 +13,7 @@ import { deleteBlob, deleteRepBlob, getFilesFromBlobHashed, - getFilesFromBlobproxy, + getFilesFromBlobproxy } from "../../../actions"; const LoadingMessage = () =>
Loading the editor...
; @@ -23,7 +23,7 @@ const ReactQuill = dynamic( () => import("react-quill-new").then((mod) => mod.default), { ssr: false, - loading: () => , // This is valid as long as it's a valid React component + loading: () => // This is valid as long as it's a valid React component } ); import { useDispatch } from "react-redux"; // Import the useDispatch hook @@ -35,13 +35,13 @@ import { parseISO, subDays, subMonths, - subYears, + subYears } from "date-fns"; import { bytesToSize, getThumbnailIconByExtension, - updateLinks, + updateLinks } from "../../utils"; import { useRouter } from "next/router"; @@ -537,18 +537,19 @@ export const RenderPickList = ({ ? optionsArr[key] == "Questionnaire" ? "Holiadur" : optionsArr[key] == "Statement" - ? "Datganiad" - : optionsArr[key] == - "Final comments" - ? "Sylwadau terfynol" - : optionsArr[key] == - "Written representations" - ? "Sylwadau ysgrifenedig" - : optionsArr[key] == "Inquiry" - ? "Ymchwiliad" - : optionsArr[key] == "Hearing" - ? "Gwrandawiad" - : optionsArr[key] + ? "Datganiad" + : optionsArr[key] == + "Final comments" + ? "Sylwadau terfynol" + : optionsArr[key] == + "Written representations" + ? "Sylwadau ysgrifenedig" + : optionsArr[key] == "Inquiry" + ? "Ymchwiliad" + : optionsArr[key] == + "Hearing" + ? "Gwrandawiad" + : optionsArr[key] : optionsArr[key]} ); @@ -627,31 +628,31 @@ export const RenderDatePicker = ({ startDateArr == 0 ? new Date() : startDateArr[0] == "-" - ? startDateArr[2] == "y" - ? subYears(new Date(), startDateArr[1]) + ? startDateArr[2] == "y" + ? subYears(new Date(), startDateArr[1]) + : startDateArr[2] == "m" + ? subMonths(new Date(), startDateArr[1]) + : subDays(new Date(), startDateArr[1]) + : startDateArr[2] == "y" + ? addYears(new Date(), startDateArr[1]) : startDateArr[2] == "m" - ? subMonths(new Date(), startDateArr[1]) - : subDays(new Date(), startDateArr[1]) - : startDateArr[2] == "y" - ? addYears(new Date(), startDateArr[1]) - : startDateArr[2] == "m" - ? addMonths(new Date(), startDateArr[1]) - : addDays(new Date(), startDateArr[1]); + ? addMonths(new Date(), startDateArr[1]) + : addDays(new Date(), startDateArr[1]); var maxDate = endDateArr == 0 ? new Date() : startDateArr[0] == "-" - ? startDateArr[2] == "y" - ? subYears(new Date(), startDateArr[1]) + ? startDateArr[2] == "y" + ? subYears(new Date(), startDateArr[1]) + : startDateArr[2] == "m" + ? subMonths(new Date(), startDateArr[1]) + : subDays(new Date(), startDateArr[1]) + : startDateArr[2] == "y" + ? addYears(new Date(), startDateArr[1]) : startDateArr[2] == "m" - ? subMonths(new Date(), startDateArr[1]) - : subDays(new Date(), startDateArr[1]) - : startDateArr[2] == "y" - ? addYears(new Date(), startDateArr[1]) - : startDateArr[2] == "m" - ? addMonths(new Date(), startDateArr[1]) - : addDays(new Date(), startDateArr[1]); + ? addMonths(new Date(), startDateArr[1]) + : addDays(new Date(), startDateArr[1]); return ( <> @@ -739,8 +740,8 @@ export const RenderMultiline = ({ [{ "header": [1, 2, false] }], ["bold", "italic", "underline", "blockquote"], [{ "list": "ordered" }, { "list": "bullet" }], - ["clean"], - ], + ["clean"] + ] }; return ( @@ -805,8 +806,8 @@ export const RenderRichMultiline = ({ [{ "header": [1, 2, false] }], ["bold", "italic", "underline", "blockquote"], [{ "list": "ordered" }, { "list": "bullet" }], - ["clean"], - ], + ["clean"] + ] }; return ( @@ -874,19 +875,19 @@ const baseStyle = { borderStyle: "dashed", backgroundColor: "#fafafa", color: "#bdbdbd", - transition: "border .3s ease-in-out", + transition: "border .3s ease-in-out" }; const activeStyle = { - borderColor: "#2196f3", + borderColor: "#2196f3" }; const acceptStyle = { - borderColor: "#00e676", + borderColor: "#00e676" }; const rejectStyle = { - borderColor: "#ff1744", + borderColor: "#ff1744" }; export const RenderFileUpload = (field) => { @@ -897,7 +898,7 @@ export const RenderFileUpload = (field) => { const style = useMemo( () => ({ - ...baseStyle, + ...baseStyle // ...(isDragActive ? activeStyle : {}), // ...(isDragAccept ? acceptStyle : {}), // ...(isDragReject ? rejectStyle : {}), @@ -993,7 +994,7 @@ export const RenderFileUpload = (field) => { typeof filesUploadObj[key].name != "undefined" && buildAppealFilesArray.push({ "name": filesUploadObj[key].name, - "size": filesUploadObj[key].size, + "size": filesUploadObj[key].size }); } @@ -1087,7 +1088,7 @@ export const RenderFileUpload = (field) => { setRejectedFiles([]); // Clear any previously rejected file errorsss }; - const FILENAME_ALLOWED = /^[A-Za-z0-9 ._\-:()]+$/; + const FILENAME_ALLOWED = /^[A-Za-z0-9 ._\-:()—]+$/; const validateFilename = (file, t) => { const name = file.name; @@ -1098,7 +1099,7 @@ export const RenderFileUpload = (field) => { code: "filename-invalid-chars", message: `${name} ${t( "myrepresentations:fileupload-file-error-invalid-filename-label" - )}`, + )}` }; } @@ -1108,7 +1109,7 @@ export const RenderFileUpload = (field) => { code: "filename-invalid-chars", message: `${name} ${t( "myrepresentations:fileupload-file-error-invalid-filename-label" - )}`, + )}` }; } @@ -1118,7 +1119,7 @@ export const RenderFileUpload = (field) => { code: "filename-invalid-chars", message: `${name} ${t( "myrepresentations:fileupload-file-error-invalid-filename-label" - )}`, + )}` }; } @@ -1138,7 +1139,7 @@ export const RenderFileUpload = (field) => { "image/jpeg": [".jpg", ".jpeg"], "image/png": [".png"], "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": - [".xlsx"], + [".xlsx"] }} validator={(file) => validateFilename(file, t)} onDrop={(acceptedFiles, fileRejections, e) => { @@ -1178,7 +1179,7 @@ export const RenderFileUpload = (field) => { .values.repfile_name }_-_Attachment_-_${file.name}`, { - type: file.type, + type: file.type } ) ); @@ -1211,7 +1212,7 @@ export const RenderFileUpload = (field) => { typeof filesUploadObj[key].name != "undefined" && buildAppealFilesArray.push({ "name": filesUploadObj[key].name, - "size": filesUploadObj[key].size, + "size": filesUploadObj[key].size }); } @@ -1313,14 +1314,14 @@ export const RenderFileUpload = (field) => { {uploadCountMessage > 0 && completedUploadFiles == false && (
{t("home:uploading-files-label", { - number: uploadCountMessage, + number: uploadCountMessage })}
)} {completedUploadFiles > 0 && uploadCountMessage >= 0 && (
{t("home:completed-uploading-files-label", { - number: uploadCountMessage, + number: uploadCountMessage })}
)} @@ -1449,9 +1450,9 @@ export function FileUploadField(props) { ? props.filenamePrefix.representationForm.values .repfile_name : props.filenamePrefix.hasOwnProperty("formObj") - ? props.filenamePrefix.formObj["representationForm"] - .values.repfile_name - : "" + ? props.filenamePrefix.formObj["representationForm"] + .values.repfile_name + : "" } props={props} /> diff --git a/components/elements/index.js b/components/elements/index.js index 2e6256f0..2850044d 100644 --- a/components/elements/index.js +++ b/components/elements/index.js @@ -14,7 +14,7 @@ import { deleteBlob, getFilesFromBlobHashed, uploadSingleFile, - getFilesFromBlobproxy, + getFilesFromBlobproxy } from "../../actions"; import fieldLookup from "../../data/crmfieldlookuptranslations.json"; import pickListLookup from "../../data/picklistLookups.json"; @@ -30,7 +30,7 @@ import { parseISO, subDays, subMonths, - subYears, + subYears } from "date-fns"; import "react-quill-new/dist/quill.snow.css"; const ReactQuill = dynamic(() => import("react-quill-new"), { ssr: false }); @@ -126,7 +126,7 @@ export function Textfield(props) { parentField, parentFieldShowOnValue, maxFieldLength, - hint, + hint } = props; const required = (value) => { @@ -339,7 +339,7 @@ export function MultiLinefield(props) { parentFieldShowOnValue, validation, maxFieldLength, - hint, + hint } = props; const required = (value) => { @@ -484,8 +484,8 @@ export const RenderRichMultiline = ({ [{ "header": [1, 2, false] }], ["bold", "italic", "underline", "blockquote"], [{ "list": "ordered" }, { "list": "bullet" }], - ["clean"], - ], + ["clean"] + ] }; return ( @@ -537,7 +537,7 @@ export function RichMultiLinefield(props) { parentField, parentFieldShowOnValue, validation, - maxFieldLength, + maxFieldLength } = props; const required = (value) => value ? undefined : t("newappeal:is-required-label"); @@ -792,7 +792,7 @@ export function DateFieldPicker(props) { form, formProps, parentFieldShowOnValue, - validation, + validation } = props; let dateStart = props.dateStart; let dateEnd = props.dateEnd; @@ -1053,7 +1053,7 @@ const RenderYesNo = ({ { ["documentCheckList_" + id]: - custom.requiredDocumentLabel, + custom.requiredDocumentLabel } )) : delete docListObj[ @@ -1090,7 +1090,7 @@ export function YesNofield(props) { formProps, validation, parentFieldShowOnValue, - parentField, + parentField } = props; const yesNo = router.locale == "cy" ? ["Ydw", "Na"] : ["Yes", "No"]; const required = (value) => (value ? undefined : "Required"); @@ -1236,7 +1236,7 @@ const RenderRadio = ({ { ["documentCheckList_" + id]: - custom.requiredDocumentLabel, + custom.requiredDocumentLabel } )) : delete docListObj[ @@ -1270,7 +1270,7 @@ export function Radiofield(props) { formProps, parentFieldShowOnValue, parentField, - validation, + validation } = props; const router = useRouter(); @@ -1461,7 +1461,7 @@ const RenderPickList = ({ label, input, errorMsg, - meta: { touched, error }, + meta: { touched, error } }) => { let { t } = useTranslation(); @@ -1469,7 +1469,7 @@ const RenderPickList = ({ path: "$..value[?(@ && @.LogicalName=='" + datafieldname + "')]..Options", json: picklistData, - eval: true, + eval: true }); dropdownObj = dropdownObj[0]; @@ -1549,7 +1549,7 @@ export function NumericField(props) { formProps, parentFieldShowOnValue, parentField, - maxFieldLength, + maxFieldLength } = props; let { t } = useTranslation(); @@ -1649,7 +1649,7 @@ export function NumericField(props) { validate={[ required, isNumber, - maxLength(props.maxFieldLength), + maxLength(props.maxFieldLength) ]} component={RenderTextfield} label={props.label} @@ -1670,7 +1670,7 @@ export function DecimalField(props) { formProps, parentFieldShowOnValue, parentField, - maxFieldLength, + maxFieldLength } = props; let { t } = useTranslation(); @@ -1868,7 +1868,7 @@ export const FieldsTranslations = (label) => { let formObj = jsonpath({ path: "$['" + appealtypes + "']", json: fieldLookup, - eval: true, + eval: true }); let labelTrans = @@ -1876,7 +1876,7 @@ export const FieldsTranslations = (label) => { ? jsonpath({ path: '$..[?(@ && @.value=="' + label + '")].value_cy', json: formObj, - eval: true, + eval: true })[0] : label; @@ -1895,7 +1895,7 @@ const PickListTranslations = (optionValue) => { ? jsonpath({ path: '$..[?(@ && @.value=="' + optionValue + '")].value_cy', json: pickListLookup, - eval: true, + eval: true }) : optionValue; //console.log(optionTrans, optionValue); @@ -1948,19 +1948,19 @@ const baseStyle = { borderStyle: "dashed", backgroundColor: "#fafafa", color: "#bdbdbd", - transition: "border .3s ease-in-out", + transition: "border .3s ease-in-out" }; const activeStyle = { - borderColor: "#2196f3", + borderColor: "#2196f3" }; const acceptStyle = { - borderColor: "#00e676", + borderColor: "#00e676" }; const rejectStyle = { - borderColor: "#ff1744", + borderColor: "#ff1744" }; const RenderFileUpload = (field) => { @@ -1969,7 +1969,7 @@ const RenderFileUpload = (field) => { const style = useMemo( () => ({ - ...baseStyle, + ...baseStyle // ...(isDragActive ? activeStyle : {}), // ...(isDragAccept ? acceptStyle : {}), // ...(isDragReject ? rejectStyle : {}), @@ -2098,7 +2098,7 @@ const RenderFileUpload = (field) => { const blobList = jsonpath({ path: "$..[?(@ && @.documentType=='" + field.documentTypeCode + "')]", json: filelistObj, - eval: true, + eval: true }); //const blobList = filelistObj; @@ -2175,7 +2175,7 @@ const RenderFileUpload = (field) => { setRejectedFiles([]); // Clear any previously rejected file errorsss }; - const FILENAME_ALLOWED = /^[A-Za-z0-9 ._\-:()]+$/; + const FILENAME_ALLOWED = /^[A-Za-z0-9 ._\-:()—]+$/; const validateFilename = (file, t) => { const name = file.name; @@ -2186,7 +2186,7 @@ const RenderFileUpload = (field) => { code: "filename-invalid-chars", message: `${name} ${t( "newappeal:new-appeal-fileupload-file-error-invalid-filename-label" - )}`, + )}` }; } @@ -2195,7 +2195,7 @@ const RenderFileUpload = (field) => { code: "filename-invalid-chars", message: `${name} ${t( "newappeal:new-appeal-fileupload-file-error-invalid-filename-label" - )}`, + )}` }; } @@ -2205,7 +2205,7 @@ const RenderFileUpload = (field) => { code: "filename-invalid-chars", message: `${name} ${t( "newappeal:new-appeal-fileupload-file-error-invalid-filename-label" - )}`, + )}` }; } @@ -2226,7 +2226,7 @@ const RenderFileUpload = (field) => { "image/jpeg": [".jpg", ".jpeg"], "image/png": [".png"], "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": - [".xlsx"], + [".xlsx"] }} validator={(file) => validateFilename(file, t)} onDrop={(acceptedFiles, fileRejections, e) => { @@ -2286,7 +2286,7 @@ const RenderFileUpload = (field) => { "undefined" && buildAppealFilesArray.push({ name: filesUploadObj[key].name, - size: filesUploadObj[key].size, + size: filesUploadObj[key].size }); } @@ -2312,14 +2312,14 @@ const RenderFileUpload = (field) => { ); Object.assign(values, { - filesList: buildAppealFilesArray, + filesList: buildAppealFilesArray }); // keep your existing server-side invalid handling if (data.invalidFiles?.length > 0) { setRejectedFiles((prev) => [ ...prev, - ...data.invalidFiles, + ...data.invalidFiles ]); setUploadCountMessage( renamedAcceptedFiles.length - @@ -2378,14 +2378,14 @@ const RenderFileUpload = (field) => { {uploadCountMessage > 0 && completedUploadFiles == false && (
{t("home:uploading-files-label", { - number: uploadCountMessage, + number: uploadCountMessage })}
)} {completedUploadFiles > 0 && uploadCountMessage >= 0 && (
{t("home:completed-uploading-files-label", { - number: uploadCountMessage, + number: uploadCountMessage })}
)} @@ -2563,7 +2563,7 @@ const RenderSubFields = ({ fields, meta: { touched, error }, ...custom }) => { className="gouk-grid-row" style={{ display: "flex", - marginBottom: "20px", + marginBottom: "20px" }} > { parentFieldShowOnValue, parentField, maxFieldLength, - maxSubField, + maxSubField } = props; const dispatch = useDispatch(); // Get dispatch using useDispatch hook diff --git a/components/search/pagination.js b/components/search/pagination.js index 8bfc5787..9d602a5c 100644 --- a/components/search/pagination.js +++ b/components/search/pagination.js @@ -13,7 +13,7 @@ const PaginationControl = (props) => { currentPage, spinnerState, getSearchPageResults, - setCurrentPage, + setCurrentPage } = props; let { t } = useTranslation(); @@ -47,7 +47,7 @@ const PaginationControl = (props) => { const range = { start: Math.round(currentPage - delta / 2), - end: Math.round(currentPage + delta / 2), + end: Math.round(currentPage + delta / 2) }; if (range.start - 1 === 1 || range.end + 1 === pageCount) { @@ -92,7 +92,7 @@ const PaginationControl = (props) => {