From 6007a0011b3ee7bc1a1752e063a75cb2a9439996 Mon Sep 17 00:00:00 2001 From: s-alves10 Date: Mon, 15 Jan 2024 08:29:12 -0600 Subject: [PATCH 1/4] refactor: migrate TeachersUnite to TS --- .../{ImTeacherPage.js => ImTeacherPage.tsx} | 25 +-- ...ilPage.js => ImTeacherUpdateEmailPage.tsx} | 6 - .../TeachersUnite/IntroSchoolPrincipalPage.js | 157 ------------------ .../IntroSchoolPrincipalPage.tsx | 153 +++++++++++++++++ ...owATeacherPage.js => KnowATeacherPage.tsx} | 61 ++++--- ...veTheWorldPage.js => SaveTheWorldPage.tsx} | 0 6 files changed, 190 insertions(+), 212 deletions(-) rename src/pages/TeachersUnite/{ImTeacherPage.js => ImTeacherPage.tsx} (56%) rename src/pages/TeachersUnite/{ImTeacherUpdateEmailPage.js => ImTeacherUpdateEmailPage.tsx} (93%) delete mode 100644 src/pages/TeachersUnite/IntroSchoolPrincipalPage.js create mode 100644 src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx rename src/pages/TeachersUnite/{KnowATeacherPage.js => KnowATeacherPage.tsx} (75%) rename src/pages/TeachersUnite/{SaveTheWorldPage.js => SaveTheWorldPage.tsx} (100%) diff --git a/src/pages/TeachersUnite/ImTeacherPage.js b/src/pages/TeachersUnite/ImTeacherPage.tsx similarity index 56% rename from src/pages/TeachersUnite/ImTeacherPage.js rename to src/pages/TeachersUnite/ImTeacherPage.tsx index 62cd4529611b..aa26d82c1227 100644 --- a/src/pages/TeachersUnite/ImTeacherPage.js +++ b/src/pages/TeachersUnite/ImTeacherPage.tsx @@ -1,35 +1,26 @@ -import PropTypes from 'prop-types'; import React from 'react'; +import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import * as LoginUtils from '@libs/LoginUtils'; import ONYXKEYS from '@src/ONYXKEYS'; +import type {Session} from '@src/types/onyx'; import ImTeacherUpdateEmailPage from './ImTeacherUpdateEmailPage'; import IntroSchoolPrincipalPage from './IntroSchoolPrincipalPage'; -const propTypes = { - /** Current user session */ - session: PropTypes.shape({ - /** Current user primary login */ - email: PropTypes.string.isRequired, - }), +type ImTeacherPageOnyxProps = { + session: OnyxEntry; }; -const defaultProps = { - session: { - email: null, - }, -}; +type ImTeacherPageProps = ImTeacherPageOnyxProps; -function ImTeacherPage(props) { - const isLoggedInEmailPublicDomain = LoginUtils.isEmailPublicDomain(props.session.email); +function ImTeacherPage(props: ImTeacherPageProps) { + const isLoggedInEmailPublicDomain = LoginUtils.isEmailPublicDomain(props.session?.email ?? ''); return isLoggedInEmailPublicDomain ? : ; } -ImTeacherPage.propTypes = propTypes; -ImTeacherPage.defaultProps = defaultProps; ImTeacherPage.displayName = 'ImTeacherPage'; -export default withOnyx({ +export default withOnyx({ session: { key: ONYXKEYS.SESSION, }, diff --git a/src/pages/TeachersUnite/ImTeacherUpdateEmailPage.js b/src/pages/TeachersUnite/ImTeacherUpdateEmailPage.tsx similarity index 93% rename from src/pages/TeachersUnite/ImTeacherUpdateEmailPage.js rename to src/pages/TeachersUnite/ImTeacherUpdateEmailPage.tsx index 994350629da6..9433aba2f299 100644 --- a/src/pages/TeachersUnite/ImTeacherUpdateEmailPage.js +++ b/src/pages/TeachersUnite/ImTeacherUpdateEmailPage.tsx @@ -11,10 +11,6 @@ import Navigation from '@libs/Navigation/Navigation'; import variables from '@styles/variables'; import ROUTES from '@src/ROUTES'; -const propTypes = {}; - -const defaultProps = {}; - function ImTeacherUpdateEmailPage() { const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -49,8 +45,6 @@ function ImTeacherUpdateEmailPage() { ); } -ImTeacherUpdateEmailPage.propTypes = propTypes; -ImTeacherUpdateEmailPage.defaultProps = defaultProps; ImTeacherUpdateEmailPage.displayName = 'ImTeacherUpdateEmailPage'; export default ImTeacherUpdateEmailPage; diff --git a/src/pages/TeachersUnite/IntroSchoolPrincipalPage.js b/src/pages/TeachersUnite/IntroSchoolPrincipalPage.js deleted file mode 100644 index e0715da9e5ef..000000000000 --- a/src/pages/TeachersUnite/IntroSchoolPrincipalPage.js +++ /dev/null @@ -1,157 +0,0 @@ -import Str from 'expensify-common/lib/str'; -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 _ from 'underscore'; -import FormProvider from '@components/Form/FormProvider'; -import InputWrapper from '@components/Form/InputWrapper'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import Text from '@components/Text'; -import TextInput from '@components/TextInput'; -import useEnvironment from '@hooks/useEnvironment'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import * as ErrorUtils from '@libs/ErrorUtils'; -import * as LoginUtils from '@libs/LoginUtils'; -import Navigation from '@libs/Navigation/Navigation'; -import * as ValidationUtils from '@libs/ValidationUtils'; -import TeachersUnite from '@userActions/TeachersUnite'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; - -const propTypes = { - /** Login list for the user that is signed in */ - loginList: PropTypes.shape({ - /** Phone/Email associated with user */ - partnerUserID: PropTypes.string, - }), -}; - -const defaultProps = { - loginList: {}, -}; - -function IntroSchoolPrincipalPage(props) { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - const {isProduction} = useEnvironment(); - - /** - * @param {Object} values - * @param {String} values.firstName - * @param {String} values.partnerUserID - * @param {String} values.lastName - */ - const onSubmit = (values) => { - const policyID = isProduction ? CONST.TEACHERS_UNITE.PROD_POLICY_ID : CONST.TEACHERS_UNITE.TEST_POLICY_ID; - TeachersUnite.addSchoolPrincipal(values.firstName.trim(), values.partnerUserID.trim(), values.lastName.trim(), policyID); - }; - - /** - * @param {Object} values - * @param {String} values.firstName - * @param {String} values.partnerUserID - * @returns {Object} - An object containing the errors for each inputID - */ - const validate = useCallback( - (values) => { - const errors = {}; - - if (!ValidationUtils.isValidLegalName(values.firstName)) { - ErrorUtils.addErrorMessage(errors, 'firstName', translate('privatePersonalDetails.error.hasInvalidCharacter')); - } else if (_.isEmpty(values.firstName)) { - ErrorUtils.addErrorMessage(errors, 'firstName', translate('bankAccount.error.firstName')); - } - if (!ValidationUtils.isValidLegalName(values.lastName)) { - ErrorUtils.addErrorMessage(errors, 'lastName', translate('privatePersonalDetails.error.hasInvalidCharacter')); - } else if (_.isEmpty(values.lastName)) { - ErrorUtils.addErrorMessage(errors, 'lastName', translate('bankAccount.error.lastName')); - } - if (_.isEmpty(values.partnerUserID)) { - ErrorUtils.addErrorMessage(errors, 'partnerUserID', translate('teachersUnitePage.error.enterEmail')); - } - if (!_.isEmpty(values.partnerUserID) && lodashGet(props.loginList, values.partnerUserID.toLowerCase())) { - ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.tryDifferentEmail'); - } - if (!_.isEmpty(values.partnerUserID) && !Str.isValidEmail(values.partnerUserID)) { - ErrorUtils.addErrorMessage(errors, 'partnerUserID', translate('teachersUnitePage.error.enterValidEmail')); - } - if (!_.isEmpty(values.partnerUserID) && LoginUtils.isEmailPublicDomain(values.partnerUserID)) { - ErrorUtils.addErrorMessage(errors, 'partnerUserID', translate('teachersUnitePage.error.tryDifferentEmail')); - } - - return errors; - }, - [props.loginList, translate], - ); - - return ( - - Navigation.goBack(ROUTES.TEACHERS_UNITE)} - /> - - {translate('teachersUnitePage.schoolPrincipalVerfiyExpense')} - - - - - - - - - - - - ); -} - -IntroSchoolPrincipalPage.propTypes = propTypes; -IntroSchoolPrincipalPage.defaultProps = defaultProps; -IntroSchoolPrincipalPage.displayName = 'IntroSchoolPrincipalPage'; - -export default withOnyx({ - loginList: {key: ONYXKEYS.LOGIN_LIST}, -})(IntroSchoolPrincipalPage); diff --git a/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx b/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx new file mode 100644 index 000000000000..7e595766fecc --- /dev/null +++ b/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx @@ -0,0 +1,153 @@ +import Str from 'expensify-common/lib/str'; +import React, {useCallback} from 'react'; +import {View} from 'react-native'; +import {withOnyx} from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx/lib/types'; +import FormProvider from '@components/Form/FormProvider'; +import InputWrapper from '@components/Form/InputWrapper'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import Text from '@components/Text'; +import TextInput from '@components/TextInput'; +import useEnvironment from '@hooks/useEnvironment'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as ErrorUtils from '@libs/ErrorUtils'; +import * as LoginUtils from '@libs/LoginUtils'; +import Navigation from '@libs/Navigation/Navigation'; +import * as ValidationUtils from '@libs/ValidationUtils'; +import TeachersUnite from '@userActions/TeachersUnite'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; +import type {LoginList} from '@src/types/onyx'; + +type IntroSchoolPrincipalFormData = { + firstName: string; + lastName: string; + partnerUserID: string; +}; + +type IntroSchoolPrincipalPageOnyxProps = { + loginList: OnyxEntry; +}; + +type IntroSchoolPrincipalPageProps = IntroSchoolPrincipalPageOnyxProps; + +function IntroSchoolPrincipalPage(props: IntroSchoolPrincipalPageProps) { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + const {isProduction} = useEnvironment(); + + /** + */ + const onSubmit = (values: IntroSchoolPrincipalFormData) => { + const policyID = isProduction ? CONST.TEACHERS_UNITE.PROD_POLICY_ID : CONST.TEACHERS_UNITE.TEST_POLICY_ID; + TeachersUnite.addSchoolPrincipal(values.firstName.trim(), values.partnerUserID.trim(), values.lastName.trim(), policyID); + }; + + /** + * @returns {Object} - An object containing the errors for each inputID + */ + const validate = useCallback( + (values: IntroSchoolPrincipalFormData) => { + const errors = {}; + + if (!ValidationUtils.isValidLegalName(values.firstName)) { + ErrorUtils.addErrorMessage(errors, 'firstName', 'privatePersonalDetails.error.hasInvalidCharacter'); + } else if (values.firstName) { + ErrorUtils.addErrorMessage(errors, 'firstName', 'bankAccount.error.firstName'); + } + if (!ValidationUtils.isValidLegalName(values.lastName)) { + ErrorUtils.addErrorMessage(errors, 'lastName', 'privatePersonalDetails.error.hasInvalidCharacter'); + } else if (values.lastName) { + ErrorUtils.addErrorMessage(errors, 'lastName', 'bankAccount.error.lastName'); + } + if (values.partnerUserID) { + ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.enterEmail'); + } + if (!values.partnerUserID && props.loginList?.[values.partnerUserID.toLowerCase()]) { + ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.tryDifferentEmail'); + } + if (!values.partnerUserID && !Str.isValidEmail(values.partnerUserID)) { + ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.enterValidEmail'); + } + if (!values.partnerUserID && LoginUtils.isEmailPublicDomain(values.partnerUserID)) { + ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.tryDifferentEmail'); + } + + return errors; + }, + [props.loginList], + ); + + return ( + + Navigation.goBack(ROUTES.TEACHERS_UNITE)} + /> + {/* @ts-expect-error TODO: Remove this once FormProvider (https://github.com/Expensify/App/issues/31972) is migrated to TypeScript. */} + + <> + {translate('teachersUnitePage.schoolPrincipalVerfiyExpense')} + + + + + + + + + + + + + ); +} + +IntroSchoolPrincipalPage.displayName = 'IntroSchoolPrincipalPage'; + +export default withOnyx({ + loginList: {key: ONYXKEYS.LOGIN_LIST}, +})(IntroSchoolPrincipalPage); diff --git a/src/pages/TeachersUnite/KnowATeacherPage.js b/src/pages/TeachersUnite/KnowATeacherPage.tsx similarity index 75% rename from src/pages/TeachersUnite/KnowATeacherPage.js rename to src/pages/TeachersUnite/KnowATeacherPage.tsx index 5b8c9455ba38..b10f5d4e8d24 100644 --- a/src/pages/TeachersUnite/KnowATeacherPage.js +++ b/src/pages/TeachersUnite/KnowATeacherPage.tsx @@ -1,10 +1,8 @@ import Str from 'expensify-common/lib/str'; -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 _ from 'underscore'; +import type {OnyxEntry} from 'react-native-onyx/lib/types'; import FormProvider from '@components/Form/FormProvider'; import InputWrapper from '@components/Form/InputWrapper'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; @@ -22,32 +20,29 @@ import TeachersUnite from '@userActions/TeachersUnite'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import type {LoginList} from '@src/types/onyx'; -const propTypes = { - /** Login list for the user that is signed in */ - loginList: PropTypes.shape({ - /** Phone/Email associated with user */ - partnerUserID: PropTypes.string, - }), +type KnowATeacherFormData = { + firstName: string; + lastName: string; + partnerUserID: string; }; -const defaultProps = { - loginList: {}, +type KnowATeacherPageOnyxProps = { + loginList: OnyxEntry; }; -function KnowATeacherPage(props) { +type KnowATeacherPageProps = KnowATeacherPageOnyxProps; + +function KnowATeacherPage(props: KnowATeacherPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const {isProduction} = useEnvironment(); /** * Submit form to pass firstName, partnerUserID and lastName - * @param {Object} values - * @param {String} values.partnerUserID - * @param {String} values.firstName - * @param {String} values.lastName */ - const onSubmit = (values) => { + const onSubmit = (values: KnowATeacherFormData) => { const phoneLogin = LoginUtils.getPhoneLogin(values.partnerUserID); const validateIfnumber = LoginUtils.validateNumber(phoneLogin); const contactMethod = (validateIfnumber || values.partnerUserID).trim().toLowerCase(); @@ -66,34 +61,34 @@ function KnowATeacherPage(props) { * @returns {Object} - An object containing the errors for each inputID */ const validate = useCallback( - (values) => { + (values: KnowATeacherFormData) => { const errors = {}; const phoneLogin = LoginUtils.getPhoneLogin(values.partnerUserID); const validateIfnumber = LoginUtils.validateNumber(phoneLogin); if (!ValidationUtils.isValidLegalName(values.firstName)) { - ErrorUtils.addErrorMessage(errors, 'firstName', translate('privatePersonalDetails.error.hasInvalidCharacter')); - } else if (_.isEmpty(values.firstName)) { - ErrorUtils.addErrorMessage(errors, 'firstName', translate('bankAccount.error.firstName')); + ErrorUtils.addErrorMessage(errors, 'firstName', 'privatePersonalDetails.error.hasInvalidCharacter'); + } else if (values.firstName) { + ErrorUtils.addErrorMessage(errors, 'firstName', 'bankAccount.error.firstName'); } if (!ValidationUtils.isValidLegalName(values.lastName)) { - ErrorUtils.addErrorMessage(errors, 'lastName', translate('privatePersonalDetails.error.hasInvalidCharacter')); - } else if (_.isEmpty(values.lastName)) { - ErrorUtils.addErrorMessage(errors, 'lastName', translate('bankAccount.error.lastName')); + ErrorUtils.addErrorMessage(errors, 'lastName', 'privatePersonalDetails.error.hasInvalidCharacter'); + } else if (values.lastName) { + ErrorUtils.addErrorMessage(errors, 'lastName', 'bankAccount.error.lastName'); } - if (_.isEmpty(values.partnerUserID)) { - ErrorUtils.addErrorMessage(errors, 'partnerUserID', translate('teachersUnitePage.error.enterPhoneEmail')); + if (values.partnerUserID) { + ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.enterPhoneEmail'); } - if (!_.isEmpty(values.partnerUserID) && lodashGet(props.loginList, validateIfnumber || values.partnerUserID.toLowerCase())) { + if (!values.partnerUserID && props.loginList?.[validateIfnumber || values.partnerUserID.toLowerCase()]) { ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.tryDifferentEmail'); } - if (!_.isEmpty(values.partnerUserID) && !(validateIfnumber || Str.isValidEmail(values.partnerUserID))) { + if (!values.partnerUserID && !(validateIfnumber || Str.isValidEmail(values.partnerUserID))) { ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'contacts.genericFailureMessages.invalidContactMethod'); } return errors; }, - [props.loginList, translate], + [props.loginList], ); return ( @@ -105,6 +100,7 @@ function KnowATeacherPage(props) { title={translate('teachersUnitePage.iKnowATeacher')} onBackButtonPress={() => Navigation.goBack(ROUTES.TEACHERS_UNITE)} /> + {/* @ts-expect-error TODO: Remove this once FormProvider (https://github.com/Expensify/App/issues/31972) is migrated to TypeScript. */} {translate('teachersUnitePage.getInTouch')} ({ loginList: {key: ONYXKEYS.LOGIN_LIST}, })(KnowATeacherPage); diff --git a/src/pages/TeachersUnite/SaveTheWorldPage.js b/src/pages/TeachersUnite/SaveTheWorldPage.tsx similarity index 100% rename from src/pages/TeachersUnite/SaveTheWorldPage.js rename to src/pages/TeachersUnite/SaveTheWorldPage.tsx From 59b16741eba95157c81ca17f465224d8a4ab8650 Mon Sep 17 00:00:00 2001 From: s-alves10 Date: Mon, 15 Jan 2024 08:49:54 -0600 Subject: [PATCH 2/4] fix: validations --- src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx | 12 ++++++------ src/pages/TeachersUnite/KnowATeacherPage.tsx | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx b/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx index 7e595766fecc..119a36a5520e 100644 --- a/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx +++ b/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx @@ -55,24 +55,24 @@ function IntroSchoolPrincipalPage(props: IntroSchoolPrincipalPageProps) { if (!ValidationUtils.isValidLegalName(values.firstName)) { ErrorUtils.addErrorMessage(errors, 'firstName', 'privatePersonalDetails.error.hasInvalidCharacter'); - } else if (values.firstName) { + } else if (!values.firstName) { ErrorUtils.addErrorMessage(errors, 'firstName', 'bankAccount.error.firstName'); } if (!ValidationUtils.isValidLegalName(values.lastName)) { ErrorUtils.addErrorMessage(errors, 'lastName', 'privatePersonalDetails.error.hasInvalidCharacter'); - } else if (values.lastName) { + } else if (!values.lastName) { ErrorUtils.addErrorMessage(errors, 'lastName', 'bankAccount.error.lastName'); } - if (values.partnerUserID) { + if (!values.partnerUserID) { ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.enterEmail'); } - if (!values.partnerUserID && props.loginList?.[values.partnerUserID.toLowerCase()]) { + if (values.partnerUserID && props.loginList?.[values.partnerUserID.toLowerCase()]) { ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.tryDifferentEmail'); } - if (!values.partnerUserID && !Str.isValidEmail(values.partnerUserID)) { + if (values.partnerUserID && !Str.isValidEmail(values.partnerUserID)) { ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.enterValidEmail'); } - if (!values.partnerUserID && LoginUtils.isEmailPublicDomain(values.partnerUserID)) { + if (values.partnerUserID && LoginUtils.isEmailPublicDomain(values.partnerUserID)) { ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.tryDifferentEmail'); } diff --git a/src/pages/TeachersUnite/KnowATeacherPage.tsx b/src/pages/TeachersUnite/KnowATeacherPage.tsx index b10f5d4e8d24..d4dddb05b190 100644 --- a/src/pages/TeachersUnite/KnowATeacherPage.tsx +++ b/src/pages/TeachersUnite/KnowATeacherPage.tsx @@ -68,21 +68,21 @@ function KnowATeacherPage(props: KnowATeacherPageProps) { if (!ValidationUtils.isValidLegalName(values.firstName)) { ErrorUtils.addErrorMessage(errors, 'firstName', 'privatePersonalDetails.error.hasInvalidCharacter'); - } else if (values.firstName) { + } else if (!values.firstName) { ErrorUtils.addErrorMessage(errors, 'firstName', 'bankAccount.error.firstName'); } if (!ValidationUtils.isValidLegalName(values.lastName)) { ErrorUtils.addErrorMessage(errors, 'lastName', 'privatePersonalDetails.error.hasInvalidCharacter'); - } else if (values.lastName) { + } else if (!values.lastName) { ErrorUtils.addErrorMessage(errors, 'lastName', 'bankAccount.error.lastName'); } - if (values.partnerUserID) { + if (!values.partnerUserID) { ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.enterPhoneEmail'); } - if (!values.partnerUserID && props.loginList?.[validateIfnumber || values.partnerUserID.toLowerCase()]) { + if (values.partnerUserID && props.loginList?.[validateIfnumber || values.partnerUserID.toLowerCase()]) { ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.tryDifferentEmail'); } - if (!values.partnerUserID && !(validateIfnumber || Str.isValidEmail(values.partnerUserID))) { + if (values.partnerUserID && !(validateIfnumber || Str.isValidEmail(values.partnerUserID))) { ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'contacts.genericFailureMessages.invalidContactMethod'); } From 5587c58408c340806fbd9c641faf477c5e3030f5 Mon Sep 17 00:00:00 2001 From: s-alves10 Date: Tue, 16 Jan 2024 08:36:44 -0600 Subject: [PATCH 3/4] fix: remove types from JSDOC --- src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx | 3 ++- src/pages/TeachersUnite/KnowATeacherPage.tsx | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx b/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx index 119a36a5520e..dd908c62f670 100644 --- a/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx +++ b/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx @@ -40,6 +40,7 @@ function IntroSchoolPrincipalPage(props: IntroSchoolPrincipalPageProps) { const {isProduction} = useEnvironment(); /** + * Submit form to pass firstName, partnerUserID and lastName */ const onSubmit = (values: IntroSchoolPrincipalFormData) => { const policyID = isProduction ? CONST.TEACHERS_UNITE.PROD_POLICY_ID : CONST.TEACHERS_UNITE.TEST_POLICY_ID; @@ -47,7 +48,7 @@ function IntroSchoolPrincipalPage(props: IntroSchoolPrincipalPageProps) { }; /** - * @returns {Object} - An object containing the errors for each inputID + * @returns - An object containing the errors for each inputID */ const validate = useCallback( (values: IntroSchoolPrincipalFormData) => { diff --git a/src/pages/TeachersUnite/KnowATeacherPage.tsx b/src/pages/TeachersUnite/KnowATeacherPage.tsx index d4dddb05b190..a309f628850a 100644 --- a/src/pages/TeachersUnite/KnowATeacherPage.tsx +++ b/src/pages/TeachersUnite/KnowATeacherPage.tsx @@ -55,10 +55,7 @@ function KnowATeacherPage(props: KnowATeacherPageProps) { }; /** - * @param {Object} values - * @param {String} values.firstName - * @param {String} values.partnerUserID - * @returns {Object} - An object containing the errors for each inputID + * @returns - An object containing the errors for each inputID */ const validate = useCallback( (values: KnowATeacherFormData) => { From eb988f3b47f921fdf464bc137d897b46a92c3582 Mon Sep 17 00:00:00 2001 From: s-alves10 Date: Thu, 18 Jan 2024 13:38:14 -0600 Subject: [PATCH 4/4] fix: remove redundant wrapper --- .../IntroSchoolPrincipalPage.tsx | 82 +++++++++---------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx b/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx index dd908c62f670..b84ad62858eb 100644 --- a/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx +++ b/src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx @@ -100,48 +100,46 @@ function IntroSchoolPrincipalPage(props: IntroSchoolPrincipalPageProps) { onSubmit={onSubmit} submitButtonText={translate('common.letsStart')} > - <> - {translate('teachersUnitePage.schoolPrincipalVerfiyExpense')} - - - - - - - - - - + {translate('teachersUnitePage.schoolPrincipalVerfiyExpense')} + + + + + + + + + );