diff --git a/.env.local b/.env.local index 9038599b..dc2349dc 100644 --- a/.env.local +++ b/.env.local @@ -2,9 +2,9 @@ ACCESS_TOKEN_ENDPOINT = https://login.microsoftonline.com/ //ESNR Tenant -//TENANT = a8d860de-d5e1-45af-8376-d93f02e6b502 +TENANT = a8d860de-d5e1-45af-8376-d93f02e6b502 //WGO Tenant -TENANT = 9ac1a5ab-cd58-409e-a1b6-6b10422a68f5 +//TENANT = 9ac1a5ab-cd58-409e-a1b6-6b10422a68f5 GRANT_TYPE = "client_credentials" HASHKEY = 028ffbae928d7191c0017f298260995f901d78eabde1436c0af0423459cc3715832136d84f68818d3a96399467b52143e273d4f3bf4ae190848891535421cd6c @@ -37,11 +37,11 @@ RELAYPATH = "test-pedw-hc" //Prod Oauth WGO -CLIENT_ID = 3e4141a3-1fbd-454e-98f0-7f3a4f14a3cc -CLIENT_SECRET = mJN7Q~lFu.xFGa5KCc.zwIm_fJAWxajyQaFo~ -RELAY_ROOT = https://prod-pedw-ns.servicebus.windows.net/prod-pedw-hc/ -RELAYURI = "prod-pedw-ns.servicebus.windows.net" -RELAYPATH = "prod-pedw-hc" +//CLIENT_ID = 3e4141a3-1fbd-454e-98f0-7f3a4f14a3cc +//CLIENT_SECRET = mJN7Q~lFu.xFGa5KCc.zwIm_fJAWxajyQaFo~ +//RELAY_ROOT = https://prod-pedw-ns.servicebus.windows.net/prod-pedw-hc/ +//RELAYURI = "prod-pedw-ns.servicebus.windows.net" +//RELAYPATH = "prod-pedw-hc" GOOGLE_TAG_MANAGER = GTM-T78CBC3 diff --git a/components/elements/index.js b/components/elements/index.js index d6b2934c..68e4b0e6 100644 --- a/components/elements/index.js +++ b/components/elements/index.js @@ -3,13 +3,15 @@ import { Field, reduxForm } from "redux-form"; import { useRouter } from "next/router"; import DatePicker, { registerLocale, setDefaultLocale } from "react-datepicker"; import cy from "date-fns/locale/cy"; -import React, { useState } from "react"; +import React, { useCallback, useEffect, useMemo, useState } from "react"; import "react-datepicker/dist/react-datepicker.css"; import moment from "moment"; import jsonpath from "jsonpath"; import fieldLookup from "../../data/crmfieldlookuptranslations.json"; import pickListLookup from "../../data/picklistLookups.json"; import useTranslation from "next-translate/useTranslation"; +import FileUpload from "../newappeal/fileupload"; +import { useDropzone } from "react-dropzone"; const RenderTextfield = ({ id, @@ -538,3 +540,122 @@ const PickListTranslations = (optionValue) => { //console.log(optionTrans, optionValue); return optionTrans; }; + +export function FileUploadField(props) { + return ( +
+ + helllo +
+ ); +} + +const baseStyle = { + display: "flex", + flexDirection: "column", + alignItems: "center", + padding: "20px", + borderWidth: 2, + borderRadius: 2, + borderColor: "#eeeeee", + borderStyle: "dashed", + backgroundColor: "#fafafa", + color: "#bdbdbd", + transition: "border .3s ease-in-out", +}; + +const activeStyle = { + borderColor: "#2196f3", +}; + +const acceptStyle = { + borderColor: "#00e676", +}; + +const rejectStyle = { + borderColor: "#ff1744", +}; + +const RenderFileUpload = ({ + id, + className, + rows, + datafieldname, + name, + label, + input, + errorMsg, + meta: { touched, error }, + ...custom +}) => { + const [files, setFiles] = useState([]); + + const onDrop = useCallback((acceptedFiles) => { + setFiles( + acceptedFiles.map((file) => + Object.assign(file, { + preview: URL.createObjectURL(file), + }) + ) + ); + }, []); + + const { + getRootProps, + getInputProps, + isDragActive, + isDragAccept, + isDragReject, + } = useDropzone({ + onDrop, + }); + + const style = useMemo( + () => ({ + ...baseStyle, + ...(isDragActive ? activeStyle : {}), + ...(isDragAccept ? acceptStyle : {}), + ...(isDragReject ? rejectStyle : {}), + }), + [isDragActive, isDragReject, isDragAccept] + ); + + const thumbs = files.map((file) => ( +
+ {file.name} -{" "} + + {file.name} ({file.size / 1024}kb) + +
+ )); + + // clean up + useEffect( + () => () => { + files.forEach((file) => URL.revokeObjectURL(file.preview)); + }, + [files] + ); + return ( +
+
+
+
+ +

Drag and drop files here or click to select files

+
+
{" "} + + {touched && errorStr && {errorStr}} +
+ ); +}; diff --git a/components/newappeal/buildcheckrow.js b/components/newappeal/buildcheckrow.js index 699de42c..6ebf6762 100644 --- a/components/newappeal/buildcheckrow.js +++ b/components/newappeal/buildcheckrow.js @@ -93,53 +93,65 @@ let BuildCheckRow = (props) => { datafieldname[0].value + "')]" ); - - if (isRequiredField[0].RequiredLevel.Value != "None") { - return ( -
-
- {FieldsTranslations(rows[0].value)} -
-
- {fieldtype[0].value == - "{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" - ? formatDate( - props.props.form["appealForm"] + if (typeof isRequiredField[0] != "undefined") { + if (isRequiredField[0].RequiredLevel.Value != "None") { + return ( +
+
+ {FieldsTranslations(rows[0].value)} +
+
+ {fieldtype[0].value == + "{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" + ? formatDate( + props.props.form["appealForm"] + .values[ + datafieldname[0].value + ] + ) + : fieldtype[0].value == + "{3EF39988-22BB-4f0b-BBBE-64B5A3748AEE}" + ? getPickListLabel( + props.props.formData + .pickListData, + datafieldname[0].value, + props.props.form["appealForm"] + .values[ + datafieldname[0].value + ] + ) + : props.props.form["appealForm"] .values[ datafieldname[0].value - ] - ) - : fieldtype[0].value == - "{3EF39988-22BB-4f0b-BBBE-64B5A3748AEE}" - ? getPickListLabel( - props.props.formData.pickListData, - datafieldname[0].value, - props.props.form["appealForm"] - .values[ - datafieldname[0].value - ] - ) - : props.props.form["appealForm"].values[ - datafieldname[0].value - ]} -
-
- { - updateCurrentSection(whichSection); - }} - > - {t("newappeal:change-link-label")} - - {" "} - {FieldsTranslations(rows[0].value)} - - -
-
- ); + ]} + +
+ { + updateCurrentSection( + whichSection + ); + }} + > + {t("newappeal:change-link-label")} + + {" "} + {FieldsTranslations( + rows[0].value + )} + + +
+ + ); + } else { + return null; + } } else { return null; } diff --git a/components/newappeal/buildfield.js b/components/newappeal/buildfield.js index 00abafa9..2cc60696 100644 --- a/components/newappeal/buildfield.js +++ b/components/newappeal/buildfield.js @@ -13,6 +13,7 @@ import { NumericField, ReadOnlyfield, DecimalField, + FileUploadField, } from "../elements"; export default function BuildField(props) { @@ -25,6 +26,8 @@ export default function BuildField(props) { const parser = new DOMParser(); + console.log(props); + const whichFieldType = (classid) => { switch (classid) { case "{270BD3DB-D9AF-4782-9025-509E298DEC0A}": @@ -107,6 +110,14 @@ export default function BuildField(props) { /> ); break; + case "{16D63FD6-119B-4353-BDCA-18358721C3FE}": + return ( + + ); + break; default: return ( diff --git a/components/newappeal/buildrow.js b/components/newappeal/buildrow.js index 7efdb493..80249e3e 100644 --- a/components/newappeal/buildrow.js +++ b/components/newappeal/buildrow.js @@ -5,6 +5,7 @@ import useTranslation from "next-translate/useTranslation"; import xpath from "xpath"; import BuildField from "./buildfield"; import jsonpath from "jsonpath"; +import FileUpload from "./fileupload"; export default function BuildRow(props) { let { t } = useTranslation(); @@ -36,6 +37,8 @@ export default function BuildRow(props) { var fieldtype = xpath.select("//@classid", doc); var datafieldname = xpath.select("//@datafieldname", doc); + console.log(doc, datafieldname[0].value); + const isRequiredField = jsonpath.query( mandatoryFieldsData, "$..value[?(@.LogicalName=='" + @@ -43,7 +46,7 @@ export default function BuildRow(props) { "')]" ); - if (isRequiredField[0].RequiredLevel.Value != "None") { + if (datafieldname[0].value == "pinswg_fileUpload") { return ( ); } else { - return null; + if (typeof isRequiredField[0] != "undefined") { + if ( + isRequiredField[0].RequiredLevel.Value != "None" + ) { + return ( + + ); + } else { + return null; + } + } else { + return null; + } } } })} diff --git a/components/newappeal/buildsection.js b/components/newappeal/buildsection.js index 452126b2..ad15ac5d 100644 --- a/components/newappeal/buildsection.js +++ b/components/newappeal/buildsection.js @@ -38,15 +38,15 @@ let BuildSection = (props) => { const currentSection = props.appealType.currentSection; const parser = new DOMParser(); var doc = parser.parseFromString(props.formXML, "text/xml"); - // var titles = xpath.select( - // "//form/tabs/tab[" + currentSection + " ]/labels/label/@description", - // doc - // ); + var titles = xpath.select( + "//form/tabs/tab[" + currentSection + " ]/labels/label/@description", + doc + ); var rowXML = xpath.select( - // "/form/tabs/tab[" + - // currentSection + - // "]/columns//sections/section/rows/row", - "/form/tabs/tab/columns//sections/section/rows/row", + "/form/tabs/tab[" + + currentSection + + "]/columns//sections/section/rows/row", + //"/form/tabs/tab/columns//sections/section/rows/row", doc ); @@ -65,7 +65,7 @@ let BuildSection = (props) => { const getErrors = () => { let errorsobj = props.props.form["appealForm"]; - setHasErrors(errorsobj.hasOwnProperty("syncErrors")); + //setHasErrors(errorsobj.hasOwnProperty("syncErrors")); window.scrollTo(0, 0); }; @@ -152,9 +152,9 @@ let BuildSection = (props) => { mandatoryFieldsData={mandatoryFieldsData} props={props} /> - {} +
- {/* {props.sectionCount != currentSection ? ( + {props.sectionCount != currentSection ? ( - {/* ) : ( + {props.sectionCount == currentSection ? ( + + ) : ( "" )} {currentSection > 1 ? ( @@ -189,11 +189,11 @@ let BuildSection = (props) => { ) : ( "" - )} */} + )}
- {/*
+
-
*/} +
); }; diff --git a/components/newappeal/createCase.js b/components/newappeal/createCase.js index 0e176059..87d5a3c5 100644 --- a/components/newappeal/createCase.js +++ b/components/newappeal/createCase.js @@ -247,7 +247,6 @@ let CreateCase = (props) => { label={t("newappeal:select-appeal-type-label")} errorMsg={t("newappeal:select-appeal-type-label-error-msg")} /> -