diff --git a/package.json b/package.json index 073bce68e..7f51356d5 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/src/App.tsx b/src/App.tsx index d81440aec..4c72f4c17 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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<{}> = () => { diff --git a/src/config/environments/environment.default.config.ts b/src/config/environments/environment.default.config.ts index 0e1c938e4..6b9b02526 100644 --- a/src/config/environments/environment.default.config.ts +++ b/src/config/environments/environment.default.config.ts @@ -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, diff --git a/src/config/environments/environment.prod.config.ts b/src/config/environments/environment.prod.config.ts index 44d87c356..14d232096 100644 --- a/src/config/environments/environment.prod.config.ts +++ b/src/config/environments/environment.prod.config.ts @@ -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, diff --git a/src/header/utility-selectors/UtilitySelector/ProfileSelector/profile-logged-in/ProfileLoggedIn.module.scss b/src/header/utility-selectors/UtilitySelector/ProfileSelector/profile-logged-in/ProfileLoggedIn.module.scss index d4c19f025..5b5626e41 100644 --- a/src/header/utility-selectors/UtilitySelector/ProfileSelector/profile-logged-in/ProfileLoggedIn.module.scss +++ b/src/header/utility-selectors/UtilitySelector/ProfileSelector/profile-logged-in/ProfileLoggedIn.module.scss @@ -2,7 +2,7 @@ $overlaySquare: calc($pad-xxxxl + 2 * $border); -.profile-avater, +.profile-avatar, .overlay { cursor: pointer; } diff --git a/src/header/utility-selectors/UtilitySelector/ProfileSelector/profile-logged-in/ProfileLoggedIn.tsx b/src/header/utility-selectors/UtilitySelector/ProfileSelector/profile-logged-in/ProfileLoggedIn.tsx index becea8cfa..6a14a8a17 100644 --- a/src/header/utility-selectors/UtilitySelector/ProfileSelector/profile-logged-in/ProfileLoggedIn.tsx +++ b/src/header/utility-selectors/UtilitySelector/ProfileSelector/profile-logged-in/ProfileLoggedIn.tsx @@ -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' @@ -9,10 +9,9 @@ const ProfileLoggedIn: FC<{}> = () => { const { profile }: ProfileContextData = useContext(ProfileContext) const [profilePanelOpen, setProfilePanelOpen]: [boolean, Dispatch>] = useState(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 <> } @@ -22,7 +21,7 @@ const ProfileLoggedIn: FC<{}> = () => { return ( <> -
toggleProfilePanel()} > +
toggleProfilePanel()} > = (props: ProfilePanelProps) => { props.toggleProfilePanel()} - to={ProfileRouteConfig.profile} + to={profileRoute} > My Profile - + Log Out
diff --git a/src/header/utility-selectors/UtilitySelector/ProfileSelector/profile-not-logged-in/ProfileNotLoggedIn.tsx b/src/header/utility-selectors/UtilitySelector/ProfileSelector/profile-not-logged-in/ProfileNotLoggedIn.tsx index 8fff4946d..4c9114d99 100644 --- a/src/header/utility-selectors/UtilitySelector/ProfileSelector/profile-not-logged-in/ProfileNotLoggedIn.tsx +++ b/src/header/utility-selectors/UtilitySelector/ProfileSelector/profile-not-logged-in/ProfileNotLoggedIn.tsx @@ -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 ( <> - - Log In - - - Sign Up - + + ) +} + +export default Button diff --git a/src/lib/button/Buttons.test.tsx b/src/lib/button/Buttons.test.tsx new file mode 100644 index 000000000..0dae599ff --- /dev/null +++ b/src/lib/button/Buttons.test.tsx @@ -0,0 +1,6 @@ +import '@testing-library/jest-dom' + +describe('
+ + ) diff --git a/src/utils/profile/profile-form.config.ts b/src/utils/profile/profile-form.config.ts new file mode 100644 index 000000000..c67b270ed --- /dev/null +++ b/src/utils/profile/profile-form.config.ts @@ -0,0 +1,77 @@ +import { emailValidator, FormDefinition, requiredIfOtherValidator, requiredValidator } from '../../lib' + +export enum FieldNames { + confirmPassword = 'confirmPassword', + currentPassword = 'password', + email = 'email', + firstName = 'firstName', + handle = 'handle', + lastName = 'lastName', + newPassword = 'newPassword', +} + +export const profileFormDef: FormDefinition = { + confirmPassword: { + label: 'Confirm Password', + name: FieldNames.confirmPassword, + placeholder: 're-type your new password', + requiredIfField: FieldNames.newPassword, + type: 'password', + validators: [ + requiredIfOtherValidator, + ], + }, + email: { + label: 'Email', + name: FieldNames.email, + type: 'text', + validators: [ + requiredValidator, + emailValidator, + ], + }, + firstName: { + label: 'First Name', + name: FieldNames.firstName, + type: 'text', + validators: [ + requiredValidator, + ], + }, + handle: { + disabled: true, + label: 'Username', + name: FieldNames.handle, + type: 'text', + validators: [], + }, + lastName: { + label: 'Last Name', + name: FieldNames.lastName, + type: 'text', + validators: [ + requiredValidator, + ], + }, + newPassword: { + dependentFields: [ + FieldNames.confirmPassword, + FieldNames.currentPassword, + ], + label: 'New Password', + name: FieldNames.newPassword, + placeholder: 'type your new password', + type: 'password', + validators: [], + }, + password: { + label: 'Current Password', + name: FieldNames.currentPassword, + placeholder: 'type your current password', + requiredIfField: FieldNames.newPassword, + type: 'password', + validators: [ + requiredIfOtherValidator, + ], + }, +} diff --git a/yarn.lock b/yarn.lock index 004ce4d37..c7862aca2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1647,6 +1647,13 @@ resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.2.tgz#ed4e0ad92306a704f9fb132a0cfcf77486dbe2bc" integrity sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig== +"@types/axios@^0.14.0": + version "0.14.0" + resolved "https://registry.yarnpkg.com/@types/axios/-/axios-0.14.0.tgz#ec2300fbe7d7dddd7eb9d3abf87999964cafce46" + integrity sha1-7CMA++fX3d1+udOr+HmZlkyvzkY= + dependencies: + axios "*" + "@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14": version "7.1.18" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.18.tgz#1a29abcc411a9c05e2094c98f9a1b7da6cdf49f8" @@ -2499,6 +2506,13 @@ axe-core@^4.3.5: resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.4.1.tgz#7dbdc25989298f9ad006645cd396782443757413" integrity sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw== +axios@*, axios@^0.26.1: + version "0.26.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.26.1.tgz#1ede41c51fcf51bbbd6fd43669caaa4f0495aaa9" + integrity sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA== + dependencies: + follow-redirects "^1.14.8" + axobject-query@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.2.0.tgz#943d47e10c0b704aa42275e20edf3722648989be" @@ -4286,7 +4300,7 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3" integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg== -follow-redirects@^1.0.0: +follow-redirects@^1.0.0, follow-redirects@^1.14.8: version "1.14.9" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7" integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==