Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ki/APPEALS-42563 - Package Details: Inbound Ops Team Superuser/visor: Edit Information #22944

Merged
merged 11 commits into from
Oct 1, 2024
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 @@ -1028,6 +1036,7 @@ class QueueApp extends React.PureComponent {
title={`${PAGE_TITLES.CORRESPONDENCE_INTAKE}`}
render={this.routedCorrespondenceIntake}
/>

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

<PageRoute
exact
path={
Expand Down Expand Up @@ -1078,6 +1088,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
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export const setTasksUnrelatedToAppealEmpty = (tasksUnrelatedToAppealEmpty) => (
});
};

export const updateCorrespondenceRelations = (correspondence) =>
export const updateCorrespondenceInfo = (correspondence) =>
HunJerBAH marked this conversation as resolved.
Show resolved Hide resolved
(dispatch) => {
dispatch({
type: ACTIONS.CORRESPONDENCE_INFO,
Expand All @@ -286,3 +286,25 @@ export const updateCorrespondenceRelations = (correspondence) =>
}
});
};

export const editCorrespondenceGeneralInformation = (payload, uuid) => (dispatch) => {
return ApiUtil.patch(`/queue/correspondence/${uuid}/edit_general_information`, payload).
then((response) => {
const correspondence = response.body.correspondence;

dispatch({
type: ACTIONS.CORRESPONDENCE_INFO,
payload: {
correspondence
}
});

}).
catch((error) => {
const errorMessage = error?.response?.body?.message ?
error.response.body.message.replace(/^Error:\s*/, '') :
error.message;

console.error(errorMessage);
});
};
Loading
Loading