diff --git a/.env.local b/.env.local index 4b58fdf3..8ee37a0e 100644 --- a/.env.local +++ b/.env.local @@ -13,11 +13,11 @@ RELAYPATH = "dev-pedw-hc" //Test Oauth ESNR -//CLIENT_ID = d40b9373-96c2-4b04-8bd8-c2a2fe6444c1 -//CLIENT_SECRET = IXI8Q~D5oqsC-nrtayHHc~tUAfjQFzNiKVQ~fc2S -//RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ -//RELAYURI = "test-pedw-ns.servicebus.windows.net" -//RELAYPATH = "test-pedw-hc" +CLIENT_ID = d40b9373-96c2-4b04-8bd8-c2a2fe6444c1 +CLIENT_SECRET = IXI8Q~D5oqsC-nrtayHHc~tUAfjQFzNiKVQ~fc2S +RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ +RELAYURI = "test-pedw-ns.servicebus.windows.net" +RELAYPATH = "test-pedw-hc" //Preprod Oauth WGO @@ -63,12 +63,12 @@ SECRET = SuperSecret AZURE_CLIENT_ID = $CLIENT_ID AZURE_TENANT_ID = $TENANT AZURE_CLIENT_SECRET = $CLIENT_SECRET -AZURE_STORAGE_ACCOUNT_NAME= "pedwdev" -//AZURE_STORAGE_ACCOUNT_NAME= "pedwtest" +//AZURE_STORAGE_ACCOUNT_NAME= "pedwdev" +AZURE_STORAGE_ACCOUNT_NAME= "pedwtest" AZURE_STORAGE_ACCOUNT_KEY = JS3ZIXianhYhB1lZrHB+bXbdzaLlON0alCyKrFAb+jVEwr9iqo2dty92EBxwnufNFM+CSN/fKX2R+AStDn0byg== -AZURE_PEDW_STORAGE_ENDPOINT = https://pedwdev.blob.core.windows.net -//AZURE_PEDW_STORAGE_ENDPOINT = https://pedwtest.blob.core.windows.net +//AZURE_PEDW_STORAGE_ENDPOINT = https://pedwdev.blob.core.windows.net +AZURE_PEDW_STORAGE_ENDPOINT = https://pedwtest.blob.core.windows.net AZURE_PEDW_CONTAINER = "pedwapplications" AZURE_PEDW_QUEUE_ENDPOINT = https://$AZURE_STORAGE_ACCOUNT_NAME.queue.core.windows.net diff --git a/actions/index.js b/actions/index.js index b428fabe..18a75fb3 100644 --- a/actions/index.js +++ b/actions/index.js @@ -1399,7 +1399,7 @@ export const generateAppealPDF = async ( //formValues.append("filesList", fileList); Object.assign(formValues, { - "filesList": fileList.hasOwnProperty("value") ? fileList.value : [], + "filesList": fileList, }); var queryUrl = "/api/file/generateappealpdf?appealType=" + appealType; diff --git a/components/elements/index.js b/components/elements/index.js index 6be54d64..cca33efe 100644 --- a/components/elements/index.js +++ b/components/elements/index.js @@ -71,13 +71,16 @@ const RenderTextfield = ({ )} @@ -212,7 +215,9 @@ const RenderMultiline = ({ maxLength={ custom.hasOwnProperty("maxFieldLength") ? custom.maxFieldLength - : undefined + ? custom.maxFieldLength + : 800 + : 800 } > diff --git a/components/newappeal/aboutyou.js b/components/newappeal/aboutyou.js index d4a1d078..b7847f25 100644 --- a/components/newappeal/aboutyou.js +++ b/components/newappeal/aboutyou.js @@ -49,11 +49,6 @@ const RenderTextfield = ({ id={id} type={type} disabled={disabled ? true : false} - maxLength={ - custom.hasOwnProperty("maxFieldLength") - ? custom.maxFieldLength - : undefined - } /> diff --git a/components/newappeal/buildcheckrow.js b/components/newappeal/buildcheckrow.js index 87f92555..f4499d9e 100644 --- a/components/newappeal/buildcheckrow.js +++ b/components/newappeal/buildcheckrow.js @@ -63,7 +63,7 @@ let BuildCheckRow = (props) => { const { locale } = router; const { appealtypes } = router.query; - let formObj = jsonpath(fieldLookup, "$['" + appealtypes + "']"); + let formObj = jsonpath("$['" + appealtypes + "']", fieldLookup); let labelTrans = router.locale == "cy" diff --git a/components/newappeal/buildchecksection.js b/components/newappeal/buildchecksection.js index e4a88aa0..1ee3b638 100644 --- a/components/newappeal/buildchecksection.js +++ b/components/newappeal/buildchecksection.js @@ -16,6 +16,7 @@ import { getThumbnailIconByExtension, bytesToSize, } from "../utils"; +import { generateAppealPDF } from "../../actions"; let BuildCheckSection = (props) => { useEffect(() => { @@ -70,6 +71,38 @@ let BuildCheckSection = (props) => { alert(1); }; + let buildAppealFilesArray = []; + console.log("attached docs: - ", buildAppealFilesArray); + + let filesUplaodObj = Object.keys(props.props.form.appealForm.values) + .filter(function (k) { + return k.indexOf("pinswg_fileUpload") == 0; + }) + .reduce(function (newData, k) { + newData[k] = props.props.form.appealForm.values[k]; + return newData; + }, {}); + + console.log(filesUplaodObj); + + for (let key in filesUplaodObj) { + for (let j in filesUplaodObj[key]) { + buildAppealFilesArray.push({ + "name": filesUplaodObj[key][j].name, + "size": filesUplaodObj[key][j].size, + }); + } + } + + console.log(buildAppealFilesArray); + + let pdfObj = props.props.form.appealForm.values; + + Object.assign(pdfObj, { + "containerID": props.props.accountDetails.containerID, + "casefolderID": props.appealType.caseReference.ticketnumber, + }); + return (
@@ -98,41 +131,30 @@ let BuildCheckSection = (props) => {
- {props.props.appealType.fileList.value.length > - 0 - ? props.props.appealType.fileList.value.map( - (blob, i) => ( -
- {blob[i].name.slice( + {buildAppealFilesArray.length > 0 + ? buildAppealFilesArray.map((blob, i) => ( +
+ {blob.name.slice( - - {blob[i].name.slice( - blob[i].name.indexOf( - "_" - ) + 1 - )} - ( - {bytesToSize( - blob[i].contentLength - )} - ) - -
- ) - ) + + {blob.name.slice( + blob.name.indexOf("_") + 1 + )} + ({bytesToSize(blob?.size)}) + +
+ )) : ""}
@@ -153,7 +175,16 @@ let BuildCheckSection = (props) => { setCurrentSection(9999)} + onClick={() => { + setCurrentSection(9999), + generateAppealPDF( + pdfObj, + props.props.accountDetails.containerID, + props.appealType.caseReference.ticketnumber, + router.query.appealtypes, + props.appealType.fileList + ); + }} > {t("newappeal:submit-appeal-button")} diff --git a/components/newappeal/buildsection.js b/components/newappeal/buildsection.js index a182b897..47f1b9e0 100644 --- a/components/newappeal/buildsection.js +++ b/components/newappeal/buildsection.js @@ -115,9 +115,9 @@ let BuildSection = (props) => { var dataObj = values; - for (let key in dataObj) { - _.includes(key, "pinswg_fileUpload") == true && delete dataObj[key]; - } + // for (let key in dataObj) { + // _.includes(key, "pinswg_fileUpload") == true && delete dataObj[key]; + // } uploadFiles( dataObj, @@ -177,23 +177,9 @@ let BuildSection = (props) => { "\n////////////////////////\n" ); - let pdfObj = values; - - Object.assign(pdfObj, { - "containerID": props.props.accountDetails.containerID, - "casefolderID": props.appealType.caseReference.ticketnumber, - }); - - generateAppealPDF( - pdfObj, - props.props.accountDetails.containerID, - props.appealType.caseReference.ticketnumber, - router.query.appealtypes, - props.appealType.fileList - ), - props.setNewAppealProgress( - getProgressObj(formXML, titleList, mandatoryFieldsData, props) - ); + props.setNewAppealProgress( + getProgressObj(formXML, titleList, mandatoryFieldsData, props) + ); let appTypeCollection = getFormCollectionByID( props.appealType.appealTypeID @@ -270,6 +256,31 @@ let BuildSection = (props) => { const onHandleSubmit = (values) => { //if (currentSection == sectionCount) { let valuesObj = values || {}; + let buildAppealFilesArray = []; + let filesUplaodObj = Object.keys(values) + .filter(function (k) { + return k.indexOf("pinswg_fileUpload") == 0; + }) + .reduce(function (newData, k) { + newData[k] = values[k]; + return newData; + }, {}); + + console.log(filesUplaodObj); + + for (let key in filesUplaodObj) { + for (let j in filesUplaodObj[key]) { + buildAppealFilesArray.push({ + "name": filesUplaodObj[key][j].name, + "size": filesUplaodObj[key][j].size, + }); + } + } + + console.log(buildAppealFilesArray); + setFilesForAppeal(buildAppealFilesArray); + + // Object.assign(values, { "filesList": buildAppealFilesArray }); delete valuesObj["_pinswg_appellant_value"]; console.log("has errors:", props.invalid); diff --git a/components/newappeal/createCase.js b/components/newappeal/createCase.js index d65ba695..75dab272 100644 --- a/components/newappeal/createCase.js +++ b/components/newappeal/createCase.js @@ -17,6 +17,351 @@ import Aboutyou from "./aboutyou"; import { createNewCase, createNewCaseBlob, consoleLogger } from "../../actions"; import { FieldsTranslations } from "../elements"; +const RenderLPAList = ({ + name, + input, + optionsObj, + meta: { touched, error }, + label, + errorMsg, +}) => { + let { t } = useTranslation(); + const router = useRouter(); + + return ( + <> +
+ {" "} + + {touched && error && ( + + Error:{" "} + {errorMsg} + + )} +
+ +
+
+ + ); +}; + +const RenderAppealTypeList = ({ + name, + input, + optionsObj, + meta: { touched, error }, + label, + errorMsg, +}) => { + let { t } = useTranslation(); + const router = useRouter(); + return ( + <> +
+ + {touched && error && ( + + Error:{" "} + {errorMsg} + + )} +
+ +
+
+ + ); +}; + +const RenderRadio = ({ + datafieldname, + name, + label, + id, + errorMsg, + options, + input: { onChange, value }, + meta: { touched, error }, + ...custom +}) => { + let { t } = useTranslation(); + const required = (value) => (value ? undefined : "Required"); + return ( + <> +
+
+ + + + {touched && error && ( + + + Error: + {" "} + {errorMsg} + + )} +
+ {" "} + {custom.hint != undefined && ( +
{custom.hint}
+ )} + {Object.keys(options).map((key, index) => ( +
+ { + let docListObj = custom.documentList; + if ( + custom.requiredDocumentValue == + "Yes" + ) { + e.target.value != "846040000" + ? (docListObj = Object.assign( + docListObj, + { + ["documentCheckList_" + + id]: + custom.requiredDocumentLabel, + } + )) + : delete docListObj[ + "documentCheckList_" + id + ]; + custom.setDocumentsList(docListObj); + } + }} + /> + +
+ ))} +
+
+
+ + ); +}; + +function Radiofield(props) { + const { + name, + label, + datafieldname, + parentField, + form, + formProps, + parentFieldShowOnValue, + validation, + } = props; + + const router = useRouter(); + const required = (value) => (value ? undefined : "Required"); + // console.log(props.options); + + const fieldOptions = props.options + .slice(1, props.options.length - 1) + .split(","); + + //parentFieldShowOnValue + var showIfHasParentShowValue = parentField != false; + //debugger; + // parentField != false && + // !_.isEmpty(formProps[form]) && + // _.has(formProps[form].values, parentField) && + // parentFieldShowOnValue.indexOf( + // formProps[form].values[parentField].toString() + // ) > -1; + + (showIfHasParentShowValue == parentField) != false && + showIfHasParentShowValue; + + // console.log( + // datafieldname, + // showIfHasParentShowValue, + // formProps[form].values[parentField] + // ); + + return ( + <> + {parentField != false ? ( + showIfHasParentShowValue && ( + + ) + ) : ( + + )} + + ); +} + let CreateCase = (props) => { // useEffect(() => { // window.scrollTo(0, 0); @@ -49,368 +394,6 @@ let CreateCase = (props) => { ? [{}] : props.LPAData.LPAData.value; - const RenderLPAList = ({ - name, - input, - optionsObj, - meta: { touched, error }, - label, - errorMsg, - }) => { - return ( - <> -
- {" "} - - {touched && error && ( - - - Error: - {" "} - {errorMsg} - - )} -
- -
-
- - ); - }; - - const RenderAppealTypeList = ({ - name, - input, - optionsObj, - meta: { touched, error }, - label, - errorMsg, - }) => { - return ( - <> -
- - {touched && error && ( - - - Error: - {" "} - {errorMsg} - - )} -
- -
-
- - ); - }; - - const RenderRadio = ({ - datafieldname, - name, - label, - id, - errorMsg, - options, - input: { onChange, value }, - meta: { touched, error }, - ...custom - }) => { - let { t } = useTranslation(); - const required = (value) => (value ? undefined : "Required"); - return ( - <> -
-
- - - - {touched && error && ( - - - Error: - {" "} - {errorMsg} - - )} -
- {" "} - {custom.hint != undefined && ( -
{custom.hint}
- )} - {Object.keys(options).map((key, index) => ( -
- { - let docListObj = - custom.documentList; - if ( - custom.requiredDocumentValue == - "Yes" - ) { - e.target.value != "846040000" - ? (docListObj = - Object.assign( - docListObj, - { - ["documentCheckList_" + - id]: - custom.requiredDocumentLabel, - } - )) - : delete docListObj[ - "documentCheckList_" + - id - ]; - custom.setDocumentsList( - docListObj - ); - } - }} - /> - -
- ))} -
-
-
- - ); - }; - - function Radiofield(props) { - const { - name, - label, - datafieldname, - parentField, - form, - formProps, - parentFieldShowOnValue, - validation, - } = props; - - const router = useRouter(); - const required = (value) => (value ? undefined : "Required"); - // console.log(props.options); - - const fieldOptions = props.options - .slice(1, props.options.length - 1) - .split(","); - - //parentFieldShowOnValue - var showIfHasParentShowValue = parentField != false; - //debugger; - // parentField != false && - // !_.isEmpty(formProps[form]) && - // _.has(formProps[form].values, parentField) && - // parentFieldShowOnValue.indexOf( - // formProps[form].values[parentField].toString() - // ) > -1; - - (showIfHasParentShowValue == parentField) != false && - showIfHasParentShowValue; - - // console.log( - // datafieldname, - // showIfHasParentShowValue, - // formProps[form].values[parentField] - // ); - - return ( - <> - {parentField != false ? ( - showIfHasParentShowValue && ( - - ) - ) : ( - - )} - - ); - } - const required = (value) => (value ? undefined : "Required"); const [formStep, setFormStep] = useState(0); diff --git a/components/utils/index.js b/components/utils/index.js index 085cbde8..ef279b0f 100644 --- a/components/utils/index.js +++ b/components/utils/index.js @@ -228,8 +228,14 @@ export const getProgressObj = ( "totalFields": formObj[key].fieldsTotal, "allFieldsComplete": titleList[key].value == "Upload documents" - ? _.has(props.props.appealType.fileList, "value") && - props.props.appealType.fileList.value.length > 0 + ? (_.has(props.props.appealType.fileList, "value") && + props.props.appealType.fileList.value.length > + 0) || + (_.has(props.props.form.appealForm, "values") && + Object.keys( + props.props.form.appealForm.values + ).filter((k) => k.startsWith("pinswg_fileUpload")) + .length > 0) : rowCount == formObj[key].fieldsTotal, }; }); diff --git a/package.json b/package.json index d5e1e866..9ca1499e 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "react-quill": "^2.0.0", "react-redux": "^7.2.6", "redux": "^4.2.1", - "redux-form": "^8.3.9", + "redux-form": "^8.3.10", "redux-persist": "^6.0.0", "redux-thunk": "^2.4.2", "sass": "1.69", @@ -90,4 +90,4 @@ "next-translate-plugin": "^2.6.2", "prisma": "^5.0.0" } -} \ No newline at end of file +} diff --git a/store/appealType/reducer.js b/store/appealType/reducer.js index f6eca85b..060cf079 100644 --- a/store/appealType/reducer.js +++ b/store/appealType/reducer.js @@ -9,7 +9,7 @@ const appealTypeDataInitialState = { caseReference: {}, formComplete: "false", documentList: {}, - fileList: {}, + fileList: [], progress: [], }; diff --git a/styles/sass/welshgov/_application.scss b/styles/sass/welshgov/_application.scss index 3635f36f..ec673b4d 100644 --- a/styles/sass/welshgov/_application.scss +++ b/styles/sass/welshgov/_application.scss @@ -432,6 +432,7 @@ textarea, background-color: #fff; padding: 7px 15px; border: 1px solid #666666; + min-width: 15rem; &:focus { outline: 2px solid #ffdd00;