Skip to content

Commit

Permalink
Merge pull request #5472 from bcgov/test-marshal-JC-FOIMOD-2842-3132-…
Browse files Browse the repository at this point in the history
…3125-3450

Fix applicant correspondence issues
  • Loading branch information
jocelyncabildo-aot authored Dec 6, 2024
2 parents 0957597 + afef314 commit c2efa4e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ export default function AttachmentModal({
disabled={isSaveDisabled()}
onClick={handleSave}
>
{uploadFor === "email" ? "Save Changes" :"Continue"}
Continue
</button>
)}
<button className="btn-bottom btn-cancel" onClick={handleClose}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const PreviewModal = React.memo(({
<DialogContentText id="state-change-dialog-description" component={'span'}>
<div className="state-change-email-note">
{enableSend && selectedEmails.length > 0 && (<p>Email to: {selectedEmails.join(', ')}</p>)}
{!enableSend && (<p>There is no email associated with this applicant a word doc will be created to be printed.</p>)}
{!enableSend && (<p>No email address has been selected to send this correspondence to. Instead, you can export this correspondence as a PDF.</p>)}
</div>
<div className="preview-container">
<iframe srcDoc={ renderTemplate(template, innerhtml, templateVariables) } className="preview-frame" sandbox="allow-same-origin" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,16 @@ export const ContactApplicant = ({
}
})

setTemplates((oldArray) =>
setTemplates(oldArray =>
oldArray.filter(
(existingItem) =>
isEnabledTemplate(existingItem) ||
listOfDraftTemplates.includes(existingItem.templateid) ||
existingItem.templateid === null
template => updatedTemplates.includes(template.value) || template.value === ""
)
);

const updatedTemplates: string[] = [];
applicantCorrespondenceTemplates.forEach((item: any) => {
if (isEnabledTemplate(item) || listOfDraftTemplates.includes(item.templateid)) {
updatedTemplates.push(item.name)
const rootpath = OSS_S3_BUCKET_FULL_PATH
const fileInfoList = [{
filename: item.name,
Expand Down Expand Up @@ -406,6 +405,7 @@ export const ContactApplicant = ({
const attachments = await saveAttachments(files);
let callback = (_res: string) => {
clearcorrespondence();
changeCorrespondenceFilter("log");
if (!skiptoast) {
toast.success("Message has been sent to applicant successfully", {
position: "top-right",
Expand Down Expand Up @@ -690,7 +690,7 @@ export const ContactApplicant = ({
setOpenConfirmationModal(true);
setConfirmationFor("delete-response")
setConfirmationTitle("Delete Response")
setConfirmationMessage("Are you sure you want to delete this response? This can not be undone");
setConfirmationMessage("Are you sure you want to delete this response? This can not be undone.");
}

const deleteResponseAction = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import _ from 'lodash';
import TextField from "@material-ui/core/TextField";
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faPlusCircle } from '@fortawesome/free-solid-svg-icons';
import * as EmailValidator from "email-validator";



Expand Down Expand Up @@ -55,6 +56,7 @@ export default function CorrespondenceEmail({
const [requestemailList, setRequestemailList] = React.useState([]);
const [noOfSelectedEmails, setNoOfSelectedEmails] = React.useState(0);
const [showAddEmail, setShowAddEmail] = React.useState(false);
const [validation, setValidation] = React.useState({});

React.useEffect(() => {
dispatch(
Expand Down Expand Up @@ -114,6 +116,17 @@ export default function CorrespondenceEmail({


const handleNewCorrespondenceEmailChange = (e) => {
let emailValidation = {};
if (e.target.value) {
const helperText = EmailValidator.validate(e.target.value)
? ""
: "Email is not valid.";
emailValidation = { field: "Email", helperTextValue: helperText };
setValidation(emailValidation);
} else {
emailValidation = { field: "Email", helperTextValue: "" };
setValidation(emailValidation);
}
setNewCorrespondenceEmail(e.target.value);
};
//creates the grouped menu items for assignedTo combobox
Expand All @@ -139,9 +152,14 @@ export default function CorrespondenceEmail({
<TextField id="new-email" label="Add New Email Address" variant="outlined" fullWidth
value={newCorrespondenceEmail} onChange={handleNewCorrespondenceEmailChange}
onKeyDown={(e) => {e.stopPropagation();}} onKeyUp={(e) => {e.stopPropagation();}}
error={(validation.helperTextValue !== undefined &&validation.helperTextValue !== "")}
helperText={validation.helperTextValue}
/>
<div>
<button className="btn-bottom btn-save" onClick={handleEmailSave} disabled={!newCorrespondenceEmail || isEmailPresent(newCorrespondenceEmail)}>
<button className="btn-bottom btn-save"
onClick={handleEmailSave}
disabled={!newCorrespondenceEmail || isEmailPresent(newCorrespondenceEmail) ||
(validation.helperTextValue !== undefined && validation.helperTextValue !== "")}>
Save
</button>
<button className="btn-cancel" onClick={() => setShowAddEmail(false)} >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ const FileUpload = ({
return "Drag and drop attachments, or click Add Files"
}

const getTagMessage = (uploadFor) => {
if (uploadFor === "email") return null;
if (uploadFor === "response") {
return <p>Only one response may be added at a time.</p>;
}
return (
<p>
When uploading more than one {uploadFor}, all {uploadFor}s will have the same selected tag.
</p>
);
};

return (
<>
{(modalFor === "add" && (uploadFor === "attachment" || uploadFor === 'record')) && (<div>
Expand Down Expand Up @@ -249,9 +261,9 @@ const FileUpload = ({
</div>
</div>
</section>
{modalFor === "add" && (<div className="tag-message-container">
<p>When uploading more than one {uploadFor}, all {uploadFor}s will have the same selected tag.</p>
</div>)}
{modalFor === "add" && (
<div className="tag-message-container">{getTagMessage(uploadFor)}</div>
)}
<ul className="error-message-ul">
{errorMessage
? errorMessage.map((error) => (
Expand Down

0 comments on commit c2efa4e

Please sign in to comment.