From ee4d00a5007ebadceb647f2fe69e88c2ea1c89f2 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Thu, 5 Jan 2023 14:26:08 +0000 Subject: [PATCH] reps trigger for logged out & upload storage acc --- .env.local | 2 +- components/case.js | 2 +- components/case/representation/index.js | 52 +++---- .../representation/representationAgent.js | 141 ++++------------- .../representation/representationAppellant.js | 143 ++++------------- .../representationCapacitySelection.js | 2 +- .../representationCompleteSubmit.js | 13 +- .../representationInterestedPartyPerson.js | 27 ++-- .../representation/representationLandowner.js | 144 ++++-------------- components/case/summary.js | 82 +++++----- components/myportal/topthree_reps.js | 2 +- pages/myportal/index.js | 22 +-- pages/myportal/representation.js | 47 +++++- pages/myportal/searchresults.js | 7 + store/currentView/reducer.js | 1 + styles/sass/welshgov/_application.scss | 29 ++-- 16 files changed, 251 insertions(+), 465 deletions(-) diff --git a/.env.local b/.env.local index b25b40e9..bda06a64 100644 --- a/.env.local +++ b/.env.local @@ -45,7 +45,7 @@ RELAYPATH = "dev-pedw-hc" GOOGLE_TAG_MANAGER = GTM-T78CBC3 SHOWLOGIN = "true" -SHOWREPRESENTATIONS = "true" +SHOWREPRESENTATIONS = true SHOWFILEUPLOAD = "false" SHOWMAPS = "false" //BASIC_AUTH_CREDENTIALS = pinswg:password|pinswg2:password2 diff --git a/components/case.js b/components/case.js index ab83efee..6dde13cb 100644 --- a/components/case.js +++ b/components/case.js @@ -45,7 +45,7 @@ const Case = (props) => { searchDetailsObj={props.searchDetailsObj} documentDetailsObj={props.documentDetailsObj} /> - {showRepresentations == "true" && ( + {showRepresentations == true && ( { setRepresentationSubmitConfirmation, } = props; const formObj = props.props.form; - let setCaseQueryObj = props[currentType]; + let setCaseQueryObj = props[currentType] || {}; var casesObj = {}; currentType == "searchResultsObj" @@ -84,16 +84,6 @@ let MakeRepresentation = (props) => { var detailsObj = {}; - currentType == "searchResultsObj" - ? (casesObj = jsonpath.query( - setCaseQueryObj, - '$..[?(@.title=="' + caseReference + '")]' - )) - : (casesObj = jsonpath.query( - setCaseQueryObj, - '$..[?(@.reference=="' + caseReference + '")]' - )); - const capacityOptionsArr = [ "Appellant", "Agent", @@ -213,6 +203,7 @@ let MakeRepresentation = (props) => { setRepresentationSubmit={setRepresentationSubmit} currentView={currentView} setSubmitBack={setSubmitBack} + props={props} /> ); break; @@ -248,6 +239,7 @@ let MakeRepresentation = (props) => { let day = repDate.getDate(); let month = repDate.getMonth() + 1; let year = repDate.getFullYear(); + let time = repDate.getTime(); const repType = ""; switch (values.representationCapacity) { @@ -276,6 +268,8 @@ let MakeRepresentation = (props) => { "-" + day + "-" + + time + + "-" + repType + "-REP" + "_" + @@ -299,7 +293,7 @@ let MakeRepresentation = (props) => { //console.log(updateBody); - window.alert(`form is :\n\n${JSON.stringify(updateBody, null, 2)}`); + //window.alert(`form is :\n\n${JSON.stringify(updateBody, null, 2)}`); const reference = "PEDW-PARTIAL-REP"; const templateId = "021b0a7b-df00-41f1-b94e-c269bee98c75"; @@ -323,35 +317,23 @@ let MakeRepresentation = (props) => { const onHandleSubmit = (values) => { currentView.representationSubmit != true - ? // console.log( - // values, - // values.representationCapacity, - // currentView.representationCapacity - // ); - - // console.log(_.isEmpty(currentView.representationCapacity)); - // console.log( - // values.representationCapacity - // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") - // .toLowerCase() == currentView.representationCapacity - // ); - - _.isEmpty(currentView.representationCapacity) + ? _.isEmpty(currentView.representationCapacity) ? setRepresentationCapacity( values.representationCapacity .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") .toLowerCase() ) : setRepresentationSubmit(true) - : currentView.representationSubmit == true && - (console.log("capacity", currentView.representationCapacity), + : currentView.representationSubmit == true + ? (console.log("capacity", currentView.representationCapacity), console.log("has errors:", props.invalid), props.invalid == false && updateRepresentation(values, false, false), uploadRepresentationFiles(values), - setRepresentationSubmitConfirmation(true)); + setRepresentationSubmitConfirmation(true)) + : console.log("nit updated"); - window.alert(`You submitted:\n\n${JSON.stringify(values, null, 2)}`); + //window.alert(`You submitted:\n\n${JSON.stringify(values, null, 2)}`); }; const uploadRepresentationFiles = (values) => { @@ -388,15 +370,15 @@ let MakeRepresentation = (props) => { const repForm = props.props.form; - // console.log( - // "waht is representationSubmit:", - // currentView.representationSubmit - // ); + console.log( + "waht is representationSubmit:", + currentView.representationSubmit + ); return (
- {currentView.representationSubmit == "true" ? ( + {currentView.representationSubmit == true ? ( { />
+

@@ -101,122 +103,33 @@ const RepAgent = (props) => { aria-describedby="commentBox-hint" >

- My comments are set out in:* + My comments are set out in:
-
-
- - -
-
+ +
+ +
+ -
- -
-
-
- - -
-
-
-
-
- -

- Drag and drop files here or - click to select files -

-
- -
-
-
+ />
{" "} diff --git a/components/case/representation/representationAppellant.js b/components/case/representation/representationAppellant.js index ac1bdaaa..30eaffed 100644 --- a/components/case/representation/representationAppellant.js +++ b/components/case/representation/representationAppellant.js @@ -11,6 +11,7 @@ import { RenderRadioList, RenderMultiline, RenderFileUpload, + FileUploadField, } from "./representationElements"; import { useDropzone } from "react-dropzone"; // import { @@ -70,6 +71,7 @@ const RepAppellant = (props) => { />
*/} +

@@ -81,124 +83,33 @@ const RepAppellant = (props) => { aria-describedby="commentBox-hint" >

- My comments are set out in:* + My comments are set out in:
-
-
- - -
-
+ +
+ +
+ -
- -
-
-
- - -
-
-

- {props.label}{" "} -

- -
+ />
{" "} diff --git a/components/case/representation/representationCapacitySelection.js b/components/case/representation/representationCapacitySelection.js index a6f86ceb..3ea08db6 100644 --- a/components/case/representation/representationCapacitySelection.js +++ b/components/case/representation/representationCapacitySelection.js @@ -77,7 +77,7 @@ let RepCapacitySelection = (props) => { className="govuk-button" data-module="govuk-button" > - Continue + {t("common:continue-button")}
diff --git a/components/case/representation/representationCompleteSubmit.js b/components/case/representation/representationCompleteSubmit.js index 859e6225..9630e02e 100644 --- a/components/case/representation/representationCompleteSubmit.js +++ b/components/case/representation/representationCompleteSubmit.js @@ -166,6 +166,7 @@ const RepCompleteSubmit = (props) => {
{ type="submit" className="govuk-button" data-module="govuk-button" - onClick={() => - //setRepresentationSubmitConfirmation() - setRepresentationSubmit(true) - } + // onClick={() => { + // setRepresentationSubmitConfirmation(); + // setRepresentationSubmit(true); + // }} > - Continue + {t("common:continue-button")} {/* { @@ -280,7 +281,7 @@ const RepCompleteSubmit = (props) => { onClick={() => setSubmitBack()} className="govuk-link" > - Back + {t("case:summary-back-button-label")} diff --git a/components/case/representation/representationInterestedPartyPerson.js b/components/case/representation/representationInterestedPartyPerson.js index 40a89886..d33d2485 100644 --- a/components/case/representation/representationInterestedPartyPerson.js +++ b/components/case/representation/representationInterestedPartyPerson.js @@ -117,25 +117,26 @@ const RepInterestedPartyPerson = (props) => { {" "} +
diff --git a/components/case/representation/representationLandowner.js b/components/case/representation/representationLandowner.js index d87d4538..8e9e6b01 100644 --- a/components/case/representation/representationLandowner.js +++ b/components/case/representation/representationLandowner.js @@ -7,6 +7,7 @@ import { RenderTextfield, RenderRadioList, RenderMultiline, + FileUploadField, } from "./representationElements"; import { useDropzone } from "react-dropzone"; import { @@ -69,6 +70,7 @@ const RepLandOwner = (props) => { /> */} +

@@ -80,126 +82,38 @@ const RepLandOwner = (props) => { aria-describedby="commentBox-hint" >

- My comments are set out in:* + My comments are set out in:
-
-
- - -
-
+ +
+ +
+ -
- -
-
-
- - -
-
-
-
-
- -

- Drag and drop files here or - click to select files -

-
- -
-
-
+ />
-
+
{" "} +
- {props.currentView.showReps == "true" && - _.has(detailsObj, "pinswg_startdate") && - hasEndDate && - showReps( - detailsObj.pinswg_startdate, - detailsObj.pinswg_representation_period_end_date - ) && ( -
-
- - )} - {props.currentView.showReps == "true" && + ))} + {props.currentView.showReps == true && _.has(detailsObj, "pinswg_startdate") && hasEndDate && showRepsEnded( @@ -352,7 +355,6 @@ const CaseSummary = (props) => {
)} - {/* 1{" "} {_.has(detailsObj, "pinswg_startdatetimeiftheevent") && detailsObj.pinswg_startdatetimeiftheevent} diff --git a/components/myportal/topthree_reps.js b/components/myportal/topthree_reps.js index afb00f42..973e32c3 100644 --- a/components/myportal/topthree_reps.js +++ b/components/myportal/topthree_reps.js @@ -133,7 +133,7 @@ const TopThree = (props) => { } }; - let topThreeOnlyArr = showTopThreeArr.slice(0, 3); + let topThreeOnlyArr = showTopThreeArr; //.slice(0, 3); Object.keys(topThreeOnlyArr).map((key, index) => { topthreeRow.push(
diff --git a/pages/myportal/index.js b/pages/myportal/index.js index 064c113d..506732fe 100644 --- a/pages/myportal/index.js +++ b/pages/myportal/index.js @@ -162,23 +162,25 @@ export const getServerSideProps = wrapper.getServerSideProps( let loggedInUserCookie = cookies.pinsUser; let thisSession = await getSession(ctx); + let loggedInUser = {}; - let [loggedInUser] = await Promise.all([ - await getPortalLogin(thisSession.user.email), - ]); - - loggedInUser = loggedInUser.value[0].contactid; - console.log("nextAuth Session:", thisSession); - - if (_.has(thisSession, "user") == false) { + if (!thisSession) { + console.log("not has sesssion......."); return { redirect: { - destination: "/error", + destination: "/auth/signin", permanent: false, }, }; - } + } else { + console.log(" has sesssion......."); + [loggedInUser] = await Promise.all([ + await getPortalLogin(thisSession.user.email), + ]); + loggedInUser = loggedInUser.value[0].contactid; + console.log("nextAuth Session:", thisSession); + } //Create Storage container for logged in user await createContainer(thisSession.user.id); diff --git a/pages/myportal/representation.js b/pages/myportal/representation.js index fa988486..cf0b1e63 100644 --- a/pages/myportal/representation.js +++ b/pages/myportal/representation.js @@ -1,7 +1,9 @@ import useTranslation from "next-translate/useTranslation"; import Head from "next/head"; +import { useEffect } from "react"; + import { useRouter } from "next/router"; -import { connect } from "react-redux"; +import { connect, useDispatch } from "react-redux"; import Breadcrumbs from "../../components/breadcrumbs"; import CookieBanner from "../../components/cookieBanner"; import Footer from "../../components/footer"; @@ -9,7 +11,17 @@ import Header from "../../components/header"; import Case from "../../components/representation"; import { wrapper } from "../../store/store"; import { getSession, useSession } from "next-auth/react"; -import { getPersonalAccount } from "../../actions"; +import { + consoleLogger, + getPersonalAccount, + getPortalLogin, +} from "../../actions"; +import { + setRepresentationCapacity, + setRepresentationSubmit, + setSubmitBack, + setRepresentationSubmitConfirmation, +} from "../../store/currentView/action"; import { setAccountDetails, setContainerID, @@ -24,6 +36,27 @@ const Home = (props) => { const { locale } = router; const { appealtypes } = router.query; + const dispatch = useDispatch(); + + useEffect(async () => { + const thisSession = await getSession(); + + if (thisSession) { + let [loggedInUser] = await Promise.all([ + await getPortalLogin(thisSession.user.email), + ]); + + dispatch( + setAccountDetails( + await getPersonalAccount(loggedInUser.value[0].contactid) + ) + ); + dispatch(setContainerID(thisSession.user.id)); + + //dispatch(setRepresentationSubmit(true)); + } + }, [dispatch]); + return (
@@ -148,6 +181,14 @@ const Home = (props) => { // } // ); +const mapDispatchToProps = (dispatch) => { + return { + setAccountDetails: (loggedInUser) => { + dispatch(setAccountDetails(loggedInUser)); + }, + }; +}; + const mapStateToProps = (state) => { //console.log(state); @@ -166,4 +207,4 @@ const mapStateToProps = (state) => { }; }; -export default connect(mapStateToProps)(Home); +export default connect(mapStateToProps, mapDispatchToProps)(Home); diff --git a/pages/myportal/searchresults.js b/pages/myportal/searchresults.js index 0037c0a4..86b172ab 100644 --- a/pages/myportal/searchresults.js +++ b/pages/myportal/searchresults.js @@ -29,6 +29,8 @@ import { setWatchedCases, setWatchedCasesDetails, } from "../../store/watchedCases/action"; +import { setShowReps } from "../../store/currentView/action"; + import TimeOut from "../../components/timeout"; import { getSession, useSession } from "next-auth/react"; import { @@ -87,6 +89,11 @@ export const getServerSideProps = wrapper.getServerSideProps( await getPortalLogin(thisSession.user.email), ]); + const showReps = process.env.SHOWREPRESENTATIONS || false; + + console.log("env var ", process.env.SHOWREPRESENTATIONS); + store.dispatch(setShowReps(showReps)); + searchResultsObj = searchResultsObj.status == 502 ? { diff --git a/store/currentView/reducer.js b/store/currentView/reducer.js index 005c21ce..6cd5e550 100644 --- a/store/currentView/reducer.js +++ b/store/currentView/reducer.js @@ -8,6 +8,7 @@ const currentViewInitialState = { representationSubmitConfirmation: {}, linkedCaseReferences: {}, currentPage: 1, + showReps: false, }; export default function reducer(state = currentViewInitialState, action) { diff --git a/styles/sass/welshgov/_application.scss b/styles/sass/welshgov/_application.scss index d00a11df..2ce1058c 100644 --- a/styles/sass/welshgov/_application.scss +++ b/styles/sass/welshgov/_application.scss @@ -907,11 +907,11 @@ textarea, .app-step-nav__step--active .app-step-nav__circle--number, .app-step-nav__step--active:after, .app-step-nav__step--active .app-step-nav__help:after { - border-color: $lightgrey !important; + border-color: $lightgrey !important; } .app-step-nav__circle--number { - border-color: $lightgrey !important; + border-color: $lightgrey !important; } .app-step-nav__circle-background { @@ -998,6 +998,17 @@ textarea, } +.govuk-summary-list__value { + .multiline-elipsis { + -webkit-box-orient: vertical; + display: -webkit-box; + -webkit-line-clamp: 10; + overflow: hidden; + text-overflow: ellipsis; + white-space: normal; + } +} + .documentList { .govuk-summary-list__key:first-of-type { width: 40%; @@ -1039,12 +1050,12 @@ textarea, padding: 10px 15px !important; font-size: 16px; float: right; - border-color: $midgrey !important; - color: $midgrey !important; + border-color: $midgrey !important; + color: $midgrey !important; &:hover { - background-color: $midgrey !important; - color: $white !important; + background-color: $midgrey !important; + color: $white !important; } } @@ -1054,7 +1065,7 @@ textarea, font-size: 16px; float: right; - color: $midgrey !important; + color: $midgrey !important; @@ -1167,7 +1178,7 @@ textarea, height: 2.5rem; margin-top: 0; padding: 10px 15px; - border: 1px solid $darkgrey !important; + border: 1px solid $darkgrey !important; border-radius: 0; -webkit-appearance: none; appearance: none; @@ -2024,7 +2035,7 @@ ul#sharePageLinks.active { } &.watched_link { - color: $black !important; + color: $black !important; background-color: $white; width: 13px; display: block;