From 28908054ab085563e85bec599dba84cd8e38d26f Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 4 Jan 2024 22:23:14 +0700 Subject: [PATCH 1/3] reset amount when updating waypoints --- src/CONST.ts | 1 + src/libs/actions/Transaction.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index b5563825e016..0c98645511d4 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1177,6 +1177,7 @@ const CONST = { EXPENSIFY: 'Expensify', VBBA: 'ACH', }, + DEFAULT_AMOUNT: 0, TYPE: { SEND: 'send', SPLIT: 'split', diff --git a/src/libs/actions/Transaction.ts b/src/libs/actions/Transaction.ts index f8bfa5fe78fd..84c60756b0c6 100644 --- a/src/libs/actions/Transaction.ts +++ b/src/libs/actions/Transaction.ts @@ -10,6 +10,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {RecentWaypoint, Transaction} from '@src/types/onyx'; import type {OnyxData} from '@src/types/onyx/Request'; import type {WaypointCollection} from '@src/types/onyx/Transaction'; +import * as IOU from './IOU'; let recentWaypoints: RecentWaypoint[] = []; Onyx.connect({ @@ -64,6 +65,7 @@ function saveWaypoint(transactionID: string, index: string, waypoint: RecentWayp [`waypoint${index}`]: waypoint, }, }, + amount: CONST.IOU.DEFAULT_AMOUNT, // Empty out errors when we're saving a new waypoint as this indicates the user is updating their input errorFields: { route: null, @@ -132,6 +134,7 @@ function removeWaypoint(transaction: Transaction, currentIndex: string, isDraft: ...transaction.comment, waypoints: reIndexedWaypoints, }, + amount: CONST.IOU.DEFAULT_AMOUNT }; if (!isRemovedWaypointEmpty) { @@ -244,7 +247,7 @@ function updateWaypoints(transactionID: string, waypoints: WaypointCollection, i comment: { waypoints, }, - + amount: CONST.IOU.DEFAULT_AMOUNT, // Empty out errors when we're saving new waypoints as this indicates the user is updating their input errorFields: { route: null, From 396539451cd9fb5cadc29ba2a9ce171de1ed6b2f Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 4 Jan 2024 22:35:29 +0700 Subject: [PATCH 2/3] fix lint --- src/libs/actions/Transaction.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Transaction.ts b/src/libs/actions/Transaction.ts index 84c60756b0c6..d42d3ca719b5 100644 --- a/src/libs/actions/Transaction.ts +++ b/src/libs/actions/Transaction.ts @@ -134,7 +134,7 @@ function removeWaypoint(transaction: Transaction, currentIndex: string, isDraft: ...transaction.comment, waypoints: reIndexedWaypoints, }, - amount: CONST.IOU.DEFAULT_AMOUNT + amount: CONST.IOU.DEFAULT_AMOUNT, }; if (!isRemovedWaypointEmpty) { From 5520db66750d60697025123d2c7d841d8be91cd7 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 4 Jan 2024 22:43:16 +0700 Subject: [PATCH 3/3] fix lint --- src/libs/actions/Transaction.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Transaction.ts b/src/libs/actions/Transaction.ts index d42d3ca719b5..674d0c000656 100644 --- a/src/libs/actions/Transaction.ts +++ b/src/libs/actions/Transaction.ts @@ -10,7 +10,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {RecentWaypoint, Transaction} from '@src/types/onyx'; import type {OnyxData} from '@src/types/onyx/Request'; import type {WaypointCollection} from '@src/types/onyx/Transaction'; -import * as IOU from './IOU'; let recentWaypoints: RecentWaypoint[] = []; Onyx.connect({