Skip to content

Commit

Permalink
Merge pull request #5361 from bcgov/dev-marshal-MD-2981
Browse files Browse the repository at this point in the history
2981 - Communication tab for raw request states
  • Loading branch information
milosdes authored Aug 20, 2024
2 parents bebe45f + e59536f commit 46ddc08
Show file tree
Hide file tree
Showing 18 changed files with 709 additions and 105 deletions.
12 changes: 6 additions & 6 deletions forms-flow-web/src/apiManager/endpoints/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ const API = {
FOI_POST_CFR_FORM: `${FOI_BASE_API_URL}/api/foicfrfee/foirequest/<requestid>/ministryrequest/<ministryrequestid>`,
FOI_POST_CFR_FORM_IAO: `${FOI_BASE_API_URL}/api/foicfrfee/foirequest/<requestid>/ministryrequest/<ministryrequestid>/sanction`,

FOI_POST_REQUEST_CORRESPONDENCE_EMAIL: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/email/<ministryid>`,
FOI_GET_REQUEST_CORRESPONDENCE_EMAILS: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/email/<ministryid>`,
FOI_POST_REQUEST_CORRESPONDENCE_EMAIL: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/email/<ministryid>/<rawrequestid>`,
FOI_GET_REQUEST_CORRESPONDENCE_EMAILS: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/email/<ministryid>/<rawrequestid>`,

FOI_POST_EMAIL_CORRESPONDENCE: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/<requestid>/<ministryrequestid>`,
FOI_POST_DRAFT_EMAIL_CORRESPONDENCE: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/draft/<requestid>/<ministryrequestid>`,
FOI_EDIT_DRAFT_EMAIL_CORRESPONDENCE: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/draft/edit/<requestid>/<ministryrequestid>`,
FOI_DELETE_DRAFT_EMAIL_CORRESPONDENCE: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/draft/delete/<ministryrequestid>/<correspondenceid>`,
FOI_POST_RESPONSE_EMAIL_CORRESPONDENCE: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/response/<ministryrequestid>`,
FOI_EDIT_RESPONSE_EMAIL_CORRESPONDENCE: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/response/edit/<ministryrequestid>`,
FOI_DELETE_RESPONSE_EMAIL_CORRESPONDENCE: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/response/delete/<ministryrequestid>`,
FOI_DELETE_DRAFT_EMAIL_CORRESPONDENCE: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/draft/delete/<ministryrequestid>/<rawrequestid>/<correspondenceid>`,
FOI_POST_RESPONSE_EMAIL_CORRESPONDENCE: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/response/<ministryrequestid>/<rawrequestid>`,
FOI_EDIT_RESPONSE_EMAIL_CORRESPONDENCE: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/response/edit/<ministryrequestid>/<rawrequestid>`,
FOI_DELETE_RESPONSE_EMAIL_CORRESPONDENCE: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/response/delete/<ministryrequestid>/<rawrequestid>/<correspondenceid>`,

FOI_GET_EMAIL_CORRESPONDENCE: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/<requestid>/<ministryrequestid>`,
FOI_GET_EMAIL_CORRESPONDENCE_TEMPLATES: `${FOI_BASE_API_URL}/api/foiflow/applicantcorrespondence/templates`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ import {
import { replaceUrl } from "../../../helper/FOI/helper";
import { catchError, fnDone } from "./foiServicesUtil";

export const fetchCorrespondenceEmailList = (ministryId, ...rest) => {
export const fetchCorrespondenceEmailList = (ministryId, requestId, ...rest) => {
const done = fnDone(rest);
let apiUrl = '';
if (!ministryId) ministryId = 'None'
if (!requestId) requestId = 'None'

apiUrl = replaceUrl(
API.FOI_GET_REQUEST_CORRESPONDENCE_EMAILS,
"<ministryid>",
ministryId
);
apiUrl = replaceUrl(apiUrl, "<rawrequestid>", requestId);
return (dispatch) => {
httpGETRequest(apiUrl, {}, UserService.getToken())
.then((res) => {
Expand All @@ -35,14 +39,18 @@ export const fetchCorrespondenceEmailList = (ministryId, ...rest) => {
};
};

export const saveCorrespondenceEmail = (ministryId, data, ...rest) => {
export const saveCorrespondenceEmail = (ministryId, requestId, data, ...rest) => {
const done = fnDone(rest);
let apiUrl = API.FOI_POST_REQUEST_CORRESPONDENCE_EMAIL;
if (!ministryId) ministryId = 'None';
if (!requestId) requestId = 'None';

apiUrl = replaceUrl(
API.FOI_POST_REQUEST_CORRESPONDENCE_EMAIL,
"<ministryid>",
ministryId
);
apiUrl = replaceUrl(apiUrl, "<rawrequestid>", requestId);
return (dispatch) => {
httpPOSTRequest(apiUrl, data)
.then((res) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export const fetchApplicantCorrespondence = (
ministryId,
errorCallback = null
) => {

if (ministryId == null) {
return () => {};
ministryId = 'None'
}
const apiUrl = replaceUrl(replaceUrl(
API.FOI_GET_EMAIL_CORRESPONDENCE,
Expand Down Expand Up @@ -55,7 +55,7 @@ export const saveEmailCorrespondence = (
errorCallback,
) => {
if (!ministryId) {
dispatch(serviceActionError("No request id"));
ministryId = 'None';
}
dispatch(setFOICorrespondenceLoader(true));
const apiUrl = replaceUrl(replaceUrl(
Expand Down Expand Up @@ -92,7 +92,7 @@ export const saveDraftCorrespondence = (
errorCallback,
) => {
if (!ministryId) {
dispatch(serviceActionError("No request id"));
ministryId = 'None';
}
dispatch(setFOICorrespondenceLoader(true));
const apiUrl = replaceUrl(replaceUrl(
Expand Down Expand Up @@ -130,7 +130,7 @@ export const editDraftCorrespondence = (
errorCallback,
) => {
if (!ministryId) {
dispatch(serviceActionError("No request id"));
ministryId = 'None';
}
dispatch(setFOICorrespondenceLoader(true));
const apiUrl = replaceUrl(replaceUrl(
Expand Down Expand Up @@ -161,20 +161,22 @@ export const editDraftCorrespondence = (
export const deleteDraftCorrespondence = (
correspondenceid,
ministryId,
requestId,
dispatch,
callback,
errorCallback,
) => {
if (!ministryId) {
dispatch(serviceActionError("No request id"));
ministryId = 'None';
}
dispatch(setFOICorrespondenceLoader(true));
const apiUrl = replaceUrl(replaceUrl(
let apiUrl = replaceUrl(replaceUrl(
API.FOI_DELETE_DRAFT_EMAIL_CORRESPONDENCE,
"<ministryrequestid>",
ministryId),"<correspondenceid>", correspondenceid,

);
apiUrl = replaceUrl(apiUrl,"<rawrequestid>",requestId);
httpPOSTRequest(apiUrl,{})
.then((res) => {
if (res.data) {
Expand All @@ -198,20 +200,22 @@ export const deleteDraftCorrespondence = (
export const deleteResponseCorrespondence = (
correspondenceid,
ministryId,
requestId,
dispatch,
callback,
errorCallback,
) => {
if (!ministryId) {
dispatch(serviceActionError("No request id"));
ministryId = 'None';
}
dispatch(setFOICorrespondenceLoader(true));
const apiUrl = replaceUrl(replaceUrl(
API.FOI_DELETE_DRAFT_EMAIL_CORRESPONDENCE,
let apiUrl = replaceUrl(replaceUrl(
API.FOI_DELETE_RESPONSE_EMAIL_CORRESPONDENCE,
"<ministryrequestid>",
ministryId),"<correspondenceid>", correspondenceid,

);
apiUrl = replaceUrl(apiUrl,"<rawrequestid>",requestId);
httpPOSTRequest(apiUrl,{})
.then((res) => {
if (res.data) {
Expand All @@ -235,19 +239,20 @@ export const deleteResponseCorrespondence = (
export const saveCorrespondenceResponse = (
data,
ministryId,
requestId,
dispatch,
callback,
errorCallback,
) => {
if (!ministryId) {
dispatch(serviceActionError("No request id"));
ministryId = 'None';
}
dispatch(setFOICorrespondenceLoader(true));
const apiUrl = replaceUrl(replaceUrl(
API.FOI_POST_RESPONSE_EMAIL_CORRESPONDENCE,
"<ministryrequestid>",
ministryId)
);
ministryId),
"<rawrequestid>", requestId);
httpPOSTRequest(apiUrl, data)
.then((res) => {
if (res.data) {
Expand All @@ -271,18 +276,20 @@ export const saveCorrespondenceResponse = (
export const editCorrespondenceResponse = (
data,
ministryId,
rawRequestId,
dispatch,
callback,
errorCallback,
) => {
if (!ministryId) {
dispatch(serviceActionError("No request id"));
ministryId = 'None';
}
dispatch(setFOICorrespondenceLoader(true));
const apiUrl = replaceUrl(replaceUrl(
API.FOI_EDIT_RESPONSE_EMAIL_CORRESPONDENCE,
"<ministryrequestid>",
ministryId)
ministryId),
"<rawrequestid>", rawRequestId
);
httpPOSTRequest(apiUrl, data)
.then((res) => {
Expand Down
8 changes: 4 additions & 4 deletions forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1025,10 +1025,10 @@ const FOIRequest = React.memo(({ userDetail, openApplicantProfileModal }) => {

const showContactApplicantTab = () => {
return (
requestState !== StateEnum.intakeinprogress.name &&
requestState !== StateEnum.unopened.name &&
//requestState !== StateEnum.open.name &&
requestState !== StateEnum.appfeeowing.name &&
// requestState !== StateEnum.intakeinprogress.name &&
// requestState !== StateEnum.unopened.name &&
// requestState !== StateEnum.open.name &&
// requestState !== StateEnum.appfeeowing.name &&
requestDetails?.requestType === FOI_COMPONENT_CONSTANTS.REQUEST_TYPE_GENERAL)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ const CommunicationStructure = ({correspondence, currentIndex,
</>
)
}
<Chip label={correspondence.sentby ? 'emailed' : 'exported'} variant="outlined" />
{correspondence.category !== "draft" && <Chip label={correspondence.sentby ? 'emailed' : 'exported'} variant="outlined" />}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ export const ContactApplicant = ({
const type = (templateId && [1, 2].includes(templateId)) ? "CFRFee" : "";
let data = {
templateid: currentTemplate ? templates[currentTemplate as keyof typeof templates].templateid : null,
correspondenceid:correspondenceId,
correspondencemessagejson: JSON.stringify({
"emailhtml": emailContent,
"id": approvedForm?.cfrfeeid,
Expand Down Expand Up @@ -491,6 +492,7 @@ export const ContactApplicant = ({
const type = (templateId && [1, 2].includes(templateId)) ? "CFRFee" : "";
let data = {
templateid: currentTemplate ? templates[currentTemplate as keyof typeof templates].templateid : null,
correspondenceid:correspondenceId,
correspondencemessagejson: JSON.stringify({
"emailhtml": editorValue,
"id": approvedForm?.cfrfeeid,
Expand Down Expand Up @@ -552,6 +554,7 @@ export const ContactApplicant = ({
saveCorrespondenceResponse(
data,
ministryId,
requestId,
dispatch,
callback,
(errorMessage: string) => {
Expand Down Expand Up @@ -627,7 +630,7 @@ export const ContactApplicant = ({
});
dispatch(fetchApplicantCorrespondence(requestId, ministryId));
}
deleteDraftCorrespondence(draftCorrespondence.applicantcorrespondenceid,ministryId,
deleteDraftCorrespondence(draftCorrespondence.applicantcorrespondenceid,ministryId,requestId,
dispatch,
callback,
(errorMessage: string) => {
Expand Down Expand Up @@ -677,7 +680,7 @@ export const ContactApplicant = ({
});
dispatch(fetchApplicantCorrespondence(requestId, ministryId));
}
deleteResponseCorrespondence(selectedCorrespondence.applicantcorrespondenceid,ministryId,
deleteResponseCorrespondence(selectedCorrespondence.applicantcorrespondenceid,ministryId,requestId,
dispatch,
callback,
(errorMessage: string) => {
Expand Down Expand Up @@ -759,6 +762,7 @@ export const ContactApplicant = ({
editCorrespondenceResponse(
{ filename: newFilename, correspondenceattachmentid: correspondenceAttachmentId, correspondenceid: correspondenceId },
ministryId,
requestId,
dispatch,
() => {
setSelectedCorrespondence({})
Expand All @@ -774,6 +778,7 @@ export const ContactApplicant = ({
editCorrespondenceResponse(
{responsedate: newDate, correspondenceid: selectedCorrespondence.applicantcorrespondenceid},
ministryId,
requestId,
dispatch,
() => {
setSelectedCorrespondence({})
Expand Down Expand Up @@ -1047,6 +1052,7 @@ export const ContactApplicant = ({
<Grid item xs={'auto'}>
<CorrespondenceEmail
ministryId={ministryId}
requestId={requestId}
selectedEmails={selectedEmails}
setSelectedEmails={setSelectedEmails}
defaultEmail={requestDetails.email}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const useStyles = makeStyles((theme) => ({

export default function CorrespondenceEmail({
ministryId,
requestId,
selectedEmails,
setSelectedEmails,
defaultEmail
Expand All @@ -54,7 +55,7 @@ export default function CorrespondenceEmail({

React.useEffect(() => {
dispatch(
fetchCorrespondenceEmailList(ministryId, (_err, res) => {
fetchCorrespondenceEmailList(ministryId, requestId, (_err, res) => {
setRequestemailList( [{"email": defaultEmail}, ...res]);
})
);
Expand All @@ -74,7 +75,7 @@ export default function CorrespondenceEmail({
const handleEmailSave = (e) => {
if (newCorrespondenceEmail && !isEmailPresent(newCorrespondenceEmail)) {
dispatch(
saveCorrespondenceEmail(ministryId, {"email": newCorrespondenceEmail}, (_err, res) => {
saveCorrespondenceEmail(ministryId, requestId, {"email": newCorrespondenceEmail}, (_err, res) => {
setRequestemailList((oldArray) => [...oldArray, {"email": newCorrespondenceEmail}]);
setNewCorrespondenceEmail("");
})
Expand Down
Loading

0 comments on commit 46ddc08

Please sign in to comment.