diff --git a/services/app-web/src/documentHelpers/makeDocumentDateLookupTable.ts b/services/app-web/src/documentHelpers/makeDocumentDateLookupTable.ts index 0df8e6bcfc..89100623ce 100644 --- a/services/app-web/src/documentHelpers/makeDocumentDateLookupTable.ts +++ b/services/app-web/src/documentHelpers/makeDocumentDateLookupTable.ts @@ -25,15 +25,17 @@ function makeDocumentDateTable( revisionsLookup: RevisionsLookupType ): DocumentDateLookupTableType { const lookupTable: DocumentDateLookupTableType = { - previousSubmissionDate: null, + previousSubmissionDate: null, // the last time there was a submission on this package } - Object.keys(revisionsLookup).forEach( - (revisionId: string, index: number) => { + const listOfRevisionLookups = Object.keys(revisionsLookup) + listOfRevisionLookups.forEach( + (revisionId: string, index) => { const revision = revisionsLookup[revisionId] - const previousSubmission = getDateAdded(revision) // used in UploadedDocumentsTable to determine if we should show NEW tag - if (previousSubmission && !lookupTable['previousSubmissionDate']) - lookupTable['previousSubmissionDate'] = previousSubmission + const submitDate = revision.submitInfo?.updatedAt + if (submitDate && (listOfRevisionLookups.length === 1 || index === 1)) { // if we have a package with only one submitted revision, use that - otherwise use whatever in is the 1 index because thats the last submitted + lookupTable['previousSubmissionDate'] = submitDate + } const allDocuments = getAllDocuments(revision.formData) allDocuments.forEach((doc) => {