wip for delete reps in view all
This commit is contained in:
@@ -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));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}}
|
||||
>
|
||||
—
|
||||
</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
|
||||
);
|
||||
}}
|
||||
>
|
||||
—
|
||||
</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));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user