Skip to content

Commit

Permalink
Merge pull request #27750 from akinwale/task-27225
Browse files Browse the repository at this point in the history
fix: consolidate 'I am a Teacher' and 'Intro to School Principal' pages
  • Loading branch information
marcochavezf authored Sep 22, 2023
2 parents f2405de + a315c5b commit 0e9a1c1
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 68 deletions.
2 changes: 1 addition & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ export default {
SEARCH: 'search',
TEACHERS_UNITE: 'teachersunite',
I_KNOW_A_TEACHER: 'teachersunite/i-know-a-teacher',
INTRO_SCHOOL_PRINCIPAL: 'teachersunite/intro-school-principal',
I_AM_A_TEACHER: 'teachersunite/i-am-a-teacher',
INTRO_SCHOOL_PRINCIPAL: 'teachersunite/intro-school-principal',
DETAILS: 'details',
getDetailsRoute: (login: string) => `details?login=${encodeURIComponent(login)}`,
PROFILE: 'a/:accountID',
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/AppNavigator/ModalStackNavigators.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ const NewTeachersUniteNavigator = createModalStackNavigator([
},
{
getComponent: () => {
const IntroSchoolPrincipalPage = require('../../../pages/TeachersUnite/IntroSchoolPrincipalPage').default;
const IntroSchoolPrincipalPage = require('../../../pages/TeachersUnite/ImTeacherPage').default;
return IntroSchoolPrincipalPage;
},
name: 'Intro_School_Principal',
Expand Down
70 changes: 26 additions & 44 deletions src/pages/TeachersUnite/ImTeacherPage.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,36 @@
import React from 'react';
import ScreenWrapper from '../../components/ScreenWrapper';
import HeaderWithBackButton from '../../components/HeaderWithBackButton';
import ROUTES from '../../ROUTES';
import Navigation from '../../libs/Navigation/Navigation';
import FixedFooter from '../../components/FixedFooter';
import styles from '../../styles/styles';
import Button from '../../components/Button';
import * as Illustrations from '../../components/Icon/Illustrations';
import variables from '../../styles/variables';
import useLocalize from '../../hooks/useLocalize';
import BlockingView from '../../components/BlockingViews/BlockingView';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import ONYXKEYS from '../../ONYXKEYS';
import * as LoginUtils from '../../libs/LoginUtils';
import ImTeacherUpdateEmailPage from './ImTeacherUpdateEmailPage';
import IntroSchoolPrincipalPage from './IntroSchoolPrincipalPage';

const propTypes = {};
const propTypes = {
/** Current user session */
session: PropTypes.shape({
/** Current user primary login */
email: PropTypes.string.isRequired,
}),
};

const defaultProps = {};
const defaultProps = {
session: {
email: null,
},
};

function ImTeacherPage() {
const {translate} = useLocalize();

return (
<ScreenWrapper testID="ImTeacherPage">
<HeaderWithBackButton
title={translate('teachersUnitePage.iAmATeacher')}
onBackButtonPress={() => Navigation.goBack(ROUTES.TEACHERS_UNITE)}
/>
<BlockingView
shouldShowLink
shouldEmbedLinkWithSubtitle
icon={Illustrations.EmailAddress}
title={translate('teachersUnitePage.updateYourEmail')}
subtitle={translate('teachersUnitePage.schoolMailAsDefault')}
linkKey="teachersUnitePage.contactMethods"
onLinkPress={() => Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHODS)}
iconWidth={variables.signInLogoWidthLargeScreen}
iconHeight={variables.lhnLogoWidth}
/>
<FixedFooter style={[styles.flexGrow0]}>
<Button
success
accessibilityLabel={translate('teachersUnitePage.updateEmail')}
text={translate('teachersUnitePage.updateEmail')}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHODS)}
/>
</FixedFooter>
</ScreenWrapper>
);
function ImTeacherPage(props) {
const isLoggedInEmailPublicDomain = LoginUtils.isEmailPublicDomain(props.session.email);
return isLoggedInEmailPublicDomain ? <ImTeacherUpdateEmailPage /> : <IntroSchoolPrincipalPage />;
}

ImTeacherPage.propTypes = propTypes;
ImTeacherPage.defaultProps = defaultProps;
ImTeacherPage.displayName = 'ImTeacherPage';

export default ImTeacherPage;
export default withOnyx({
session: {
key: ONYXKEYS.SESSION,
},
})(ImTeacherPage);
54 changes: 54 additions & 0 deletions src/pages/TeachersUnite/ImTeacherUpdateEmailPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import ScreenWrapper from '../../components/ScreenWrapper';
import HeaderWithBackButton from '../../components/HeaderWithBackButton';
import ROUTES from '../../ROUTES';
import Navigation from '../../libs/Navigation/Navigation';
import FixedFooter from '../../components/FixedFooter';
import styles from '../../styles/styles';
import Button from '../../components/Button';
import * as Illustrations from '../../components/Icon/Illustrations';
import variables from '../../styles/variables';
import useLocalize from '../../hooks/useLocalize';
import BlockingView from '../../components/BlockingViews/BlockingView';

const propTypes = {};

const defaultProps = {};

function ImTeacherUpdateEmailPage() {
const {translate} = useLocalize();

return (
<ScreenWrapper testID="ImTeacherPage">
<HeaderWithBackButton
title={translate('teachersUnitePage.iAmATeacher')}
onBackButtonPress={() => Navigation.goBack(ROUTES.TEACHERS_UNITE)}
/>
<BlockingView
shouldShowLink
shouldEmbedLinkWithSubtitle
icon={Illustrations.EmailAddress}
title={translate('teachersUnitePage.updateYourEmail')}
subtitle={translate('teachersUnitePage.schoolMailAsDefault')}
linkKey="teachersUnitePage.contactMethods"
onLinkPress={() => Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHODS)}
iconWidth={variables.signInLogoWidthLargeScreen}
iconHeight={variables.lhnLogoWidth}
/>
<FixedFooter style={[styles.flexGrow0]}>
<Button
success
accessibilityLabel={translate('teachersUnitePage.updateEmail')}
text={translate('teachersUnitePage.updateEmail')}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHODS)}
/>
</FixedFooter>
</ScreenWrapper>
);
}

