diff --git a/src/components/ValidateCode/ExpiredValidateCodeModal.js b/src/components/ValidateCode/ExpiredValidateCodeModal.tsx
similarity index 73%
rename from src/components/ValidateCode/ExpiredValidateCodeModal.js
rename to src/components/ValidateCode/ExpiredValidateCodeModal.tsx
index cb880a0a2844..e99c481c044b 100644
--- a/src/components/ValidateCode/ExpiredValidateCodeModal.js
+++ b/src/components/ValidateCode/ExpiredValidateCodeModal.tsx
@@ -4,18 +4,15 @@ import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import * as Illustrations from '@components/Icon/Illustrations';
import Text from '@components/Text';
-import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
+import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';
-const propTypes = {
- ...withLocalizePropTypes,
-};
-
-function ExpiredValidateCodeModal(props) {
+function ExpiredValidateCodeModal() {
const theme = useTheme();
const styles = useThemeStyles();
+ const {translate} = useLocalize();
return (
@@ -26,9 +23,9 @@ function ExpiredValidateCodeModal(props) {
src={Illustrations.ToddBehindCloud}
/>
- {props.translate('validateCodeModal.expiredCodeTitle')}
+ {translate('validateCodeModal.expiredCodeTitle')}
- {props.translate('validateCodeModal.expiredCodeDescription')}
+ {translate('validateCodeModal.expiredCodeDescription')}
@@ -43,6 +40,5 @@ function ExpiredValidateCodeModal(props) {
);
}
-ExpiredValidateCodeModal.propTypes = propTypes;
ExpiredValidateCodeModal.displayName = 'ExpiredValidateCodeModal';
-export default withLocalize(ExpiredValidateCodeModal);
+export default ExpiredValidateCodeModal;
diff --git a/src/components/ValidateCode/JustSignedInModal.js b/src/components/ValidateCode/JustSignedInModal.tsx
similarity index 60%
rename from src/components/ValidateCode/JustSignedInModal.js
rename to src/components/ValidateCode/JustSignedInModal.tsx
index fedb92c49ee3..19e67b0c56fe 100644
--- a/src/components/ValidateCode/JustSignedInModal.js
+++ b/src/components/ValidateCode/JustSignedInModal.tsx
@@ -1,42 +1,38 @@
-import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import * as Illustrations from '@components/Icon/Illustrations';
import Text from '@components/Text';
-import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
+import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';
-const propTypes = {
- ...withLocalizePropTypes,
-
+type JustSignedInModalProps = {
/** Whether the 2FA is needed to get fully authenticated. */
- is2FARequired: PropTypes.bool.isRequired,
+ is2FARequired: boolean;
};
-function JustSignedInModal(props) {
+function JustSignedInModal({is2FARequired}: JustSignedInModalProps) {
const theme = useTheme();
const styles = useThemeStyles();
+ const {translate} = useLocalize();
return (
- {props.translate(props.is2FARequired ? 'validateCodeModal.tfaRequiredTitle' : 'validateCodeModal.successfulSignInTitle')}
+ {translate(is2FARequired ? 'validateCodeModal.tfaRequiredTitle' : 'validateCodeModal.successfulSignInTitle')}
-
- {props.translate(props.is2FARequired ? 'validateCodeModal.tfaRequiredDescription' : 'validateCodeModal.successfulSignInDescription')}
-
+ {translate(is2FARequired ? 'validateCodeModal.tfaRequiredDescription' : 'validateCodeModal.successfulSignInDescription')}
@@ -51,7 +47,6 @@ function JustSignedInModal(props) {
);
}
-JustSignedInModal.propTypes = propTypes;
JustSignedInModal.displayName = 'JustSignedInModal';
-export default withLocalize(JustSignedInModal);
+export default JustSignedInModal;
diff --git a/src/components/ValidateCode/ValidateCodeModal.js b/src/components/ValidateCode/ValidateCodeModal.tsx
similarity index 56%
rename from src/components/ValidateCode/ValidateCodeModal.js
rename to src/components/ValidateCode/ValidateCodeModal.tsx
index a2fea513f851..ce3022484345 100644
--- a/src/components/ValidateCode/ValidateCodeModal.js
+++ b/src/components/ValidateCode/ValidateCodeModal.tsx
@@ -1,47 +1,36 @@
-import lodashGet from 'lodash/get';
-import PropTypes from 'prop-types';
import React, {useCallback} from 'react';
import {View} from 'react-native';
-import {withOnyx} from 'react-native-onyx';
-import {compose} from 'underscore';
+import {OnyxEntry, withOnyx} from 'react-native-onyx';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import * as Illustrations from '@components/Icon/Illustrations';
import Text from '@components/Text';
import TextLink from '@components/TextLink';
-import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
+import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';
import * as Session from '@userActions/Session';
import ONYXKEYS from '@src/ONYXKEYS';
+import {Session as SessionType} from '@src/types/onyx';
-const propTypes = {
- /** Code to display. */
- code: PropTypes.string.isRequired,
-
- /** The ID of the account to which the code belongs. */
- accountID: PropTypes.string.isRequired,
-
+type ValidateCodeModalOnyxProps = {
/** Session of currently logged in user */
- session: PropTypes.shape({
- /** Currently logged in user authToken */
- authToken: PropTypes.string,
- }),
-
- ...withLocalizePropTypes,
+ session: OnyxEntry;
};
-const defaultProps = {
- session: {
- authToken: null,
- },
+type ValidateCodeModalProps = ValidateCodeModalOnyxProps & {
+ /** Code to display. */
+ code: string;
+ /** The ID of the account to which the code belongs. */
+ accountID: number;
};
-function ValidateCodeModal(props) {
+function ValidateCodeModal({code, accountID, session = {}}: ValidateCodeModalProps) {
const theme = useTheme();
const styles = useThemeStyles();
- const signInHere = useCallback(() => Session.signInWithValidateCode(props.accountID, props.code), [props.accountID, props.code]);
+ const signInHere = useCallback(() => Session.signInWithValidateCode(accountID, code), [accountID, code]);
+ const {translate} = useLocalize();
return (
@@ -53,20 +42,20 @@ function ValidateCodeModal(props) {
src={Illustrations.MagicCode}
/>
- {props.translate('validateCodeModal.title')}
+ {translate('validateCodeModal.title')}
-
- {props.translate('validateCodeModal.description')}
- {!lodashGet(props, 'session.authToken', null) && (
+
+ {translate('validateCodeModal.description')}
+ {!session?.authToken && (
<>
- {props.translate('validateCodeModal.or')} {props.translate('validateCodeModal.signInHere')}
+ {translate('validateCodeModal.or')} {translate('validateCodeModal.signInHere')}
>
)}
- {props.shouldShowSignInHere ? '!' : '.'}
+ .
- {props.code}
+ {code}
@@ -81,13 +70,8 @@ function ValidateCodeModal(props) {
);
}
-ValidateCodeModal.propTypes = propTypes;
-ValidateCodeModal.defaultProps = defaultProps;
ValidateCodeModal.displayName = 'ValidateCodeModal';
-export default compose(
- withLocalize,
- withOnyx({
- session: {key: ONYXKEYS.SESSION},
- }),
-)(ValidateCodeModal);
+export default withOnyx({
+ session: {key: ONYXKEYS.SESSION},
+})(ValidateCodeModal);