Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS migration] Migrate 'IOUEditRequestReceipt' page to TypeScript #36314

Merged
merged 71 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
91f94c7
Migrate to Typescript
eucool Feb 12, 2024
9a291eb
Put Request types
eucool Feb 12, 2024
5bcb3e3
Update types
eucool Feb 12, 2024
eb8dd5f
blank commit for HOC
eucool Feb 12, 2024
bbacf1c
fix lint
eucool Feb 12, 2024
d632eb8
Add typescript exception for AttachmentPicker
eucool Feb 13, 2024
2ddae0c
Resolve merge conflict
eucool Feb 13, 2024
63e86cb
Migrate to typescript
eucool Feb 13, 2024
7273c5b
Update types
eucool Feb 14, 2024
1725caa
Push deleted file
eucool Feb 14, 2024
8960d8f
Migrate to typescript
eucool Feb 14, 2024
243afc8
revert deleted file
eucool Feb 14, 2024
1bb8fc2
remove conflict
eucool Feb 14, 2024
33363ca
remove conflict
eucool Feb 14, 2024
3c6c657
Merge branch 'main' into issueScan
eucool Feb 14, 2024
4384ed3
Fix lint
eucool Feb 15, 2024
cdaec4b
Fix lint
eucool Feb 15, 2024
a056120
Fix Route type
eucool Feb 15, 2024
c3e70d3
Fix Route type
eucool Feb 15, 2024
a97accd
Fix implicit types
eucool Feb 15, 2024
95dc977
remove torch error
eucool Feb 23, 2024
73d8372
Add camera permission module
eucool Feb 25, 2024
e782d0d
Apply suggestions from code review
eucool Feb 28, 2024
a0a3063
Apply suggestions from code review
eucool Feb 28, 2024
01ae45e
merge conflict resolve
eucool Feb 28, 2024
2f6ebf1
Update index.native.tsx
eucool Feb 28, 2024
f9c443a
Merge branch 'main' into issueScan
eucool Feb 28, 2024
e0eeabd
Update index.native.tsx
eucool Mar 3, 2024
7259339
Remove merge conflict
eucool Mar 4, 2024
896f75f
Merge branch 'main' into issueScan
eucool Mar 4, 2024
767c945
Merge branch 'Expensify:main' into issueScan
eucool Mar 9, 2024
778f35d
Merge branch 'Expensify:main' into issueScan
eucool Mar 10, 2024
8ccd9cc
migrate to typescript
eucool Mar 10, 2024
f2d59d0
Merge branch 'Expensify:main' into issueScan
eucool Mar 14, 2024
a5d527a
Migrate to typescript
eucool Mar 14, 2024
ef4685a
run prettier
eucool Mar 14, 2024
29eac3d
migrate to typescript
eucool Mar 14, 2024
3a7b4c1
Merge into main
eucool Mar 20, 2024
d6209ba
Merge branch 'main' into issueScan
eucool Mar 20, 2024
d0abff5
Undo EditRequestReceiptPage
eucool Mar 24, 2024
92e3bb5
Fix pretteir
eucool Mar 24, 2024
9addf33
Merge branch 'Expensify:main' into issueScan
eucool Mar 24, 2024
dcab8c7
migrate to typescript
eucool Mar 24, 2024
b40f90a
migrate to typescript
eucool Mar 24, 2024
b80eeb9
Resolve merge conflict
eucool Mar 31, 2024
f072419
Fix type errors after merge conflict
eucool Mar 31, 2024
61588d5
Resolve type errors
eucool Mar 31, 2024
2de7096
Resolve type errors
eucool Mar 31, 2024
f85a3a9
Fix nullish operator type error
eucool Mar 31, 2024
331db8f
Fix lint
eucool Mar 31, 2024
7ddf954
Resolve Merge Conflict
eucool Apr 1, 2024
ebb1972
Fix camera Issue
eucool Apr 1, 2024
9a8fb99
Fix camera Issue
eucool Apr 1, 2024
9094b82
Fix camera Issue
eucool Apr 1, 2024
c54527f
Fix camera Issue
eucool Apr 1, 2024
020e899
Fix camera Issue
eucool Apr 1, 2024
7530ded
Fix camera Issue
eucool Apr 1, 2024
2366548
Fix camera Issue
eucool Apr 1, 2024
59fdb7d
Fix device error
eucool Apr 1, 2024
38895a3
Resolve merge conflict
eucool Apr 5, 2024
d2c004a
fix lint
eucool Apr 5, 2024
60cd81b
Merge branch 'Expensify:main' into issueScan
eucool Apr 5, 2024
97ba43e
Merge branch 'Expensify:main' into issueScan
eucool Apr 5, 2024
75a160d
Fix HOC errors
eucool Apr 5, 2024
6eb8473
fix prettier
eucool Apr 5, 2024
08cd715
Merge branch 'main' into issueScan
eucool Apr 8, 2024
852a4c2
Fix onyx report
eucool Apr 8, 2024
35c05cf
Merge branch 'Expensify:main' into issueScan
eucool Apr 9, 2024
0eca33c
Fix on suggestions
eucool Apr 9, 2024
a671cfe
Fix not found
eucool Apr 9, 2024
4c53b63
Resolve merge conflicts
eucool Apr 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ type MoneyRequestNavigatorParamList = {
iouType: string;
reportID: string;
};
[SCREENS.MONEY_REQUEST.STEP_SCAN]: {
action: ValueOf<typeof CONST.IOU.ACTION>;
iouType: ValueOf<typeof CONST.IOU.TYPE>;
transactionID: string;
reportID: string;
pageIndex: number;
backTo: Routes;
};
};