ImTeacherUpdateEmailPage.propTypes = propTypes;
ImTeacherUpdateEmailPage.defaultProps = defaultProps;
ImTeacherUpdateEmailPage.displayName = 'ImTeacherUpdateEmailPage';

export default ImTeacherUpdateEmailPage;
1 change: 1 addition & 0 deletions src/pages/TeachersUnite/IntroSchoolPrincipalPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const defaultProps = {

function IntroSchoolPrincipalPage(props) {
const {translate} = useLocalize();

/**
* @param {Object} values
* @param {String} values.firstName
Expand Down
23 changes: 1 addition & 22 deletions src/pages/TeachersUnite/SaveTheWorldPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@ import Text from '../../components/Text';
import MenuItem from '../../components/MenuItem';
import IllustratedHeaderPageLayout from '../../components/IllustratedHeaderPageLayout';
import * as LottieAnimations from '../../components/LottieAnimations';
import * as LoginUtils from '../../libs/LoginUtils';
import useLocalize from '../../hooks/useLocalize';

const propTypes = {
/** Current user session */
session: PropTypes.shape({
/** Current user primary login */
email: PropTypes.string.isRequired,
}),
/** The list of this user's policies */
policy: PropTypes.shape({
/** The user's role in the policy */
Expand All @@ -31,25 +25,13 @@ const propTypes = {
};

const defaultProps = {
session: {
email: null,
},
policy: {},
};

function SaveTheWorldPage(props) {
const {translate} = useLocalize();
const isLoggedInEmailPublicDomain = LoginUtils.isEmailPublicDomain(props.session.email);
const isTeacherAlreadyInvited = !_.isUndefined(props.policy) && props.policy.role === CONST.POLICY.ROLE.USER;

const handleNavigation = () => {
if (isLoggedInEmailPublicDomain) {
Navigation.navigate(ROUTES.I_AM_A_TEACHER);
} else {
Navigation.navigate(ROUTES.INTRO_SCHOOL_PRINCIPAL);
}
};

return (
<IllustratedHeaderPageLayout
shouldShowBackButton
Expand All @@ -73,7 +55,7 @@ function SaveTheWorldPage(props) {
<MenuItem
shouldShowRightIcon
title={translate('teachersUnitePage.iAmATeacher')}
onPress={handleNavigation}
onPress={() => Navigation.navigate(ROUTES.I_AM_A_TEACHER)}
/>
)}
</IllustratedHeaderPageLayout>
Expand All @@ -85,9 +67,6 @@ SaveTheWorldPage.defaultProps = defaultProps;
SaveTheWorldPage.displayName = 'SaveTheWorldPage';

export default withOnyx({
session: {
key: ONYXKEYS.SESSION,
},
policy: {
key: () => `${ONYXKEYS.COLLECTION.POLICY}${CONST.TEACHERS_UNITE.POLICY_ID}`,
},
Expand Down

0 comments on commit 0e9a1c1

Please sign in to comment.