Skip to content

Commit

Permalink
Merge pull request #4816 from bcgov/dev-rook
Browse files Browse the repository at this point in the history
Dev rook
  • Loading branch information
sumathi-thirumani authored Dec 1, 2023
2 parents 4461f9d + f59adde commit f71378a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 15 deletions.
22 changes: 19 additions & 3 deletions forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ const FOIRequest = React.memo(({ userDetail }) => {
const [attachments, setAttachments] = useState(requestAttachments);
const [comment, setComment] = useState([]);
const [requestState, setRequestState] = useState(StateEnum.unopened.name);
const disableInput =
requestState?.toLowerCase() === StateEnum.closed.name.toLowerCase();
const [disableInput, setDisableInput] = useState(requestState?.toLowerCase() === StateEnum.closed.name.toLowerCase());
const [_tabStatus, settabStatus] = React.useState(requestState);
let foitabheaderBG = getTabBG(_tabStatus, requestState);

Expand Down Expand Up @@ -258,7 +257,24 @@ const FOIRequest = React.memo(({ userDetail }) => {
const [redactedSections, setRedactedSections] = useState("");
const [isMCFPersonal, setIsMCFPersonal] = useState(bcgovcode.replaceAll('"', '') == "MCF" && requestDetails.requestType == FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_PERSONAL);
const {oipcData, addOIPC, removeOIPC, updateOIPC, isOIPCReview, setIsOIPCReview} = useOIPCHook();

const [oipcDataInitial, setOipcDataInitial] = useState(oipcData);

//Update disableInput when requestState changes
useEffect(() => {
setDisableInput(requestState?.toLowerCase() === StateEnum.closed.name.toLowerCase())
}, [requestState])

useEffect(() => {
if (!oipcDataInitial) {
setOipcDataInitial(oipcData);
return;
}
//check to see if oipcData has been updated, if so, enable save button
if (JSON.stringify(oipcData) != JSON.stringify(oipcDataInitial)) {
setDisableInput(false)
}
}, [oipcData]);

useEffect(() => {
if (window.location.href.indexOf("comments") > -1) {
tabclick("Comments");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,14 @@ const OIPCItem = (props) => {
return (
<>
<div style={{display: "flex", flexDirection: "row", justifyContent: "flex-end"}}>
<button onClick={() => setShowDeleteModal(true)} style={{ border: "none", background: "none" }}>
<button onClick={(e) => {
e.preventDefault()
setShowDeleteModal(true)
}} style={{ border: "none", background: "none" }}>
<FontAwesomeIcon icon={faTrash} color="#38598A" />
</button>
</div>
{showDeleteModal && <RemoveOIPCModal removeOIPC={removeOIPC} showModal={showDeleteModal} setShowModal={setShowDeleteModal} oipcid={oipc.id} />}
{showDeleteModal && <RemoveOIPCModal removeOIPC={removeOIPC} showModal={showDeleteModal} setShowModal={setShowDeleteModal} oipc={oipc} />}
{showOutcomeModal && <OutcomeModal updateOIPC={updateOIPC} showModal={showOutcomeModal} setShowModal={setShowOutcomeModal} setOipc={setOipc} oipc={oipc} />}
{showAmendModal && <AmendModal updateOIPC={updateOIPC} showModal={showAmendModal} setShowModal={setShowAmendModal} setOipc={setOipc} oipc={oipc} />}
<Grid container spacing={1}>
Expand Down Expand Up @@ -191,13 +194,16 @@ const OIPCItem = (props) => {
select
variant="outlined"
fullWidth
value={oipc.reviewtypeid}
value={oipc.reviewtypeid ? oipc.reviewtypeid : -1}
label="Review Type"
onChange={(event) => handleReviewType(event.target.value)}
error={(!oipc.outcomeid || oipc.outcomeid === 5) && oipc.reviewtypeid === null}
required
disabled={oipc.outcomeid && oipc.outcomeid !== 5}
>
<MenuItem disabled value={-1}>
Select Review Type
</MenuItem>
{uniqueReviewTypes(oipcReviewtypes).map((reviewtype) => {
return <MenuItem key={reviewtype.reviewtypeid} value={reviewtype.reviewtypeid}>{reviewtype.type_name}</MenuItem>
})}
Expand All @@ -209,13 +215,16 @@ const OIPCItem = (props) => {
select
variant="outlined"
fullWidth
value={oipc.reasonid}
value={oipc.reasonid ? oipc.reasonid : -1}
label="Reason"
onChange = {(event) => handleReason(event.target.value)}
error={(!oipc.outcomeid || oipc.outcomeid === 5) && oipc.reasonid === null}
required
disabled={oipc.outcomeid && oipc.outcomeid !== 5}
>
<MenuItem disabled value={-1}>
Select Review Type & Reason
</MenuItem>
{oipc.reviewtypeid ?
oipcReviewtypes.map((reviewtype) => {
if (reviewtype.reviewtypeid === oipc.reviewtypeid) {
Expand All @@ -230,13 +239,16 @@ const OIPCItem = (props) => {
select
variant="outlined"
fullWidth
value={oipc.statusid}
value={oipc.statusid ? oipc.statusid : -1}
label="Status"
onChange = {(event) => handleStatus(event.target.value)}
error={(!oipc.outcomeid || oipc.outcomeid === 5) && oipc.statusid === null}
required
disabled={oipc.outcomeid && oipc.outcomeid !== 5}
>
<MenuItem disabled value={-1}>
Select Status
</MenuItem>
{oipcStatuses.map((status) => {
return <MenuItem key={status.statusid} value={status.statusid}>{status.name}</MenuItem>
})}
Expand All @@ -261,9 +273,12 @@ const OIPCItem = (props) => {
variant="outlined"
onChange = {(event) => handleOutcome(event.target.value)}
fullWidth
value={oipc.outcomeid}
value={oipc.outcomeid ? oipc.outcomeid : -1}
label="Outcome"
>
<MenuItem disabled value={-1}>
Select Outcome
</MenuItem>
{oipcOutcomes.map((outcome) => {
if (outcome.outcomeid !== 5) {
return <MenuItem disabled={oipc.outcomeid && oipc.outcomeid !== 5} key={outcome.outcomeid} value={outcome.outcomeid}>{outcome.name}</MenuItem>
Expand Down Expand Up @@ -378,12 +393,15 @@ const OIPCItem = (props) => {
variant="outlined"
onChange = {(event) => handleInquiryFields(event.target.value, "INQUIRYOUTCOME")}
fullWidth
value={oipc.inquiryattributes.inquiryoutcome}
value={oipc.inquiryattributes.inquiryoutcome ? oipc.inquiryattributes.inquiryoutcome : -1}
label="Outcome"
error={(!oipc.outcomeid || oipc.outcomeid === 5) && oipc.inquiryattributes.inquiryoutcome === null}
required
disabled={oipc.outcomeid && oipc.outcomeid !== 5}
>
>
<MenuItem disabled value={-1}>
Select Inquiry Outcome
</MenuItem>
{oipcInquiryoutcomes.map((inquiryoutcome) => {
return <MenuItem key={inquiryoutcome.inquiryoutcomeid} value={inquiryoutcome.inquiryoutcomeid}>{inquiryoutcome.name}</MenuItem>
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ const RemoveOIPCModal= ({
showModal,
removeOIPC,
setShowModal,
oipcid,
oipc,
}) =>{

const handleSave = () => {
setShowModal(false);
removeOIPC(oipcid)
removeOIPC(oipc.id)
};
const handleClose = () => {
setShowModal(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const useOIPCHook = () => {
//OIPC State
const requestDetails = useSelector((state) => state.foiRequests.foiRequestDetail);
const stageOIPCData = (isoipcreview, oipcData) => {
console.log(isoipcreview)
if (isoipcreview) {
if (oipcData?.length > 0) {
return oipcData.map((item, index) => {
Expand Down Expand Up @@ -39,7 +38,6 @@ const useOIPCHook = () => {
setOipcData(stagedOIPCData);
}, [isOIPCReview])


//OIPC Functions
const addOIPC = () => {
setOipcData((prev) => {
Expand Down

0 comments on commit f71378a

Please sign in to comment.