Skip to content

Commit

Permalink
ensure file upload only shows required/optional contract and rate pages
Browse files Browse the repository at this point in the history
  • Loading branch information
pearl-truss committed Sep 14, 2023
1 parent 04f770e commit 678779e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
14 changes: 12 additions & 2 deletions services/app-web/src/components/FileUpload/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type FileUploadProps = {
hint?: React.ReactNode
initialItems?: FileItemT[]
isLabelVisible?: boolean
showRequiredOptionalLabel?: boolean
uploadFile: (file: File) => Promise<S3FileData>
scanFile?: (key: string) => Promise<void | Error> // optional function to be called after uploading (used for scanning)
deleteFile: (key: string) => Promise<void>
Expand Down Expand Up @@ -61,9 +62,9 @@ export const FileUpload = ({
uploadFile,
scanFile,
deleteFile,
// ariaRequired,
onFileItemsUpdate,
isContractOnly,
showRequiredOptionalLabel = false,
shouldDisplayMissingCategoriesError = false,
innerInputRef,
...inputProps
Expand Down Expand Up @@ -420,13 +421,22 @@ export const FileUpload = ({
fileItems.length
)} added `

let isRequiredLabel
if (showRequiredOptionalLabel) {
if (isRequired) {
isRequiredLabel = 'Required'
} else {
isRequiredLabel = 'Optional'
}
}

return (
<FormGroup className="margin-top-0">
<Label className={isLabelVisible ? '' : 'srOnly'} htmlFor={id}>
{label}
</Label>
<span className={styles.requiredOptionalText}>
{isRequired ? 'Required' : 'Optional'}
{isRequiredLabel}
</span>

<PoliteErrorMessage id={`${id}-error`}>{error}</PoliteErrorMessage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ export const ContractDetails = ({
label="Upload contract"
renderMode="list"
aria-required
showRequiredOptionalLabel={true}
error={documentsErrorMessage}
hint={
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export const SingleRateCert = ({
label="Upload one rate certification document"
renderMode="list"
aria-required
showRequiredOptionalLabel={true}
error={showFieldErrors('rateDocuments')}
hint={
<span className={styles.guidanceTextBlockNoPadding}>
Expand Down Expand Up @@ -222,6 +223,7 @@ export const SingleRateCert = ({
label="Upload supporting documents"
renderMode="list"
aria-required={false}
showRequiredOptionalLabel={true}
error={showFieldErrors('supportingDocuments')}
hint={
<span className={styles.guidanceTextBlockNoPadding}>
Expand Down

0 comments on commit 678779e

Please sign in to comment.