Skip to content

Commit

Permalink
[CST] - Add documents filed section for v2 (#28363)
Browse files Browse the repository at this point in the history
* update order of components on the files tab

* create claim-files-tab folder and move v2 files tab components to there, also updated imports

* update imports

* update imports and move addfilesform to claim-files-tab folder

* add ClaimFileHeader to the new folder and created DocumentsFiled component

* update logic for documents filed

* update documents filed component

* updated docfiled

* added tests to Docs Filed

* add tests to docs filed

* add tests to files page

* update margins

* updated padding
  • Loading branch information
pmclaren19 committed Mar 7, 2024
1 parent f4181ea commit 23d1a8e
Show file tree
Hide file tree
Showing 17 changed files with 935 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ import {
import { getScrollOptions } from '@department-of-veterans-affairs/platform-utilities/ui';
import scrollTo from '@department-of-veterans-affairs/platform-utilities/scrollTo';

import { displayFileSize, DOC_TYPES, getTopPosition } from '../utils/helpers';
import { setFocus } from '../utils/page';
import {
displayFileSize,
DOC_TYPES,
getTopPosition,
} from '../../utils/helpers';
import { setFocus } from '../../utils/page';
import {
validateIfDirty,
isNotBlank,
Expand All @@ -33,9 +37,9 @@ import {
FILE_TYPES,
MAX_FILE_SIZE_MB,
MAX_PDF_SIZE_MB,
} from '../utils/validations';
import UploadStatus from './UploadStatus';
import mailMessage from './MailMessage';
} from '../../utils/validations';
import UploadStatus from '../UploadStatus';
import mailMessage from '../MailMessage';

const scrollToFile = position => {
const options = getScrollOptions({ offset: -25 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import { getScrollOptions } from '@department-of-veterans-affairs/platform-utili
import scrollToTop from '@department-of-veterans-affairs/platform-utilities/scrollToTop';
import scrollTo from '@department-of-veterans-affairs/platform-utilities/scrollTo';

import AddFilesForm from '../components/AddFilesForm';
import Notification from '../components/Notification';
import FilesOptional from '../components/FilesOptional';
import FilesNeeded from '../components/FilesNeeded';
import AddFilesForm from './AddFilesForm';
import Notification from '../Notification';
import FilesOptional from './FilesOptional';
import FilesNeeded from './FilesNeeded';

import { cstUseLighthouse, benefitsDocumentsUseLighthouse } from '../selectors';
import { setFocus, setPageFocus, setUpPage } from '../utils/page';
import {
cstUseLighthouse,
benefitsDocumentsUseLighthouse,
} from '../../selectors';
import { setFocus, setPageFocus, setUpPage } from '../../utils/page';
import {
addFile,
removeFile,
Expand All @@ -31,13 +34,13 @@ import {
setFieldsDirty,
resetUploads,
clearAdditionalEvidenceNotification,
} from '../actions';
} from '../../actions';
import {
getTrackedItemId,
getTrackedItems,
getFilesNeeded,
getFilesOptional,
} from '../utils/helpers';
} from '../../utils/helpers';

const scrollToError = () => {
const options = getScrollOptions({ offset: -25 });
Expand Down Expand Up @@ -98,6 +101,8 @@ class AdditionalEvidencePage extends React.Component {
const filesPath = `your-claims/${this.props.params.id}/additional-evidence`;
let content;

// TODO: Add logic for isOpen and then add that to the if statement here

if (this.props.loading) {
content = (
<va-loading-indicator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
import PropTypes from 'prop-types';
import React, { useCallback, useState } from 'react';
import { VaPagination } from '@department-of-veterans-affairs/component-library/dist/react-bindings';
import moment from 'moment';
import { buildDateFormatter } from '../../utils/helpers';
import { ITEMS_PER_PAGE } from '../../constants';

const NEED_ITEMS_STATUS = 'NEEDED_FROM_';

const formatDate = date => buildDateFormatter('MMMM d, yyyy')(date);

const getTrackedItemText = item => {
if (item.status === 'INITIAL_REVIEW_COMPLETE' || item.status === 'ACCEPTED') {
return `Reviewed by VA on ${formatDate(item.receivedDate)}`;
}
if (item.status === 'NO_LONGER_REQUIRED' && item.closedDate !== null) {
return 'No longer needed';
}
if (item.status === 'SUBMITTED_AWAITING_REVIEW') {
return 'Pending review';
}
return null;
};

const generateDocsFiled = docsFiled => {
return docsFiled.map(document => {
if (document.id && document.status) {
return {
requestTypeText: `Request type: ${document.displayName}`,
documents: document.documents,
text: getTrackedItemText(document),
date: document.date,
type: 'tracked_item',
};
}
return {
requestTypeText: 'Additional evidence',
documents: [
{
originalFileName: document.originalFileName,
documentTypeLabel: document.documentTypeLabel,
uploadDate: document.date,
},
],
text: null,
date: document.date,
type: 'additional_evidence_item',
};
});
};

const getSortedItems = itemsFiled => {
// Get items from trackedItems and additionalEvidence
const items = generateDocsFiled(itemsFiled);

return items.sort((item1, item2) => {
return moment(item2.date) - moment(item1.date);
});
};

const reviewed = text => {
return text?.includes('Reviewed');
};

const receivedDateExists = (uploadDate, itemDate) => {
return uploadDate !== null || (uploadDate === null && itemDate !== null);
};

const docsFiledDocType = (uploadDate, itemDate) =>
[
'vads-u-margin-top--0p5',
receivedDateExists(uploadDate, itemDate)
? 'vads-u-margin-bottom--0'
: 'vads-u-margin-bottom--1',
].join(' ');

function DocumentsFiled({ claim }) {
const { supportingDocuments, trackedItems } = claim.attributes;
const [currentPage, setCurrentPage] = useState(1);

// Get itemsFiled from trackedItems and supportingDocuments
const itemsFiled = trackedItems.filter(
item => !item.status.startsWith(NEED_ITEMS_STATUS),
);
itemsFiled.push(...supportingDocuments);

const items = getSortedItems(itemsFiled);
const pageLength = items.length;
const numPages = Math.ceil(pageLength / ITEMS_PER_PAGE);
const shouldPaginate = numPages > 1;

let currentPageItems = items;

if (shouldPaginate) {
const start = (currentPage - 1) * ITEMS_PER_PAGE;
const end = Math.min(currentPage * ITEMS_PER_PAGE, pageLength);
currentPageItems = items.slice(start, end);
}

const onPageSelect = useCallback(
selectedPage => {
setCurrentPage(selectedPage);
},
[setCurrentPage],
);

return (
<div className="documents-filed-container">
<h3 className="vads-u-margin-top--0 vads-u-margin-bottom--3">
Documents filed
</h3>
{currentPageItems.length === 0 ? (
<div>
<p>You haven’t turned in any documents to the VA.</p>
</div>
) : (
<>
{pageLength > 0 && (
<ol className="va-list-horizontal">
{currentPageItems.map((item, itemIndex) => (
<li
key={itemIndex}
className="vads-u-margin-bottom--2 vads-u-padding-bottom--1"
>
{item.documents.length === 0 ? (
<>
<h4 className="vads-u-margin-y--0">File name unknown</h4>
<p className="vads-u-margin-top--0p5 vads-u-margin-bottom--0">
{item.requestTypeText}
</p>
{item.date !== null && (
<p className="vads-u-margin-top--0p5 vads-u-margin-bottom--1">
{`Received on ${formatDate(item.date)}`}
</p>
)}
</>
) : (
item.documents.map((doc, index) => (
<div key={index}>
<h4 className="vads-u-margin-y--0">
{doc.originalFileName
? doc.originalFileName
: 'File name unknown'}
</h4>
<p className="vads-u-margin-top--0p5 vads-u-margin-bottom--0">
{item.requestTypeText}
</p>
<p
className={docsFiledDocType(
doc.uploadDate,
item.date,
)}
>
{`Document type: ${doc.documentTypeLabel}`}
</p>
{doc.uploadDate !== null && (
<p className="vads-u-margin-top--0p5 vads-u-margin-bottom--1">
{`Received on ${formatDate(doc.uploadDate)}`}
</p>
)}
{doc.uploadDate === null &&
item.date !== null && (
<p className="vads-u-margin-top--0p5 vads-u-margin-bottom--1">
{`Received on ${formatDate(item.date)}`}
</p>
)}
</div>
))
)}
{item.text && (
<div className="vads-u-margin-top--0 vads-u-margin-bottom--1">
{reviewed(item.text) && (
<i className="fa fa-check-circle docs-filed-icon" />
)}
<span className="docs-filed-text">{item.text}</span>
</div>
)}
</li>
))}
</ol>
)}
{shouldPaginate && (
<VaPagination
uswds
className="vads-u-border--0"
page={currentPage}
pages={numPages}
onPageSelect={e => onPageSelect(e.detail.page)}
/>
)}
</>
)}
</div>
);
}

DocumentsFiled.propTypes = {
claim: PropTypes.object,
};

export default DocumentsFiled;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PropTypes from 'prop-types';
import React from 'react';
import { Link } from 'react-router';
import { getTrackedItemId, truncateDescription } from '../utils/helpers';
import DueDate from './DueDate';
import { getTrackedItemId, truncateDescription } from '../../utils/helpers';
import DueDate from '../DueDate';

function FilesNeeded({ id, item }) {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import { Link } from 'react-router';
import { getTrackedItemId, truncateDescription } from '../utils/helpers';
import { getTrackedItemId, truncateDescription } from '../../utils/helpers';

function FilesOptional({ id, item }) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getFilesNeeded,
} from '../../utils/helpers';

import FilesNeeded from '../FilesNeeded';
import FilesNeeded from '../claim-files-tab/FilesNeeded';

function WhatYouNeedToDo({ claim, useLighthouse }) {
const trackedItems = getTrackedItems(claim, useLighthouse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AdditionalEvidenceItem from './AdditionalEvidenceItem';
import AskVAToDecide from '../AskVAToDecide';
import RequestedFilesInfo from '../RequestedFilesInfo';
import SubmittedTrackedItem from './SubmittedTrackedItem';
import AdditionalEvidencePage from '../../containers/AdditionalEvidencePage';
import AdditionalEvidencePage from '../claim-files-tab/AdditionalEvidencePage';

import { getFilesNeeded, getFilesOptional } from '../../utils/helpers';
import { Toggler } from '~/platform/utilities/feature-toggles';
Expand Down
61 changes: 32 additions & 29 deletions src/applications/claims-status/containers/FilesPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import ClaimDetailLayoutLighthouse from '../components/ClaimDetailLayout';
// END lighthouse_migration
import RequestedFilesInfo from '../components/RequestedFilesInfo';
import SubmittedTrackedItem from '../components/SubmittedTrackedItem';
import AdditionalEvidencePage from './AdditionalEvidencePage';
import ClaimFileHeader from '../components/ClaimFileHeader';
import AdditionalEvidencePage from '../components/claim-files-tab/AdditionalEvidencePage';
import ClaimFileHeader from '../components/claim-files-tab/ClaimFileHeader';
import DocumentsFiled from '../components/claim-files-tab/DocumentsFiled';

import { clearNotification } from '../actions';
import { cstUseLighthouse } from '../selectors';
Expand Down Expand Up @@ -109,39 +110,41 @@ class FilesPage extends React.Component {

return (
<div>
{isOpen && (
<Toggler toggleName={Toggler.TOGGLE_NAMES.cstUseClaimDetailsV2}>
<Toggler.Disabled>
<Toggler toggleName={Toggler.TOGGLE_NAMES.cstUseClaimDetailsV2}>
<Toggler.Disabled>
{isOpen && (
<RequestedFilesInfo
id={claim.id}
filesNeeded={filesNeeded}
optionalFiles={optionalFiles}
/>
</Toggler.Disabled>
<Toggler.Enabled>
<ClaimFileHeader />
<AdditionalEvidencePage />
</Toggler.Enabled>
</Toggler>
)}
{showDecision && <AskVAToDecide id={params.id} />}
<div className="submitted-files-list">
<h2 className="claim-file-border">Documents filed</h2>
{documentsTurnedIn.length === 0 ? (
<div>
<p>You haven’t turned in any documents to VA.</p>
)}
{showDecision && <AskVAToDecide id={params.id} />}
<div className="submitted-files-list">
<h2 className="claim-file-border">Documents filed</h2>
{documentsTurnedIn.length === 0 ? (
<div>
<p>You haven’t turned in any documents to VA.</p>
</div>
) : null}

{documentsTurnedIn.map(
(item, itemIndex) =>
item.status && item.id ? (
<SubmittedTrackedItem item={item} key={itemIndex} />
) : (
<AdditionalEvidenceItem item={item} key={itemIndex} />
),
)}
</div>
) : null}

{documentsTurnedIn.map(
(item, itemIndex) =>
item.status && item.id ? (
<SubmittedTrackedItem item={item} key={itemIndex} />
) : (
<AdditionalEvidenceItem item={item} key={itemIndex} />
),
)}
</div>
</Toggler.Disabled>
<Toggler.Enabled>
<ClaimFileHeader />
<AdditionalEvidencePage />
{showDecision && <AskVAToDecide id={params.id} />}
<DocumentsFiled claim={claim} />
</Toggler.Enabled>
</Toggler>
</div>
);
}
Expand Down

0 comments on commit 23d1a8e

Please sign in to comment.