Skip to content

Commit

Permalink
Revert "Feature/connect/display rejected status page #889 (#918)" (#926)
Browse files Browse the repository at this point in the history
This reverts commit 5bfcd3b.
  • Loading branch information
helloanil authored Jun 29, 2024
1 parent 6f837d1 commit e497342
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 115 deletions.
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
}
]
},
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"editor.codeActionsOnSave": { "source.organizeImports": true },
"explorer.fileNesting.patterns": {
"*.ts": "${capture}.js, ${capture}.typegen.ts, ${capture}.graphql, ${capture}.generated.ts",
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts",
Expand Down
4 changes: 1 addition & 3 deletions apps/redi-connect/src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@
"profile": {
"notification": {
"deactivatedMentee": "Dear {{ name }}, your ReDI Connect profile has been deactivated by the ReDI Talent Success Team. This could be for a number of reasons. If you think this has been done by mistake, please contact us at {{ email }}. Thank you!",
"deactivatedMentor": "Dear {{ name }}, your ReDI Connect profile has been deactivated by the ReDI Talent Success Team. Likely you have not been active for a while. This means you are not visible to prospective mentees. If you want to become active as a mentor again, please contact {{ email }}. Speak soon!",
"rejectedMentee": "Dear {{ name }}, your ReDI Connect profile has been rejected by the ReDI Talent Success Team. This could be for a number of reasons. If you think this has been done by mistake, please contact us at {{ email }}. Thank you!",
"rejectedMentor": "Dear {{ name }}, your ReDI Connect profile has been rejected by the ReDI Talent Success Team. Likely you have not been active for a while. This means you are not visible to prospective mentees. If you want to become active as a mentor again, please contact {{ email }}. Speak soon!"
"deactivatedMentor": "Dear {{ name }}, your ReDI Connect profile has been deactivated by the ReDI Talent Success Team. Likely you have not been active for a while. This means you are not visible to prospective mentees. If you want to become active as a mentor again, please contact {{ email }}. Speak soon!"
}
}
},
Expand Down
20 changes: 0 additions & 20 deletions apps/redi-connect/src/components/templates/LoggedIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,6 @@ function LoggedIn({ children }: Props) {
})}
</RediNotification>
)}
{profile?.userType === 'MENTEE' &&
profile?.profileStatus === ConnectProfileStatus.Rejected && (
<RediNotification>
{t('loggedInArea.profile.notification.rejectedMentee', {
name: profile.firstName,
email:
'<a href="mailto:career@redi-school.org">career@redi-school.org</a>',
})}
</RediNotification>
)}
{profile?.userType === 'MENTOR' &&
profile?.profileStatus === ConnectProfileStatus.Deactivated && (
<RediNotification>
Expand All @@ -127,16 +117,6 @@ function LoggedIn({ children }: Props) {
})}
</RediNotification>
)}
{profile?.userType === 'MENTOR' &&
profile?.profileStatus === ConnectProfileStatus.Rejected && (
<RediNotification>
{t('loggedInArea.profile.notification.rejectedMentor', {
name: profile.firstName,
email:
'<a href="mailto:career@redi-school.org">career@redi-school.org</a>',
})}
</RediNotification>
)}
{match && isNewAcceptedMatch && (
<Modal
show={isNewAcceptedMatch}
Expand Down
41 changes: 6 additions & 35 deletions apps/redi-connect/src/pages/front/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ import * as Yup from 'yup'
import Teaser from '../../../components/molecules/Teaser'
import AccountOperation from '../../../components/templates/AccountOperation'
import { login } from '../../../services/api/api'
import {
getAccessTokenFromLocalStorage,
purgeAllSessionData,
} from '../../../services/auth/auth'
import { getAccessTokenFromLocalStorage } from '../../../services/auth/auth'

interface LoginFormValues {
username: string
Expand All @@ -52,53 +49,26 @@ const validationSchema = Yup.object({
const myTpDataFetcher = fetcher<MyTpDataQuery, MyTpDataQueryVariables>(
MyTpDataDocument
)

export default function Login() {
const history = useHistory()
const conProfileSignUpMutation = useConProfileSignUpMutation()

const [loginError, setLoginError] = useState<string>('')

const checkConProfileStatus = (conProfileStatus: string) => {
const isConProfileStatusRejected = conProfileStatus === 'REJECTED'
const isConProfileStatusDeactivated = conProfileStatus === 'DEACTIVATED'

if (isConProfileStatusRejected || isConProfileStatusDeactivated) {
purgeAllSessionData()
history.push('/front/login-result')
return
}
}

const submitForm = async () => {
// LOG THE USER IN VIA LOOPBACK
try {
const { username, password } = formik.values
const { userId } = await login(username, password)

// Load "outside" of react-query to avoid having to build
// a complex logic adhering to the rules-of-hooks.

const { conProfile } = await fetcher<
LoadMyProfileQuery,
LoadMyProfileQueryVariables
>(LoadMyProfileDocument, {
loopbackUserId: userId,
})()
const conProfileStatus = conProfile?.profileStatus
// this will logout and redirect the user to /front/login-result if their profile status is rejected/deactivated
checkConProfileStatus(conProfileStatus)

// TODO: insert proper error handling here and elsewhere. We should cover cases where we
// get values usch as myProfileResult.isError. Perhaps we-ure the error boundary logic
// that Eric has been looking into.
await login(formik.values.username, formik.values.password)
} catch (err) {
console.log(err)
formik.setSubmitting(false)
setLoginError('You entered an incorrect email, password, or both.')
return
}

const jwtToken = decodeJwt(getAccessTokenFromLocalStorage().jwtToken)
if (!jwtToken?.emailVerified) {
if (!jwtToken.emailVerified) {
formik.setSubmitting(false)
showNotification(
'Please verify your email address first. Check your inbox.',
Expand All @@ -117,6 +87,7 @@ export default function Login() {
loopbackUserId: getAccessTokenFromLocalStorage().userId,
}
)()

// TODO: insert proper error handling here and elsewhere. We should cover cases where we
// get values usch as myProfileResult.isError. Perhaps we-ure the error boundary logic
// that Eric has been looking into.
Expand Down
42 changes: 0 additions & 42 deletions apps/redi-connect/src/pages/front/login/LoginError.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions apps/redi-connect/src/routes/routes__logged-out.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ const Login = lazy(
/* webpackChunkName: "Login", webpackPreload: true */ '../pages/front/login/Login'
)
)
const LoginError = lazy(
() =>
import(
/* webpackChunkName: "LoginError", webpackPreload: true */ '../pages/front/login/LoginError'
)
)
const SignUpLanding = lazy(
() =>
import(
Expand Down Expand Up @@ -75,11 +69,6 @@ export const routes__loggedOut: RouteDefinition[] = [
component: Login,
exact: true,
},
{
path: '/front/login-result',
component: LoginError,
exact: true,
},
{
path: '/front/signup-landing',
component: SignUpLanding,
Expand Down
2 changes: 1 addition & 1 deletion apps/redi-connect/src/services/api/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const login = async (
RedProduct: 'CON',
},
})
const accessToken = loginResp?.data as AccessToken
const accessToken = loginResp.data as AccessToken
saveAccessTokenToLocalStorage(accessToken)
setGraphQlClientAuthHeader(accessToken)
return accessToken
Expand Down

0 comments on commit e497342

Please sign in to comment.