-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #480 from osu-wams/dd1318-covidz
Dd1318 covidz
- Loading branch information
Showing
12 changed files
with
214 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React, { FC, useContext } from 'react'; | ||
import { Loading } from 'src/ui/Loading'; | ||
import styled, { ThemeContext } from 'styled-components/macro'; | ||
import { | ||
faCheckCircle, | ||
faExclamationCircle, | ||
faNotesMedical, | ||
} from '@fortawesome/pro-light-svg-icons'; | ||
import { Card, CardHeader, CardContent, CardIcon } from 'src/ui/Card'; | ||
import { fontSize, spacing } from '@osu-wams/theme'; | ||
import { useMedical } from '@osu-wams/hooks'; | ||
import { ExternalLink } from 'src/ui/Link'; | ||
import { Url } from '@osu-wams/utils'; | ||
import { Event } from 'src/util/gaTracking'; | ||
import { Types } from '@osu-wams/lib'; | ||
import Icon from 'src/ui/Icon'; | ||
|
||
const VaccinationContent = styled.div({ | ||
flex: 1, | ||
flexDirection: 'row', | ||
display: 'flex', | ||
paddingBottom: spacing.default, | ||
paddingLeft: spacing.default, | ||
}); | ||
|
||
const VaccinationContentBody = styled.div(({ theme }) => ({ | ||
color: theme.features.covidVaccination.content.color, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
fontSize: fontSize['14'], | ||
paddingLeft: spacing.large, | ||
paddingRight: spacing.xl, | ||
paddingTop: spacing.small, | ||
})); | ||
|
||
const hasCovidVaccination = (medical: Types.Medical[]) => { | ||
return medical.some((m: Types.Medical) => m.code === 'COVIDVACC'); | ||
}; | ||
|
||
const CovidCompliance: FC = () => { | ||
const theme = useContext(ThemeContext); | ||
const { data, isSuccess, isLoading } = useMedical(); | ||
return ( | ||
<Card collapsing={false}> | ||
<CardHeader title="Covid Vaccination" badge={<CardIcon icon={faNotesMedical} />} /> | ||
<CardContent> | ||
{isLoading && <Loading lines={5} />} | ||
{isSuccess && data && hasCovidVaccination(data) ? ( | ||
<VaccinationContent> | ||
<Icon | ||
icon={faCheckCircle} | ||
color={theme.features.covidVaccination.icon.compliantColor} | ||
size={'4x'} | ||
/> | ||
<VaccinationContentBody> | ||
You are in compliance with the university covid vaccination policy. | ||
</VaccinationContentBody> | ||
</VaccinationContent> | ||
) : ( | ||
<VaccinationContent> | ||
<Icon | ||
icon={faExclamationCircle} | ||
color={theme.features.covidVaccination.icon.nonCompliantColor} | ||
size={'4x'} | ||
/> | ||
<VaccinationContentBody> | ||
<b> | ||
You are not in compliance with the university covid vaccination policy. Please take | ||
one of the following actions: | ||
</b> | ||
<ExternalLink | ||
href={Url.covidCompliance.getVaccinated} | ||
onClick={() => Event('covid-compliance', `Clicked get vaccinated`)} | ||
> | ||
• Get the vaccination | ||
</ExternalLink> | ||
<ExternalLink | ||
href={Url.covidCompliance.register} | ||
onClick={() => Event('covid-compliance', `Clicked register my vaccine`)} | ||
> | ||
• Enter your vaccine information | ||
</ExternalLink> | ||
<ExternalLink | ||
href={Url.covidCompliance.decline} | ||
onClick={() => Event('covid-compliance', `Clicked declination form`)} | ||
> | ||
• Complete the declination form | ||
</ExternalLink> | ||
</VaccinationContentBody> | ||
</VaccinationContent> | ||
)} | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default CovidCompliance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react'; | ||
import { renderWithAllContexts as render } from 'src/util/test-utils'; | ||
import { screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { Person } from '@osu-wams/hooks'; | ||
import CovidCompliance from '../CovidCompliance'; | ||
import { mockGAEvent } from 'src/setupTests'; | ||
|
||
const mockMedical = Person.Medical.mockMedical; | ||
const mockUseMedical = jest.fn(); | ||
|
||
jest.mock('@osu-wams/hooks', () => { | ||
return { | ||
...jest.requireActual('@osu-wams/hooks'), | ||
useMedical: () => mockUseMedical(), | ||
}; | ||
}); | ||
|
||
describe('<CovidCompliance />', () => { | ||
beforeEach(() => { | ||
mockUseMedical.mockReturnValue(mockMedical); | ||
}); | ||
|
||
it('should have title: "Covid Vaccination"', () => { | ||
render(<CovidCompliance />); | ||
|
||
expect(screen.getByText(/covid vaccination/i, { selector: 'h2 > span' })).toBeInTheDocument(); | ||
}); | ||
|
||
it('should have a positive vaccination message', () => { | ||
render(<CovidCompliance />); | ||
|
||
expect(screen.getByText(/you are in compliance/i)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should find links to become compliant', async () => { | ||
mockUseMedical.mockReturnValue({ ...mockMedical, data: [] }); | ||
render(<CovidCompliance />); | ||
const getVaccinated = screen.getByText(/get the vaccination/i); | ||
const register = screen.getByText(/enter your vaccine information/i); | ||
const decline = screen.getByText(/complete the declination form/i); | ||
userEvent.click(getVaccinated); | ||
expect(mockGAEvent).toHaveBeenCalledTimes(1); | ||
userEvent.click(register); | ||
expect(mockGAEvent).toHaveBeenCalledTimes(2); | ||
userEvent.click(decline); | ||
expect(mockGAEvent).toHaveBeenCalledTimes(3); | ||
}); | ||
|
||
it('should show a negative vaccination message', async () => { | ||
mockUseMedical.mockReturnValue({ ...mockMedical, data: [] }); | ||
render(<CovidCompliance />); | ||
|
||
expect(screen.getByText(/you are not in compliance/i)).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.