type NewTaskNavigatorParamList = {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/fileDownload/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type GetImageResolution = (url: File | Asset) => Promise<ImageResolution>;
type ExtensionAndFileName = {fileName: string; fileExtension: string};
type SplitExtensionFromFileName = (fileName: string) => ExtensionAndFileName;

type ReadFileAsync = (path: string, fileName: string, onSuccess: (file: File) => void, onFailure: (error?: unknown) => void, fileType?: string) => Promise<File | void>;
type ReadFileAsync = (path: string, fileName: string, onSuccess: (file: File) => void, onFailure?: (error?: unknown) => void, fileType?: string) => Promise<File | void>;

type AttachmentDetails = {
previewSourceURL: null | string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import ReceiptUpload from '@assets/images/receipt-upload.svg';
Expand All @@ -9,25 +8,20 @@ import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';

const propTypes = {
/** Callback to execute when a file is dropped. */
onDrop: PropTypes.func.isRequired,
type ReceiptDropUIProps = {
/** Function to execute when an item is dropped in the drop zone. */
onDrop: (event: DragEvent) => void;

/** Pixels the receipt image should be shifted down to match the non-drag view UI */
receiptImageTopPosition: PropTypes.number,
receiptImageTopPosition?: number;
};
MonilBhavsar marked this conversation as resolved.
Show resolved Hide resolved

const defaultProps = {
receiptImageTopPosition: 0,
};

function ReceiptDropUI({onDrop, receiptImageTopPosition}) {
function ReceiptDropUI({onDrop, receiptImageTopPosition}: ReceiptDropUIProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
return (
<DragAndDropConsumer onDrop={onDrop}>
<View style={[styles.receiptDropOverlay, styles.w100, styles.h100, styles.justifyContentCenter, styles.alignItemsCenter]}>
<View style={styles.receiptImageWrapper(receiptImageTopPosition)}>
<View style={styles.receiptImageWrapper(receiptImageTopPosition ?? 0)}>
<ImageSVG
MonilBhavsar marked this conversation as resolved.
Show resolved Hide resolved
src={ReceiptUpload}
contentFit="contain"
Expand All @@ -43,7 +37,5 @@ function ReceiptDropUI({onDrop, receiptImageTopPosition}) {
}

ReceiptDropUI.displayName = 'ReceiptDropUI';
ReceiptDropUI.propTypes = propTypes;
ReceiptDropUI.defaultProps = defaultProps;

export default ReceiptDropUI;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {check, PERMISSIONS, request} from 'react-native-permissions';
import type CameraPermissionModule from './types';

function requestCameraPermission() {
return request(PERMISSIONS.ANDROID.CAMERA);
Expand All @@ -9,4 +10,9 @@ function getCameraPermissionStatus() {
return check(PERMISSIONS.ANDROID.CAMERA);
}

export {requestCameraPermission, getCameraPermissionStatus};
const CameraPermission: CameraPermissionModule = {
requestCameraPermission,
getCameraPermissionStatus,
};

export default CameraPermission;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {check, PERMISSIONS, request} from 'react-native-permissions';
import type CameraPermissionModule from './types';

function requestCameraPermission() {
return request(PERMISSIONS.IOS.CAMERA);
Expand All @@ -8,4 +9,9 @@ function getCameraPermissionStatus() {
return check(PERMISSIONS.IOS.CAMERA);
}

export {requestCameraPermission, getCameraPermissionStatus};
const CameraPermission: CameraPermissionModule = {
requestCameraPermission,
getCameraPermissionStatus,
};

export default CameraPermission;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type CameraPermissionModule from './types';

const CameraPermission: CameraPermissionModule = {
requestCameraPermission: undefined,
getCameraPermissionStatus: undefined,
};

export default CameraPermission;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type CameraPermissionModule = {
requestCameraPermission: (() => Promise<string>) | undefined;
getCameraPermissionStatus: (() => Promise<string>) | undefined;
};

export default CameraPermissionModule;
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import PropTypes from 'prop-types';
import React from 'react';
import type {ForwardedRef} from 'react';
import {Camera} from 'react-native-vision-camera';
import useTabNavigatorFocus from '@hooks/useTabNavigatorFocus';

const propTypes = {
/* The index of the tab that contains this camera */
cameraTabIndex: PropTypes.number.isRequired,
};
import type {NavigationAwareCameraNativeProps} from './types';

// Wraps a camera that will only be active when the tab is focused or as soon as it starts to become focused.
const NavigationAwareCamera = React.forwardRef(({cameraTabIndex, ...props}, ref) => {
function NavigationAwareCamera({cameraTabIndex, ...props}: NavigationAwareCameraNativeProps, ref: ForwardedRef<Camera>) {
const isCameraActive = useTabNavigatorFocus({tabIndex: cameraTabIndex});

return (
Expand All @@ -20,9 +16,8 @@ const NavigationAwareCamera = React.forwardRef(({cameraTabIndex, ...props}, ref)
isActive={isCameraActive}
/>
);
});
}

NavigationAwareCamera.propTypes = propTypes;
NavigationAwareCamera.displayName = 'NavigationAwareCamera';

export default NavigationAwareCamera;
export default React.forwardRef(NavigationAwareCamera);
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import PropTypes from 'prop-types';
import React from 'react';
import type {ForwardedRef} from 'react';
import {View} from 'react-native';
import type {Camera} from 'react-native-vision-camera';
import Webcam from 'react-webcam';
import useTabNavigatorFocus from '@hooks/useTabNavigatorFocus';

const propTypes = {
/** The index of the tab that contains this camera */
cameraTabIndex: PropTypes.number.isRequired,
};
import type {NavigationAwareCameraProps} from './types';

// Wraps a camera that will only be active when the tab is focused or as soon as it starts to become focused.
const NavigationAwareCamera = React.forwardRef(({cameraTabIndex, ...props}, ref) => {
function NavigationAwareCamera({torchOn, onTorchAvailability, cameraTabIndex, ...props}: NavigationAwareCameraProps, ref: ForwardedRef<Webcam | Camera>) {
const shouldShowCamera = useTabNavigatorFocus({
tabIndex: cameraTabIndex,
});
Expand All @@ -21,17 +18,14 @@ const NavigationAwareCamera = React.forwardRef(({cameraTabIndex, ...props}, ref)
return (
<View>
<Webcam
audio={false}
screenshotFormat="image/png"
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
ref={ref}
ref={ref as unknown as ForwardedRef<Webcam>}
/>
</View>
);
});
}

NavigationAwareCamera.propTypes = propTypes;
NavigationAwareCamera.displayName = 'NavigationAwareCamera';

eucool marked this conversation as resolved.
Show resolved Hide resolved
export default NavigationAwareCamera;
export default React.forwardRef(NavigationAwareCamera);
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type {CameraProps} from 'react-native-vision-camera';
import type {WebcamProps} from 'react-webcam';

type NavigationAwareCameraProps = WebcamProps & {
/** Flag to turn on/off the torch/flashlight - if available */
torchOn?: boolean;

/** The index of the tab that contains this camera */
onTorchAvailability?: (torchAvailable: boolean) => void;

/** Callback function when media stream becomes available - user granted camera permissions and camera starts to work */
cameraTabIndex: number;
};

type NavigationAwareCameraNativeProps = CameraProps & {
cameraTabIndex: number;
};

export type {NavigationAwareCameraProps, NavigationAwareCameraNativeProps};
Loading
Loading