Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
472fc13
PLAT-536 #comment add logout #time 15m
brooketopcoder Mar 4, 2022
2ca5f17
PLAt-536 #comment fix link hover #time 5m
brooketopcoder Mar 7, 2022
80d4bbe
PLAT-536 #comment fix logo size #time 15m
brooketopcoder Mar 8, 2022
c981053
PLAT-764 #comment convert svgs to components and
brooketopcoder Mar 8, 2022
43c3b70
PLAT-764 #comment remove styling from SVGs;
brooketopcoder Mar 8, 2022
29b1ee5
PLAT-764 #comment refactor narrow tool selectors
brooketopcoder Mar 8, 2022
d14ae22
PLAT-764 #comment rename svgs folder #time 5m
brooketopcoder Mar 8, 2022
0aa2bbe
PLAT-764 #comment clean up styles and svgs; #time 30m
brooketopcoder Mar 8, 2022
25087d1
PLAT-764 #comment clean-up #time 5m
brooketopcoder Mar 8, 2022
a19de5c
PALT-764 #comment clean-up #time 5m
brooketopcoder Mar 8, 2022
5485f05
PLAT-764 #comment clean-up #time 5m
brooketopcoder Mar 8, 2022
dd5275e
PLAT-764 #comment clean-up #time 5m
brooketopcoder Mar 9, 2022
ecf205e
PLAT-764 #comment clean-upo #time 5m
brooketopcoder Mar 9, 2022
ce7209a
Merge branch 'master' into PLAT-754_tools-config
brooketopcoder Mar 9, 2022
6e902ec
PLAT-754 #comment convert url configs to constants;
brooketopcoder Mar 9, 2022
83d24b8
PLAT-754 #comment create and use route
brooketopcoder Mar 10, 2022
efd8e51
PLAT-745 #comment add child routes;
brooketopcoder Mar 10, 2022
f257056
PLAT-754 #comment configure sections in content
brooketopcoder Mar 10, 2022
38ceed9
PLAT-754 #comment replace route config
brooketopcoder Mar 10, 2022
0047be9
PLAT-754 #comment hide sections for tools
brooketopcoder Mar 10, 2022
9c467d3
PLAT-754 #comment fix styling for expanded
brooketopcoder Mar 10, 2022
6b00439
PLAT-754 #comment route provider cleanup #time 1h
brooketopcoder Mar 10, 2022
bdf45cf
PLAT-754 #comment tools narrow clean-up; #time 30m
brooketopcoder Mar 10, 2022
4420617
PLAT-764 #comment clean-up #time 5m
brooketopcoder Mar 10, 2022
a7df686
PLAT-7584 #comment clean-up #time 10m
brooketopcoder Mar 10, 2022
9478eff
POLAT-754 #comment clean-up #time 5m
brooketopcoder Mar 10, 2022
37928c7
PLAT-754 #comment clean-up #time 5m
brooketopcoder Mar 10, 2022
784461e
PLAT-754 #comment clean-up #time 5m
brooketopcoder Mar 10, 2022
9d161e8
Merge branch 'master' into PLAT-754_tools-config
brooketopcoder Mar 10, 2022
8011b5c
PLAT-754 #comment update readme #time 10m
brooketopcoder Mar 10, 2022
3070fc5
Merge branch 'master' into PLAT-754_tools-config
brooketopcoder Mar 10, 2022
9da630d
Merge branch 'master' into PLAT-754_tools-config
brooketopcoder Mar 10, 2022
fbf5296
PLAT-754 #comment fix build issues #time 10m
brooketopcoder Mar 10, 2022
74f84ba
PLAT-754 #comment clean-up #time 5m
brooketopcoder Mar 10, 2022
e5f1fc0
Merge branch 'master' into PLAT-754_tools-config
brooketopcoder Mar 11, 2022
ddad763
PLAT-754 #comment remove commented out tests #time 5m
brooketopcoder Mar 11, 2022
0687f21
PLAT-802 #comment create profile util;
brooketopcoder Mar 11, 2022
9d38a6c
PLAT-825 #comment fix profile styling;
brooketopcoder Mar 14, 2022
20411b1
Merge branch 'PLAT-802_profile-util' into PLAT-825_form-text-fields
brooketopcoder Mar 14, 2022
6373d82
PLAT-825 #comment consolidate font styles; #time 1h
brooketopcoder Mar 14, 2022
3beac2d
PLAT-828 #comment create button component;
brooketopcoder Mar 14, 2022
63b1c87
PLAT-828 #comment use axios for xhr;
brooketopcoder Mar 15, 2022
353f0d4
PLAT-828 #comment rename all services to
brooketopcoder Mar 15, 2022
2738b0e
PLAT-828 #comment add update password functions
brooketopcoder Mar 15, 2022
40f51dd
Merge branch 'PLAT-802_profile-util' into PLAT-828_profile-api
brooketopcoder Mar 15, 2022
a5288a7
PLAT-828 #comment clean-up #time 5m
brooketopcoder Mar 15, 2022
da90fd6
PLAT-828 #comment clean-up #time 10m
brooketopcoder Mar 16, 2022
322f729
PLAT-828 #comment use v3 api for pw change
brooketopcoder Mar 16, 2022
0cf4793
PLAT-828 #comment remove obsolete TODO;
brooketopcoder Mar 16, 2022
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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dependencies": {
"@datadog/browser-logs": "^4.5.0",
"@heroicons/react": "^1.0.6",
"axios": "^0.26.1",
"browser-cookies": "^1.2.0",
"classnames": "^2.3.1",
"react": "^17.0.2",
Expand Down Expand Up @@ -51,6 +52,7 @@
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.2.1",
"@types/axios": "^0.14.0",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.13",
"@types/react": "^17.0.20",
Expand Down
6 changes: 3 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { Route, Routes } from 'react-router-dom'

