Skip to content

Combine Sign-In/Sign-Up and Teacher Account Required gates into distinct pages #66351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
3 changes: 3 additions & 0 deletions apps/i18n/common/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"accountInformation_updateSuccess": "Account information successfully updated.",
"accountInformation_emailUpdateSuccess": "Email successfully updated.",
"accountExistingAccountCardContentWorkshopEnroll": "You’ll need to sign in to your Code.org account to enroll in this workshop.",
"accountExistingAccountCardDefaultDescription": "You'll need to sign in to your Code.org account to access this page.",
"accountKeepStudentAccountCardTitle": "Keep my student account",
"accountKeepStudentAccountCardContent": "Keep your student account and cancel your enrollment in this workshop.",
"accountKeepStudentAccountCardContentGeneric": "You will keep your student account and exit.",
Expand All @@ -42,11 +43,13 @@
"accountNeededJoinSectionCreateAccountCardContent": "You'll need to create an account on Code.org to join this section.",
"accountNeededJoinSectionSignInCardContent": "You'll need to sign in to your Code.org account to to join this section.",
"accountNewAccountCardContentWorkshopEnroll": "You’ll need to create an account on Code.org to enroll in this workshop.",
"accountNewAccountCardDefaultDescription": "You'll need to create an account on Code.org to access this page.",
"accountSwitchTeacherAccountCardTitle": "Switch to a teacher account",
"accountSwitchTeacherAccountCardContent": "Your account will be switched to a teacher account and you will be automatically enrolled.",
"accountSwitchTeacherAccountCardContentGeneric": "Your account will be switched to a teacher account.",
"accountSwitchTeacherAccountCardButton": "Switch account type",
"accountWelcomeBannerContentWorkshopEnroll": "To enroll in workshops, you’ll need a Code.org educator account.",
"accountWelcomeBannerDefaultDescription": "To access this page, you'll need a Code.org account.",
"accountWelcomeBannerHeaderLabel": "Continue with a Code.org account",
"achievements": "Achievements",
"activity": "Activity",
Expand Down
19 changes: 0 additions & 19 deletions apps/src/accounts/StudentUserTypeChangePrompt/style.module.scss

This file was deleted.

60 changes: 0 additions & 60 deletions apps/src/simpleSignUp/workshop/WorkshopLinkAccountPage.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions apps/src/sites/studio/pages/followers/join_logged_out.js

This file was deleted.

16 changes: 0 additions & 16 deletions apps/src/sites/studio/pages/followers/students_cannot_join.js

This file was deleted.

21 changes: 21 additions & 0 deletions apps/src/sites/studio/pages/gates/logged_out.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import ReactDOM from 'react-dom';

import {queryParams} from '@cdo/apps/code-studio/utils';
import LinkAccountPage from '@cdo/apps/templates/gates/LinkAccountPage';

document.addEventListener('DOMContentLoaded', function () {
const urlParams = queryParams();
const returnToUrlParam = urlParams['return_to']
? `?user_return_to=${urlParams['return_to']}`
: '';

ReactDOM.render(
<LinkAccountPage
sourcePage={urlParams['source_page']}
newAccountUrl={`/users/sign_up/account_type${returnToUrlParam}`}
existingAccountUrl={`/users/sign_in${returnToUrlParam}`}
/>,
document.getElementById('logged-out-page')
);
});
20 changes: 20 additions & 0 deletions apps/src/sites/studio/pages/gates/teacher_account_required.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import ReactDOM from 'react-dom';

import {queryParams} from '@cdo/apps/code-studio/utils';
import TeacherAccountRequiredPage from '@cdo/apps/templates/gates/TeacherAccountRequiredPage';

document.addEventListener('DOMContentLoaded', function () {
const urlParams = queryParams();
const editAccountLink = `/users/edit${
urlParams['return_to'] ? `?user_return_to=${urlParams['return_to']}` : ''
}#change-user-type-modal-form`;

ReactDOM.render(
<TeacherAccountRequiredPage
sourcePage={urlParams['source_page']}
editAccountLink={editAccountLink}
/>,
document.getElementById('teacher-account-required-page')
);
});
17 changes: 0 additions & 17 deletions apps/src/sites/studio/pages/pd/workshop_enrollment/logged_out.js

This file was deleted.

This file was deleted.

85 changes: 85 additions & 0 deletions apps/src/templates/gates/LinkAccountPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import React, {useEffect} from 'react';

