Skip to content

Commit

Permalink
Ki/APPEALS-42563 - Package Details: Inbound Ops Team Superuser/visor:…
Browse files Browse the repository at this point in the history
… Edit Information (#22944)

* APPEALS-42563 - Working Modal, minus Save patch request

* APPEALS-42563 - Fixed Modal, missing ApiSave

* APPEALS-42563 - ApiUtil fix

* APPEALS-42563

* Test Updates

* Remove loadCorrespondence

* Removed unused correspondenceInfo action; linting

---------

Co-authored-by: cacevesva <109166981+cacevesva@users.noreply.github.com>
Co-authored-by: HunJerBAH <99915461+HunJerBAH@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 1, 2024
1 parent 24a4e18 commit a391340
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 48 deletions.
13 changes: 13 additions & 0 deletions app/controllers/correspondence_details_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ def build_json_response
}
end

def correspondence_params
params.require(:correspondence).permit(:correspondence, :va_date_of_receipt, :correspondence_type_id, :notes)
end

def edit_general_information
correspondence.update!(
va_date_of_receipt: correspondence_params[:va_date_of_receipt],
correspondence_type_id: correspondence_params[:correspondence_type_id],
notes: correspondence_params[:notes]
)
render json: { correspondence: serialized_correspondence }, status: :created
end

# Overriding method to allow users to access the correspondence details page
def verify_correspondence_access
true
Expand Down
1 change: 1 addition & 0 deletions app/views/correspondence/correspondence_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
applicationUrls: application_urls,
feedbackUrl: feedback_url,
correspondence: @correspondence_details[:correspondence],
correspondenceTypes: @correspondence_details[:correspondence_types],
flash: flash,
isInboundOpsUser: current_user.inbound_ops_team_user?,
isInboundOpsSupervisor: current_user.inbound_ops_team_supervisor?,
Expand Down
5 changes: 5 additions & 0 deletions client/COPY.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@
"CORRESPONDENCE_OTHER_MOTION_MODAL_DETAIL": "Provide context and instructions for the action",
"CORRESPONDENCE_COMPLETE_TASK_CONFIRMATION": "Task for %s's case has been completed",
"CORRESPONDENCE_COMPLETE_TASK_CONFIRMATION_DETAIL": "Task for %s's case has been completed",
"CORRESPONDENCE_EDIT_GENERAL_INFORMATION_MODAL_TITLE": "Edit general information",
"CORRESPONDENCE_EDIT_GENERAL_INFORMATION_MODAL_VADOR": "VA DOR",
"CORRESPONDENCE_EDIT_GENERAL_INFORMATION_MODAL_TYPE": "Correspondence type",
"CORRESPONDENCE_EDIT_GENERAL_INFORMATION_MODAL_NOTES": "Notes",
"CORRESPONDENCE_EDIT_GENERAL_INFORMATION_MODAL_DETAIL": "Correspondence has been updated",
"DOCUMENT_PREVIEW": "Document Preview",
"TASK_SNAPSHOT_ABOUT_BOX_TITLE": "About the case",
"TASK_SNAPSHOT_ABOUT_BOX_HEARING_REQUEST_TYPE_LABEL": "Hearing Type",
Expand Down
17 changes: 17 additions & 0 deletions client/app/queue/QueueApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ import NotificationsView from './NotificationsView';
import CavcDashboard from './cavcDashboard/CavcDashboard';
import CorrespondenceDetails from './correspondence/details/CorrespondenceDetails';
import CorrespondenceChangeTaskTypeModal from 'app/queue/components/CorrespondenceChangeTaskTypeModal';
import CorrespondenceEditGeneralInformationModal from './components/CorrespondenceEditGeneralInformationModal';

