watched case and stop wathcing case added
This commit is contained in:
@@ -10,9 +10,9 @@ export default function MakeNewAppeal() {
|
||||
return (
|
||||
<div className="card card-3" id="casescomment-card">
|
||||
<div className="card-body">
|
||||
<h3 className="heading-small card-heading">
|
||||
<h2 className="govuk-heading-s">
|
||||
{t("myportal:makenewappeal-card-title")}
|
||||
</h3>
|
||||
</h2>
|
||||
<p className="govuk-body-s">
|
||||
{t("myportal:makenewappeal-card-paragraph-one")}
|
||||
</p>
|
||||
|
||||
@@ -37,16 +37,21 @@ const RenderTextfield = ({
|
||||
}
|
||||
>
|
||||
<div id="basicSearch-hint" className="govuk-hint ">
|
||||
<span className="govuk-body-m">{hint1}</span>
|
||||
<label
|
||||
className="govuk-label "
|
||||
htmlFor={id}
|
||||
id={id + "_label"}
|
||||
>
|
||||
{label}
|
||||
<span className="govuk-body-m">{hint1}</span>
|
||||
</label>
|
||||
|
||||
<br />
|
||||
<span className="govuk-body-s">
|
||||
{hint2} CAS-00009-W8N6W4
|
||||
</span>
|
||||
</div>
|
||||
<label className="govuk-label " htmlFor={id} id={id + "_label"}>
|
||||
{label}
|
||||
</label>
|
||||
|
||||
{touched && error && (
|
||||
<span id={id + "-error"} className="govuk-error-message">
|
||||
<span className="govuk-visually-hidden">Error:</span>{" "}
|
||||
@@ -76,7 +81,7 @@ let CaseSearch = (props) => {
|
||||
|
||||
const onHandleSubmit = (values) => {
|
||||
spinnerState();
|
||||
router.replace({
|
||||
router.push({
|
||||
pathname:
|
||||
router.locale == "cy"
|
||||
? "/fymhorth/canlyniadauchwilio"
|
||||
|
||||
+124
-64
@@ -4,77 +4,93 @@ import { useRouter } from "next/router";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import { setCurrentReference } from "../../store/currentView/action";
|
||||
import { connect } from "react-redux";
|
||||
import { parseCookies } from "nookies";
|
||||
import {
|
||||
getSASToken,
|
||||
getWatchedCasesProxy,
|
||||
getPortalModuleDetailsProxy,
|
||||
deleteWatchedCases,
|
||||
} from "../../actions";
|
||||
|
||||
import {
|
||||
setWatchedCases,
|
||||
setWatchedCasesDetails,
|
||||
} from "../../store/watchedCases/action";
|
||||
import { getFormCollectionByID } from "../../components/utils";
|
||||
|
||||
const TopThree = (props) => {
|
||||
let { t } = useTranslation();
|
||||
const { showTopThree, showDetails, setCurrentReference, topThreeType } =
|
||||
props;
|
||||
const {
|
||||
showTopThree,
|
||||
showDetails,
|
||||
setCurrentReference,
|
||||
topThreeType,
|
||||
setWatchedCases,
|
||||
setWatchedCasesDetails,
|
||||
} = props;
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
|
||||
let topthreeRow = [];
|
||||
|
||||
// for (var i = 0; i < 3; i++) {
|
||||
// (function (i) {
|
||||
// topthreeRow.push(
|
||||
// <div className="cardModuleItem" key={i}>
|
||||
// <div className="cardModuleDetails">
|
||||
// <div className="cardModuleReference">
|
||||
// <b>Case reference:</b>{" "}
|
||||
// <Link
|
||||
// href={
|
||||
// topThreeType == "awaitingSubmission"
|
||||
// ? "/representation"
|
||||
// : "/case"
|
||||
// }
|
||||
// >
|
||||
// <a
|
||||
// data-id={i}
|
||||
// onClick={() => {
|
||||
// setCurrentReference({
|
||||
// "currentReference":
|
||||
// showTopThree.value[i]
|
||||
// .ticketnumber,
|
||||
// "currentType": topThreeType,
|
||||
// });
|
||||
// }}
|
||||
// >
|
||||
// {showTopThree.value[i].ticketnumber}
|
||||
// </a>
|
||||
// </Link>
|
||||
// </div>
|
||||
// {topThreeType != "awaitingSubmission" ? (
|
||||
// <div className="carModuleAddress">
|
||||
// <b>Addressaa: </b>
|
||||
// {showDetails[i].value[0]
|
||||
// .pinswg_siteaddressline1 == null
|
||||
// ? "not entered"
|
||||
// : showDetails[i].value[0]
|
||||
// .pinswg_siteaddressline1}
|
||||
// </div>
|
||||
// ) : (
|
||||
// ""
|
||||
// )}
|
||||
|
||||
// {topThreeType == "awaitingSubmission" ? (
|
||||
// <div className="carModuleAddress">
|
||||
// Make Representation on Case Incomplete, not
|
||||
// submitted
|
||||
// </div>
|
||||
// ) : (
|
||||
// ""
|
||||
// )}
|
||||
// </div>
|
||||
// <div className="cardModuleRemoveCase"> —</div>
|
||||
// </div>
|
||||
// );
|
||||
// })(i);
|
||||
// }
|
||||
|
||||
let showTopThreeArr = showTopThree.value;
|
||||
|
||||
Object.keys(showTopThreeArr).map((key, index) => {
|
||||
const deleteItem = (caseID, topThreeType) => {
|
||||
let token = getSASToken();
|
||||
let cookies = parseCookies();
|
||||
topThreeType == "watchedCases" &&
|
||||
deleteWatchedCases(caseID)
|
||||
.then((data) => data)
|
||||
.then(() => {
|
||||
getWatchedCasesProxy(token, cookies.pinsUser).then(
|
||||
(data) => {
|
||||
setWatchedCases(data),
|
||||
getDetails(token, data, "myWatchedCases").then(
|
||||
(data) => {
|
||||
setWatchedCasesDetails(data);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const getDetails = (token, 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(
|
||||
token,
|
||||
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);
|
||||
};
|
||||
|
||||
let topThreeOnlyArr = showTopThreeArr.slice(0, 3);
|
||||
Object.keys(topThreeOnlyArr).map((key, index) => {
|
||||
topthreeRow.push(
|
||||
<div className="cardModuleItem" key={index}>
|
||||
<div className="cardModuleDetails">
|
||||
@@ -96,17 +112,32 @@ const TopThree = (props) => {
|
||||
onClick={() => {
|
||||
setCurrentReference({
|
||||
"currentReference":
|
||||
showTopThreeArr[key].ticketnumber,
|
||||
topThreeType != "watchedCases"
|
||||
? showTopThreeArr[key]
|
||||
.ticketnumber
|
||||
: showTopThreeArr[key][
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
],
|
||||
"currentType": topThreeType,
|
||||
"incidentid":
|
||||
showTopThreeArr[key].incidentid,
|
||||
topThreeType != "watchedCases"
|
||||
? showTopThreeArr[key]
|
||||
.incidentid
|
||||
: showTopThreeArr[key][
|
||||
" _pinswg_watchedcase_value"
|
||||
],
|
||||
|
||||
"appealType":
|
||||
showTopThreeArr[key]
|
||||
.pinswg_appealcasetype,
|
||||
});
|
||||
}}
|
||||
>
|
||||
{showTopThreeArr[key].ticketnumber}
|
||||
{topThreeType != "watchedCases"
|
||||
? showTopThreeArr[key].ticketnumber
|
||||
: showTopThreeArr[key][
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
]}
|
||||
</a>
|
||||
</Link>
|
||||
</div>
|
||||
@@ -140,7 +171,30 @@ const TopThree = (props) => {
|
||||
""
|
||||
)}
|
||||
</div>
|
||||
<div className="cardModuleRemoveCase"> —</div>
|
||||
|
||||
{topThreeType == "watchedCases" && (
|
||||
<div className="">
|
||||
<a
|
||||
href="#"
|
||||
className=" cardModuleRemoveCase govuk-link govuk-link--no-underline govuk-link--inverse "
|
||||
onClick={() => {
|
||||
event.preventDefault();
|
||||
deleteItem(
|
||||
showTopThreeArr[key].pinswg_watchlistid,
|
||||
"watchedCases"
|
||||
);
|
||||
alert(
|
||||
"You have stopped watching case " +
|
||||
showTopThreeArr[key][
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
);
|
||||
}}
|
||||
>
|
||||
—
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
@@ -176,6 +230,12 @@ const mapDispatchToProps = (dispatch) => {
|
||||
setCurrentReference: (currentReference) => {
|
||||
dispatch(setCurrentReference(currentReference));
|
||||
},
|
||||
setWatchedCases: (watchedCases) => {
|
||||
dispatch(setWatchedCases(watchedCases));
|
||||
},
|
||||
setWatchedCasesDetails: (watchedCasesDetails) => {
|
||||
dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -5,8 +5,13 @@ import { setCurrentReference } from "../../store/currentView/action";
|
||||
import { connect } from "react-redux";
|
||||
|
||||
const ViewAllResults = (props) => {
|
||||
const { searchString, searchResultsObj, currentView, setCurrentReference } =
|
||||
props;
|
||||
const {
|
||||
searchString,
|
||||
searchResultsObj,
|
||||
currentView,
|
||||
setCurrentReference,
|
||||
myportal,
|
||||
} = props;
|
||||
|
||||
let { t } = useTranslation();
|
||||
|
||||
@@ -21,14 +26,35 @@ const ViewAllResults = (props) => {
|
||||
resultsRowArr.push(
|
||||
<div className="govuk-summary-list__row" key={key}>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16 govuk-!-padding-left-2">
|
||||
<Link href={router.locale == "cy" ? "/achos" : "/case"}>
|
||||
<Link
|
||||
href={
|
||||
router.locale == "cy"
|
||||
? myportal == "true"
|
||||
? "/fymhorth/achos"
|
||||
: "/achos"
|
||||
: myportal == "true"
|
||||
? "/myportal/case"
|
||||
: "/case"
|
||||
}
|
||||
>
|
||||
<a
|
||||
onClick={() => {
|
||||
setCurrentReference({
|
||||
"currentReference":
|
||||
resultsArr[index].reference,
|
||||
currentView.viewKey != "watchedCases"
|
||||
? resultsArr[index].ticketnumber
|
||||
: resultsArr[index][
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
],
|
||||
|
||||
"currentType": currentView.viewKey,
|
||||
"incidentid": resultsArr[index].incidentid,
|
||||
"incidentid":
|
||||
currentView.viewKey != "watchedCases"
|
||||
? resultsArr[index].incidentid
|
||||
: resultsArr[index][
|
||||
" _pinswg_watchedcase_value"
|
||||
],
|
||||
|
||||
"appealType":
|
||||
resultsArr[index].pinswg_appealcasetype,
|
||||
});
|
||||
@@ -37,7 +63,12 @@ const ViewAllResults = (props) => {
|
||||
<span className="results-visually-hidden">
|
||||
Case Reference:
|
||||
</span>
|
||||
{resultsArr[index].ticketnumber}
|
||||
|
||||
{currentView.viewKey != "watchedCases"
|
||||
? resultsArr[index].ticketnumber
|
||||
: resultsArr[index][
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
]}
|
||||
</a>
|
||||
</Link>
|
||||
</dd>
|
||||
|
||||
Reference in New Issue
Block a user