applied downloadable checkbox on submit of new appeal

This commit is contained in:
2026-03-16 13:58:02 +00:00
parent 72eafd0a8e
commit 7c84344d5d
9 changed files with 189 additions and 57 deletions
@@ -292,7 +292,8 @@ const RepCompleteSubmit = (props) => {
const pdfBlob = await generateRepPDF(
repFormData,
containerID,
caseRef
caseRef,
{ download: true }
);
if (pdfBlob) {
+87 -1
View File
@@ -124,6 +124,8 @@ let BuildCheckSection = (props) => {
const [confirmSections, setConfirmSections] = useState(false);
const [finaliseAppealProcess, setFinaliseAppealProcess] = useState(false);
const [downloadAppealForm, setDownloadAppealForm] = useState(false);
const [downloadInProgress, setDownloadInProgress] = useState(false);
const FieldsTranslations = (label) => {
const router = useRouter();
@@ -183,6 +185,65 @@ let BuildCheckSection = (props) => {
: setConfirmSections(false);
};
const triggerAppealDownload = async () => {
if (downloadInProgress) {
return;
}
try {
setDownloadInProgress(true);
const uniqueArray = pdfObj.filesList.filter(
(value, index, self) =>
index === self.findIndex((t) => t.name === value.name)
);
pdfObj.filesList = uniqueArray;
console.log(pdfObj);
const containerID =
props.accountDetails?.containerID ||
props.props?.accountDetails?.containerID ||
props.props?.props?.accountDetails?.containerID;
const caseRef =
props?.currentView?.caseReference?.ticketnumber ||
props?.appealType?.caseReference?.ticketnumber;
if (!containerID || !caseRef) {
console.error(
"Appeal Form download skipped: missing containerID or case reference",
{ containerID, caseRef }
);
return;
}
const pdfBlob = await generateAppealPDF(
pdfObj,
containerID,
caseRef,
router.query.appealtypes,
pdfObj.filesList,
{ download: true }
);
if (pdfBlob) {
const blobUrl = window.URL.createObjectURL(pdfBlob);
const anchor = document.createElement("a");
anchor.href = blobUrl;
anchor.download = `${"appealForm"}.pdf`;
document.body.appendChild(anchor);
anchor.click();
anchor.remove();
window.URL.revokeObjectURL(blobUrl);
}
} catch (error) {
console.error("Appeal Form download failed", error);
} finally {
setDownloadInProgress(false);
}
};
let ShowDocLinks = getDocLink(docsOffline);
return (
@@ -280,6 +341,30 @@ let BuildCheckSection = (props) => {
<>
<div className="govuk-form-group ">
<fieldset className="govuk-fieldset">
<div className="govuk-checkboxes govuk-checkboxes--small">
<div className="govuk-checkboxes__item">
<input
name="pinswg_downloadAppealForm"
id="pinswg_downloadAppealForm"
type="checkbox"
className="govuk-checkboxes__input"
checked={downloadAppealForm}
onChange={(e) => {
setDownloadAppealForm(
e.target.checked
);
}}
/>
<label
className="govuk-label govuk-checkboxes__label"
htmlFor="pinswg_downloadAppealForm"
>
{t(
"newappeal:new-appeal-check-download-label"
)}
</label>
</div>
</div>
<div className="govuk-checkboxes govuk-checkboxes--small">
<div className="govuk-checkboxes__item">
<input
@@ -363,7 +448,8 @@ let BuildCheckSection = (props) => {
}
className="govuk-button"
data-module="govuk-button"
onClick={() => {
onClick={async () => {
await triggerAppealDownload();
finaliseAppeal();
}}
>
+48 -47
View File
@@ -4,7 +4,7 @@ import xpath from "xpath";
import {
bytesToSize,
getPickListLabel,
getDocumentTypeFromFilename,
getDocumentTypeFromFilename
} from "../../components/utils";
import fieldLookup from "../../data/crmfieldlookuptranslations.json";
@@ -22,7 +22,7 @@ export const AppealRow_pdf = (props) => {
sectionCount,
onSubmit,
updateCurrentSection,
mandatoryFieldsData,
mandatoryFieldsData
} = props;
const styles = StyleSheet.create({
@@ -30,23 +30,23 @@ export const AppealRow_pdf = (props) => {
backgroundColor: "white",
padding: 20,
fontSize: 16,
paddingBottom: 50,
paddingBottom: 50
},
header: {
fontSize: 25,
fontFamily: "Helvetica",
flexDirection: "row",
justifyContent: "space-between",
justifyContent: "space-between"
},
subHeader: {
fontSize: 20,
fontSize: 20
},
logoImage: { width: "200pt" },
questionBullet: { width: "5%", fontSize: 12 },
questionText: {
width: "35%",
fontSize: 12,
marginRight: 5,
marginRight: 5
},
questionTextMid: { width: "80%", fontSize: 12 },
questionTextWide: { width: "95%", fontSize: 12, marginBottom: 5 },
@@ -60,7 +60,7 @@ export const AppealRow_pdf = (props) => {
paddingLeft: 10,
backgroundColor: "white",
display: "flex",
flexWrap: "wrap",
flexWrap: "wrap"
},
questionAnswerMid: {
color: "#757575",
@@ -72,7 +72,7 @@ export const AppealRow_pdf = (props) => {
paddingLeft: 10,
backgroundColor: "white",
display: "flex",
flexWrap: "wrap",
flexWrap: "wrap"
},
questionAnswerWide: {
color: "#757575",
@@ -81,26 +81,26 @@ export const AppealRow_pdf = (props) => {
border: 1,
borderColor: "#eee",
backgroundColor: "white",
padding: 5,
padding: 5
},
questionAnswerRow: {
width: "100%",
flex: 1,
flexDirection: "row",
flexGrow: 1,
flexGrow: 1
},
questionAnswerColLeft: {
width: "40%",
width: "40%"
},
questionAnswerColRight: {
padding: 5,
width: "40%",
width: "40%"
},
sectionContainer: {
backgroundColor: "#F8F8F8",
padding: 10,
marginTop: 20,
fontSize: 15,
fontSize: 15
},
pageNumber: {
position: "absolute",
@@ -109,15 +109,15 @@ export const AppealRow_pdf = (props) => {
left: 0,
right: 0,
textAlign: "center",
color: "grey",
color: "grey"
},
documentList: {
fontSize: 10,
fontSize: 10
},
richArea: {
fontSize: 12,
flexDirection: "column",
},
flexDirection: "column"
}
});
const parser = new DOMParser();
@@ -151,7 +151,7 @@ export const AppealRow_pdf = (props) => {
let formObj = jsonpath({
path: "$['" + appealtypes + "']",
json: fieldLookup,
eval: true,
eval: true
});
let labelTrans = label;
@@ -211,7 +211,7 @@ export const AppealRow_pdf = (props) => {
<View
style={{
flexDirection: "row",
marginBottom: 10,
marginBottom: 10
}}
wrap={false}
>
@@ -243,7 +243,7 @@ export const AppealRow_pdf = (props) => {
<View
style={{
flexDirection: "column",
marginBottom: 10,
marginBottom: 10
}}
wrap={false}
>
@@ -251,7 +251,7 @@ export const AppealRow_pdf = (props) => {
wrap={false}
style={{
flexDirection: "row",
marginBottom: 10,
marginBottom: 10
}}
>
<Text
@@ -301,11 +301,13 @@ export const AppealRow_pdf = (props) => {
? fieldCopy.split("|")[1]
: fieldCopy;
const transData = require("../../locales/en/" +
(typeof fieldCopy != "undefined"
? fieldCopy.split(":")[0]
: "common") +
".json");
const transData = require(
"../../locales/en/" +
(typeof fieldCopy != "undefined"
? fieldCopy.split(":")[0]
: "common") +
".json"
);
let transCopy =
typeof fieldCopy != "undefined"
@@ -316,7 +318,7 @@ export const AppealRow_pdf = (props) => {
<View
style={{
flexDirection: "column",
marginBottom: 10,
marginBottom: 10
}}
wrap={false}
>
@@ -324,7 +326,7 @@ export const AppealRow_pdf = (props) => {
wrap={false}
style={{
flexDirection: "row",
marginBottom: 10,
marginBottom: 10
}}
>
<Text
@@ -350,14 +352,14 @@ export const AppealRow_pdf = (props) => {
<View
style={{
flexDirection: "column",
marginBottom: 10,
marginBottom: 10
}}
>
<View
wrap={false}
style={{
flexDirection: "row",
marginBottom: 10,
marginBottom: 10
}}
>
<Text
@@ -391,7 +393,7 @@ export const AppealRow_pdf = (props) => {
wrap={false}
style={{
flexDirection: "row",
marginBottom: 10,
marginBottom: 10
}}
>
<Text style={styles.questionText}>
@@ -420,16 +422,15 @@ export const AppealRow_pdf = (props) => {
//const blobList = props.filesList || [];
const blobList = Array.isArray(
props.filesList?.value
)
? props.filesList.value
: [];
const blobList =
props.filesList.hasOwnProperty("value")
? props.filesList.value
: props.filesList || [];
return (
<View
style={{
flexDirection: "column",
marginBottom: 10,
marginBottom: 10
}}
wrap={false}
>
@@ -437,7 +438,7 @@ export const AppealRow_pdf = (props) => {
wrap={false}
style={{
flexDirection: "row",
marginBottom: 10,
marginBottom: 10
}}
>
<Text
@@ -489,7 +490,7 @@ export const AppealRow_pdf = (props) => {
<View
style={{
flexDirection: "column",
marginBottom: 10,
marginBottom: 10
}}
wrap={false}
>
@@ -497,7 +498,7 @@ export const AppealRow_pdf = (props) => {
wrap={false}
style={{
flexDirection: "row",
marginBottom: 10,
marginBottom: 10
}}
>
<Text
@@ -516,7 +517,7 @@ export const AppealRow_pdf = (props) => {
<View
style={{
flexDirection: "column",
marginBottom: 10,
marginBottom: 10
}}
>
{(props.props.hasOwnProperty(
@@ -549,14 +550,14 @@ export const AppealRow_pdf = (props) => {
style={{
flexDirection:
"row",
marginBottom: 10,
marginBottom: 10
}}
>
<Text
style={{
width: "50%",
paddingRight:
"20",
"20"
}}
>
{tenant?.pinswg_agriculturaltenantname_firstname &&
@@ -579,7 +580,7 @@ export const AppealRow_pdf = (props) => {
<Text
style={{
width: "40%",
width: "40%"
}}
>
Notice
@@ -604,7 +605,7 @@ export const AppealRow_pdf = (props) => {
<View
style={{
flexDirection: "column",
marginBottom: 10,
marginBottom: 10
}}
wrap={false}
>
@@ -612,7 +613,7 @@ export const AppealRow_pdf = (props) => {
wrap={false}
style={{
flexDirection: "row",
marginBottom: 10,
marginBottom: 10
}}
>
<Text
@@ -642,7 +643,7 @@ export const AppealRow_pdf = (props) => {
wrap={false}
style={{
flexDirection: "row",
marginBottom: 10,
marginBottom: 10
}}
>
<Text style={styles.questionText}>