-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/8942-ClaimFilesSegment (#9066)
Co-authored-by: Jon Bindbeutel <[email protected]>
- Loading branch information
1 parent
66169fe
commit 681d9c9
Showing
8 changed files
with
153 additions
and
26 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
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
30 changes: 30 additions & 0 deletions
30
...src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimFiles/ClaimFiles.test.tsx
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,30 @@ | ||
import React from 'react' | ||
|
||
import { screen } from '@testing-library/react-native' | ||
|
||
import { ClaimData } from 'api/types' | ||
import { context, render } from 'testUtils' | ||
|
||
import { claim as claimData } from '../../claimData' | ||
import ClaimFiles from './ClaimFiles' | ||
|
||
jest.mock('utils/remoteConfig') | ||
|
||
context('ClaimDetailsScreen', () => { | ||
const renderWithData = (claim: ClaimData): void => { | ||
render(<ClaimFiles claim={claim} />) | ||
} | ||
|
||
describe('When there are files to display', () => { | ||
it('it should render correctly', async () => { | ||
renderWithData(claimData) | ||
expect(screen.getAllByText('filter-sketch.pdf')).toBeTruthy() | ||
expect(screen.getAllByText('Request type: other_documents_list')).toBeTruthy() | ||
expect(screen.getAllByText('Received: July 16, 2020')).toBeTruthy() | ||
|
||
expect(screen.getByText('Mark_Webb_600156928_526.pdf')).toBeTruthy() | ||
expect(screen.getByText('Document type: L533')).toBeTruthy() | ||
expect(screen.getByText('Received: June 06, 2019')).toBeTruthy() | ||
}) | ||
}) | ||
}) |
81 changes: 81 additions & 0 deletions
81
...bile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimFiles/ClaimFiles.tsx
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,81 @@ | ||
import React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { useIsFocused } from '@react-navigation/native' | ||
|
||
import _ from 'underscore' | ||
|
||
import { ClaimData } from 'api/types' | ||
import { Box, DefaultList, DefaultListItemObj, TextLine, TextView } from 'components' | ||
import { NAMESPACE } from 'constants/namespaces' | ||
import { formatDateMMMMDDYYYY } from 'utils/formattingUtils' | ||
import { useTheme } from 'utils/hooks' | ||
|
||
type ClaimFilesProps = { | ||
claim: ClaimData | ||
} | ||
|
||
function ClaimFiles({ claim }: ClaimFilesProps) { | ||
const { t } = useTranslation(NAMESPACE.COMMON) | ||
const theme = useTheme() | ||
const isFocused = useIsFocused() | ||
const { attributes } = claim | ||
const events = attributes.eventsTimeline.filter( | ||
(event) => (event.filename && event.filename.length > 0) || (event.documents && event.documents.length > 0), | ||
) | ||
const files = (): Array<DefaultListItemObj> => { | ||
const items: Array<DefaultListItemObj> = [] | ||
|
||
_.forEach(events, (event) => { | ||
if (event.filename) { | ||
const textLines: TextLine[] = [{ text: event.filename, variant: 'MobileBodyBold' }] | ||
if (event.type) { | ||
textLines.push({ text: t('appointmentList.requestType', { type: event.type }) }) | ||
} | ||
if (event.documentType) { | ||
textLines.push({ text: t('appointmentList.documentType', { type: event.documentType }) }) | ||
} | ||
if (event.uploadDate) { | ||
textLines.push({ text: t('appointmentList.received', { date: formatDateMMMMDDYYYY(event.uploadDate) }) }) | ||
} | ||
items.push({ textLines: textLines }) | ||
} else { | ||
_.forEach(event.documents || [], (document) => { | ||
if (document.filename) { | ||
const textLines: TextLine[] = [{ text: document.filename, variant: 'MobileBodyBold' }] | ||
if (document.fileType) { | ||
textLines.push({ text: t('appointmentList.requestType', { type: document.fileType }) }) | ||
} | ||
if (document.documentType) { | ||
textLines.push({ text: t('appointmentList.documentType', { type: document.documentType }) }) | ||
} | ||
if (document.uploadDate) { | ||
textLines.push({ | ||
text: t('appointmentList.received', { date: formatDateMMMMDDYYYY(document.uploadDate) }), | ||
}) | ||
} | ||
items.push({ textLines: textLines }) | ||
} | ||
}) | ||
} | ||
}) | ||
return items | ||
} | ||
const filesList = files() | ||
if (isFocused && filesList.length > 0) { | ||
return ( | ||
<Box> | ||
<DefaultList items={files()} /> | ||
</Box> | ||
) | ||
} | ||
return ( | ||
<Box mx={theme.dimensions.gutter} my={theme.dimensions.fullScreenContentButtonHeight}> | ||
<TextView variant="MobileBodyBold" textAlign="center" accessibilityRole="header"> | ||
{t('claimDetails.noFiles')} | ||
</TextView> | ||
</Box> | ||
) | ||
} | ||
|
||
export default ClaimFiles |
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