rep defect 42,questioinnaire defect 67, enf defect 16
This commit is contained in:
@@ -9,7 +9,7 @@ import { formValueSelector, reduxForm } from "redux-form";
|
|||||||
|
|
||||||
import { signIn, useSession } from "next-auth/react";
|
import { signIn, useSession } from "next-auth/react";
|
||||||
import { generateRepPDF, sendEmail, uploadRepFiles } from "../../../actions";
|
import { generateRepPDF, sendEmail, uploadRepFiles } from "../../../actions";
|
||||||
import { formatDates } from "../../../components/utils";
|
import { formatDates, updateLinks } from "../../../components/utils";
|
||||||
import {
|
import {
|
||||||
setRepresentationCapacity,
|
setRepresentationCapacity,
|
||||||
setRepresentationMessageSent,
|
setRepresentationMessageSent,
|
||||||
@@ -1100,6 +1100,8 @@ let MakeRepresentation = (props) => {
|
|||||||
? cleanFilesList(values)
|
? cleanFilesList(values)
|
||||||
: values;
|
: values;
|
||||||
|
|
||||||
|
values = updateLinks(values);
|
||||||
|
|
||||||
// get filelists from values object
|
// get filelists from values object
|
||||||
let fileListObj = _.filter(values, function (v, key) {
|
let fileListObj = _.filter(values, function (v, key) {
|
||||||
return _.includes(key, "representationDocuments");
|
return _.includes(key, "representationDocuments");
|
||||||
|
|||||||
@@ -16,7 +16,16 @@ import {
|
|||||||
getFilesFromBlobproxy,
|
getFilesFromBlobproxy,
|
||||||
} from "../../../actions";
|
} from "../../../actions";
|
||||||
|
|
||||||
const ReactQuill = dynamic(() => import("react-quill-new"), { ssr: false });
|
const LoadingMessage = () => <div>Loading the editor...</div>;
|
||||||
|
|
||||||
|
// Dynamically import ReactQuill with a proper loading state
|
||||||
|
const ReactQuill = dynamic(
|
||||||
|
() => import("react-quill-new").then((mod) => mod.default),
|
||||||
|
{
|
||||||
|
ssr: false,
|
||||||
|
loading: () => <LoadingMessage />, // This is valid as long as it's a valid React component
|
||||||
|
}
|
||||||
|
);
|
||||||
import { useDispatch } from "react-redux"; // Import the useDispatch hook
|
import { useDispatch } from "react-redux"; // Import the useDispatch hook
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -258,9 +258,13 @@ const CaseSummary = (props) => {
|
|||||||
: t("case:summary-applicant-label")}
|
: t("case:summary-applicant-label")}
|
||||||
</dt>
|
</dt>
|
||||||
<dd className="govuk-summary-list__value">
|
<dd className="govuk-summary-list__value">
|
||||||
{detailsObj[
|
{casesObj.pinswg_appellantagent == 846040001
|
||||||
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
|
? casesObj.pinswg_appellantfirstname +
|
||||||
] || "not entered"}
|
" " +
|
||||||
|
casesObj.pinswg_appellantlastname
|
||||||
|
: detailsObj[
|
||||||
|
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
|
||||||
|
] || "not entered"}
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
{detailsObj.pinswg_agentcontactname != null &&
|
{detailsObj.pinswg_agentcontactname != null &&
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
setNewAppealProgress,
|
setNewAppealProgress,
|
||||||
setFileCount,
|
setFileCount,
|
||||||
} from "../../store/appealType/action";
|
} from "../../store/appealType/action";
|
||||||
import { getFormCollectionByID, getProgressObj } from "../utils";
|
import { getFormCollectionByID, getProgressObj, updateLinks } from "../utils";
|
||||||
import BuildRow from "./buildrow";
|
import BuildRow from "./buildrow";
|
||||||
|
|
||||||
import { FieldsTranslations } from "../elements";
|
import { FieldsTranslations } from "../elements";
|
||||||
@@ -141,6 +141,8 @@ let BuildSection = (props) => {
|
|||||||
let buildAppealFilesArray = [];
|
let buildAppealFilesArray = [];
|
||||||
//console.log("attached docs: - ", buildAppealFilesArray);
|
//console.log("attached docs: - ", buildAppealFilesArray);
|
||||||
|
|
||||||
|
values = updateLinks(values);
|
||||||
|
|
||||||
let filesUploadObj = Object.keys(values)
|
let filesUploadObj = Object.keys(values)
|
||||||
.filter(function (k) {
|
.filter(function (k) {
|
||||||
return k.indexOf("pinswg_fileUpload") == 0;
|
return k.indexOf("pinswg_fileUpload") == 0;
|
||||||
|
|||||||
@@ -550,3 +550,67 @@ export const getDocumentTypeFromFilename = (filename) => {
|
|||||||
|
|
||||||
return doctypeCode;
|
return doctypeCode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const updateLinks = (jsonObject) => {
|
||||||
|
const wrapPlainUrlsInAnchorTags = (htmlString) => {
|
||||||
|
return htmlString
|
||||||
|
.replace(
|
||||||
|
/(?<=^|>|\s)(?=\S)(?:https?:\/\/)?(?:www\.)?[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/[^\s]*)?(?=\s|<|$)/g,
|
||||||
|
(match) => {
|
||||||
|
// If the match is already wrapped in <a> tag, return it as is
|
||||||
|
if (match.includes('<a href="') || match.includes("<a ")) {
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
// Check if the URL starts with http:// or https://, else prepend http://
|
||||||
|
const url =
|
||||||
|
match.startsWith("http://") ||
|
||||||
|
match.startsWith("https://")
|
||||||
|
? match
|
||||||
|
: "https://" + match;
|
||||||
|
|
||||||
|
// Return the URL wrapped in <a> tag
|
||||||
|
return `<a href="${url}" rel="noopener noreferrer" target="_blank">${match}</a>`;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
/<a [^>]*><a [^>]*>(.*?)<\/a><\/a>/g,
|
||||||
|
(match, innerContent) => {
|
||||||
|
return `<a href="${innerContent}" rel="noopener noreferrer" target="_blank">${innerContent}</a>`;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
// Helper function to ensure that any href attributes in <a> tags have https/http
|
||||||
|
const ensureHttpsInLinks = (inputString) => {
|
||||||
|
// Match <a> tags with href attributes and check if they lack a scheme (http:// or https://)
|
||||||
|
return inputString.replace(
|
||||||
|
/<a [^>]*href=["']([^"']*)["'][^>]*>/g,
|
||||||
|
(match, url) => {
|
||||||
|
// If the URL doesn't already have a scheme (http:// or https://), add https://
|
||||||
|
if (!/^https?:\/\//.test(url)) {
|
||||||
|
const newUrl = `https://${url}`;
|
||||||
|
return match.replace(url, newUrl);
|
||||||
|
}
|
||||||
|
return match; // Return the unchanged anchor tag if it already has a scheme
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Iterate through all properties of the JSON object
|
||||||
|
Object.keys(jsonObject).forEach((key) => {
|
||||||
|
const value = jsonObject[key];
|
||||||
|
|
||||||
|
// If the value is a string and contains plain URLs that are not wrapped
|
||||||
|
if (typeof value === "string") {
|
||||||
|
// Step 1: Wrap plain URLs in anchor tags if not already wrapped
|
||||||
|
let updatedValue = wrapPlainUrlsInAnchorTags(value);
|
||||||
|
|
||||||
|
// Step 2: Ensure that hrefs in anchor tags have https:// or http://
|
||||||
|
updatedValue = ensureHttpsInLinks(updatedValue);
|
||||||
|
|
||||||
|
// Assign the updated value back to the key
|
||||||
|
jsonObject[key] = updatedValue;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return jsonObject;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user