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 8 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
7 changes: 7 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ type MoneyRequestNavigatorParamList = {
iouType: string;
reportID: string;
};
[SCREENS.MONEY_REQUEST.CREATE]: {
action: ValueOf<typeof CONST.IOU.ACTION>;
iouType: ValueOf<typeof CONST.IOU.TYPE>;
transactionID: string;
reportID: string;
backTo: Route;
};
};

type NewTaskNavigatorParamList = {
Expand Down
55 changes: 0 additions & 55 deletions src/pages/EditRequestCreatedPage.js

This file was deleted.

eucool marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PropTypes from 'prop-types';
import type {StackScreenProps} from '@react-navigation/stack';
import React, {useState} from 'react';
import {View} from 'react-native';
import DragAndDropProvider from '@components/DragAndDrop/Provider';
Expand All @@ -7,23 +7,13 @@ import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import type {MoneyRequestNavigatorParamList} from '@libs/Navigation/types';
import type SCREENS from '@src/SCREENS';
import IOURequestStepScan from './iou/request/step/IOURequestStepScan';

const propTypes = {
/** React Navigation route */
route: PropTypes.shape({
/** Params from the route */
params: PropTypes.shape({
/** The type of IOU report, i.e. bill, request, send */
iouType: PropTypes.string,
type EditRequestReceiptPageProps = StackScreenProps<MoneyRequestNavigatorParamList, typeof SCREENS.MONEY_REQUEST.SCAN_TAB>;

/** The report ID of the IOU */
reportID: PropTypes.string,
}),
}).isRequired,
};

function EditRequestReceiptPage({route}) {
function EditRequestReceiptPage({route}: EditRequestReceiptPageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [isDraggingOver, setIsDraggingOver] = useState(false);
Expand All @@ -50,7 +40,6 @@ function EditRequestReceiptPage({route}) {
);
}

EditRequestReceiptPage.propTypes = propTypes;
EditRequestReceiptPage.displayName = 'EditRequestReceiptPage';

export default EditRequestReceiptPage;
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,19 +8,14 @@ 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;
};
eucool 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 (
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
@@ -0,0 +1,18 @@
import type {StackScreenProps} from '@react-navigation/stack';
eucool marked this conversation as resolved.
Show resolved Hide resolved
import type {MoneyRequestNavigatorParamList} from '@libs/Navigation/types';
import type SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';

type IOURequestStepRoute = StackScreenProps<MoneyRequestNavigatorParamList, typeof SCREENS.MONEY_REQUEST.SCAN_TAB>;

type IOURequestStepReport = {
report: OnyxTypes.Report;
};

type IOURequestStepTransaction = {
transaction: OnyxTypes.Transaction;
};

type IOURequestStepProps = IOURequestStepRoute & IOURequestStepReport & IOURequestStepTransaction;

export default IOURequestStepProps;
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import PropTypes from 'prop-types';
import React from 'react';
import type {Ref} from 'react';
import {Camera} from 'react-native-vision-camera';
import type {CameraDevice} 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,
type NavigationAwareCameraProps = {
cameraTabIndex: number;
eucool marked this conversation as resolved.
Show resolved Hide resolved
device: CameraDevice;
};

// 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) => {
const NavigationAwareCamera = React.forwardRef(({cameraTabIndex, ...props}: NavigationAwareCameraProps, ref: Ref<Camera>) => {
const isCameraActive = useTabNavigatorFocus({tabIndex: cameraTabIndex});
eucool marked this conversation as resolved.
Show resolved Hide resolved

return (
Expand All @@ -22,7 +23,4 @@ const NavigationAwareCamera = React.forwardRef(({cameraTabIndex, ...props}, ref)
);
});

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

export default NavigationAwareCamera;
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
import PropTypes from 'prop-types';
import React, {useEffect, useRef} from 'react';
import React, {forwardRef, useEffect, useRef} from 'react';
import type {Ref} from 'react';
import {View} from 'react-native';
import Webcam from 'react-webcam';
import useTabNavigatorFocus from '@hooks/useTabNavigatorFocus';

const propTypes = {
/** Flag to turn on/off the torch/flashlight - if available */
torchOn: PropTypes.bool,

/** The index of the tab that contains this camera */
cameraTabIndex: PropTypes.number.isRequired,

/** Callback function when media stream becomes available - user granted camera permissions and camera starts to work */
onUserMedia: PropTypes.func,

/** Callback function passing torch/flashlight capability as bool param of the browser */
onTorchAvailability: PropTypes.func,
};

const defaultProps = {
onUserMedia: undefined,
onTorchAvailability: undefined,
torchOn: false,
type NavigationAwareCameraProps = {
torchOn: boolean;
eucool marked this conversation as resolved.
Show resolved Hide resolved
onTorchAvailability?: (torchAvailable: boolean) => void;
eucool marked this conversation as resolved.
Show resolved Hide resolved
cameraTabIndex: number;
onUserMedia?: (stream: MediaStream) => void;
};

// 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(({torchOn, onTorchAvailability, cameraTabIndex, ...props}, ref) => {
const trackRef = useRef(null);
const NavigationAwareCamera = forwardRef(({torchOn, onTorchAvailability, cameraTabIndex, ...props}: NavigationAwareCameraProps, ref: Ref<Webcam>) => {
const trackRef = useRef<MediaStreamTrack | null>(null);
eucool marked this conversation as resolved.
Show resolved Hide resolved
const shouldShowCamera = useTabNavigatorFocus({
tabIndex: cameraTabIndex,
});

const handleOnUserMedia = (stream) => {
const handleOnUserMedia = (stream: MediaStream) => {
if (props.onUserMedia) {
props.onUserMedia(stream);
}
Expand Down Expand Up @@ -73,8 +60,4 @@ const NavigationAwareCamera = React.forwardRef(({torchOn, onTorchAvailability, c
);
});

NavigationAwareCamera.propTypes = propTypes;
NavigationAwareCamera.displayName = 'NavigationAwareCamera';
NavigationAwareCamera.defaultProps = defaultProps;
eucool marked this conversation as resolved.
Show resolved Hide resolved

export default NavigationAwareCamera;
Loading
Loading