Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
daledah committed Feb 8, 2025
1 parent 493dc43 commit 8419c0f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 34 deletions.
20 changes: 10 additions & 10 deletions src/libs/PersonalDetailsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import type {OnyxInputOrEntry, PersonalDetails, PersonalDetailsList, PrivatePers
import type {Address} from '@src/types/onyx/PrivatePersonalDetails';
import type {OnyxData} from '@src/types/onyx/Request';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import * as LocalePhoneNumber from './LocalePhoneNumber';
import * as Localize from './Localize';
import * as UserUtils from './UserUtils';
import {formatPhoneNumber} from './LocalePhoneNumber';
import {translateLocal} from './Localize';
import {generateAccountID} from './UserUtils';

type FirstAndLastName = {
firstName: string;
Expand Down Expand Up @@ -42,8 +42,8 @@ Onyx.connect({
if (!value) {
return;
}
hiddenTranslation = Localize.translateLocal('common.hidden');
youTranslation = Localize.translateLocal('common.you').toLowerCase();
hiddenTranslation = translateLocal('common.hidden');
youTranslation = translateLocal('common.you').toLowerCase();
},
});

Expand Down Expand Up @@ -130,7 +130,7 @@ function getPersonalDetailsByIDs({
if (shouldChangeUserDisplayName && currentUserAccountID === detail.accountID) {
return {
...detail,
displayName: Localize.translateLocal('common.you'),
displayName: translateLocal('common.you'),
};
}

Expand All @@ -155,7 +155,7 @@ function getAccountIDsByLogins(logins: string[]): number[] {
const currentDetail = personalDetails.find((detail) => detail?.login === login?.toLowerCase());
if (!currentDetail) {
// generate an account ID because in this case the detail is probably new, so we don't have a real accountID yet
foundAccountIDs.push(UserUtils.generateAccountID(login));
foundAccountIDs.push(generateAccountID(login));
} else {
foundAccountIDs.push(Number(currentDetail.accountID));
}
Expand Down Expand Up @@ -209,7 +209,7 @@ function getPersonalDetailsOnyxDataForOptimisticUsers(newLogins: string[], newAc
personalDetailsNew[accountID] = {
login,
accountID,
displayName: LocalePhoneNumber.formatPhoneNumber(login),
displayName: formatPhoneNumber(login),
isOptimisticPersonalDetail: true,
};

Expand Down Expand Up @@ -306,7 +306,7 @@ function getFormattedAddress(privatePersonalDetails: OnyxEntry<PrivatePersonalDe
*/
function getEffectiveDisplayName(personalDetail?: PersonalDetails): string | undefined {
if (personalDetail) {
return LocalePhoneNumber.formatPhoneNumber(personalDetail?.login ?? '') || personalDetail.displayName;
return formatPhoneNumber(personalDetail?.login ?? '') || personalDetail.displayName;
}

return undefined;
Expand All @@ -318,7 +318,7 @@ function getEffectiveDisplayName(personalDetail?: PersonalDetails): string | und
function createDisplayName(login: string, passedPersonalDetails: Pick<PersonalDetails, 'firstName' | 'lastName'> | OnyxInputOrEntry<PersonalDetails>): string {
// If we have a number like [email protected] then let's remove @expensify.sms and format it
// so that the option looks cleaner in our UI.
const userLogin = LocalePhoneNumber.formatPhoneNumber(login);
const userLogin = formatPhoneNumber(login);

if (!passedPersonalDetails) {
return userLogin;
Expand Down
29 changes: 5 additions & 24 deletions src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
import React, {useMemo} from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import {getCurrentAddress, getDefaultCountry} from '@libs/PersonalDetailsUtils';
import AddressPage from '@pages/AddressPage';
import type {FormOnyxValues} from '@src/components/Form/types';
import type {Country} from '@src/CONST';
import {updateAddress as updateAddressPersonalDetails} from '@src/libs/actions/PersonalDetails';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import type {PrivatePersonalDetails} from '@src/types/onyx';

type PersonalAddressPageOnyxProps = {
/** User's private personal details */
privatePersonalDetails: OnyxEntry<PrivatePersonalDetails>;
/** Whether app is loading */
isLoadingApp: OnyxEntry<boolean>;
};

type PersonalAddressPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.PROFILE.ADDRESS> & PersonalAddressPageOnyxProps;

/**
* Submit form to update user's first and last legal name
Expand All @@ -37,8 +23,10 @@ function updateAddress(values: FormOnyxValues<typeof ONYXKEYS.FORMS.HOME_ADDRESS
);
}

function PersonalAddressPage({privatePersonalDetails, isLoadingApp = true}: PersonalAddressPageProps) {
function PersonalAddressPage() {
const {translate} = useLocalize();
const [privatePersonalDetails] = useOnyx(ONYXKEYS.PRIVATE_PERSONAL_DETAILS);
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP);
const address = useMemo(() => getCurrentAddress(privatePersonalDetails), [privatePersonalDetails]);
const defaultCountry = getDefaultCountry();

Expand All @@ -55,11 +43,4 @@ function PersonalAddressPage({privatePersonalDetails, isLoadingApp = true}: Pers

PersonalAddressPage.displayName = 'PersonalAddressPage';

export default withOnyx<PersonalAddressPageProps, PersonalAddressPageOnyxProps>({
privatePersonalDetails: {
key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS,
},
isLoadingApp: {
key: ONYXKEYS.IS_LOADING_APP,
},
})(PersonalAddressPage);
export default PersonalAddressPage;

0 comments on commit 8419c0f

Please sign in to comment.