Skip to content

Commit

Permalink
Forbid uploads in pno forms when in read-only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Sep 18, 2024
1 parent 481039f commit 5a4c3f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function Form({ detail, initialFormValues }: FormProps) {

<UploadFiles
isManualPriorNotification={false}
isReadOnly={isReadOnly}
operationDate={detail.operationDate}
reportId={detail.reportId}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ export function Content({ detail, isValidatingOnChange, onClose, onSubmit, onVer
<>
<hr style={{ marginBottom: 24 }} />

<UploadFiles isManualPriorNotification operationDate={detail.operationDate} reportId={detail.reportId} />
<UploadFiles
isManualPriorNotification
isReadOnly={isReadOnly}
operationDate={detail.operationDate}
reportId={detail.reportId}
/>
</>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import type { FileType } from 'rsuite/esm/Uploader'

type UploadFilesProps = Readonly<{
isManualPriorNotification: boolean
isReadOnly: boolean
operationDate: string
reportId: string
}>
export function UploadFiles({ isManualPriorNotification, operationDate, reportId }: UploadFilesProps) {
export function UploadFiles({ isManualPriorNotification, isReadOnly, operationDate, reportId }: UploadFilesProps) {
const dispatch = useMainAppDispatch()
const headers = useAuthRequestHeaders()

Expand Down Expand Up @@ -89,8 +90,13 @@ export function UploadFiles({ isManualPriorNotification, operationDate, reportId
onPreview={download}
onRemove={remove}
onSuccess={refetch}
readOnly={isReadOnly}
>
<File>Glissez ou déposez des fichier à ajouter au préavis.</File>
<File>
{isReadOnly
? `Ce préavis est en lecture seule, vous ne pouvez pas y déposer de fichier pour l'instant.`
: `Glissez ou déposez des fichier à ajouter au préavis.`}
</File>
</Uploader>
</Wrapper>
)
Expand Down

0 comments on commit 5a4c3f1

Please sign in to comment.