reps defects

This commit is contained in:
2024-06-03 11:57:11 +01:00
parent c63ea33c64
commit c947995e7b
19 changed files with 392 additions and 167 deletions
@@ -0,0 +1,69 @@
/**
* @swagger
* /api/endpoint/getportallogin_api:
* get:
* tags: [Login]
* description: Returns portal login
* summary: Phase 2
* parameters:
* - name: emailaddress
* in: query
* required: true
* schema:
* type: string
* responses:
* 200:
* description: hello world
*/
import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash";
import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions";
const WORDKEY = process.env.HASHKEY;
const WEBAPI_URL =
process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
const hashAPIPath = (queryPath) => {
var hashlink = CryptoJS.HmacSHA256(
queryPath,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString(CryptoJS.enc.Hex);
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var emailAddress = req.query.emailAddress;
var token = await getToken();
var queryUrl =
"contacts?$filter=emailaddress1 eq '" +
emailAddress +
"'&$count=true&$select=emailaddress1,contactid,yomifullname,firstname,lastname";
//console.log(req.query);
var apiResponse = _.isEmpty(req.query)
? res.status(400).json()
: typeof emailAddress != "undefined" && emailAddress.length > 0
? axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
//console.log(data);
res.status(200).json(data);
})
.catch((err) => {
console.log(consoleLogger(err));
res.status(400).json(err);
})
: res.status(400).json();
return apiResponse;
}
+4 -2
View File
@@ -36,7 +36,7 @@ import {
import _ from "lodash";
import nextConnect from "next-connect";
import middleware from "../middleware/middleware";
import { hashAPIPath } from "../../../actions";
import { consoleLogger, hashAPIPath } from "../../../actions";
const ApiProxy = nextConnect();
ApiProxy.use(middleware);
@@ -80,7 +80,9 @@ ApiProxy.get(async (req, res) => {
error +
"\n///////////////////////\n"
);
console.log("API call error", error);
//console.log("API call error", error);
console.log(consoleLogger(error));
});
} else {
return res.status(400).json({ msg: "error" });
+34 -9
View File
@@ -29,7 +29,13 @@ import {
} from "../../store/accountDetails/action";
const CaseHome = (props) => {
const { footerLinks, pages } = props;
const {
footerLinks,
pages,
setSearchResults,
setSearchDetails,
searchResultsObj,
} = props;
let { t, lang } = useTranslation();
const router = useRouter();
@@ -54,9 +60,9 @@ const CaseHome = (props) => {
props={props}
myCases={props.myCases.myCases}
myCasesDetails={props.myCases.myCasesDetails}
directSearchResultsObj={
props.searchResultsObj.searchResultsObj
}
// directSearchResultsObj={
// props.searchResultsObj.searchResultsObj
// }
searchDetailsObj={
props.searchResultsObj.searchDetailsObj
}
@@ -172,6 +178,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
},
};
} else {
store.dispatch(setSearchResults(searchResultsObj));
store.dispatch(setSearchDetails(searchDetailsObj));
store.dispatch(
setCurrentReference({
"ticketnumber": searchResultsObj.value[0].ticketnumber,
@@ -180,6 +188,17 @@ export const getServerSideProps = wrapper.getServerSideProps(
"incidentid": searchResultsObj.value[0].incidentid,
"appealType":
searchResultsObj.value[0].pinswg_appealcasetype,
"showLoginCheck": true,
"specialistProcess":
searchDetailsObj[0].value[0]
.pinswg_speacialistcaseprocess != null ||
searchDetailsObj[0].value[0]
.pinswg_specialistcaseprocess != null
? searchDetailsObj[0].value[0]
.pinswg_speacialistcaseprocess ||
searchDetailsObj[0].value[0]
.pinswg_specialistcaseprocess
: "",
})
);
}
@@ -187,10 +206,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
// console.log(searchResultsObj);
return {
props: {
searchResultsObj: {
searchResultsObj: searchResultsObj,
searchDetailsObj: searchDetailsObj,
},
// searchResultsObj: {
// searchResultsObj: searchResultsObj,
// searchDetailsObj: searchDetailsObj,
// },
currentType: "directResultsObj",
},
};
@@ -202,7 +221,7 @@ const mapStateToProps = (state) => {
accountDetails: state.accountDetails,
currentView: state.currentView,
search: state.search,
//searchResultsObj: state.searchResultsObj,
searchResultsObj: state.searchResultsObj,
documentDetailsObj: state.searchResultsObj.documentDetailsObj,
formData: state.formData,
appealType: state.appealType,
@@ -219,6 +238,12 @@ const mapDispatchToProps = (dispatch) => {
setCurrentReference: (currentReference) => {
dispatch(setCurrentReference(refno));
},
setSearchResults: (searchResults) => {
dispatch(setSearchResults(searchResults));
},
setSearchDetails: (searchDetails) => {
dispatch(setSearchDetails(searchDetails));
},
};
};
+41 -22
View File
@@ -29,7 +29,7 @@ import {
} from "../../../store/accountDetails/action";
const CaseHome = (props) => {
const { footerLinks, pages } = props;
const { footerLinks, pages, setSearchResults, setSearchDetails } = props;
let { t, lang } = useTranslation();
const router = useRouter();
@@ -54,12 +54,10 @@ const CaseHome = (props) => {
props={props}
myCases={props.myCases.myCases}
myCasesDetails={props.myCases.myCasesDetails}
directSearchResultsObj={
props.searchResultsObj.searchResultsObj
}
searchDetailsObj={
props.searchResultsObj.searchDetailsObj
}
// directSearchResultsObj={
// props.searchResultsObj.searchResultsObj
// }
searchDetailsObj={props.searchDetailsObj}
documentDetailsObj={props.documentDetailsObj}
myRepresentations={
props.myRepresentations.myRepresentations
@@ -72,18 +70,13 @@ const CaseHome = (props) => {
props.awaitingSubmission.awaitingSubmission
}
caseReference={
props.searchResultsObj.searchResultsObj.value[0]
.ticketnumber
props.currentView.caseReference.currentReference
}
currentType={props.currentType}
appealTypeID={
props.searchResultsObj.searchResultsObj.value[0]
.pinswg_appealcasetype
}
incidentid={
props.searchResultsObj.searchResultsObj.value[0]
.incidentid
props.currentView.caseReference.appealType
}
incidentid={props.currentView.caseReference.incidentid}
representationsObj={
props.searchResultsObj.representationsObj
}
@@ -94,8 +87,7 @@ const CaseHome = (props) => {
footerLinks={footerLinks}
props={props}
ticketnumber={
props.searchResultsObj.searchResultsObj.value[0]
.ticketnumber
props.currentView.caseReference.currentReference
}
/>
</div>
@@ -112,6 +104,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
console.log(cookies);
console.log("the query :", query.ticketnumber);
const showLoginCheck = process.env.SHOWLOGIN || false;
let thisSession = await getSession(ctx);
let loggedInUser = {};
@@ -124,7 +117,9 @@ export const getServerSideProps = wrapper.getServerSideProps(
loggedInUser = loggedInUser.value[0].contactid;
const accountDetails = await getPersonalAccount(loggedInUser);
store.dispatch(setContainerID(thisSession.user.id));
store.dispatch(setAccountDetails(accountDetails));
store.dispatch(setLoggedInUserId(loggedInUser));
} else {
console.log("not has sesssion.......");
}
@@ -172,6 +167,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
},
};
} else {
store.dispatch(setSearchResults(searchResultsObj));
store.dispatch(setSearchDetails(searchDetailsObj));
store.dispatch(
setCurrentReference({
"ticketnumber": searchResultsObj.value[0].ticketnumber,
@@ -180,17 +177,30 @@ export const getServerSideProps = wrapper.getServerSideProps(
"incidentid": searchResultsObj.value[0].incidentid,
"appealType":
searchResultsObj.value[0].pinswg_appealcasetype,
"showLoginCheck": showLoginCheck,
"specialistProcess":
searchDetailsObj[0].value[0]
.pinswg_speacialistcaseprocess != null ||
searchDetailsObj[0].value[0]
.pinswg_specialistcaseprocess != null
? searchDetailsObj[0].value[0]
.pinswg_speacialistcaseprocess ||
searchDetailsObj[0].value[0]
.pinswg_specialistcaseprocess
: "",
})
);
}
}
// console.log(searchResultsObj);
console.log(loggedInUser);
return {
props: {
searchResultsObj: {
searchResultsObj: searchResultsObj,
searchDetailsObj: searchDetailsObj,
},
// searchResultsObj: {
// searchResultsObj: searchResultsObj,
// searchDetailsObj: searchDetailsObj,
// },
currentType: "directResultsObj",
},
};
@@ -202,7 +212,7 @@ const mapStateToProps = (state) => {
accountDetails: state.accountDetails,
currentView: state.currentView,
search: state.search,
//searchResultsObj: state.searchResultsObj,
searchResultsObj: state.searchResultsObj,
documentDetailsObj: state.searchResultsObj.documentDetailsObj,
formData: state.formData,
appealType: state.appealType,
@@ -219,6 +229,15 @@ const mapDispatchToProps = (dispatch) => {
setCurrentReference: (currentReference) => {
dispatch(setCurrentReference(refno));
},
setSearchResults: (searchResults) => {
dispatch(setSearchResults(searchResults));
},
setSearchDetails: (searchDetails) => {
dispatch(setSearchDetails(searchDetails));
},
setLoggedInUserId: (loggedInUser) => {
dispatch(setLoggedInUserId(loggedInUser));
},
};
};
+54 -25
View File
@@ -30,8 +30,8 @@ import {
import NoSessionWarning from "../../components/nosession";
const Home = (props) => {
const { footerLinks, pages } = props;
const RepresentationF = (props) => {
const { footerLinks, pages, accountDetails } = props;
let { t, lang } = useTranslation();
const router = useRouter();
@@ -40,26 +40,26 @@ const Home = (props) => {
const dispatch = useDispatch();
// useEffect(() => {
// const updateAccountStore = async () => {
// const thisSession = await getSession();
useEffect(() => {
const updateAccountStore = async () => {
const thisSession = await getSession();
// if (thisSession) {
// let loggedInUser = await getPortalLogin(thisSession.user.email);
// dispatch(
// setAccountDetails(
// await getPersonalAccount(
// loggedInUser.value[0].contactid
// )
// )
// );
// dispatch(setContainerID(thisSession.user.id));
// //dispatch(setRepresentationSubmit(true));
// }
// };
// updateAccountStore();
// }, [dispatch]);
if (thisSession) {
let loggedInUser = await getPortalLogin(thisSession.user.email);
dispatch(
setAccountDetails(
await getPersonalAccount(
loggedInUser.value[0].contactid
)
)
);
dispatch(setContainerID(thisSession.user.id));
dispatch(setLoggedInUserId(loggedInUser.value[0].contactid));
//dispatch(setRepresentationSubmit(true));
}
};
updateAccountStore();
}, [dispatch]);
const { data: session, status } = useSession();
@@ -158,6 +158,13 @@ const Home = (props) => {
currentType={
props.currentView.caseReference.currentType
}
appealTypeID={
props.currentView.caseReference.appealType
}
incidentid={props.currentView.caseReference.incidentid}
representationsObj={
props.searchResultsObj.representationsObj
}
props={props}
/>
</div>
@@ -174,15 +181,37 @@ const Home = (props) => {
// const { cookies } = req;
// let loggedInUser = cookies.pinsUser;
// let loggedInUserCookie = cookies.pinsUser;
// let thisSession = await getSession(ctx);
// let loggedInUser = {};
// console.log(loggedInUser, thisSession);
// if (!thisSession) {
// console.log("not has sesssion.......");
// return {
// redirect: {
// destination: "/auth/signin",
// permanent: false,
// },
// };
// } else {
// [loggedInUser] = await Promise.all([
// await getPortalLogin(thisSession.user.email),
// ]);
// console.log(
// "=====//////////=====",
// thisSession,
// thisSession.user.email,
// loggedInUser
// );
// loggedInUser = loggedInUser.value[0].contactid;
// }
// const accountDetails = await getPersonalAccount(loggedInUser);
// store.dispatch(setAccountDetails(accountDetails));
// console.log(accountDetails);
// store.dispatch(setAccountDetails(accountDetails));
// return {
// props: {
// containerID: thisSession.user.id,
@@ -217,4 +246,4 @@ const mapStateToProps = (state) => {
};
};
export default connect(mapStateToProps, mapDispatchToProps)(Home);
export default connect(mapStateToProps, mapDispatchToProps)(RepresentationF);