Skip to content

Commit

Permalink
Resolve type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
eucool committed Mar 31, 2024
1 parent f072419 commit 61588d5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
17 changes: 9 additions & 8 deletions src/pages/iou/request/step/IOURequestStepScan/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import {ActivityIndicator, Alert, AppState, InteractionManager, View} from 'reac
import {Gesture, GestureDetector} from 'react-native-gesture-handler';
import {RESULTS} from 'react-native-permissions';
import Animated, {runOnJS, useAnimatedStyle, useSharedValue, withDelay, withSequence, withSpring, withTiming} from 'react-native-reanimated';
import type {Camera, Point} from 'react-native-vision-camera';
import type {Camera, PhotoFile, Point} from 'react-native-vision-camera';
import {useCameraDevice} from 'react-native-vision-camera';
import Hand from '@assets/images/hand.svg';
import Shutter from '@assets/images/shutter.svg';
import type {FileObject} from '@components/AttachmentModal';
import AttachmentPicker from '@components/AttachmentPicker';
import Button from '@components/Button';
import Icon from '@components/Icon';
Expand All @@ -30,16 +31,15 @@ import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import CameraPermission from './CameraPermission';
import NavigationAwareCamera from './NavigationAwareCamera';
import type IOURequestStepProps from './types';
import { FileObject } from '@components/AttachmentModal';
import type IOURequestStepOnyxProps from './types';

function IOURequestStepScan({
report,
route: {
params: {action, iouType, reportID, transactionID, backTo},
},
transaction: {isFromGlobalCreate},
}: IOURequestStepProps) {
}: IOURequestStepOnyxProps) {
const theme = useTheme();
const styles = useThemeStyles();
const device = useCameraDevice('back', {
Expand Down Expand Up @@ -194,6 +194,7 @@ function IOURequestStepScan({
// Store the receipt on the transaction object in Onyx
// On Android devices, fetching blob for a file with name containing spaces fails to retrieve the type of file.
// So, let us also save the file type in receipt for later use during blob fetch
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
IOU.setMoneyRequestReceipt(transactionID, file?.uri ?? '', file.name || '', action !== CONST.IOU.ACTION.EDIT, file.type);

if (action === CONST.IOU.ACTION.EDIT) {
Expand All @@ -218,11 +219,11 @@ function IOURequestStepScan({
showCameraAlert();
}

return camera?.current?
.takePhoto({
camera?.current
?.takePhoto({
flash: flash && hasFlash ? 'on' : 'off',
})
.then((photo) => {
.then((photo: PhotoFile) => {
// Store the receipt on the transaction object in Onyx
const source = `file://${photo.path}`;
IOU.setMoneyRequestReceipt(transactionID, source, photo.path, action !== CONST.IOU.ACTION.EDIT);
Expand All @@ -236,7 +237,7 @@ function IOURequestStepScan({

navigateToConfirmationStep();
})
.catch((error) => {
.catch((error: string) => {
showCameraAlert();
Log.warn('Error taking photo', error);
});
Expand Down
4 changes: 2 additions & 2 deletions src/pages/iou/request/step/IOURequestStepScan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ import type {TranslationPaths} from '@src/languages/types';
import ROUTES from '@src/ROUTES';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import NavigationAwareCamera from './NavigationAwareCamera';
import type IOURequestStepProps from './types';
import type IOURequestStepOnyxProps from './types';

function IOURequestStepScan({
report,
route: {
params: {action, iouType, reportID, transactionID, backTo},
},
transaction: {isFromGlobalCreate},
}: IOURequestStepProps) {
}: IOURequestStepOnyxProps) {
const theme = useTheme();
const styles = useThemeStyles();

Expand Down
4 changes: 2 additions & 2 deletions src/pages/iou/request/step/IOURequestStepScan/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import type {MoneyRequestNavigatorParamList} from '@libs/Navigation/types';
import type SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';

type IOURequestStepProps = {
type IOURequestStepOnyxProps = {
route: RouteProp<MoneyRequestNavigatorParamList, typeof SCREENS.MONEY_REQUEST.STEP_SCAN>;
report: OnyxTypes.Report;
transaction: OnyxTypes.Transaction;
};

export default IOURequestStepProps;
export default IOURequestStepOnyxProps;
4 changes: 1 addition & 3 deletions src/pages/iou/request/step/withWritableReportOrNotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import type {Report, Transaction} from '@src/types/onyx';
import type {Report} from '@src/types/onyx';

type WithWritableReportOrNotFoundOnyxProps = {
/** The report corresponding to the reportID in the route params */
report: OnyxEntry<Report>;
/** The transaction that the user is trying to create */
transaction?: OnyxEntry<Transaction>;
};

type Route = RouteProp<MoneyRequestNavigatorParamList, typeof SCREENS.MONEY_REQUEST.STEP_WAYPOINT>;
Expand Down

0 comments on commit 61588d5

Please sign in to comment.