Skip to content

TCA-845 clean /account page > dev #452

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 2 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src-ts/config/environments/environment.default.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const EnvironmentConfigDefault: EnvironmentConfigModel = {
THRIVE_PAGE: `${COMMUNITY_WEBSITE}/thrive`,
USER_PROFILE: `${COMMUNITY_WEBSITE}/members`,
WP_CONTENT: `${COMMUNITY_WEBSITE}/wp-content`,
ACC_SETTINGS: `${COMMUNITY_WEBSITE}/settings/profile`,
},
UNIVERSAL_NAV: {
URL: 'https://uni-nav.topcoder-dev.com/v1/tc-universal-nav.js',
Expand Down
1 change: 1 addition & 0 deletions src-ts/config/environments/environment.prod.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const EnvironmentConfigProd: EnvironmentConfigModel = {
THRIVE_PAGE: `${COMMUNITY_WEBSITE}/thrive`,
USER_PROFILE: `${COMMUNITY_WEBSITE}/members`,
WP_CONTENT: `${COMMUNITY_WEBSITE}/wp-content`,
ACC_SETTINGS: `${COMMUNITY_WEBSITE}/settings/profile`,
},
UNIVERSAL_NAV: {
URL: 'https://uni-nav.topcoder.com/v1/tc-universal-nav.js',
Expand Down
1 change: 1 addition & 0 deletions src-ts/lib/global-config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface GlobalConfig {
THRIVE_PAGE: string
USER_PROFILE: string
WP_CONTENT: string
ACC_SETTINGS: string
}
UNIVERSAL_NAV: {
URL: string
Expand Down
14 changes: 5 additions & 9 deletions src-ts/utils/settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import { FC, useContext } from 'react'
import { Outlet, Routes } from 'react-router-dom'

import { ContentLayout, profileContext, ProfileContextData, routeContext, RouteContextData } from '../../lib'
import { ContentLayout, routeContext, RouteContextData } from '../../lib'

export const toolTitle: string = 'Account Settings'

/**
* DEPRECATED
* TODO: Remove after some time, when clear no one links to here...
*/
const Settings: FC<{}> = () => {

const { getChildRoutes }: RouteContextData = useContext(routeContext)

const profileContextData: ProfileContextData = useContext(profileContext)
const { profile }: ProfileContextData = profileContextData

// if we don't have a profile, don't show the page
if (!profile) {
return <></>
}

return (
<ContentLayout title={toolTitle}>
<>
Expand Down
31 changes: 12 additions & 19 deletions src-ts/utils/settings/account/Account.module.scss
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
@import '../../../lib/styles/includes';

:global(.account-settings-modal) {
h2 {
margin-bottom: $space-xxl;
padding: 0 0 $space-xxl;
border-bottom: 1px solid $black-10;
}

}

/**
* DEPRECATED
* TODO: Remove after some time, when no used...
*/
.cards {
display: grid;
grid-template-columns: repeat(3, 1fr);
column-gap: $space-xxl;
margin: $space-xxl 0 0;

@include ltemd {
grid-template-columns: 1fr;
row-gap: $space-xxl;
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;

h3 {
margin-bottom: 32px;
}
}
117 changes: 16 additions & 101 deletions src-ts/utils/settings/account/Account.tsx
Original file line number Diff line number Diff line change
@@ -1,112 +1,27 @@
/* eslint-disable jsx-a11y/tabindex-no-positive */
import { Dispatch, FC, SetStateAction, useCallback, useContext, useState } from 'react'
import Modal from 'react-responsive-modal'

import {
Button,
Card,
formGetInputFields,
FormInputModel,
formOnReset,
profileContext,
ProfileContextData,
} from '../../../lib'

import { ChangePassword } from './change-password'
import { EditName, editNameFormDef } from './edit-name'
import { FC, useEffect } from 'react'
import { Button } from '../../../lib'
import styles from './Account.module.scss'
import { EnvironmentConfig } from '../../../config'

/**
* DEPRECTED
* TODO: Remove after some time, when clear no one links to here...
*/
const Account: FC<{}> = () => {

const profileContextData: ProfileContextData = useContext(profileContext)
const { profile }: ProfileContextData = profileContextData

const [editProfileOpen, setEditNameOpen]: [boolean, Dispatch<SetStateAction<boolean>>]
= useState<boolean>(false)
const [changePasswordOpen, setChangePasswordOpen]: [boolean, Dispatch<SetStateAction<boolean>>]
= useState<boolean>(false)

const toggleEditName = useCallback((): void => {
const inputs: Array<FormInputModel> = formGetInputFields(editNameFormDef.groups || [])
formOnReset(inputs)
setEditNameOpen(!editProfileOpen)
}, [editProfileOpen])

const toggleChangePassword = useCallback((): void => {
const inputs: Array<FormInputModel> = formGetInputFields(editNameFormDef.groups || [])
formOnReset(inputs)
setChangePasswordOpen(!changePasswordOpen)
}, [changePasswordOpen])

// if we don't have a profile, don't show the page
if (!profile) {
return <></>
}
// setup auto redirect in 5sec.
useEffect(() => {
setTimeout(() => {
window.location.href = EnvironmentConfig.TOPCODER_URLS.ACC_SETTINGS
}, 5000)
}, [])

return (
<div className={styles.cards}>

<Card title='Account'>
<p>
<strong>Email:</strong>
{' '}
{profile.email}
</p>
<p>
<strong>Username:</strong>
{' '}
{profile.handle}
</p>
</Card>

<Card
title='Name'
onClick={toggleEditName}
>
<p>
{profile.firstName}
{' '}
{profile.lastName}
</p>
<Button
label='edit name'
onClick={toggleEditName}
tabIndex={1}
buttonStyle='secondary'
/>
</Card>

<Modal
open={editProfileOpen}
onClose={toggleEditName}
classNames={{ modal: 'account-settings-modal' }}
>
<EditName onClose={toggleEditName} />
</Modal>

<Card
onClick={toggleChangePassword}
title='Password'
>
<p>
*******************
</p>
<Button
label='change password'
onClick={toggleChangePassword}
tabIndex={2}
buttonStyle='secondary'
/>
</Card>

<Modal
open={changePasswordOpen}
onClose={toggleChangePassword}
classNames={{ modal: 'account-settings-modal' }}
>
<ChangePassword onClose={toggleChangePassword} />
</Modal>

<h3>This page is obsolete.</h3>
<Button label='Navigate to Account Settings' url={`${EnvironmentConfig.TOPCODER_URLS.ACC_SETTINGS}`} />
<p>We will automatically redirect you in 5 seconds...</p>
</div>
)
}
Expand Down
58 changes: 0 additions & 58 deletions src-ts/utils/settings/account/change-password/ChangePassword.tsx

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions src-ts/utils/settings/account/change-password/index.ts

This file was deleted.

Loading