Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e47f246
migrate BaseValidateCodeForm to TypeScript
JKobrynski Jan 30, 2024
32e8322
migrate ValidateCodeForm to TypeScript
JKobrynski Jan 30, 2024
be04e4f
improve code structure
JKobrynski Jan 30, 2024
9cd4355
apply suggested changes
JKobrynski Jan 31, 2024
97d9c2e
apply suggested changes
JKobrynski Jan 31, 2024
e1ff833
Merge branch 'main' into migrateValidateCodeFormToTypeScript
JKobrynski Feb 1, 2024
4b77282
apply suggested changes
JKobrynski Feb 1, 2024
1c037dd
Merge branch 'main' into migrateValidateCodeFormToTypeScript
JKobrynski Feb 7, 2024
ee28929
remove undefined type from formatPhoneNumber
JKobrynski Feb 7, 2024
3d04daf
remove isEmptyObject from ChangeExpensifyLoginLink
JKobrynski Feb 7, 2024
4fc41f4
simplify needToClearError type
JKobrynski Feb 7, 2024
d55e22d
remove null from ref types
JKobrynski Feb 7, 2024
f728ff0
replace Boolean() with isEmptyObject()
JKobrynski Feb 7, 2024
be5d1ed
remove unnecessary isEmptyObject check
JKobrynski Feb 7, 2024
d662f32
modify setFormError call for consistency
JKobrynski Feb 7, 2024
fa9a187
Merge branch 'main' into migrateValidateCodeFormToTypeScript
JKobrynski Feb 8, 2024
ffc805f
Merge branch 'main' into migrateValidateCodeFormToTypeScript
JKobrynski Feb 9, 2024
d62923e
Merge branch 'main' into migrateValidateCodeFormToTypeScript
JKobrynski Feb 20, 2024
334f02b
apply suggested changes
JKobrynski Feb 20, 2024
c632fd2
Merge branch 'main' into migrateValidateCodeFormToTypeScript
JKobrynski Feb 21, 2024
d3fc423
apply suggested changes
JKobrynski Feb 21, 2024
3011c3e
remove unused @ts-expect-error from ChoseSSOOrMagicCode
JKobrynski Feb 21, 2024
ac477ea
fix type error in RoomMembersPage
JKobrynski Feb 21, 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/components/LocaleContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type LocaleContextProps = {

/** Returns a locally converted phone number for numbers from the same region
* and an internationally converted phone number with the country code for numbers from other regions */
formatPhoneNumber: (phoneNumber: string | undefined) => string;
formatPhoneNumber: (phoneNumber: string) => string;

/** Gets the locale digit corresponding to a standard digit */
toLocaleDigit: (digit: string) => string;
Expand Down
1 change: 1 addition & 0 deletions src/components/MagicCodeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,4 @@ function MagicCodeInput(
MagicCodeInput.displayName = 'MagicCodeInput';

export default forwardRef(MagicCodeInput);
export type {MagicCodeInputHandle};
2 changes: 1 addition & 1 deletion src/components/withToggleVisibilityView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import getComponentDisplayName from '@libs/getComponentDisplayName';

type WithToggleVisibilityViewProps = {
/** Whether the content is visible. */
isVisible?: boolean;
isVisible: boolean;
};

export default function withToggleVisibilityView<TProps extends WithToggleVisibilityViewProps, TRef>(
Expand Down
2 changes: 1 addition & 1 deletion src/libs/LocalePhoneNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Onyx.connect({
* Returns a locally converted phone number for numbers from the same region
* and an internationally converted phone number with the country code for numbers from other regions
*/
function formatPhoneNumber(number: string | undefined): string {
function formatPhoneNumber(number: string): string {
if (!number) {
return '';
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RoomMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) {
isSelected: selectedMembers.includes(accountID),
isDisabled: accountID === session?.accountID,
text: formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(details)),
alternateText: formatPhoneNumber(details.login),
alternateText: details?.login ? formatPhoneNumber(details.login) : '',
icons: [
{
source: UserUtils.getAvatar(details.avatar, accountID),
Expand Down
8 changes: 4 additions & 4 deletions src/pages/settings/Security/CloseAccountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ function CloseAccountPage({session}: CloseAccountPageProps) {
const sanitizePhoneOrEmail = (phoneOrEmail: string): string => phoneOrEmail.replace(/\s+/g, '').toLowerCase();

const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM> => {
const userEmailOrPhone = formatPhoneNumber(session?.email);
const userEmailOrPhone = session?.email ? formatPhoneNumber(session.email) : null;
const errors = ValidationUtils.getFieldRequiredErrors(values, ['phoneOrEmail']);

if (values.phoneOrEmail && sanitizePhoneOrEmail(userEmailOrPhone) !== sanitizePhoneOrEmail(values.phoneOrEmail)) {
if (values.phoneOrEmail && userEmailOrPhone && sanitizePhoneOrEmail(userEmailOrPhone) !== sanitizePhoneOrEmail(values.phoneOrEmail)) {
errors.phoneOrEmail = 'closeAccountPage.enterYourDefaultContactMethod';
}
return errors;
};

const userEmailOrPhone = formatPhoneNumber(session?.email);
const userEmailOrPhone = session?.email ? formatPhoneNumber(session.email) : null;

return (
<ScreenWrapper
Expand Down Expand Up @@ -118,7 +118,7 @@ function CloseAccountPage({session}: CloseAccountPageProps) {
role={CONST.ROLE.PRESENTATION}
containerStyles={[styles.mt5]}
autoCorrect={false}
inputMode={Str.isValidEmail(userEmailOrPhone) ? CONST.INPUT_MODE.EMAIL : CONST.INPUT_MODE.TEXT}
inputMode={userEmailOrPhone && Str.isValidEmail(userEmailOrPhone) ? CONST.INPUT_MODE.EMAIL : CONST.INPUT_MODE.TEXT}
/>
<ConfirmModal
danger
Expand Down
62 changes: 0 additions & 62 deletions src/pages/signin/ChangeExpensifyLoginLink.js

This file was deleted.

47 changes: 47 additions & 0 deletions src/pages/signin/ChangeExpensifyLoginLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Credentials} from '@src/types/onyx';

type ChangeExpensifyLoginLinkOnyxProps = {
/** The credentials of the person logging in */
credentials: OnyxEntry<Credentials>;
};

type ChangeExpensifyLoginLinkProps = ChangeExpensifyLoginLinkOnyxProps & {
onPress: () => void;
};

function ChangeExpensifyLoginLink({credentials, onPress}: ChangeExpensifyLoginLinkProps) {
const styles = useThemeStyles();
const {translate, formatPhoneNumber} = useLocalize();

return (
<View style={[styles.changeExpensifyLoginLinkContainer, styles.mt3]}>
{!!credentials?.login && <Text style={styles.mr1}>{translate('loginForm.notYou', {user: formatPhoneNumber(credentials.login)})}</Text>}
<PressableWithFeedback
style={[styles.link]}
onPress={onPress}
role={CONST.ROLE.LINK}
accessibilityLabel={translate('common.goBack')}
>
<Text style={[styles.link]}>{translate('common.goBack')}.</Text>
</PressableWithFeedback>
</View>
);
}

ChangeExpensifyLoginLink.displayName = 'ChangeExpensifyLoginLink';

export default withOnyx<ChangeExpensifyLoginLinkProps, ChangeExpensifyLoginLinkOnyxProps>({
credentials: {
key: ONYXKEYS.CREDENTIALS,
},
})(ChangeExpensifyLoginLink);
5 changes: 1 addition & 4 deletions src/pages/signin/ChooseSSOOrMagicCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ function ChooseSSOOrMagicCode({credentials, account, setIsUsingMagicCode}: Choos
}}
/>
{!!account && !isEmptyObject(account.errors) && <FormHelpMessage message={ErrorUtils.getLatestErrorMessage(account)} />}
<ChangeExpensifyLoginLink
// @ts-expect-error TODO: Remove this once https://github.com/Expensify/App/pull/35404 is merged
onPress={() => Session.clearSignInData()}
/>
<ChangeExpensifyLoginLink onPress={() => Session.clearSignInData()} />
</View>
<View style={[styles.mt5, styles.signInPageWelcomeTextContainer]}>
<Terms />
Expand Down
1 change: 0 additions & 1 deletion src/pages/signin/SignInPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ function SignInPageInner({credentials, account, activeClients = [], preferredLoc
/>
{shouldShowValidateCodeForm && (
<ValidateCodeForm
// @ts-expect-error TODO: Remove this once https://github.com/Expensify/App/pull/35404 is merged
isVisible={!shouldShowAnotherLoginPageOpenedMessage}
isUsingRecoveryCode={isUsingRecoveryCode}
setIsUsingRecoveryCode={setIsUsingRecoveryCode}
Expand Down
Loading