import {EVENTS, PLATFORMS} from '@cdo/apps/metrics/AnalyticsConstants';
import analyticsReporter from '@cdo/apps/metrics/AnalyticsReporter';
import AccountBanner from '@cdo/apps/templates/account/AccountBanner';
import AccountCard from '@cdo/apps/templates/account/AccountCard';
import i18n from '@cdo/locale';

import styles from './gate-pages.module.scss';

const SOURCE_PAGE_TEXT: {
[key: string]: {
headerDesc: string;
newAccountDesc: string;
existingAccountDesc: string;
};
} = {
default: {
headerDesc: i18n.accountWelcomeBannerDefaultDescription(),
newAccountDesc: i18n.accountNewAccountCardDefaultDescription(),
existingAccountDesc: i18n.accountExistingAccountCardDefaultDescription(),
},
'workshop enroll': {
headerDesc: i18n.accountWelcomeBannerContentWorkshopEnroll(),
newAccountDesc: i18n.accountNewAccountCardContentWorkshopEnroll(),
existingAccountDesc: i18n.accountExistingAccountCardContentWorkshopEnroll(),
},
'join section': {
headerDesc: i18n.accountNeededJoinSectionWithoutCodeBannerLabel(),
newAccountDesc: i18n.accountNeededJoinSectionCreateAccountCardContent(),
existingAccountDesc: i18n.accountNeededJoinSectionSignInCardContent(),
},
};

const LinkAccountPage: React.FunctionComponent<{
sourcePage: string;
newAccountUrl: string;
existingAccountUrl: string;
}> = ({sourcePage, newAccountUrl, existingAccountUrl}) => {
useEffect(() => {
analyticsReporter.sendEvent(
EVENTS.LINK_ACCOUNT_PAGE_VISITED_EVENT,
{source: sourcePage},
PLATFORMS.BOTH
);
}, [sourcePage]);

const sourcePageTextKey = Object.keys(SOURCE_PAGE_TEXT).includes(sourcePage)
? sourcePage
: 'default';

return (
<main>
<div className={styles.contentContainer}>
<AccountBanner
heading={i18n.accountWelcomeBannerHeaderLabel()}
desc={SOURCE_PAGE_TEXT[sourcePageTextKey].headerDesc}
showLogo={true}
/>
<div className={styles.cardContainer}>
<AccountCard
id={'new-account-card'}
icon={'user-plus'}
title={i18n.ltiLinkAccountNewAccountCardHeaderLabel()}
content={SOURCE_PAGE_TEXT[sourcePageTextKey].newAccountDesc}
buttonText={i18n.createAccount()}
buttonType="secondary"
href={newAccountUrl}
/>
<AccountCard
id={'existing-account-card'}
icon={'user-check'}
title={i18n.ltiLinkAccountExistingAccountCardHeaderLabel()}
content={SOURCE_PAGE_TEXT[sourcePageTextKey].existingAccountDesc}
buttonText={i18n.ltiLinkAccountExistingAccountCardActionLabel()}
buttonType="primary"
href={existingAccountUrl}
/>
</div>
</div>
</main>
);
};

export default LinkAccountPage;
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ import AccountBanner from '@cdo/apps/templates/account/AccountBanner';
import AccountCard from '@cdo/apps/templates/account/AccountCard';
import i18n from '@cdo/locale';

import styles from './style.module.scss';
import styles from './gate-pages.module.scss';

const StudentUserTypeChangePrompt: React.FunctionComponent<{
userReturnTo?: string;
}> = ({userReturnTo}) => {
const TeacherAccountRequiredPage: React.FunctionComponent<{
sourcePage: string;
editAccountLink: string;
}> = ({sourcePage, editAccountLink}) => {
useEffect(() => {
analyticsReporter.sendEvent(
EVENTS.UPGRADE_TO_TEACHER_ACCOUNT_PAGE_VISITED_EVENT,
{source: 'workshop enroll'},
{source: sourcePage},
PLATFORMS.BOTH
);
}, []);
}, [sourcePage]);

return (
<main>
Expand All @@ -44,16 +45,12 @@ const StudentUserTypeChangePrompt: React.FunctionComponent<{
content={i18n.accountSwitchTeacherAccountCardContentGeneric()}
buttonText={i18n.accountSwitchTeacherAccountCardButton()}
buttonType="primary"
href={`/users/edit${
userReturnTo
? `?user_return_to=${encodeURIComponent(userReturnTo)}`
: ''
}#change-user-type-modal-form`}
href={editAccountLink}
/>
</div>
</div>
</main>
);
};

export default StudentUserTypeChangePrompt;
export default TeacherAccountRequiredPage;
Loading