Skip to content

Commit a2685c4

Browse files
Merge branch 'dev' into dev-center
2 parents 3173949 + df70dab commit a2685c4

File tree

67 files changed

+562
-213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+562
-213
lines changed

src-ts/config/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export enum ToolTitle {
2+
learn = 'Learn',
23
settings = 'Account Settings',
34
work = 'Work',
45
}

src-ts/config/environments/environment.prod.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const EnvironmentConfigProd: GlobalConfig = {
1919
},
2020
DISABLED_TOOLS: [ ],
2121
ENV: AppHostEnvironment.prod,
22-
LEARN_SRC: 'https://fcc.topcoder.com:4431',
22+
LEARN_SRC: 'https://freecodecamp.topcoder.com',
2323
// TODO: Move stripe creds to .env file
2424
STRIPE: {
2525
ADMIN_TOKEN:

src-ts/header/tool-selectors/tool-selectors-narrow/tool-selector-narrow/ToolSelectorNarrow.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import classNames from 'classnames'
22
import { FC, useContext } from 'react'
33
import { Link, useLocation } from 'react-router-dom'
44

5-
import { IconOutline, PlatformRoute, routeContext, RouteContextData } from '../../../../lib'
5+
import { IconOutline, PlatformRoute, routeContext, RouteContextData, routeIsActiveTool } from '../../../../lib'
66

77
import styles from './ToolSelectorNarrow.module.scss'
88

@@ -16,13 +16,12 @@ const ToolSelectorNarrow: FC<ToolSelectorNarrowProps> = (props: ToolSelectorNarr
1616

1717
const {
1818
getPathFromRoute,
19-
isActiveTool,
2019
}: RouteContextData = useContext(routeContext)
2120

2221
const toolRoute: PlatformRoute = props.route
2322
const toolPath: string = getPathFromRoute(toolRoute)
2423
const baseClass: string = 'tool-selector-narrow'
25-
const isActive: boolean = isActiveTool(useLocation().pathname, toolRoute)
24+
const isActive: boolean = routeIsActiveTool(useLocation().pathname, toolRoute)
2625
const activeIndicaterClass: string = `${baseClass}-${isActive ? '' : 'in'}active`
2726
const hasChildren: boolean = !!toolRoute.children?.some(child => !!child.route && !isParamRoute(child.route))
2827

src-ts/header/tool-selectors/tool-selectors-wide/tool-selector-wide/ToolSelectorWide.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
PlatformRoute,
77
routeContext,
88
RouteContextData,
9+
routeIsActiveTool,
910
} from '../../../../lib'
1011
import '../../../../lib/styles/index.scss'
1112

@@ -19,15 +20,14 @@ const ToolSelectorWide: FC<ToolSelectorWideProps> = (props: ToolSelectorWideProp
1920

2021
const {
2122
getPathFromRoute,
22-
isActiveTool,
2323
isRootRoute,
2424
}: RouteContextData = useContext(routeContext)
2525

2626
const activePath: string = useLocation().pathname
2727
const toolRoute: PlatformRoute = props.route
2828
const toolPath: string = getPathFromRoute(toolRoute)
2929
const baseClass: string = 'tool-selector-wide'
30-
const isActive: boolean = isActiveTool(activePath, toolRoute)
30+
const isActive: boolean = routeIsActiveTool(activePath, toolRoute)
3131
const activeIndicatorClass: string = `${baseClass}-${isActive ? '' : 'in'}active`
3232

3333
// the tool link should be usable for all active routes except the home page

src-ts/header/utility-selectors/UtilitySelector/ProfileSelector/profile-not-logged-in/ProfileNotLoggedIn.module.scss

Lines changed: 0 additions & 12 deletions
This file was deleted.

src-ts/header/utility-selectors/UtilitySelector/ProfileSelector/profile-not-logged-in/ProfileNotLoggedIn.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
1-
import { FC } from 'react'
1+
import { FC, useContext } from 'react'
2+
import { Location, useLocation } from 'react-router-dom'
23

3-
import { authUrlLogin, authUrlSignup, Button } from '../../../../../lib'
4+
import {
5+
authUrlLogin,
6+
Button,
7+
routeContext,
8+
RouteContextData,
9+
} from '../../../../../lib'
410
import '../../../../../lib/styles/index.scss'
511

6-
import styles from './ProfileNotLoggedIn.module.scss'
7-
812
const ProfileNotLoggedIn: FC<{}> = () => {
913

14+
const routeData: RouteContextData = useContext(routeContext)
15+
const location: Location = useLocation()
16+
17+
function signUp(): void {
18+
const signupUrl: string = routeData.getSignupUrl(location.pathname, routeData.toolsRoutes)
19+
window.location.href = signupUrl
20+
}
21+
1022
return (
1123
<>
1224
<Button
1325
buttonStyle='text'
14-
className={styles.login}
26+
className='mobile-hide'
1527
label='Log In'
1628
size='md'
1729
tabIndex={-1}
18-
url={authUrlLogin}
30+
url={authUrlLogin()}
1931
/>
2032
<Button
2133
buttonStyle='tertiary'
22-
className={styles.signup}
2334
label='Sign Up'
2435
size='md'
2536
tabIndex={-1}
26-
url={authUrlSignup}
37+
onClick={signUp}
2738
/>
2839
</>
2940
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export enum AuthenticationRegistrationSource {
2+
work = 'selfService',
3+
}
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import { EnvironmentConfig } from '../../../config'
22

3+
import { AuthenticationRegistrationSource } from './authentication-reg-source.enum'
4+
35
export const authentication: string = EnvironmentConfig.URL.ACCOUNTS_APP_CONNECTOR
46

5-
export const login: string = `${authentication}?retUrl=${encodeURIComponent(window.location.href.match(/[^?]*/)?.[0] || window.location.host)}`
7+
export function login(returnUrl?: string): string {
8+
const retUrl: string = returnUrl ?? window.location.href.match(/[^?]*/)?.[0] ?? window.location.host
9+
return `${authentication}?retUrl=${encodeURIComponent(retUrl)}`
10+
}
611

712
export const logout: string = `${authentication}?logout=true&retUrl=${encodeURIComponent('https://' + window.location.host)}`
813

9-
export const signup: string = `${login}&regSource=tcBusiness&mode=signUp`
14+
export function signup(returnUrl?: string, regSource?: AuthenticationRegistrationSource): string {
15+
return `${login(returnUrl)}&mode=signUp${!!regSource ? `&regSource=${regSource}` : ''}`
16+
}

src-ts/lib/functions/authentication-functions/authentication.functions.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import cookies from 'browser-cookies'
22
import { configureConnector, decodeToken, getFreshToken } from 'tc-auth-lib'
33

44
import { User } from '../../../../types/tc-auth-lib'
5-
import { EnvironmentConfig } from '../../../config'
5+
import { EnvironmentConfig, ToolTitle } from '../../../config'
6+
import { PlatformRoute } from '../../route-provider'
67
import { logError } from '../logging-functions'
78

9+
import { AuthenticationRegistrationSource } from './authentication-reg-source.enum'
810
import { authentication as authenticationUrl } from './authentication-url.config'
911
import { CookieKeys } from './cookie-keys.enum'
1012

@@ -20,6 +22,21 @@ configureConnector({
2022
mockToken: undefined,
2123
})
2224

25+
export function getRegistrationSource(activeTool: PlatformRoute | undefined): AuthenticationRegistrationSource | undefined {
26+
27+
switch (activeTool?.title) {
28+
29+
// currently, there is no reg source for members
30+
case ToolTitle.learn:
31+
return
32+
33+
// currently, the work tool and the platform
34+
// landing page use the reg source of selfService
35+
default:
36+
return AuthenticationRegistrationSource.work
37+
}
38+
}
39+
2340
export async function initializeAsync(): Promise<string | undefined> {
2441
return getFreshToken()
2542
.then((tokenV3: string) => {
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
export * from './authentication-reg-source.enum'
12
export {
23
authentication as authUrl,
34
login as authUrlLogin,
45
logout as authUrlLogout,
56
signup as authUrlSignup,
67
} from './authentication-url.config'
7-
export { initializeAsync as authInitializeAsync } from './authentication.functions'
8+
export {
9+
getRegistrationSource as authGetRegistrationSource,
10+
initializeAsync as authInitializeAsync,
11+
} from './authentication.functions'

0 commit comments

Comments
 (0)