wip for delete reps in view all

This commit is contained in:
2024-05-30 15:43:33 +01:00
parent ec6c76ded0
commit cf8ff7f45f
14 changed files with 651 additions and 21 deletions
+77 -10
View File
@@ -4,11 +4,17 @@ import _ from "lodash";
import { useState } from "react";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
import { getSession, useSession } from "next-auth/react";
import {
setCurrentLinkedCases,
setCurrentReference,
setCurrentView,
} from "../store/currentView/action";
const Breadcrumbs = (props) => {
const { courseContent, slug, currentView } = props;
const { courseContent, slug, currentView, setCurrentView } = props;
const router = useRouter();
const { appealType, section } = router.query;
@@ -456,16 +462,18 @@ const Breadcrumbs = (props) => {
</Link>
</li>
<li className="govuk-breadcrumbs__list-item">
{currentView.viewKey ==
{currentView.currentView.viewKey ==
"awaitingSubmissionDetails" &&
t(
"myportal:awatitingsubmission-card-title"
)}
{currentView.viewKey == "watchedCases" &&
{currentView.currentView.viewKey ==
"watchedCases" &&
t("myportal:watchedcases-card-title")}
{currentView.viewKey == "myCases" &&
{currentView.currentView.viewKey ==
"myCases" &&
t("myportal:mycases-card-title")}
{currentView.viewKey ==
{currentView.currentView.viewKey ==
"myRepresentations" &&
t(
"myportal:myrepresentations-card-title"
@@ -491,7 +499,7 @@ const Breadcrumbs = (props) => {
{t("common:breadcrumb-my-portal")}
</Link>
</li>
<li className="govuk-breadcrumbs__list-item">
{/* <li className="govuk-breadcrumbs__list-item">
<Link
href={
router.locale != "en"
@@ -501,10 +509,18 @@ const Breadcrumbs = (props) => {
: "/myportal/viewall"
}
className="govuk-breadcrumbs__link"
onClick={() => {
setCurrentView({
"viewName":
"Awaiting Submission",
"viewKey":
"awaitingSubmissionDetails",
});
}}
>
{t("common:breadcrumb-your-cases")}
</Link>
</li>
</li> */}
<li className="govuk-breadcrumbs__list-item">
{t("common:breadcrumb-case-reference")}:{" "}
{
@@ -648,6 +664,35 @@ const Breadcrumbs = (props) => {
) : (
""
)}
{router.pathname == "/myportal/case/[ticketnumber]" ? (
<>
{" "}
<li className="govuk-breadcrumbs__list-item">
<Link
href={
router.locale != "en"
? "/" +
router.locale +
"/fymhorth"
: "/myportal"
}
className="govuk-breadcrumbs__link"
>
{t("common:breadcrumb-my-portal")}
</Link>
</li>
<li className="govuk-breadcrumbs__list-item">
{t("common:breadcrumb-case-reference")}:{" "}
{
props.props.currentView.caseReference
.currentReference
}
</li>
</>
) : (
""
)}
{router.pathname == "/myportal/dnsapplications" ? (
<>
{" "}
@@ -764,8 +809,15 @@ const Breadcrumbs = (props) => {
<Link
href={
router.locale != "en"
? router.locale + "/case"
: "/case"
? router.locale +
"/myportal/case" +
props.props.currentView
.caseReference
.currentReference
: "/myportal/case/" +
props.props.currentView
.caseReference
.currentReference
}
className="govuk-breadcrumbs__link"
>
@@ -1080,4 +1132,19 @@ const Breadcrumbs = (props) => {
</>
);
};
export default Breadcrumbs;
const mapStateToProps = (state) => {
return {
...state,
};
};
const mapDispatchToProps = (dispatch) => {
return {
setCurrentView: (currentView) => {
dispatch(setCurrentView(currentView));
},
};
};
export default connect(mapStateToProps, mapDispatchToProps)(Breadcrumbs);
@@ -16,6 +16,10 @@ import {
import { setAwaitingSubmissionFromBlob } from "../../store/awaitingSubmission/action";
import { parseCookies, setCookie, destroyCookie } from "nookies";
import { getFormCollectionByID } from "../../components/utils";
import {
setAwaitingSubmission,
setAwaitingSubmissionDetails,
} from "../../store/awaitingSubmission/action";
const AwaitingSubmissionFromBlob = (props) => {
let { t } = useTranslation();
@@ -55,6 +59,7 @@ const AwaitingSubmissionFromBlob = (props) => {
.then(() => {
getAwaitingSubmissionFromBlobProxy(containerID).then((data) => {
props.setAwaitingSubmissionFromBlob(data);
props.setAwaitingSubmissionDetails(data);
});
});
};
@@ -350,6 +355,9 @@ const mapDispatchToProps = (dispatch) => {
setAwaitingSubmissionFromBlob: (awaitingSubmission) => {
dispatch(setAwaitingSubmissionFromBlob(awaitingSubmission));
},
setAwaitingSubmissionDetails: (awaitingSubmissionDetails) => {
dispatch(setAwaitingSubmissionDetails(awaitingSubmissionDetails));
},
};
};
+180 -7
View File
@@ -17,8 +17,10 @@ import {
deleteWatchedCases,
deleteAwaitingSubmissions,
deleteAwaitingSubmissionsFromBlob,
deleteMyRepresentationsFromBlob,
getAwaitingSubmissionFromBlobProxy,
getAwaitingSubmissionProxy,
getRepsFromBlobProxy,
} from "../../actions";
import { setAwaitingSubmissionFromBlob } from "../../store/awaitingSubmission/action";
@@ -36,6 +38,12 @@ import {
setCurrentReference,
setCurrentView,
} from "../../store/currentView/action";
import {
setMyRepresentations,
setMyRepresentationsDetails,
setMySubmittedReps,
setMySubmittedRepsDetails,
} from "../../store/myRepresentations/action";
const ViewAllResults = (props) => {
const {
@@ -48,6 +56,10 @@ const ViewAllResults = (props) => {
accountDetails,
setAwaitingSubmissionFromBlob,
setAwaitingSubmissionDetails,
setWatchedCasesDetails,
setWatchedCases,
setMyRepresentations,
setMyRepresentationsDetails,
} = props;
let { t } = useTranslation();
@@ -101,10 +113,19 @@ const ViewAllResults = (props) => {
const buildResultsRowArr = () => {
resultsArr.map((item, key) => {
let detailsObj = jsonpath(
'$..value[?(@.pinswg_name=="' + currentView.viewKey ==
"awaitingSubmissionDetails"
? item.title
: item.pinswg_title + '")]',
"$" +
(currentView.viewKey == "myRepresentations"
? ""
: "..value") +
'[?(@.pinswg_name=="' +
(currentView.viewKey == "awaitingSubmissionDetails"
? item.title
: currentView.viewKey == "watchedCases"
? item.ticketnumber
: currentView.viewKey == "myRepresentations"
? item.pinswg_name
: item.pinswg_title) +
'")]',
searchDetailsObj
);
detailsObj = detailsObj[0];
@@ -163,8 +184,10 @@ const ViewAllResults = (props) => {
? "/fymhorth/achos"
: "/achos"
: myportal == true
? "/myportal/case"
: "/case"
? "/myportal/case/" +
resultsArr[key].ticketnumber
: "/case/" +
resultsArr[key].ticketnumber
}
onClick={() => {
setCurrentReference({
@@ -589,7 +612,62 @@ const ViewAllResults = (props) => {
) &&
deleteCaseItem(
props.accountDetails.containerID,
item.ticketnumber
item.pinswg_name
);
}}
>
&mdash;
</button>
</dd>
)}
{/* {currentView.viewKey == "myRepresentations" && (
<dd className="govuk-summary-list__value govuk-!-font-size-16 cardModuleItem ">
<button
title={t(
"case:do-you-want-to-delete-case-label"
)}
className=" cardModuleRemoveCase govuk-link govuk-link--no-underline govuk-link--inverse "
onClick={() => {
confirm(
t(
"case:do-you-want-to-delete-case-label"
) +
item.pinswg_name +
"?\n" +
t(
"case:do-you-want-to-delete-case-disclaimer-label"
)
) &&
deleteRepItem(
props.accountDetails.containerID,
item.pinswg_name,
item.repfile_name
);
}}
>
&mdash;
</button>
</dd>
)} */}
{currentView.viewKey == "watchedCases" && (
<dd className="govuk-summary-list__value govuk-!-font-size-16 cardModuleItem ">
<button
title={t(
"case:do-you-want-to-delete-case-label"
)}
className=" cardModuleRemoveCase govuk-link govuk-link--no-underline govuk-link--inverse "
onClick={() => {
confirm(
t(
"case:you-have-stopped-watching-label"
) +
item[
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
]
) &&
deleteItem(
item.pinswg_watchlistid,
"watchedCases"
);
}}
>
@@ -669,6 +747,86 @@ const ViewAllResults = (props) => {
});
};
const deleteRepItem = (containerID, caseID, repfile) => {
let cookies = parseCookies();
console.log("sssss", containerID, caseID, repfile);
deleteMyRepresentationsFromBlob(containerID, caseID, repfile)
.then((data) => {
return data;
})
.then(() => {
getRepsFromBlobProxy(containerID)
.then((data) => {
setMyRepresentations(data);
setMyRepresentationsDetails(data);
})
.catch((err) => {
consoleLogger(err);
res.status(400).json(err);
})
.then(() => {
setCurrentView({
"viewName": "My Representations",
"viewKey": "myRepresentations",
});
});
});
};
const deleteItem = (caseID, topThreeType) => {
let cookies = parseCookies();
//console.log("sssss", caseID, topThreeType);
topThreeType == "watchedCases" &&
deleteWatchedCases(caseID)
.then((data) => data)
.then(() => {
getWatchedCasesProxy(cookies.pinsUser).then((data) => {
setWatchedCases(data),
getDetails(data, "myWatchedCases")
.then((data) => {
setWatchedCasesDetails(data);
})
.then(() => {
setCurrentView({
"viewName": "Watched Cases",
"viewKey": "watchedCases",
});
});
});
});
};
const getDetails = (resultsObj, detailsType) => {
//console.log(resultsObj);
let detailsArr = [];
resultsObj = resultsObj.value;
const detailsObj = resultsObj.map((searchDetail, index) => {
if (searchDetail.pinswg_appealcasetype == null) {
console.log(
detailsType != "myWatchedCases"
? searchDetail.ticketnumber
: searchDetail[
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
]
);
} else {
detailsArr.push(
getPortalModuleDetailsProxy(
getFormCollectionByID(
searchDetail.pinswg_appealcasetype
).LogicalCollectionName,
detailsType != "myWatchedCases"
? searchDetail.ticketnumber
: searchDetail[
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
]
)
);
}
});
//console.log(detailsArr);
return Promise.all(detailsArr);
};
return (
<>
<div className="govuk-grid-row">
@@ -882,6 +1040,21 @@ const mapDispatchToProps = (dispatch) => {
setAwaitingSubmissionDetails: (awaitingSubmission) => {
dispatch(setAwaitingSubmissionDetails(awaitingSubmission));
},
setWatchedCases: (watchedCases) => {
dispatch(setWatchedCases(watchedCases));
},
setWatchedCasesDetails: (watchedCasesDetails) => {
dispatch(setWatchedCasesDetails(watchedCasesDetails));
},
setWatchedCasesDetails: (watchedCasesDetails) => {
dispatch(setWatchedCasesDetails(watchedCasesDetails));
},
setMyRepresentations: (myRepresentations) => {
dispatch(setMyRepresentations(myRepresentations));
},
setMyRepresentationsDetails: (myRepresentationsDetails) => {
dispatch(setMyRepresentationsDetails(myRepresentationsDetails));
},
};
};