Skip to content

Commit

Permalink
Merge pull request #48923 from Krishna2323/krishna2323/issue/48865
Browse files Browse the repository at this point in the history
fix: Web - Scan - 'Description' and 'Category' fields are disabled after dismissing 'Allow location' modal.
(cherry picked from commit a010f3d)

(CP triggered by luacmartins)
  • Loading branch information
luacmartins authored and OSBotify committed Sep 10, 2024
1 parent 3ad1a68 commit a46009f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
16 changes: 10 additions & 6 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps &

/** Should play sound on confirmation */
shouldPlaySound?: boolean;

/** Whether the expense is confirmed or not */
isConfirmed?: boolean;
};

type MoneyRequestConfirmationListItem = Participant | ReportUtils.OptionData;
Expand Down Expand Up @@ -209,6 +212,7 @@ function MoneyRequestConfirmationList({
currencyList,
shouldDisplayReceipt = false,
shouldPlaySound = true,
isConfirmed,
}: MoneyRequestConfirmationListProps) {
const policy = policyReal ?? policyDraft;
const policyCategories = policyCategoriesReal ?? policyCategoriesDraft;
Expand Down Expand Up @@ -300,7 +304,7 @@ function MoneyRequestConfirmationList({
const isFocused = useIsFocused();
const [formError, debouncedFormError, setFormError] = useDebouncedState<TranslationPaths | ''>('');

const [didConfirm, setDidConfirm] = useState(false);
const [didConfirm, setDidConfirm] = useState(isConfirmed);
const [didConfirmSplit, setDidConfirmSplit] = useState(false);

const shouldDisplayFieldError: boolean = useMemo(() => {
Expand Down Expand Up @@ -420,6 +424,10 @@ function MoneyRequestConfirmationList({
setDidConfirm(false);
}

useEffect(() => {
setDidConfirm(isConfirmed);
}, [isConfirmed]);

const splitOrRequestOptions: Array<DropdownOption<string>> = useMemo(() => {
let text;
if (isTypeInvoice) {
Expand Down Expand Up @@ -776,7 +784,6 @@ function MoneyRequestConfirmationList({
if (shouldPlaySound) {
playSound(SOUNDS.DONE);
}
setDidConfirm(true);
onConfirm?.(selectedParticipants);
} else {
if (!paymentMethod) {
Expand All @@ -785,9 +792,6 @@ function MoneyRequestConfirmationList({
if (formError) {
return;
}

setDidConfirm(true);

Log.info(`[IOU] Sending money via: ${paymentMethod}`);
onSendMoney?.(paymentMethod);
}
Expand Down Expand Up @@ -907,7 +911,7 @@ function MoneyRequestConfirmationList({
action={action}
canUseP2PDistanceRequests={canUseP2PDistanceRequests}
currency={currency}
didConfirm={didConfirm}
didConfirm={!!didConfirm}
distance={distance}
formattedAmount={formattedAmount}
formError={formError}
Expand Down
12 changes: 7 additions & 5 deletions src/pages/iou/SplitBillDetailsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {StackScreenProps} from '@react-navigation/stack';
import type {ComponentType} from 'react';
import React, {useCallback, useMemo} from 'react';
import React, {useCallback, useMemo, useState} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
Expand Down Expand Up @@ -84,6 +84,7 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr
const isScanning = TransactionUtils.hasReceipt(transaction) && TransactionUtils.isReceiptBeingScanned(transaction);
const hasSmartScanFailed = TransactionUtils.hasReceipt(transaction) && transaction?.receipt?.state === CONST.IOU.RECEIPT_STATE.SCANFAILED;
const isEditingSplitBill = session?.accountID === reportAction?.actorAccountID && TransactionUtils.areRequiredFieldsEmpty(transaction);
const [isConfirmed, setIsConfirmed] = useState(false);

const {
amount: splitAmount,
Expand All @@ -95,10 +96,10 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr
billable: splitBillable,
} = ReportUtils.getTransactionDetails(isEditingSplitBill && draftTransaction ? draftTransaction : transaction) ?? {};

const onConfirm = useCallback(
() => IOU.completeSplitBill(reportID, reportAction, draftTransaction, session?.accountID ?? -1, session?.email ?? ''),
[reportID, reportAction, draftTransaction, session?.accountID, session?.email],
);
const onConfirm = useCallback(() => {
setIsConfirmed(true);
IOU.completeSplitBill(reportID, reportAction, draftTransaction, session?.accountID ?? -1, session?.email ?? '');
}, [reportID, reportAction, draftTransaction, session?.accountID, session?.email]);

return (
<ScreenWrapper testID={SplitBillDetailsPage.displayName}>
Expand Down Expand Up @@ -150,6 +151,7 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr
onToggleBillable={(billable) => {
IOU.setDraftSplitTransaction(transaction?.transactionID ?? '-1', {billable});
}}
isConfirmed={isConfirmed}
/>
)}
</View>
Expand Down
5 changes: 5 additions & 0 deletions src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function IOURequestStepConfirmation({
}, [personalDetails, transaction?.participants, transaction?.splitPayerAccountIDs]);

const gpsRequired = transaction?.amount === 0 && iouType !== CONST.IOU.TYPE.SPLIT && receiptFile;
const [isConfirmed, setIsConfirmed] = useState(false);

const headerTitle = useMemo(() => {
if (isCategorizingTrackExpense) {
Expand Down Expand Up @@ -355,6 +356,7 @@ function IOURequestStepConfirmation({

const createTransaction = useCallback(
(selectedParticipants: Participant[], locationPermissionGranted = false) => {
setIsConfirmed(true);
let splitParticipants = selectedParticipants;

// Filter out participants with an amount equal to O
Expand Down Expand Up @@ -557,11 +559,13 @@ function IOURequestStepConfirmation({
}

if (paymentMethod === CONST.IOU.PAYMENT_TYPE.ELSEWHERE) {
setIsConfirmed(true);
IOU.sendMoneyElsewhere(report, transaction.amount, currency, trimmedComment, currentUserPersonalDetails.accountID, participant);
return;
}

if (paymentMethod === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) {
setIsConfirmed(true);
IOU.sendMoneyWithWallet(report, transaction.amount, currency, trimmedComment, currentUserPersonalDetails.accountID, participant);
}
},
Expand Down Expand Up @@ -646,6 +650,7 @@ function IOURequestStepConfirmation({
action={action}
payeePersonalDetails={payeePersonalDetails}
shouldPlaySound={false}
isConfirmed={isConfirmed}
/>
</View>
)}
Expand Down

0 comments on commit a46009f

Please sign in to comment.