import { EnvironmentConfig } from './config'
import { Header } from './header'
import { AnalyticsService, LoggingService, ProfileProvider } from './lib'
import { initializeAnalytics, initializeLogger, ProfileProvider } from './lib'
import { RouteContext, RouteContextData } from './lib/route-provider'

new AnalyticsService().initialize(EnvironmentConfig)
new LoggingService().initialize(EnvironmentConfig)
initializeAnalytics(EnvironmentConfig)
initializeLogger(EnvironmentConfig)

const App: FC<{}> = () => {

Expand Down
1 change: 1 addition & 0 deletions src/config/environments/environment.default.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AppHostEnvironment } from './app-host-environment.enum'

export const EnvironmentConfigDefault: GlobalConfig = {
API: {
V3: 'https://api.topcoder-dev.com/v3',
V5: 'https://api.topcoder-dev.com/v5',
},
ENV: AppHostEnvironment.default,
Expand Down
1 change: 1 addition & 0 deletions src/config/environments/environment.prod.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { EnvironmentConfigDefault } from './environment.default.config'
export const EnvironmentConfigProd: GlobalConfig = {
...EnvironmentConfigDefault,
API: {
V3: 'https://api.topcoder.com/v3',
V5: 'https://api.topcoder.com/v5',
},
ENV: AppHostEnvironment.prod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$overlaySquare: calc($pad-xxxxl + 2 * $border);

.profile-avater,
.profile-avatar,
.overlay {
cursor: pointer;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dispatch, FC, SetStateAction, useContext, useState } from 'react'

import { Avatar, IconOutline, LoggingService, ProfileContext, ProfileContextData } from '../../../../../lib'
import { Avatar, IconOutline, logInfo , ProfileContext, ProfileContextData } from '../../../../../lib'

import { ProfilePanel } from './profile-panel'
import styles from './ProfileLoggedIn.module.scss'
Expand All @@ -9,10 +9,9 @@ const ProfileLoggedIn: FC<{}> = () => {

const { profile }: ProfileContextData = useContext(ProfileContext)
const [profilePanelOpen, setProfilePanelOpen]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)
const logger: LoggingService = new LoggingService()

if (!profile) {
logger.logInfo('tried to render the logged in profile w/out a profile')
logInfo('tried to render the logged in profile w/out a profile')
return <></>
}

Expand All @@ -22,7 +21,7 @@ const ProfileLoggedIn: FC<{}> = () => {

return (
<>
<div className={styles['profile-avater']} onClick={() => toggleProfilePanel()} >
<div className={styles['profile-avatar']} onClick={() => toggleProfilePanel()} >
<Avatar
firstName={profile.firstName}
lastName={profile.lastName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { FC, useContext } from 'react'
import { Link } from 'react-router-dom'

import {
AuthenticationUrlConfig,
logoutUrl,
ProfileContext,
ProfileContextData,
ProfileRouteConfig,
profileRoute,
} from '../../../../../../lib'

import styles from './ProfilePanel.module.scss'
Expand All @@ -31,11 +31,11 @@ const ProfilePanel: FC<ProfilePanelProps> = (props: ProfilePanelProps) => {
<Link
className={styles.profile}
onClick={() => props.toggleProfilePanel()}
to={ProfileRouteConfig.profile}
to={profileRoute}
>
My Profile
</Link>
<a href={AuthenticationUrlConfig.logout} className={styles.logout}>
<a href={logoutUrl} className={styles.logout}>
Log Out
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
import classNames from 'classnames'
import { FC } from 'react'

import { AuthenticationUrlConfig, routeRoot } from '../../../../../lib'
import { Button, loginUrl, routeRoot, signupUrl } from '../../../../../lib'
import '../../../../../lib/styles/index.scss'

import styles from './ProfileNotLoggedIn.module.scss'

const ProfileNotLoggedIn: FC<{}> = () => {

const buttonClass: string = 'button'

return (
<>
<a
className={classNames(buttonClass, styles.login)}
href={AuthenticationUrlConfig.login(routeRoot)}
>
Log In
</a>
<a
className={classNames(buttonClass, 'all-white', styles.signup)}
href={AuthenticationUrlConfig.signup(routeRoot)}
>
Sign Up
</a>
<Button
className={styles.login}
label='Log In'
size='sm'
buttonStyle='text'
url={loginUrl(routeRoot)}
/>
<Button
className={styles.signup}
label='Sign Up'
size='sm'
buttonStyle='tertiary'
url={signupUrl(routeRoot)}
/>
</>
)
}
Expand Down
57 changes: 57 additions & 0 deletions src/lib/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import classNames from 'classnames'
import { FC } from 'react'

interface ButtonProps {
readonly buttonStyle?: 'primary' | 'secondary' | 'tertiary' | 'text'
readonly className?: string
readonly disable?: boolean
readonly label: string
readonly onClick?: (event?: any) => void
readonly size?: 'sm' | 'md' | 'lg' | 'xl'
readonly type?: 'button' | 'submit'
readonly url?: string
}

const Button: FC<ButtonProps> = (props: ButtonProps) => {

const classes: string = classNames(
'button',
props.className,
props.buttonStyle || 'primary',
`button-${props.size || 'md'}`
)

// if there is a url, this is a link button
if (!!props.url) {
return (
<a
className={classes}
href={props.url}
>
{props.label}
</a>
)
}

// if there is no url and no click handler, we hava a prob
if (!props.onClick) {
throw new Error(`button has neither a url or a click handler`)
}

// create a safe click handler that isn't null so the compiler
// doesn't complain
const clickHandler: (event: any) => void = props.onClick

return (
<button
className={classes}
disabled={!!props.disable}
onClick={event => clickHandler(event)}
type={props.type || 'button'}
>
{props.label}
</button>
)
}

export default Button
6 changes: 6 additions & 0 deletions src/lib/button/Buttons.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import '@testing-library/jest-dom'

describe('<Button />', () => {

test('it should render the content', () => { })
})
1 change: 1 addition & 0 deletions src/lib/button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Button } from './Button'
1 change: 1 addition & 0 deletions src/lib/form-elements/form-field/Form-Field.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ $border-xs: 1px;
@extend .ultra-small;
@include font-weight-medium;
line-height: calc($pad-md - $border);
font-style: normal;
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/lib/form-elements/form-field/text-input/Text-Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ import styles from './Text-Input.module.scss'
interface TextInputProps {
defaultValue?: string
name: string
props: { [attr: string]: string | boolean }
props: {
[attr: string]: string | boolean,
}
styleName?: string
type?: 'text' | 'password'
}

const TextInput: FC<TextInputProps> = (props: TextInputProps) => {
return (
<input
className={classNames(styles['form-input-text'], props.styleName || '')}
name={props.name}
type='text'
type={props.type || 'text'}
{...props.props}
/>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import '@testing-library/jest-dom'

describe('Analytics Functions', () => {

test('analytics', () => { })
})
17 changes: 17 additions & 0 deletions src/lib/functions/analytics-functions/analytics.functions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import TagManager from 'react-gtm-module'

import { GlobalConfig } from '../../global-config.model'

export function initialize(config: GlobalConfig): void {

// if we don't have an ID
// then tags aren't supported in this environment,
// so don't initialize anything
if (!config.TAG_MANAGER_ID) {
return
}

TagManager.initialize({
gtmId: config.TAG_MANAGER_ID,
})
}
1 change: 1 addition & 0 deletions src/lib/functions/analytics-functions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { initialize as initializeAnalytics } from './analytics.functions'
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { EnvironmentConfig } from '../../../config'

export const authentication: string = EnvironmentConfig.URL.ACCOUNTS_APP_CONNECTOR

export function login(fallback: string): string {
return `${authentication}?retUrl=${encodeURIComponent(window.location.href.match(/[^?]*/)?.[0] || fallback)}`
}

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

export function signup(fallback: string): string {
return `${login(fallback)}&regSource=tcBusiness&mode=signUp`
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '@testing-library/jest-dom'

describe('Authentication Service', () => {
describe('Authentication Functions', () => {

test('authentication', () => { })
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import cookies from 'browser-cookies'
import { configureConnector, decodeToken, getFreshToken } from 'tc-auth-lib'

import { User } from '../../../../types/tc-auth-lib'
import { EnvironmentConfig } from '../../../config'
import { logError } from '../logging-functions'

import { authentication as authenticationUrl } from './authentication-url.config'
import { CookieKeys } from './cookie-keys.enum'

interface TokenData {
tokenV2?: string
tokenV3?: string
}

configureConnector({
connectorUrl: authenticationUrl,
frameId: 'tc-accounts-iframe',
mockMode: undefined,
mockToken: undefined,
})

export async function authenticate(): Promise<string | undefined> {

return getFreshToken()
.then((tokenV3: string) => {
const tokenV2: string | null = cookies.get(CookieKeys.tcjwt)
return {
tokenV2,
tokenV3,
}
})
.catch((error: Error) => {
logError(error?.message || `${error}` || 'unknown error getting authentication token')
return {}
})
.then((token: TokenData) => {
handleRefresh(token)
return token.tokenV3
})
}

function handleRefresh(token: TokenData): number {

let time: number = Number.MAX_VALUE

const user: User = !!token.tokenV3 ? decodeToken(token.tokenV3) : {}

// if we havea tctv2, use its expiration
if (!!token.tokenV2) {
time = decodeToken(token.tokenV2).exp
}

// if we have a user, take the min btwn
// the current time and the uservl expiration
if (!!user.exp) {
time = Math.min(time, user.exp)
}

if (time < Number.MAX_VALUE) {
time = 1000 * (time - EnvironmentConfig.REAUTH_OFFSET)
time = Math.max(0, time - Date.now())
setTimeout(() => authenticate(), time)
}

return time
}
6 changes: 6 additions & 0 deletions src/lib/functions/authentication-functions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export {
login as loginUrl,
logout as logoutUrl,
signup as signupUrl,
} from './authentication-url.config'
export * from './authentication.functions'
5 changes: 5 additions & 0 deletions src/lib/functions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './analytics-functions'
export { loginUrl, logoutUrl, signupUrl } from './authentication-functions'
export * from './logging-functions'
export * from './user-functions'
export * from './xhr-functions'
5 changes: 5 additions & 0 deletions src/lib/functions/logging-functions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export {
initialize as initializeLogger,
logError,
logInfo,
} from './logging.functions'
6 changes: 6 additions & 0 deletions src/lib/functions/logging-functions/logging.functions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import '@testing-library/jest-dom'

describe('Logging Functions', () => {

test('', () => { })
})
Loading