Skip to content

Commit

Permalink
Merge branch 'main' into wml-migrate-old-submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
macrael committed Apr 29, 2024
2 parents e2a9a35 + aad5d4d commit c06cb7e
Show file tree
Hide file tree
Showing 14 changed files with 284 additions and 140 deletions.
21 changes: 11 additions & 10 deletions services/app-web/src/components/ChangeHistory/ChangeHistoryV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ export const ChangeHistoryV2 = ({
}: ChangeHistoryProps): React.ReactElement => {
const flattenedRevisions = (): flatRevisions[] => {
const result: flatRevisions[] = []

const contractSubmissions = contract.packageSubmissions.filter(
(submission) => {
return submission.cause === 'CONTRACT_SUBMISSION'
}
)

//Reverse revisions to order from earliest to latest revision. This is to correctly set version for each
// contract & recontract.
const reversedRevisions = [...contractSubmissions].reverse()
Expand All @@ -40,9 +42,8 @@ export const ChangeHistoryV2 = ({
}
if (r.submitInfo) {
const newSubmit: flatRevisions = {} as flatRevisions

const revisionVersion =
index !== contract.packageSubmissions.length - 1
index !== contract.packageSubmissions.length - 1 // if we aren't at the last item in list, assign a version
? String(index + 1) //Offset version, we want to start at 1
: undefined

Expand All @@ -62,7 +63,7 @@ export const ChangeHistoryV2 = ({

const revisedItems: AccordionItemProps[] = revisionHistory.map(
(r, index) => {
const isInitialSubmission = r.updatedReason === 'Initial contract'
const isInitialSubmission = r.updatedReason === 'Initial submission'
const isSubsequentSubmission = r.kind === 'submit'
// We want to know if this contract has multiple submissions. To have multiple submissions, there must be minimum
// more than the initial contract revision.
Expand All @@ -84,14 +85,14 @@ export const ChangeHistoryV2 = ({
content: isInitialSubmission ? (
<div data-testid={`change-history-record`}>
<span className={styles.tag}>Submitted by:</span>
<span> {r.updatedBy}</span>
<span> {r.updatedBy}&nbsp;</span>
<br />
{r.revisionVersion && hasSubsequentSubmissions && (
<Link
href={`/contracts/${contract.id}/revisions/${r.revisionVersion}`}
href={`/submissions/${contract.id}/revisions/${r.revisionVersion}`}
data-testid={`revision-link-${r.revisionVersion}`}
>
View past contract version
View past submission version
</Link>
)}
</div>
Expand All @@ -101,9 +102,9 @@ export const ChangeHistoryV2 = ({
<span className={styles.tag}>
{isSubsequentSubmission
? 'Submitted by: '
: 'Unlocked by: '}{' '}
: 'Unlocked by: '}
</span>
<span>{r.updatedBy}</span>
<span>{r.updatedBy}&nbsp;</span>
</div>
<div>
<span className={styles.tag}>
Expand All @@ -115,10 +116,10 @@ export const ChangeHistoryV2 = ({
</div>
{isSubsequentSubmission && r.revisionVersion && (
<Link
href={`/contracts/${contract.id}/revisions/${r.revisionVersion}`}
href={`/submissions/${contract.id}/revisions/${r.revisionVersion}`}
data-testid={`revision-link-${r.revisionVersion}`}
>
View past contract version
View past submission version
</Link>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ const relatedSubmissions = (
statePrograms: Program[]
): React.ReactElement => {
return (
<>
<ul className={styles.commaList}>
{contractRevisions.map((contractRev) => (
<Link
key={contractRev.contract.id}
<li key={contractRev.contract.id}>
<Link
asCustom={NavLink}
to={`/submissions/${contractRev.contract.id}`}
>
Expand All @@ -80,9 +80,9 @@ const relatedSubmissions = (
contractRev.formData.programIDs,
statePrograms
)}
</Link>
</Link></li>
))}
</>
</ul>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,20 @@
li {
padding: uswds.units(1) 0;
}
&.commaList {
li {
padding: 0;
}
li:after {
content: ', ';
}
li:last-of-type::after{
display: none;
}
}
}


// align state contacts
dl div[class^='grid-container'] {
padding: 0;
Expand Down Expand Up @@ -115,3 +127,4 @@
padding: 0;
}
}

146 changes: 72 additions & 74 deletions services/app-web/src/pages/LinkYourRates/LinkRateSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,46 +41,46 @@ export const LinkRateSelect = ({

const rates = data?.indexRates.edges.map((e) => e.node) || []

const rateNames: LinkRateOptionType[] = rates
.map((rate) => {
const revision = rate.revisions[0]
return {
value: rate.id,
label: (
<>
<strong>
{revision.formData.rateCertificationName}
</strong>
<div style={{ lineHeight: '50%', fontSize: '14px' }}>
<p>
Programs:&nbsp;
{programNames(
statePrograms,
revision.formData.rateProgramIDs
).join(', ')}
</p>
<p>
Rating period:&nbsp;
{formatCalendarDate(
revision.formData.rateDateStart
)}
-
{formatCalendarDate(
revision.formData.rateDateEnd
)}
</p>
<p>
Certification date:&nbsp;
{formatCalendarDate(
revision.formData.rateDateCertified
)}
</p>
</div>
</>
),
}
})
.reverse()
// Sort rates by latest submission in desc order
rates.sort(
(a, b) =>
new Date(b.revisions[0].submitInfo?.updatedAt).getTime() -
new Date(a.revisions[0].submitInfo?.updatedAt).getTime()
)

const rateNames: LinkRateOptionType[] = rates.map((rate) => {
const revision = rate.revisions[0]
return {
value: rate.id,
label: (
<>
<strong>{revision.formData.rateCertificationName}</strong>
<div style={{ lineHeight: '50%', fontSize: '14px' }}>
<p>
Programs:&nbsp;
{programNames(
statePrograms,
revision.formData.rateProgramIDs
).join(', ')}
</p>
<p>
Rating period:&nbsp;
{formatCalendarDate(
revision.formData.rateDateStart
)}
-{formatCalendarDate(revision.formData.rateDateEnd)}
</p>
<p>
Certification date:&nbsp;
{formatCalendarDate(
revision.formData.rateDateCertified
)}
</p>
</div>
</>
),
}
})

const onFocus: AriaOnFocus<LinkRateOptionType> = ({
focused,
Expand Down Expand Up @@ -143,39 +143,37 @@ export const LinkRateSelect = ({
const selectedRates = values.rateForms.map((rate) => rate.id && rate.id)

return (
<>
<Select
defaultMenuIsOpen
value={defaultValue}
className={styles.rateMultiSelect}
options={
error || loading
? undefined
: rateNames.filter(
(rate) => !selectedRates.includes(rate.value)
)
}
isSearchable
maxMenuHeight={400}
aria-label="linked rates (required)"
ariaLiveMessages={{
onFocus,
}}
isClearable
noOptionsMessage={() => noOptionsMessage()}
classNamePrefix="select"
id={`${name}-linkRateSelect`}
inputId=""
placeholder={
loading ? 'Loading rate certifications...' : 'Select...'
}
loadingMessage={() => 'Loading rate certifications...'}
name={name}
filterOption={filterOptions}
{...selectProps}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onChange={onInputChange as any} // TODO see why the types definitions are messed up for react-select "single" (not multi) onChange - may need to upgrade dep if this bug was fixed
/>
</>
<Select
defaultMenuIsOpen
value={defaultValue}
className={styles.rateMultiSelect}
options={
error || loading
? undefined
: rateNames.filter(
(rate) => !selectedRates.includes(rate.value)
)
}
isSearchable
maxMenuHeight={400}
aria-label="linked rates (required)"
ariaLiveMessages={{
onFocus,
}}
isClearable
noOptionsMessage={() => noOptionsMessage()}
classNamePrefix="select"
id={`${name}-linkRateSelect`}
inputId=""
placeholder={
loading ? 'Loading rate certifications...' : 'Select...'
}
loadingMessage={() => 'Loading rate certifications...'}
name={name}
filterOption={filterOptions}
{...selectProps}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onChange={onInputChange as any} // TODO see why the types definitions are messed up for react-select "single" (not multi) onChange - may need to upgrade dep if this bug was fixed
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const LinkedRateSummary = ({
id="submissionDate"
label="Submission date"
children={formatCalendarDate(
rateForm.rateDateCertified
rateForm.initiallySubmittedAt
)}
/>

Expand Down
Loading

0 comments on commit c06cb7e

Please sign in to comment.