class QueueApp extends React.PureComponent {
componentDidMount = () => {
Expand Down Expand Up @@ -747,6 +748,7 @@ class QueueApp extends React.PureComponent {
<CorrespondenceDetails {...props.match.params}
{...this.props}
correspondenceResponseLetters={this.props.correspondenceResponseLetters}
correspondenceTypes={this.props.correspondenceTypes}
/>
);

Expand All @@ -757,6 +759,12 @@ class QueueApp extends React.PureComponent {
/>
);

routedCorrespondenceEditGeneralInformationModal = (props) => (
<CorrespondenceEditGeneralInformationModal {...props.match.params}
{...this.props}
/>
);

routedCompleteHearingWithdrawalRequest = (props) => (
<CompleteHearingWithdrawalRequestModal {...props.match.params} />
);
Expand Down Expand Up @@ -1022,6 +1030,7 @@ class QueueApp extends React.PureComponent {
title={`${PAGE_TITLES.CORRESPONDENCE_INTAKE}`}
render={this.routedCorrespondenceIntake}
/>

<PageRoute
exact
path={
Expand All @@ -1043,6 +1052,7 @@ class QueueApp extends React.PureComponent {
title={`${PAGE_TITLES.ASSIGN_TASK} | Caseflow`}
render={this.routedCorrespondenceAssignTaskModal}
/>

<PageRoute
exact
path={
Expand Down Expand Up @@ -1072,6 +1082,13 @@ class QueueApp extends React.PureComponent {
render={this.routedCorrespondenceCompleteTaskModal}
/>

<PageRoute
exact
path ="/queue/correspondence/:correspondence_uuid/modal/edit_correspondence_general_information"
title={`${PAGE_TITLES.EDIT_GENERAL_INFORMATION} | Caseflow}`}
render={this.routedCorrespondenceEditGeneralInformationModal}
/>

{motionToVacateRoutes.page}

{docketSwitchRoutes.page}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import moment from 'moment';
import DateSelector from '../../components/DateSelector';
import SearchableDropdown from '../../components/SearchableDropdown';
import TextareaField from '../../components/TextareaField';
import COPY from '../../../COPY';
import QueueFlowModal from './QueueFlowModal';
import { editCorrespondenceGeneralInformation } from
'../correspondence/correspondenceDetailsReducer/correspondenceDetailsActions';

const CorrespondenceEditGeneralInformationModal = (props) => {
const { correspondenceInfo, correspondenceTypes, handleEditGeneralInformationModal } = props;
const [changeVaDor, setChangeVaDor] = useState(
moment.utc((correspondenceInfo?.vaDateOfReceipt)).format('YYYY-MM-DD')
);
const [changeCorrespondenceTypeId, setChangeCorrespondenceTypeId] = useState(
// eslint-disable-next-line camelcase
correspondenceInfo?.correspondence_type_id
);
const [changeNotes, setChangeNotes] = useState(correspondenceInfo?.notes);
const [dateError, setDateError] = useState(false);
const [saveButton, setSaveButton] = useState(true);

// Handling VA DOR changes
const validateDateNotInFuture = (date) => {
const currentDate = new Date();
const enteredDate = new Date(date);

if (currentDate < enteredDate) {
return false;
}

return true;
};

const handleSelectVaDor = (value) => {
// Check for future date
const error = validateDateNotInFuture(value) ? false : 'Receipt date cannot be in the future';

setChangeVaDor(value);
setDateError(error);

// If no errors, enable the save button
if (!error) {
setSaveButton(false);
}
};

// Handling Correspondence changes
const generateOptions = (options) =>
options?.map((option) => ({
value: option.id,
label: option.name,
id: option.id,
}));

const handleSelectCorrespondenceType = (value) => {
// Update the corresppondence type and type id with placeholder
setChangeCorrespondenceTypeId(value.id);
setSaveButton(false);
};

const handleCorrespondenceTypeEmpty = () => {
// eslint-disable-next-line camelcase
if (correspondenceInfo?.correspondence_type_id === null) {
return 'Select...';
}

// eslint-disable-next-line camelcase
const type = correspondenceTypes?.find((value) => value?.id === correspondenceInfo?.correspondence_type_id);

return type?.name;
};

// Handling Notes Changes
const handleChangeNotes = (value) => {
setChangeNotes(value);
setSaveButton(false);
};

// Handling Submit
const handleSubmit = async () => {
// Disable the save button on submit
setSaveButton(true);

const payload = {
data: {
correspondence: {
va_date_of_receipt: changeVaDor,
correspondence_type_id: changeCorrespondenceTypeId,
notes: changeNotes
}
}
};

await (props.editCorrespondenceGeneralInformation(payload, correspondenceInfo.uuid));

handleEditGeneralInformationModal();
};

// useEffects to activate save button
// enable save button if changes happen to form (with no errors)
useEffect(() => {
// error validation
if (dateError || props?.errorMessage) {
setSaveButton(true);
}
}, [handleSelectVaDor, handleSelectCorrespondenceType, handleChangeNotes]);

return (
<QueueFlowModal
title={COPY.CORRESPONDENCE_EDIT_GENERAL_INFORMATION_MODAL_TITLE}
button={COPY.MODAL_SAVE_BUTTON}
submitDisabled={saveButton}
// eslint-disable-next-line camelcase
pathAfterSubmit={correspondenceInfo?.redirect_after ??
`/queue/correspondence/${correspondenceInfo.uuid}`}
submit={handleSubmit}
onCancel={handleEditGeneralInformationModal}
>
<DateSelector
class= "field-style-rp"
label="VA DOR"
name="date"
type="date"
onChange={handleSelectVaDor}
value={changeVaDor}
errorMessage={dateError}
/>
<br></br>
<SearchableDropdown
name="correspondence-dropdown"
label="Correspondence type"
options={generateOptions(props?.correspondenceTypes)}
onChange={handleSelectCorrespondenceType}
placeholder={handleCorrespondenceTypeEmpty()}
/>
<br></br>
<TextareaField
name="Notes"
id="taskInstructions"
onChange={handleChangeNotes}
value={changeNotes}
/>
</QueueFlowModal>
);
};

CorrespondenceEditGeneralInformationModal.propTypes = {
correspondence_uuid: PropTypes.string,
editCorrespondenceGeneralInformation: PropTypes.func,
team: PropTypes.string,
correspondenceTypes: PropTypes.array,
correspondenceTypeId: PropTypes.number,
setCorrespondenceTypeId: PropTypes.func,
notes: PropTypes.string,
vaDateOfReceipt: PropTypes.string,
setSaveButton: PropTypes.bool,
setCorrespondence: PropTypes.func,
setErrorMessage: PropTypes.func,
setNotes: PropTypes.func,
setVaDor: PropTypes.func,
errorMessage: PropTypes.string,
userIsInboundOpsSupervisor: PropTypes.bool,
correspondenceInfo: PropTypes.object,
handleEditGeneralInformationModal: PropTypes.func
};

const mapStateToProps = (state) => ({
correspondenceInfo: state.correspondenceDetails.correspondenceInfo
});

const mapDispatchToProps = (dispatch) => bindActionCreators({
editCorrespondenceGeneralInformation
}, dispatch);

export default (withRouter(
connect(
mapStateToProps,
mapDispatchToProps
)(CorrespondenceEditGeneralInformationModal)
));
1 change: 1 addition & 0 deletions client/app/queue/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export const PAGE_TITLES = {
CORRESPONDENCE_CASES_LIST: 'Correspondence Cases',
CORRESPONDENCE_INTAKE: 'Correspondence Intake',
CORRESPONDENCE_DETAILS: 'Correspondence Details',
EDIT_GENERAL_INFORMATION: 'Edit General Information',
ASSIGN_CORR_TASK_TO_TEAM: 'Assign Task',
};

Expand Down
Loading

0 comments on commit a391340

Please sign in to comment.