From a1524c501864831362e15109119d6ce316db4eb2 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Wed, 16 Oct 2024 12:41:37 +0100 Subject: [PATCH] added caseinvolvement api for rep --- .env.local | 38 ++-------- actions/index.js | 18 +++++ components/breadcrumbs.js | 2 +- .../representation/representationAgent.js | 51 +++++++------ .../representation/representationAppellant.js | 50 ++++++------ .../representation/representationComplete.js | 7 +- .../representationCompleteSubmit.js | 59 +++++++------- .../representationInterestedPartyPerson.js | 12 ++- components/pdftemplates/statement_pdf.js | 7 +- locales/cy/myportal.json | 2 +- locales/en/myportal.json | 2 +- pages/api/file/createrepinvolvement_api.js | 76 +++++++++++++++++++ pages/myportal/[appealtypes].js | 4 +- pages/newappeal/[appealtypes].js | 1 - 14 files changed, 214 insertions(+), 115 deletions(-) create mode 100644 pages/api/file/createrepinvolvement_api.js diff --git a/.env.local b/.env.local index 75910c4f..9e58a99d 100644 --- a/.env.local +++ b/.env.local @@ -10,13 +10,7 @@ CLIENT_SECRET = bFq8Q~9VX5Ra3lKnGGIXsB.G6-ZGMx7LqyqXjdr4 RELAY_ROOT = https://ar-ns-lz-pedw-cnr-uks-01.servicebus.windows.net/ar-hc-lz-pedw-cnr-uks-01/ RELAYURI = "ar-ns-lz-pedw-cnr-uks-01.servicebus.windows.net" RELAYPATH = "ar-hc-lz-pedw-cnr-uks-01" - -//Dev oauth ESNR -//CLIENT_ID = 9b834097-03d7-409b-b038-ecfec31a394a -//CLIENT_SECRET = .Jf8Q~tKMObCJjhh_hy3J5AIctFrBalU4FS~tdxk -//RELAY_ROOT = https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/ -//RELAYURI = "dev-pedw-ns.servicebus.windows.net" -//RELAYPATH = "dev-pedw-hc" +CRMURL = "devcrm2016.llcdt.gov.wales/DVPINS" //New Dev oauth ESNR CLIENT_ID = 9b834097-03d7-409b-b038-ecfec31a394a @@ -24,14 +18,7 @@ CLIENT_SECRET = .Jf8Q~tKMObCJjhh_hy3J5AIctFrBalU4FS~tdxk RELAY_ROOT = https://ar-ns-lz-pedw-dev-uks-01.servicebus.windows.net/ar-hc-lz-pedw-dev-uks-01/ RELAYURI = "ar-ns-lz-pedw-dev-uks-01.servicebus.windows.net" RELAYPATH = "ar-hc-lz-pedw-dev-uks-01" - - -//Test Oauth ESNR -//CLIENT_ID = d40b9373-96c2-4b04-8bd8-c2a2fe6444c1 -//CLIENT_SECRET = 6hT8Q~glL~jloWpGmvXw3UY37QFwjUE0r._jobEM -//RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ -//RELAYURI = "test-pedw-ns.servicebus.windows.net" -//RELAYPATH = "test-pedw-hc" +CRMURL = "devcrm2016.llcdt.gov.wales/DVPINS" //New Test CLIENT_ID = d40b9373-96c2-4b04-8bd8-c2a2fe6444c1 @@ -39,7 +26,7 @@ CLIENT_SECRET = 6hT8Q~glL~jloWpGmvXw3UY37QFwjUE0r._jobEM RELAY_ROOT = https://ar-ns-lz-pedw-test-uks-01.servicebus.windows.net/ar-hc-lz-pedw-test-uks-01/ RELAYURI = "ar-ns-lz-pedw-test-uks-01.servicebus.windows.net" RELAYPATH = "ar-hc-lz-pedw-test-uks-01" - +CRMURL = "tscrm2016.llcdt.gov.wales/UATPINS" //Preprod Oauth WGO //CLIENT_ID = ab6c4678-b31a-4eb3-b429-e039120e488a @@ -48,8 +35,7 @@ RELAYPATH = "ar-hc-lz-pedw-test-uks-01" //RELAY_ROOT = https://pp-pedw-ns.servicebus.windows.net/pp-pedw-hc/ //RELAYURI = "pp-pedw-ns.servicebus.windows.net" //RELAYPATH = "pp-pedw-hc" - - +//CRMURL = "ppcrm2016.llc.gov.wales/PPPINSWales" //Prod Oauth WGO //CLIENT_ID = 3e4141a3-1fbd-454e-98f0-7f3a4f14a3cc @@ -58,6 +44,7 @@ RELAYPATH = "ar-hc-lz-pedw-test-uks-01" //RELAY_ROOT = https://prod-pedw-ns.servicebus.windows.net/prod-pedw-hc/ //RELAYURI = "prod-pedw-ns.servicebus.windows.net" //RELAYPATH = "prod-pedw-hc" +//CRMURL = "crm2016.llc.gov.wales/PEDW" //GOOGLE_TAG_MANAGER = GTM-T78CBC3 @@ -110,24 +97,11 @@ AZURE_CLIENT_SECRET = $CLIENT_SECRET # AZURE_STORAGE_ACCOUNT_KEY = hRffHq4IwctpaTKdS/U33Xq6nyTDF1t++WJgIwsw7gzstktZin/rRwbTIAL9KKqesVsK7EHrTTG6+ASt4+7skw== # AZURE_PEDW_STORAGE_ENDPOINT = https://sapltpedwcnruks.blob.core.windows.net - -// dev key -//AZURE_STORAGE_ACCOUNT_NAME = "pedwdev" -//AZURE_STORAGE_ACCOUNT_KEY = JS3ZIXianhYhB1lZrHB+bXbdzaLlON0alCyKrFAb+jVEwr9iqo2dty92EBxwnufNFM+CSN/fKX2R+AStDn0byg== -//AZURE_PEDW_STORAGE_ENDPOINT = https://pedwdev.blob.core.windows.net - // new dev key AZURE_STORAGE_ACCOUNT_NAME = "sapltpedwdevuks" -AZURE_STORAGE_ACCOUNT_KEY = JS3ZIXianhYhB1lZrHB+bXbdzaLlON0alCyKrFAb+jVEwr9iqo2dty92EBxwnufNFM+CSN/fKX2R+AStDn0byg== +AZURE_STORAGE_ACCOUNT_KEY = MmrsrCjBfop9pI2oImsP/+lJUWU2DrXsAB8nq5bOVROTmPovSGxjCjKw9+TAFr00k8WDUK9r6mVx+AStcMLyAA== AZURE_PEDW_STORAGE_ENDPOINT = https://sapltpedwdevuks.blob.core.windows.net - -// test key -//AZURE_STORAGE_ACCOUNT_NAME = "sapltpedwdevuks" -////AZURE_STORAGE_ACCOUNT_KEY = Dl8qUVEnR2mglklQorttMurmjUpe2lI3oMWl9V245U6BOLutXDwmpU36afeTrGLK+zfzNVLErsWM+AStiYsimw== -//AZURE_STORAGE_ACCOUNT_KEY = iEQKwh4TB9BT63pU5a6+ivn6ItiDkuIkYCrUwjm9STJTdMBOKWUT06EEcP8pcy/qeQ89ogK75mFQ+AStT53G/g== -//AZURE_PEDW_STORAGE_ENDPOINT = https://pedwtest.blob.core.windows.net - // New test key AZURE_STORAGE_ACCOUNT_NAME = "sapltpedwtestuks" AZURE_STORAGE_ACCOUNT_KEY = bqJAz5pYQVGee8dnVhlsqW+xHwinNTjgY2AmojNyB+d4uAotMR20WcO4Op13yB+9dFaXAkkjtIA4+AStHT/IYg== diff --git a/actions/index.js b/actions/index.js index 16f16f00..f89d84d3 100644 --- a/actions/index.js +++ b/actions/index.js @@ -1924,6 +1924,24 @@ export const sendRepCompleteMessage = async ( }); }; +export const setRepInvolvment = async (caseid, contactid) => { + var queryUrl = "/api/file/createrepinvolvement_api"; + + var data = { "incidentid": caseid, "contactid": contactid }; + var config = { + method: "post", + url: queryUrl, + data: data, + }; + + try { + const res = await axios(config); + return res.data; + } catch (error) { + consoleLogger(error); + } +}; + export const getAddressSearch = async (searchString) => { const params = new URLSearchParams(searchString); const str = params.toString(); diff --git a/components/breadcrumbs.js b/components/breadcrumbs.js index 95162f6a..9f8f0a14 100644 --- a/components/breadcrumbs.js +++ b/components/breadcrumbs.js @@ -793,7 +793,7 @@ const Breadcrumbs = (props) => { .representationCapacity != "undefined" && props.currentView.representationCapacity != "" && ( -
  • +
  • { setRepresentationSubmit, currentView, setRepFileName, + updateRepresentation, } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); const [savingStatus, setSavingStatus] = useState(false); setRepFileName(formObj.representationForm.values); + let filterFilesList = + props.currentView.caseReference.repDetails.filesList.filter(function ( + el + ) { + return el != null; + }); + const files = acceptedFiles.map((file) => (
  • {file.path} - {file.size} bytes @@ -175,28 +183,25 @@ const RepAgent = (props) => { props.currentView.caseReference.repDetails .filesList.length > 0 ? (
    - {props.currentView.caseReference.repDetails.filesList.map( - (blob, i) => ( -
    - {blob.name} + {filterFilesList.map((blob, i) => ( +
    + {blob.name} - - {blob.name} ( - {bytesToSize(blob.size)} - ) - -
    - ) - )} + + {blob.name} ( + {bytesToSize(blob.size)}) + +
    + ))}
    ) : ( "" @@ -252,8 +257,8 @@ const RepAgent = (props) => { className="govuk-button progress-save " onClick={() => { let valuesObj = - props.props.form[props.form].values || - {}; + props.props.props.form[props.form] + .values || {}; console.log("valuesobj:", valuesObj); diff --git a/components/case/representation/representationAppellant.js b/components/case/representation/representationAppellant.js index 21d0033a..01655754 100644 --- a/components/case/representation/representationAppellant.js +++ b/components/case/representation/representationAppellant.js @@ -30,12 +30,20 @@ const RepAppellant = (props) => { setRepresentationSubmit, currentView, setRepFileName, + updateRepresentation, } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); const [savingStatus, setSavingStatus] = useState(false); setRepFileName(formObj.representationForm.values); + let filterFilesList = + props.currentView.caseReference.repDetails.filesList.filter(function ( + el + ) { + return el != null; + }); + return ( <>
    @@ -154,27 +162,25 @@ const RepAppellant = (props) => { props.currentView.caseReference.repDetails.filesList .length > 0 ? (
    - {props.currentView.caseReference.repDetails.filesList.map( - (blob, i) => ( -
    - {blob.name} + {filterFilesList.map((blob, i) => ( +
    + {blob.name} - - {blob.name} ( - {bytesToSize(blob.size)}) - -
    - ) - )} + + {blob.name} ( + {bytesToSize(blob.size)}) + +
    + ))}
    ) : ( "" @@ -230,8 +236,8 @@ const RepAppellant = (props) => { className="govuk-button progress-save " onClick={() => { let valuesObj = - props.props.form[props.form].values || - {}; + props.props.props.form[props.form] + .values || {}; console.log("valuesobj:", valuesObj); diff --git a/components/case/representation/representationComplete.js b/components/case/representation/representationComplete.js index 3b5ebef5..0fc273a7 100644 --- a/components/case/representation/representationComplete.js +++ b/components/case/representation/representationComplete.js @@ -9,6 +9,7 @@ import { createWatchedCases, sendEmail, sendRepCompleteMessage, + setRepInvolvment, } from "../../../actions"; import { setRepresentationReset } from "../../../store/currentView/action"; @@ -50,7 +51,11 @@ const RepComplete = (props) => { }; props.props.currentView.representationMessageSent != true && - (sendRepCompleteMessage( + (setRepInvolvment( + props.props.currentView.caseReference.incidentid, + props.props.props.props.accountDetails.loggedinUserId + ), + sendRepCompleteMessage( props.props.props.props.accountDetails.containerID, props.props.currentView.caseReference.currentReference, props.repFormData.repfile_name diff --git a/components/case/representation/representationCompleteSubmit.js b/components/case/representation/representationCompleteSubmit.js index 07c0b3d4..91c35ffb 100644 --- a/components/case/representation/representationCompleteSubmit.js +++ b/components/case/representation/representationCompleteSubmit.js @@ -163,6 +163,10 @@ const RepCompleteSubmit = (props) => { // ...new Map(buildAppealFilesArray.map((v) => [v.name, v])).values(), // ]; + buildAppealFilesArray = buildAppealFilesArray.filter(function (el) { + return el != null; + }); + const arrUniq = buildAppealFilesArray.filter( (obj1, i, arr) => arr.findIndex((obj2) => obj2.name === obj1.name) === i ); @@ -173,6 +177,7 @@ const RepCompleteSubmit = (props) => { "filesList": arrUniq, }); + let filterFiles = []; return ( <> {currentView.representationSubmitConfirmation == true ? ( @@ -354,34 +359,34 @@ const RepCompleteSubmit = (props) => {
    {formObj.representationForm.values .filesList.length > 0 - ? formObj.representationForm.values.filesList.map( - (blob, i) => ( -
    - {blob.name} + ? ((filterFiles = + formObj.representationForm.values.filesList.filter( + function (el) { + return el != null; + } + )), + filterFiles.map((blob, i) => ( +
    + {blob.name} - - {blob.name} ( - {bytesToSize( - blob.size - )} - ) - -
    - ) - ) + + {blob.name} ( + {bytesToSize( + blob.size + )} + ) + +
    + ))) : ""}{" "}
    diff --git a/components/case/representation/representationInterestedPartyPerson.js b/components/case/representation/representationInterestedPartyPerson.js index 373282a1..9bdb8383 100644 --- a/components/case/representation/representationInterestedPartyPerson.js +++ b/components/case/representation/representationInterestedPartyPerson.js @@ -23,6 +23,7 @@ const RepInterestedPartyPerson = (props) => { setRepresentationCapacity, setRepresentationSubmit, setRepFileName, + updateRepresentation, } = props; const required = (value) => (value ? undefined : "Required"); @@ -31,6 +32,13 @@ const RepInterestedPartyPerson = (props) => { setRepFileName(formObj.representationForm.values); + let filterFilesList = + props.currentView.caseReference.repDetails.filesList.filter(function ( + el + ) { + return el != null; + }); + const files = acceptedFiles.map((file) => (
  • {file.path} - {file.size} bytes @@ -218,8 +226,8 @@ const RepInterestedPartyPerson = (props) => { className="govuk-button progress-save " onClick={() => { let valuesObj = - props.props.form[props.form].values || - {}; + props.props.props.form[props.form] + .values || {}; console.log("valuesobj:", valuesObj); diff --git a/components/pdftemplates/statement_pdf.js b/components/pdftemplates/statement_pdf.js index 15f1d30a..6fcef2f8 100644 --- a/components/pdftemplates/statement_pdf.js +++ b/components/pdftemplates/statement_pdf.js @@ -4,7 +4,7 @@ import { Page, StyleSheet, Text, - View + View, } from "@react-pdf/renderer"; import Html from "react-pdf-html"; import { getFormCollectionByID } from "../../components/utils"; @@ -111,6 +111,9 @@ export const statement_pdf = ({ docProps }) => { let datestr = values.pinswg_name.split("-"); let signedDate = datestr[2] + "/" + datestr[1] + "/" + datestr[0]; let appealTypeValue = getFormCollectionByID(values.appealType); + let filterFilesList = values.filesList.filter(function (el) { + return el != null; + }); return ( @@ -353,7 +356,7 @@ export const statement_pdf = ({ docProps }) => { ]} > {values.hasOwnProperty("filesList") && - values.filesList.map(function (p) { + filterFilesList.map(function (p) { return ( { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var token = await getToken(); + var contactid = req.body.contactid; + var queryUrl = + "incidents(" + + req.body.incidentid + + ")/pinswg_incident_contact_case_involvement/$ref"; + + console.log(req.body, queryUrl); + + var crmUrl = "https://" + process.env.CRMURL; + + var data = { + "@odata.id": crmUrl + "/api/data/v8.2/contacts(" + contactid + ")", + }; + + var config = { + method: "post", + url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json", + "If-None-Match": "null", + "Prefer": 'odata.include-annotations="*",return=representation', + "Authorization": "Bearer " + token.access_token, + "Content-Type": "application/json", + }, + data: data, + }; + + return axios(config) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch((error) => { + return error.status == 412 + ? res.status(200).json({ "record": "exists" }) + : (consoleLogger(Object.assign(error, data)), + res.status(400).json(error)); + }); +} diff --git a/pages/myportal/[appealtypes].js b/pages/myportal/[appealtypes].js index 70503474..432849b8 100644 --- a/pages/myportal/[appealtypes].js +++ b/pages/myportal/[appealtypes].js @@ -324,14 +324,13 @@ export const getServerSideProps = wrapper.getServerSideProps( store.dispatch(setLoggedInUserId(loggedInUser)); store.dispatch(setLoggedInUserEmail(loggedInUserEmail)); - - store.dispatch(setAccountDetails(accountDetails)); store.dispatch(setAppealLPA(query.lpa)); store.dispatch(setAppealTypeID(query.apt)); store.dispatch(setCaseReference(caseReference)); store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData)); store.dispatch(setAppealType(appealTypeData)); store.dispatch(setContainerID(thisSession.user.id)); + store.dispatch(setAccountDetails(accountDetails)); store.dispatch(setFilesForAppeal(blobList)); @@ -351,6 +350,7 @@ const mapStateToProps = (state) => { accountDetails: state.accountDetails, awaitingSubmission: state.awaitingSubmission, currentView: state.currentView, + initialValues: state.appealType.caseReference.caseDetails, }; }; diff --git a/pages/newappeal/[appealtypes].js b/pages/newappeal/[appealtypes].js index 27720a81..4c5945b0 100644 --- a/pages/newappeal/[appealtypes].js +++ b/pages/newappeal/[appealtypes].js @@ -202,7 +202,6 @@ let Home = (props) => { )} -