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

Design review: Redundant Rates display cleanup #2670

Merged
merged 10 commits into from
Aug 27, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ const naturalSort = (a: string, b: string): number => {
return a.localeCompare(b, 'en', { numeric: true })
}

const formatProgramNamesForDisplay = (statePrograms: ProgramArgType[],
rateProgramIDs: string[]): string[] => programNames(statePrograms, rateProgramIDs)
.sort(naturalSort)
.map((n) =>
n
.replace(/\s/g, '-')
.replace(/[^a-zA-Z0-9+]/g, '')
.toUpperCase()
)

const generateRateCertificationName = (
rateFormData: RateFormEditableType,
stateCode: string,
Expand Down Expand Up @@ -35,15 +45,7 @@ const generateRateCertificationName = (
const certifiedDate = rateDateCertified
? `-${formatRateNameDate(rateDateCertified)}`
: ''
const pNames = programNames(statePrograms, rateProgramIDs)
.sort(naturalSort)
.map((n) =>
n
.replace(/\s/g, '-')
.replace(/[^a-zA-Z0-9+]/g, '')
.toUpperCase()
)
.join('-')
const pNames = formatProgramNamesForDisplay(statePrograms, rateProgramIDs).join('-')

let rateName = `MCR-${stateCode.toUpperCase()}`

Expand Down Expand Up @@ -71,4 +73,4 @@ const generateRateCertificationName = (
return rateName
}

export { generateRateCertificationName }
export { generateRateCertificationName, formatProgramNamesForDisplay }
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use '../../styles/custom.scss' as custom;
@use '../../styles/uswdsImports.scss' as uswds;

.formPage {
flex: 1 0 auto;
display: flex;
flex-direction: column;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GridContainer } from '@trussworks/react-uswds'
import styles from './StateSubmissionForm.module.scss'
import styles from './FormContainer.module.scss'

type FormContainerProps = {
id: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export const LinkRateSelect = ({

const rateNames: LinkRateOptionType[] = rates.map((rate) => {
const revision = rate.revisions[0]
const rateProgramIDs = revision.formData.rateProgramIDs.length > 0 ? revision.formData.rateProgramIDs: revision.formData.deprecatedRateProgramIDs

return {
value: rate.id,
label:
Expand All @@ -80,7 +82,7 @@ export const LinkRateSelect = ({
'Unknown rate certification',
rateProgramIDs: programNames(
rate.state.programs,
revision.formData.rateProgramIDs
rateProgramIDs,
).join(', '),
rateDateStart: formatCalendarDate(revision.formData.rateDateStart),
rateDateEnd: formatCalendarDate(revision.formData.rateDateEnd),
Expand Down
43 changes: 9 additions & 34 deletions services/app-web/src/pages/ReplaceRate/ReplaceRate.module.scss
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
@use '../../styles/custom.scss' as custom;
@use '../../styles/uswdsImports.scss' as uswds;

.background{
width: 100%;
flex: 1 0 auto;
display: flex;
flex-direction: column;
background-color: none;
align-items: center
}
.gridContainer{
@include custom.default-page-container;
max-width: custom.$mcr-container-standard-width-fixed;
flex-direction: column;
margin: 2rem;
padding: 1rem;
}

.formContainer {
border: 0;
margin-top: 2rem;
margin-bottom: 2rem;
background: custom.$mcr-foundation-white;
max-width: custom.$mcr-container-standard-width-fixed;
> [class^='usa-fieldset'] {
padding: uswds.units(4);
margin-bottom: uswds.units(2);
margin-top: uswds.units(2);
background: custom.$mcr-foundation-white;
border: 1px solid custom.$mcr-gray-lighter;
@include uswds.u-radius('md');
}
padding: 2rem;

h2 {
margin-top: 0;
Expand All @@ -35,15 +16,9 @@
> div[class^='usa-form-group']:not(:first-of-type) {
margin-top: 2.5rem;
}

&[class^='usa-form'] {
min-width: 100%;
max-width: 100%;

@include uswds.at-media(tablet) {
min-width: 40rem;
max-width: 20rem;
margin: 0 auto;
}
>fieldset{
border: 0;
margin: 0;
padding:0
}
}
21 changes: 11 additions & 10 deletions services/app-web/src/pages/ReplaceRate/ReplaceRate.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
ButtonGroup,
FormGroup,
GridContainer,
Label,
} from '@trussworks/react-uswds'
import React, { useEffect } from 'react'
Expand Down Expand Up @@ -35,6 +34,8 @@ import {
ErrorSummaryProps,
ErrorSummary,
} from '../../components/Form/ErrorSummary/ErrorSummary'
import { FormContainer } from '../../components/FormContainer/FormContainer'
import { LinkedRateSummary } from '../StateSubmission/RateDetails/LinkedRateSummary'

export interface ReplaceRateFormValues {
replacementRateID: string
Expand Down Expand Up @@ -155,8 +156,7 @@ export const ReplaceRate = (): React.ReactElement => {
}

return (
<div className={styles.background}>
<GridContainer className={styles.gridContainer}>
<FormContainer id="ReplaceRate">
{replaceError && <GenericApiErrorBanner />}
<Formik
initialValues={formInitialValues}
Expand All @@ -165,7 +165,6 @@ export const ReplaceRate = (): React.ReactElement => {
>
{({ errors, values, handleSubmit }) => (
<UswdsForm
className={styles.formContainer}
id="ReplaceRateForm"
aria-label={'Withdraw and replace rate on contract'}
aria-describedby="form-guidance"
Expand All @@ -181,14 +180,14 @@ export const ReplaceRate = (): React.ReactElement => {
headingRef={errorSummaryHeadingRef}
/>
)}

<div className={styles.formContainer}>
<h2>Replace a rate review</h2>

<DataDetail id="withdrawnRate" label="Current rate">
{withdrawnRateRevisionName}
</DataDetail>

<fieldset className="usa-fieldset">
<fieldset>
<legend className="srOnly">
Withdraw and replace rate on contract
</legend>
Expand Down Expand Up @@ -252,7 +251,9 @@ export const ReplaceRate = (): React.ReactElement => {
/>
</FormGroup>
</fieldset>
<PageActionsContainer>
</div>

<PageActionsContainer>
<ButtonGroup type="default">
<ActionButton
type="button"
Expand Down Expand Up @@ -280,11 +281,11 @@ export const ReplaceRate = (): React.ReactElement => {
</ActionButton>
</ButtonGroup>
</PageActionsContainer>
</UswdsForm>
</UswdsForm>
)}

</Formik>
</GridContainer>
</div>
</FormContainer>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
DynamicStepIndicator,
SectionCard,
} from '../../../components'
import { FormContainer } from '../FormContainer'
import { FormContainer } from '../../../components/FormContainer/FormContainer'
import {
useCurrentRoute,
useHealthPlanPackageForm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import {
StatutoryRegulatoryAttestationDescription,
StatutoryRegulatoryAttestationQuestion,
} from '../../../constants/statutoryRegulatoryAttestation'
import { FormContainer } from '../FormContainer'
import { FormContainer } from '../../../components/FormContainer/FormContainer'
import {
useCurrentRoute,
useHealthPlanPackageForm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import classNames from 'classnames'
import { ErrorSummary } from '../../../components/Form'
import { activeFormPages } from '../StateSubmissionForm'
import { RoutesRecord } from '../../../constants'
import { FormContainer } from '../FormContainer'
import { FormContainer } from '../../../components/FormContainer/FormContainer'
import { useAuth } from '../../../contexts/AuthContext'
import {
useCurrentRoute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DynamicStepIndicator } from '../../../components/DynamicStepIndicator'
import { STATE_SUBMISSION_FORM_ROUTES } from '../../../constants/routes'
import stylesForm from '../StateSubmissionForm.module.scss'
import stylesSideNav from '../../SubmissionSideNav/SubmissionSideNav.module.scss'
import { FormContainer } from '../FormContainer'
import { FormContainer } from '../../../components/FormContainer/FormContainer'
import { SubmissionType } from '../SubmissionType/SubmissionType'
import { GridContainer } from '@trussworks/react-uswds'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { SubmissionType } from './SubmissionType'
import { UnlockedHealthPlanFormDataType } from '../../common-code/healthPlanFormDataType'
import { ContractFormData } from '../../gen/gqlClient'
import { RateDetails } from './RateDetails'
import styles from './StateSubmissionForm.module.scss'
import formContainerStyles from '../../components/FormContainer/FormContainer.module.scss'
import { SideNavOutletContextType } from '../SubmissionSideNav/SubmissionSideNav'

// Can move this AppRoutes on future pass - leaving it here now to make diff clear
Expand All @@ -45,7 +45,7 @@ export const StateSubmissionForm = (): React.ReactElement => {
return (
<div
data-testid="state-submission-form-page"
className={styles.formPage}
className={formContainerStyles.formPage}
>
<Routes>
<Route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
} from '../../../components/Form/FieldYesNo/FieldYesNo'
import { SubmissionTypeFormSchema } from './SubmissionTypeSchema'
import { RoutesRecord, STATE_SUBMISSION_FORM_ROUTES } from '../../../constants'
import { FormContainer } from '../FormContainer'
import { FormContainer } from '../../../components/FormContainer/FormContainer'
import { useHealthPlanPackageForm } from '../../../hooks/useHealthPlanPackageForm'
import { useCurrentRoute } from '../../../hooks'
import { ErrorOrLoadingPage } from '../ErrorOrLoadingPage'
Expand Down
Loading