Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham1206agra committed Jan 14, 2025
1 parent b305672 commit b386ff5
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 86 deletions.
4 changes: 2 additions & 2 deletions src/components/CurrencyPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {ReactNode} from 'react';
import React, {useState} from 'react';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import {getCurrencySymbol} from '@libs/CurrencyUtils';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import CurrencySelectionList from './CurrencySelectionList';
Expand Down Expand Up @@ -50,7 +50,7 @@ function CurrencyPicker({value, errorText, headerContent, excludeCurrencies, int
<>
<MenuItemWithTopDescription
shouldShowRightIcon
title={value ? `${value} - ${CurrencyUtils.getCurrencySymbol(value)}` : undefined}
title={value ? `${value} - ${getCurrencySymbol(value)}` : undefined}
description={translate('common.currency')}
onPress={() => setIsPickerVisible(true)}
brickRoadIndicator={errorText ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
Expand Down
6 changes: 3 additions & 3 deletions src/components/CurrencySelectionList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SelectionList from '@components/SelectionList';
import RadioListItem from '@components/SelectionList/RadioListItem';
import SelectableListItem from '@components/SelectionList/SelectableListItem';
import useLocalize from '@hooks/useLocalize';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import {getCurrencySymbol} from '@libs/CurrencyUtils';
import ONYXKEYS from '@src/ONYXKEYS';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type {CurrencyListItem, CurrencySelectionListProps} from './types';
Expand All @@ -29,7 +29,7 @@ function CurrencySelectionList({
if (!excludedCurrencies.includes(currencyCode) && (isSelectedCurrency || !currencyInfo?.retired)) {
acc.push({
currencyName: currencyInfo?.name ?? '',
text: `${currencyCode} - ${CurrencyUtils.getCurrencySymbol(currencyCode)}`,
text: `${currencyCode} - ${getCurrencySymbol(currencyCode)}`,
currencyCode,
keyForList: currencyCode,
isSelected: isSelectedCurrency,
Expand All @@ -44,7 +44,7 @@ function CurrencySelectionList({
const isSelectedCurrency = currencyCode === initiallySelectedCurrencyCode;
return {
currencyName: currencyInfo?.name ?? '',
text: `${currencyCode} - ${CurrencyUtils.getCurrencySymbol(currencyCode)}`,
text: `${currencyCode} - ${getCurrencySymbol(currencyCode)}`,
currencyCode,
keyForList: currencyCode,
isSelected: isSelectedCurrency,
Expand Down
22 changes: 11 additions & 11 deletions src/components/Form/FormProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type {NativeSyntheticEvent, StyleProp, TextInputSubmitEditingEventData, V
import {useOnyx} from 'react-native-onyx';
import useDebounceNonReactive from '@hooks/useDebounceNonReactive';
import useLocalize from '@hooks/useLocalize';
import * as ValidationUtils from '@libs/ValidationUtils';
import {prepareValues} from '@libs/ValidationUtils';
import Visibility from '@libs/Visibility';
import * as FormActions from '@userActions/FormActions';
import {clearErrorFields, clearErrors, setDraftValues, setErrors as setErrorsFormActions} from '@userActions/FormActions';
import CONST from '@src/CONST';
import type {OnyxFormDraftKey, OnyxFormKey} from '@src/ONYXKEYS';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -102,12 +102,12 @@ function FormProvider(

const onValidate = useCallback(
(values: FormOnyxValues, shouldClearServerError = true) => {
const trimmedStringValues = shouldTrimValues ? ValidationUtils.prepareValues(values) : values;
const trimmedStringValues = shouldTrimValues ? prepareValues(values) : values;

if (shouldClearServerError) {
FormActions.clearErrors(formID);
clearErrors(formID);
}
FormActions.clearErrorFields(formID);
clearErrorFields(formID);

const validateErrors: GenericFormInputErrors = validate?.(trimmedStringValues) ?? {};

Expand Down Expand Up @@ -172,7 +172,7 @@ function FormProvider(
}

// Prepare validation values
const trimmedStringValues = shouldTrimValues ? ValidationUtils.prepareValues(inputValues) : inputValues;
const trimmedStringValues = shouldTrimValues ? prepareValues(inputValues) : inputValues;

// Validate in order to make sure the correct error translations are displayed,
// making sure to not clear server errors if they exist
Expand All @@ -198,7 +198,7 @@ function FormProvider(
}

// Prepare values before submitting
const trimmedStringValues = shouldTrimValues ? ValidationUtils.prepareValues(inputValues) : inputValues;
const trimmedStringValues = shouldTrimValues ? prepareValues(inputValues) : inputValues;

// Touches all form inputs, so we can validate the entire form
Object.keys(inputRefs.current).forEach((inputID) => (touchedInputs.current[inputID] = true));
Expand Down Expand Up @@ -250,16 +250,16 @@ function FormProvider(
);

const resetErrors = useCallback(() => {
FormActions.clearErrors(formID);
FormActions.clearErrorFields(formID);
clearErrors(formID);
clearErrorFields(formID);
setErrors({});
}, [formID]);

const resetFormFieldError = useCallback(
(inputID: keyof Form) => {
const newErrors = {...errors};
delete newErrors[inputID];
FormActions.setErrors(formID, newErrors as Errors);
setErrorsFormActions(formID, newErrors as Errors);
setErrors(newErrors);
},
[errors, formID],
Expand Down Expand Up @@ -391,7 +391,7 @@ function FormProvider(
});

if (inputProps.shouldSaveDraft && !formID.includes('Draft')) {
FormActions.setDraftValues(formID, {[inputKey]: value});
setDraftValues(formID, {[inputKey]: value});
}
inputProps.onValueChange?.(value, inputKey);
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/Form/FormWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ScrollView from '@components/ScrollView';
import ScrollViewWithContext from '@components/ScrollViewWithContext';
import useStyledSafeAreaInsets from '@hooks/useStyledSafeAreaInsets';
import useThemeStyles from '@hooks/useThemeStyles';
import * as ErrorUtils from '@libs/ErrorUtils';
import {getLatestErrorMessage} from '@libs/ErrorUtils';
import type {OnyxFormKey} from '@src/ONYXKEYS';
import type {Form} from '@src/types/form';
import type ChildrenProps from '@src/types/utils/ChildrenProps';
Expand Down Expand Up @@ -69,7 +69,7 @@ function FormWrapper({

const [formState] = useOnyx<OnyxFormKey, Form>(`${formID}`);

const errorMessage = useMemo(() => (formState ? ErrorUtils.getLatestErrorMessage(formState) : undefined), [formState]);
const errorMessage = useMemo(() => (formState ? getLatestErrorMessage(formState) : undefined), [formState]);

const onFixTheErrorsLinkPressed = useCallback(() => {
const errorFields = !isEmptyObject(errors) ? errors : formState?.errorFields ?? {};
Expand Down
8 changes: 4 additions & 4 deletions src/libs/PaymentUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type BankAccount from '@src/types/onyx/BankAccount';
import type Fund from '@src/types/onyx/Fund';
import type PaymentMethod from '@src/types/onyx/PaymentMethod';
import type {ACHAccount} from '@src/types/onyx/Policy';
import * as Localize from './Localize';
import {translateLocal} from './Localize';
import BankAccountModel from './models/BankAccount';

type AccountType = ValueOf<typeof CONST.PAYMENT_METHODS> | undefined;
Expand All @@ -30,13 +30,13 @@ function hasExpensifyPaymentMethod(fundList: Record<string, Fund>, bankAccountLi
function getPaymentMethodDescription(accountType: AccountType, account: BankAccount['accountData'] | Fund['accountData'] | ACHAccount, bankCurrency?: string): string {
if (account) {
if (accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && 'accountNumber' in account) {
return `${bankCurrency} ${CONST.DOT_SEPARATOR} ${Localize.translateLocal('paymentMethodList.accountLastFour')} ${account.accountNumber?.slice(-4)}`;
return `${bankCurrency} ${CONST.DOT_SEPARATOR} ${translateLocal('paymentMethodList.accountLastFour')} ${account.accountNumber?.slice(-4)}`;
}
if (accountType === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT && 'accountNumber' in account) {
return `${Localize.translateLocal('paymentMethodList.accountLastFour')} ${account.accountNumber?.slice(-4)}`;
return `${translateLocal('paymentMethodList.accountLastFour')} ${account.accountNumber?.slice(-4)}`;
}
if (accountType === CONST.PAYMENT_METHODS.DEBIT_CARD && 'cardNumber' in account) {
return `${Localize.translateLocal('paymentMethodList.cardLastFour')} ${account.cardNumber?.slice(-4)}`;
return `${translateLocal('paymentMethodList.cardLastFour')} ${account.cardNumber?.slice(-4)}`;
}
}
return '';
Expand Down
12 changes: 6 additions & 6 deletions src/pages/AddPersonalBankAccountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import getPlaidOAuthReceivedRedirectURI from '@libs/getPlaidOAuthReceivedRedirectURI';
import Navigation from '@libs/Navigation/Navigation';
import * as BankAccounts from '@userActions/BankAccounts';
import * as PaymentMethods from '@userActions/PaymentMethods';
import {addPersonalBankAccount, clearPersonalBankAccount, validatePlaidSelection} from '@userActions/BankAccounts';
import {continueSetup} from '@userActions/PaymentMethods';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand All @@ -34,7 +34,7 @@ function AddPersonalBankAccountPage() {
const selectedPlaidBankAccount = bankAccounts.find((bankAccount) => bankAccount.plaidAccountID === selectedPlaidAccountId);

if (selectedPlaidBankAccount) {
BankAccounts.addPersonalBankAccount(selectedPlaidBankAccount);
addPersonalBankAccount(selectedPlaidBankAccount);
}
}, [plaidData, selectedPlaidAccountId]);

Expand Down Expand Up @@ -62,15 +62,15 @@ function AddPersonalBankAccountPage() {
if (exitReportID) {
Navigation.dismissModal(exitReportID);
} else if (shouldContinue && onSuccessFallbackRoute) {
PaymentMethods.continueSetup(onSuccessFallbackRoute);
continueSetup(onSuccessFallbackRoute);
} else {
goBack();
}
},
[personalBankAccount, goBack],
);

useEffect(() => BankAccounts.clearPersonalBankAccount, []);
useEffect(() => clearPersonalBankAccount, []);

return (
<ScreenWrapper
Expand Down Expand Up @@ -100,7 +100,7 @@ function AddPersonalBankAccountPage() {
submitButtonText={translate('common.saveAndContinue')}
scrollContextEnabled
onSubmit={submitBankAccountForm}
validate={BankAccounts.validatePlaidSelection}
validate={validatePlaidSelection}
style={[styles.mh5, styles.flex1]}
>
<InputWrapper
Expand Down
34 changes: 17 additions & 17 deletions src/pages/ReimbursementAccount/BankAccountStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import ValidateCodeActionModal from '@components/ValidateCodeActionModal';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as ErrorUtils from '@libs/ErrorUtils';
import {getEarliestErrorField, getLatestErrorField} from '@libs/ErrorUtils';
import getPlaidDesktopMessage from '@libs/getPlaidDesktopMessage';
import * as BankAccounts from '@userActions/BankAccounts';
import * as Link from '@userActions/Link';
import * as ReimbursementAccount from '@userActions/ReimbursementAccount';
import * as User from '@userActions/User';
import {openPlaidView, setBankAccountSubStep} from '@userActions/BankAccounts';
import {openExternalLink, openExternalLinkWithToken} from '@userActions/Link';
import {updateReimbursementAccountDraft} from '@userActions/ReimbursementAccount';
import {clearContactMethodErrors, requestValidateCodeAction, validateSecondaryLogin} from '@userActions/User';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -81,7 +81,7 @@ function BankAccountStep({
const selectedSubStep = useRef('');

const loginData = useMemo(() => loginList?.[contactMethod], [loginList, contactMethod]);
const validateLoginError = ErrorUtils.getEarliestErrorField(loginData, 'validateLogin');
const validateLoginError = getEarliestErrorField(loginData, 'validateLogin');
const hasMagicCodeBeenSent = !!loginData?.validateCodeSent;

let subStep = reimbursementAccount?.achData?.subStep ?? '';
Expand All @@ -99,9 +99,9 @@ function BankAccountStep({
}

if (selectedSubStep.current === CONST.BANK_ACCOUNT.SUBSTEP.MANUAL) {
BankAccounts.setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL);
setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL);
} else if (selectedSubStep.current === CONST.BANK_ACCOUNT.SUBSTEP.PLAID) {
BankAccounts.openPlaidView();
openPlaidView();
}
}, [account?.validated]);

Expand All @@ -115,7 +115,7 @@ function BankAccountStep({
[bankInfoStepKeys.PLAID_ACCOUNT_ID]: '',
[bankInfoStepKeys.PLAID_ACCESS_TOKEN]: '',
};
ReimbursementAccount.updateReimbursementAccountDraft(bankAccountData);
updateReimbursementAccountDraft(bankAccountData);
};

if (subStep === CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID || subStep === CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL) {
Expand Down Expand Up @@ -152,7 +152,7 @@ function BankAccountStep({
>
{!!plaidDesktopMessage && (
<View style={[styles.mt3, styles.flexRow, styles.justifyContentBetween]}>
<TextLink onPress={() => Link.openExternalLinkWithToken(bankAccountRoute)}>{translate(plaidDesktopMessage)}</TextLink>
<TextLink onPress={() => openExternalLinkWithToken(bankAccountRoute)}>{translate(plaidDesktopMessage)}</TextLink>
</View>
)}
{!!personalBankAccounts.length && (
Expand Down Expand Up @@ -186,7 +186,7 @@ function BankAccountStep({
return;
}
removeExistingBankAccountDetails();
BankAccounts.openPlaidView();
openPlaidView();
}}
shouldShowRightIcon
wrapperStyle={[styles.sectionMenuItemTopDescription]}
Expand All @@ -203,7 +203,7 @@ function BankAccountStep({
return;
}
removeExistingBankAccountDetails();
BankAccounts.setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL);
setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL);
}}
shouldShowRightIcon
wrapperStyle={[styles.sectionMenuItemTopDescription]}
Expand All @@ -213,7 +213,7 @@ function BankAccountStep({
<View style={[styles.mv0, styles.mh5, styles.flexRow, styles.justifyContentBetween]}>
<TextLink href={CONST.OLD_DOT_PUBLIC_URLS.PRIVACY_URL}>{translate('common.privacy')}</TextLink>
<PressableWithoutFeedback
onPress={() => Link.openExternalLink(CONST.ENCRYPTION_AND_SECURITY_HELP_URL)}
onPress={() => openExternalLink(CONST.ENCRYPTION_AND_SECURITY_HELP_URL)}
style={[styles.flexRow, styles.alignItemsCenter]}
accessibilityLabel={translate('bankAccount.yourDataIsSecure')}
>
Expand All @@ -234,10 +234,10 @@ function BankAccountStep({
isVisible={!!isValidateCodeActionModalVisible}
hasMagicCodeBeenSent={hasMagicCodeBeenSent}
validatePendingAction={loginData?.pendingFields?.validateCodeSent}
sendValidateCode={() => User.requestValidateCodeAction()}
handleSubmitForm={(validateCode) => User.validateSecondaryLogin(loginList, contactMethod, validateCode)}
validateError={!isEmptyObject(validateLoginError) ? validateLoginError : ErrorUtils.getLatestErrorField(loginData, 'validateCodeSent')}
clearError={() => User.clearContactMethodErrors(contactMethod, !isEmptyObject(validateLoginError) ? 'validateLogin' : 'validateCodeSent')}
sendValidateCode={() => requestValidateCodeAction()}
handleSubmitForm={(validateCode) => validateSecondaryLogin(loginList, contactMethod, validateCode)}
validateError={!isEmptyObject(validateLoginError) ? validateLoginError : getLatestErrorField(loginData, 'validateCodeSent')}
clearError={() => clearContactMethodErrors(contactMethod, !isEmptyObject(validateLoginError) ? 'validateLogin' : 'validateCodeSent')}
onClose={() => toggleValidateCodeActionModal?.(false)}
/>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import useSubStep from '@hooks/useSubStep';
import * as FormActions from '@libs/actions/FormActions';
import {clearDraftValues} from '@libs/actions/FormActions';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -83,7 +83,7 @@ function InternationalDepositAccountContent({privatePersonalDetails, corpayField
}, [topMostCentralPane]);

const handleFinishStep = useCallback(() => {
FormActions.clearDraftValues(ONYXKEYS.FORMS.INTERNATIONAL_BANK_ACCOUNT_FORM);
clearDraftValues(ONYXKEYS.FORMS.INTERNATIONAL_BANK_ACCOUNT_FORM);
goBack();
}, [goBack]);

Expand All @@ -105,14 +105,14 @@ function InternationalDepositAccountContent({privatePersonalDetails, corpayField

// Clicking back on the first screen should dismiss the modal
if (screenIndex === CONST.CORPAY_FIELDS.INDEXES.MAPPING.COUNTRY_SELECTOR) {
FormActions.clearDraftValues(ONYXKEYS.FORMS.INTERNATIONAL_BANK_ACCOUNT_FORM);
clearDraftValues(ONYXKEYS.FORMS.INTERNATIONAL_BANK_ACCOUNT_FORM);
goBack();
return;
}

// Clicking back on the success screen should dismiss the modal
if (screenIndex === CONST.CORPAY_FIELDS.INDEXES.MAPPING.SUCCESS) {
FormActions.clearDraftValues(ONYXKEYS.FORMS.INTERNATIONAL_BANK_ACCOUNT_FORM);
clearDraftValues(ONYXKEYS.FORMS.INTERNATIONAL_BANK_ACCOUNT_FORM);
goBack();
return;
}
Expand Down
Loading

0 comments on commit b386ff5

Please sign in to comment.