Skip to content

Commit

Permalink
fix: update allowing file type condition for signature (#7601)
Browse files Browse the repository at this point in the history
* fix: update allowing file type condition for signature

* chore: update allowedFileFormat prop type for signature
  • Loading branch information
Nil20 authored Sep 12, 2024
1 parent c38d100 commit 36f0128
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function SignatureUploader({
onChange,
modalTitle,
maxSizeMb = 2,
allowedFileFormats = ['png'],
allowedFileFormats = ['image/png'],
...props
}: SignatureUploaderProps) {
const [signatureDialogOpen, setSignatureDialogOpen] = useState(false)
Expand Down Expand Up @@ -117,13 +117,16 @@ export function SignatureUploader({
return
}
if (
!allowedFileFormats.includes(
file.type as (typeof allowedFileFormats)[0]
!allowedFileFormats.some((format) =>
file.type.includes(format)
)
) {
const formattedFileTypesOfSignatures = allowedFileFormats.map(
(val) => val.split('/')[1]
)
setSignatureError(
intl.formatMessage(formMessages.fileUploadError, {
type: allowedFileFormats.join(', ')
type: formattedFileTypesOfSignatures.join(', ')
})
)
return
Expand Down
14 changes: 12 additions & 2 deletions packages/client/src/forms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,12 @@ export interface INidVerificationButton extends IFormFieldBase {
export interface ISignatureFormField extends IFormFieldBase {
type: typeof SIGNATURE
maxSizeMb?: number
allowedFileFormats?: ('png' | 'jpg' | 'jpeg' | 'svg')[]
allowedFileFormats?: (
| 'image/png'
| 'image/jpg'
| 'image/jpeg'
| 'image/svg'
)[]
}

export type IFormField =
Expand Down Expand Up @@ -1209,7 +1214,12 @@ export interface Ii18nTimeFormField extends Ii18nFormFieldBase {
export interface Ii18nSignatureField extends Ii18nFormFieldBase {
type: typeof SIGNATURE
maxSizeMb?: number
allowedFileFormats?: ('png' | 'jpg' | 'jpeg' | 'svg')[]
allowedFileFormats?: (
| 'image/png'
| 'image/jpg'
| 'image/jpeg'
| 'image/svg'
)[]
}

export type Ii18nFormField =
Expand Down

0 comments on commit 36f0128

Please sign in to comment.