Skip to content

Commit

Permalink
Merge pull request #37810 from dukenv0307/fix/25134
Browse files Browse the repository at this point in the history
[TS migration] Migrate 'AttachmentPicker' component to TypeScript
  • Loading branch information
tgolen authored Mar 26, 2024
2 parents e0d66e8 + 640283e commit 4d59304
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 171 deletions.
12 changes: 6 additions & 6 deletions src/components/AttachmentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ type AttachmentModalOnyxProps = {
};

type ImagePickerResponse = {
height: number;
height?: number;
name: string;
size: number;
size?: number | null;
type: string;
uri: string;
width: number;
width?: number;
};

type FileObject = Partial<File | ImagePickerResponse>;
Expand Down Expand Up @@ -284,14 +284,14 @@ function AttachmentModal({
}, [transaction, report]);

const isValidFile = useCallback((fileObject: FileObject) => {
if (fileObject.size !== undefined && fileObject.size > CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE) {
if (fileObject.size && fileObject.size > CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE) {
setIsAttachmentInvalid(true);
setAttachmentInvalidReasonTitle('attachmentPicker.attachmentTooLarge');
setAttachmentInvalidReason('attachmentPicker.sizeExceeded');
return false;
}

if (fileObject.size !== undefined && fileObject.size < CONST.API_ATTACHMENT_VALIDATIONS.MIN_SIZE) {
if (fileObject.size && fileObject.size < CONST.API_ATTACHMENT_VALIDATIONS.MIN_SIZE) {
setIsAttachmentInvalid(true);
setAttachmentInvalidReasonTitle('attachmentPicker.attachmentTooSmall');
setAttachmentInvalidReason('attachmentPicker.sizeNotMet');
Expand Down Expand Up @@ -627,4 +627,4 @@ export default withOnyx<AttachmentModalProps, AttachmentModalOnyxProps>({
},
})(memo(AttachmentModal));

export type {FileObject};
export type {Attachment, FileObject, ImagePickerResponse};
33 changes: 0 additions & 33 deletions src/components/AttachmentPicker/attachmentPickerPropTypes.js

This file was deleted.

Loading

0 comments on commit 4d59304

Please sign in to comment.