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 'IOUWaypoint' page to TypeScript #33244

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
dde6aca
chore: move IOUWaypoint Pages to TS
kubabutkiewicz Dec 18, 2023
36c73ed
ref: seperate types
kubabutkiewicz Dec 18, 2023
a32e718
chore: added todos
kubabutkiewicz Dec 20, 2023
1d1f0fa
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Dec 20, 2023
049e7ad
fix: address comments
kubabutkiewicz Dec 20, 2023
2a75175
fix: adjust recentwaypoint type
kubabutkiewicz Dec 21, 2023
437636a
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 2, 2024
9b36c85
fix: type problems
kubabutkiewicz Jan 2, 2024
3a448bb
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 3, 2024
7f463df
fix: resolve comments
kubabutkiewicz Jan 3, 2024
26ee70c
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 8, 2024
72b7efb
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 15, 2024
02dbc36
fix: move changes to new file
kubabutkiewicz Jan 15, 2024
e6164a2
fix: type errors
kubabutkiewicz Jan 15, 2024
f8c1cc4
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 15, 2024
b399f8a
fix: types
kubabutkiewicz Jan 15, 2024
4755a0f
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 18, 2024
374a4a3
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 22, 2024
5adf756
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 31, 2024
bfb8b43
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 2, 2024
5190bd1
fix: typecheck
kubabutkiewicz Feb 2, 2024
4bcf243
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 2, 2024
c232f39
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 5, 2024
bf8e335
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 6, 2024
2deb942
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 6, 2024
e945840
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 7, 2024
490c77a
fix: typecheck
kubabutkiewicz Feb 7, 2024
ce58b9d
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 8, 2024
040a383
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 13, 2024
61a2595
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 14, 2024
7a7baf9
fix: typecheck
kubabutkiewicz Feb 14, 2024
75073fe
fix: typecheck
kubabutkiewicz Feb 14, 2024
59a03f9
fix: typecheck
kubabutkiewicz Feb 14, 2024
3aea0ef
fix: when searching for waypoint
kubabutkiewicz Feb 14, 2024
b94ab89
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 15, 2024
f600f67
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 15, 2024
0f84798
fix: ci
kubabutkiewicz Feb 15, 2024
e60d866
fix: removed podfile.lock and gemfile
kubabutkiewicz Feb 20, 2024
567d0a7
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 20, 2024
73d0864
fix: revert changes to Gemfile.lock
kubabutkiewicz Feb 20, 2024
28eacfe
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 22, 2024
e34ae0b
fix: resolve comments
kubabutkiewicz Feb 22, 2024
1ff718c
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Feb 23, 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
2 changes: 1 addition & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ const ROUTES = {
},
MONEY_REQUEST_EDIT_WAYPOINT: {
route: 'r/:threadReportID/edit/distance/:transactionID/waypoint/:waypointIndex',
getRoute: (threadReportID: number, transactionID: string, waypointIndex: number) => `r/${threadReportID}/edit/distance/${transactionID}/waypoint/${waypointIndex}` as const,
getRoute: (threadReportID: string, transactionID: string, waypointIndex: number) => `r/${threadReportID}/edit/distance/${transactionID}/waypoint/${waypointIndex}` as const,
},
MONEY_REQUEST_DISTANCE_TAB: {
route: ':iouType/new/:reportID?/distance',
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ type MoneyRequestNavigatorParamList = {
iouType: string;
transactionID: string;
waypointIndex: string;
threadReportID: number;
threadReportID: string;
};
[SCREENS.MONEY_REQUEST.EDIT_WAYPOINT]: {
iouType: string;
transactionID: string;
waypointIndex: string;
threadReportID: number;
threadReportID: string;
};
[SCREENS.MONEY_REQUEST.DISTANCE]: {
iouType: ValueOf<typeof CONST.IOU.TYPE>;
Expand Down
20 changes: 15 additions & 5 deletions src/libs/actions/Transaction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {isEqual} from 'lodash';
import lodashClone from 'lodash/clone';
import lodashHas from 'lodash/has';
import Onyx from 'react-native-onyx';
import Onyx, {OnyxEntry} from 'react-native-onyx';
import * as API from '@libs/API';
import * as CollectionUtils from '@libs/CollectionUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
Expand Down Expand Up @@ -99,7 +99,7 @@ function saveWaypoint(transactionID: string, index: string, waypoint: RecentWayp
}
}

function removeWaypoint(transaction: Transaction, currentIndex: string, isDraft: boolean) {
function removeWaypoint(transaction: OnyxEntry<Transaction>, currentIndex: string, isDraft?: boolean) {
// Index comes from the route params and is a string
const index = Number(currentIndex);
const existingWaypoints = transaction?.comment?.waypoints ?? {};
Expand Down Expand Up @@ -128,8 +128,18 @@ function removeWaypoint(transaction: Transaction, currentIndex: string, isDraft:
// Doing a deep clone of the transaction to avoid mutating the original object and running into a cache issue when using Onyx.set
let newTransaction: Transaction = {
...transaction,
amount: transaction?.amount ?? 0,
billable: transaction?.billable ?? false,
category: transaction?.category ?? '',
created: transaction?.created ?? '',
currency: transaction?.currency ?? '',
pendingAction: transaction?.pendingAction ?? null,
merchant: transaction?.merchant ?? '',
reportID: transaction?.reportID ?? '',
transactionID: transaction?.transactionID ?? '',
tag: transaction?.tag ?? '',
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
comment: {
...transaction.comment,
...transaction?.comment,
waypoints: reIndexedWaypoints,
},
};
Expand All @@ -153,10 +163,10 @@ function removeWaypoint(transaction: Transaction, currentIndex: string, isDraft:
};
}
if (isDraft) {
Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transaction.transactionID}`, newTransaction);
Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transaction?.transactionID}`, newTransaction);
return;
}
Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, newTransaction);
Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction?.transactionID}`, newTransaction);
MonilBhavsar marked this conversation as resolved.
Show resolved Hide resolved
}

function getOnyxDataForRouteRequest(transactionID: string, isDraft = false): OnyxData {
Expand Down
32 changes: 0 additions & 32 deletions src/pages/iou/MoneyRequestEditWaypointPage.js

This file was deleted.

15 changes: 15 additions & 0 deletions src/pages/iou/MoneyRequestEditWaypointPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {StackScreenProps} from '@react-navigation/stack';
import React from 'react';
import {MoneyRequestNavigatorParamList} from '@libs/Navigation/types';
import SCREENS from '@src/SCREENS';
import WaypointEditor from './WaypointEditor';

type MoneyRequestEditWaypointPageProps = StackScreenProps<MoneyRequestNavigatorParamList, typeof SCREENS.MONEY_REQUEST.EDIT_WAYPOINT>;

function MoneyRequestEditWaypointPage({route}: MoneyRequestEditWaypointPageProps) {
return <WaypointEditor route={route} />;
}

MoneyRequestEditWaypointPage.displayName = 'MoneyRequestEditWaypointPage';

export default MoneyRequestEditWaypointPage;
55 changes: 0 additions & 55 deletions src/pages/iou/NewDistanceRequestWaypointEditorPage.js

This file was deleted.

38 changes: 38 additions & 0 deletions src/pages/iou/NewDistanceRequestWaypointEditorPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {RouteProp} from '@react-navigation/native';
import {StackScreenProps} from '@react-navigation/stack';
import React from 'react';
import {withOnyx} from 'react-native-onyx';
import {MoneyRequestNavigatorParamList} from '@libs/Navigation/types';
import ONYXKEYS from '@src/ONYXKEYS';
import SCREENS from '@src/SCREENS';
import WaypointEditor from './WaypointEditor';

type NewDistanceRequestWaypointEditorPageOnyxProps = {
transactionID: string | undefined;
};
type NewDistanceRequestWaypointEditorPageProps = StackScreenProps<MoneyRequestNavigatorParamList, typeof SCREENS.MONEY_REQUEST.EDIT_WAYPOINT> & NewDistanceRequestWaypointEditorPageOnyxProps;

// This component is responsible for grabbing the transactionID from the IOU key
// You can't use Onyx props in the withOnyx mapping, so we need to set up and access the transactionID here, and then pass it down so that WaypointEditor can subscribe to the transaction.
function NewDistanceRequestWaypointEditorPage({transactionID, route}: NewDistanceRequestWaypointEditorPageProps) {
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
return (
<WaypointEditor
// Put the transactionID into the route params so that WaypointEdit behaves the same when creating a new waypoint
// or editing an existing waypoint.
route={
{
params: {
...route.params,
transactionID: transactionID ?? '',
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
},
} as RouteProp<MoneyRequestNavigatorParamList, typeof SCREENS.MONEY_REQUEST.EDIT_WAYPOINT>
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
}
/>
);
}

NewDistanceRequestWaypointEditorPage.displayName = 'NewDistanceRequestWaypointEditorPage';

export default withOnyx<NewDistanceRequestWaypointEditorPageProps, NewDistanceRequestWaypointEditorPageOnyxProps>({
transactionID: {key: ONYXKEYS.IOU, selector: (iou) => iou?.transactionID},
})(NewDistanceRequestWaypointEditorPage);
Loading
Loading