diff --git a/api/reviewer_api/resources/document.py b/api/reviewer_api/resources/document.py index 5bb003df4..43a730cdd 100644 --- a/api/reviewer_api/resources/document.py +++ b/api/reviewer_api/resources/document.py @@ -95,9 +95,16 @@ def get(requestid): timeout=float(requestapitimeout) ) response.raise_for_status() - bcgovcode = response.json()['bcgovcode'] - result = documentservice().getdocuments(requestid,bcgovcode) - return json.dumps(result), 200 + + jsonobj = response.json() + requestinfo = { + "requeststatusid": jsonobj["requeststatusid"], + "bcgovcode": jsonobj["bcgovcode"], + "currentstate": jsonobj["currentState"], + "requesttype": jsonobj["requestType"] + } + result = documentservice().getdocuments(requestid,requestinfo["bcgovcode"]) + return json.dumps({"requestinfo": requestinfo, "documents": result}), 200 except KeyError as err: return {'status': False, 'message':err.messages}, 400 except BusinessException as exception: diff --git a/api/reviewer_api/services/documentservice.py b/api/reviewer_api/services/documentservice.py index b6618c354..27df09539 100644 --- a/api/reviewer_api/services/documentservice.py +++ b/api/reviewer_api/services/documentservice.py @@ -294,7 +294,7 @@ def updatedocumentattributes(self, payload, userid): def getdocuments(self, requestid,bcgovcode): divisions_data = requests.request( method='GET', - url=requestapiurl + "/api/foiflow/divisions/{0}".format(bcgovcode), + url=requestapiurl + "/api/foiflow/divisions/{0}".format(bcgovcode) + "/all", headers={'Authorization': AuthHelper.getauthtoken(), 'Content-Type': 'application/json'} ).json() divisions = {div['divisionid']: div for div in divisions_data['divisions']} diff --git a/web/src/actions/actionConstants.ts b/web/src/actions/actionConstants.ts index 778626136..5e9de5777 100644 --- a/web/src/actions/actionConstants.ts +++ b/web/src/actions/actionConstants.ts @@ -12,7 +12,8 @@ const ACTION_CONSTANTS = { SET_SECTIONS:"SET_SECTIONS", SET_PAGE_FLAGS: "SET_PAGE_FLAGS", SET_DOCUMENT_LIST: "SET_DOCUMENT_LIST", - SET_KEYWORDS: "SET_KEYWORDS" + SET_KEYWORDS: "SET_KEYWORDS", + SET_REQUEST_INFO: "SET_REQUEST_INFO" }; export default ACTION_CONSTANTS; diff --git a/web/src/actions/documentActions.ts b/web/src/actions/documentActions.ts index 34f1a58c6..47d8b7aee 100644 --- a/web/src/actions/documentActions.ts +++ b/web/src/actions/documentActions.ts @@ -42,4 +42,11 @@ export const setKeywords = (data: any) => (dispatch:any) =>{ type:ACTION_CONSTANTS.SET_KEYWORDS, payload:data }) -} \ No newline at end of file +} + +export const setRequestInfo = (data: any) => (dispatch:any) =>{ + dispatch({ + type:ACTION_CONSTANTS.SET_REQUEST_INFO, + payload:data + }) +} \ No newline at end of file diff --git a/web/src/apiManager/services/docReviewerService.tsx b/web/src/apiManager/services/docReviewerService.tsx index 0d11bbed3..e79d57226 100644 --- a/web/src/apiManager/services/docReviewerService.tsx +++ b/web/src/apiManager/services/docReviewerService.tsx @@ -2,7 +2,7 @@ import { httpGETRequest, httpPOSTRequest, httpDELETERequest } from "../httpRequestHandler"; import API from "../endpoints"; import UserService from "../../services/UserService"; -import { setRedactionInfo, setIsPageLeftOff, setSections, setPageFlags, setDocumentList } from "../../actions/documentActions"; +import { setRedactionInfo, setIsPageLeftOff, setSections, setPageFlags, setDocumentList, setRequestInfo } from "../../actions/documentActions"; import { store } from "../../services/StoreService"; @@ -16,8 +16,9 @@ export const fetchDocuments = ( httpGETRequest(apiUrlGet, {}, UserService.getToken()) .then((res:any) => { if (res.data) { - store.dispatch(setDocumentList(res.data) as any); - callback(res.data); + store.dispatch(setDocumentList(res.data.documents) as any); + store.dispatch(setRequestInfo(res.data.requestinfo) as any); + callback(res.data.documents); } else { throw new Error(); } diff --git a/web/src/components/FOI/Home/DocumentSelector.tsx b/web/src/components/FOI/Home/DocumentSelector.tsx index 43c278117..9b2c95b8f 100644 --- a/web/src/components/FOI/Home/DocumentSelector.tsx +++ b/web/src/components/FOI/Home/DocumentSelector.tsx @@ -37,7 +37,7 @@ const DocumentSelector = ({ setIndividualDoc, pageMappedDocs }: any) => { - + const requestInfo = useAppSelector((state: any) => state.documents?.requestinfo); const pageFlags = useAppSelector((state: any) => state.documents?.pageFlags); const [files, setFiles] = useState(documents); const [openContextPopup, setOpenContextPopup] = useState(false); @@ -73,6 +73,13 @@ const DocumentSelector = ({ ); }, []); + useEffect(() => { + console.log("requestInfo", requestInfo); + if(requestInfo.requesttype == "personal" && ["MSD", "MCF"].includes(requestInfo.bcgovcode)) { + setOrganizeBy("division"); + } + }, [requestInfo]); + useEffect(() => { setPageFlagChanged(false); fetchPageFlagsMasterData( diff --git a/web/src/modules/documentReducer.ts b/web/src/modules/documentReducer.ts index c9a72e218..2e7ccb774 100644 --- a/web/src/modules/documentReducer.ts +++ b/web/src/modules/documentReducer.ts @@ -17,6 +17,8 @@ const documents = (state = initialState, action:any)=> { return {...state, documentList: action.payload}; case ACTION_CONSTANTS.SET_KEYWORDS: return {...state, keywords: action.payload}; + case ACTION_CONSTANTS.SET_REQUEST_INFO: + return {...state, requestinfo: action.payload}; default: return state; }