Removed proxy and added api calls, has gov gateway auth
This commit is contained in:
@@ -9,6 +9,14 @@ import data from "../../data/collections.json";
|
||||
import LoadingOverlay from "react-loading-overlay";
|
||||
import transLookup from "../../data/lookuptranslations.json";
|
||||
|
||||
const required = (errorMsg) => (value) =>
|
||||
value || typeof value === "number" ? undefined : errorMsg;
|
||||
|
||||
export const minLength = (errorMsg) => (value) =>
|
||||
value && value.length < 4
|
||||
? errorMsg //`Must be ${min} characters or more`
|
||||
: undefined;
|
||||
|
||||
let AdvancedSearch = (props) => {
|
||||
let { t } = useTranslation();
|
||||
|
||||
@@ -37,6 +45,53 @@ let AdvancedSearch = (props) => {
|
||||
? [{}]
|
||||
: props.LPAData.LPAData.value;
|
||||
|
||||
const RenderTextfield = ({
|
||||
id,
|
||||
className,
|
||||
rows,
|
||||
datafieldname,
|
||||
name,
|
||||
label,
|
||||
input,
|
||||
hint1,
|
||||
hint2,
|
||||
hint3,
|
||||
meta: { touched, error },
|
||||
...custom
|
||||
}) => {
|
||||
return (
|
||||
<>
|
||||
<div className="govuk-form-group">
|
||||
<div id="basicSearch-hint" className="govuk-hint ">
|
||||
<label className="govuk-label" htmlFor="caseRef">
|
||||
{t("search:casereference-label")}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input
|
||||
{...input}
|
||||
className={className}
|
||||
name={name}
|
||||
id={id}
|
||||
/>
|
||||
{touched && error && (
|
||||
<span
|
||||
id={id + "-error"}
|
||||
className="govuk-error-message govuk-form-group--error"
|
||||
>
|
||||
<span className="govuk-visually-hidden">
|
||||
Error:
|
||||
</span>{" "}
|
||||
{error}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const RenderLPAList = ({
|
||||
name,
|
||||
id,
|
||||
@@ -216,8 +271,6 @@ let AdvancedSearch = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
const required = (value) => (value ? undefined : "Required");
|
||||
|
||||
// const [showSpinnerState, setShowSpinnerState] = useState(false);
|
||||
|
||||
// let spinnerState = () => {
|
||||
@@ -252,8 +305,8 @@ let AdvancedSearch = (props) => {
|
||||
|
||||
router.replace(
|
||||
(router.locale == "cy"
|
||||
? "/canlyniadauchwiliouwch"
|
||||
: "/advancedsearchresults") + searchString,
|
||||
? "/fymhorth/canlyniadauchwiliouwch"
|
||||
: "/myportal/advancedsearchresults") + searchString,
|
||||
null,
|
||||
{
|
||||
shallow: true,
|
||||
@@ -275,27 +328,31 @@ let AdvancedSearch = (props) => {
|
||||
{t("search:search-title-label")}
|
||||
</h1>
|
||||
</legend>
|
||||
<div className="govuk-form-group">
|
||||
<label
|
||||
className="govuk-label"
|
||||
htmlFor="caseRef"
|
||||
>
|
||||
{t(
|
||||
"search:casereference-label"
|
||||
)}
|
||||
</label>
|
||||
|
||||
<Field
|
||||
name="caseRef"
|
||||
id="caseRef"
|
||||
component="input"
|
||||
className="govuk-input govuk-!-width-two-thirds"
|
||||
label={t(
|
||||
"search:casereference-label"
|
||||
)}
|
||||
errormsg="Appeal type is required"
|
||||
/>
|
||||
</div>
|
||||
<Field
|
||||
validate={[
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input govuk-!-width-two-thirds"
|
||||
component={RenderTextfield}
|
||||
id="caseRef"
|
||||
name="caseRef"
|
||||
type="text"
|
||||
aria-describedby="caseRef-hint"
|
||||
hint1={t(
|
||||
"myportal:searchcases-card-search-hint"
|
||||
)}
|
||||
hint2={t(
|
||||
"myportal:searchcases-card-search-example-label-1"
|
||||
)}
|
||||
hint3={t(
|
||||
"myportal:searchcases-card-search-example-label-2"
|
||||
)}
|
||||
/>
|
||||
|
||||
<Field
|
||||
name="appealTypes"
|
||||
|
||||
@@ -260,7 +260,6 @@ const DNSSearchResults = (props) => {
|
||||
|
||||
getBasicDNSSearchPaged(pageNumber)
|
||||
.then((data) => {
|
||||
//console.log(data);
|
||||
setSearchResults(data);
|
||||
return data;
|
||||
})
|
||||
|
||||
@@ -39,7 +39,6 @@ import {
|
||||
|
||||
import {
|
||||
createWatchedCases,
|
||||
getToken,
|
||||
getWatchedCasesProxy,
|
||||
getPortalModuleDetailsProxy,
|
||||
deleteWatchedCases,
|
||||
@@ -58,6 +57,7 @@ const SearchResults = (props) => {
|
||||
watchedCases,
|
||||
setWatchedCases,
|
||||
setWatchedCasesDetails,
|
||||
isLinkedCase,
|
||||
} = props;
|
||||
let { t } = useTranslation();
|
||||
|
||||
@@ -77,8 +77,6 @@ const SearchResults = (props) => {
|
||||
const cookies = parseCookies();
|
||||
|
||||
const selectWatchedCase = (loggedInUser, incidentID, appealType) => {
|
||||
let token = getToken();
|
||||
|
||||
let updateBody = {
|
||||
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
|
||||
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
|
||||
@@ -88,13 +86,11 @@ const SearchResults = (props) => {
|
||||
createWatchedCases(updateBody)
|
||||
.then((data) => data)
|
||||
.then(() => {
|
||||
getWatchedCasesProxy(token, cookies.pinsUser).then((data) => {
|
||||
getWatchedCasesProxy(cookies.pinsUser).then((data) => {
|
||||
setWatchedCases(data),
|
||||
getDetails(token, data, "myWatchedCases").then(
|
||||
(data) => {
|
||||
setWatchedCasesDetails(data);
|
||||
}
|
||||
);
|
||||
getDetails(data, "myWatchedCases").then((data) => {
|
||||
setWatchedCasesDetails(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -109,26 +105,21 @@ const SearchResults = (props) => {
|
||||
};
|
||||
|
||||
const deleteItem = (caseID, topThreeType) => {
|
||||
let token = getToken();
|
||||
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);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
getWatchedCasesProxy(cookies.pinsUser).then((data) => {
|
||||
setWatchedCases(data),
|
||||
getDetails(data, "myWatchedCases").then((data) => {
|
||||
setWatchedCasesDetails(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const getDetails = (token, resultsObj, detailsType) => {
|
||||
const getDetails = (resultsObj, detailsType) => {
|
||||
//console.log(resultsObj);
|
||||
let detailsArr = [];
|
||||
resultsObj = resultsObj.value;
|
||||
@@ -144,7 +135,6 @@ const SearchResults = (props) => {
|
||||
} else {
|
||||
detailsArr.push(
|
||||
getPortalModuleDetailsProxy(
|
||||
token,
|
||||
getFormCollectionByID(
|
||||
searchDetail.pinswg_appealcasetype
|
||||
).LogicalCollectionName,
|
||||
@@ -184,7 +174,7 @@ const SearchResults = (props) => {
|
||||
<dd className="govuk-summary-list__key govuk-!-font-size-16">
|
||||
{t("search:searchresults-status-label")}
|
||||
</dd>
|
||||
{myportal == "true" && (
|
||||
{myportal == true && (
|
||||
<dd className="govuk-summary-list__key govuk-!-font-size-16 govuk-summary-list__action"></dd>
|
||||
)}
|
||||
</div>
|
||||
@@ -201,10 +191,10 @@ const SearchResults = (props) => {
|
||||
<Link
|
||||
href={
|
||||
router.locale == "cy"
|
||||
? myportal == "true"
|
||||
? myportal == true
|
||||
? "/fymhorth/achos"
|
||||
: "/achos"
|
||||
: myportal == "true"
|
||||
: myportal == true
|
||||
? "/myportal/case"
|
||||
: "/case"
|
||||
}
|
||||
@@ -378,7 +368,7 @@ const SearchResults = (props) => {
|
||||
"statuscode@OData.Community.Display.V1.FormattedValue"
|
||||
] || "N/A"}
|
||||
</dd>
|
||||
{myportal == "true" && (
|
||||
{myportal == true && (
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-14 govuk-summary-list__action">
|
||||
{isWatchedCase(item.incidentid).length >
|
||||
0 ==
|
||||
@@ -501,27 +491,34 @@ const SearchResults = (props) => {
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<h1 className="govuk-heading-xl govuk-!-margin-bottom-7">
|
||||
{t("search:searchresults-title-label")}
|
||||
{isLinkedCase
|
||||
? t("search:searchresults-title-label-linked-case")
|
||||
: t("search:searchresults-title-label")}
|
||||
</h1>
|
||||
<p className="govuk-body">
|
||||
{resultsArr.length > 200
|
||||
? t("search:searchresults-max-count-label")
|
||||
: t("search:searchresults-count-label", {
|
||||
count: searchResultsObj["@odata.count"],
|
||||
})}
|
||||
.
|
||||
{advancedSearch != true ? (
|
||||
<>
|
||||
<span>
|
||||
{t("search:searchresults-case-count-label")}{" "}
|
||||
{" "}
|
||||
<em>"{searchString}"</em>
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</p>
|
||||
|
||||
{!isLinkedCase && (
|
||||
<p className="govuk-body">
|
||||
{resultsArr.length > 200
|
||||
? t("search:searchresults-max-count-label")
|
||||
: t("search:searchresults-count-label", {
|
||||
count: searchResultsObj["@odata.count"],
|
||||
})}
|
||||
.
|
||||
{advancedSearch != true ? (
|
||||
<>
|
||||
<span>
|
||||
{t(
|
||||
"search:searchresults-case-count-label"
|
||||
)}{" "}
|
||||
{" "}
|
||||
<em>"{searchString}"</em>
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
{resultsArr.length > 0 ? (
|
||||
ResultsView(resultsArr)
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user