diff --git a/package.json b/package.json
index 2516909c3..429278250 100644
--- a/package.json
+++ b/package.json
@@ -178,5 +178,6 @@
"lint-staged": {
"*.{js,ts,tsx}": "eslint --fix",
"*.{js,ts,html,css,md}": "prettier --write \"./**/*.{js,ts,jsx,tsx,json}\""
- }
+ },
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
diff --git a/src/components/ManagerCard.tsx b/src/components/ManagerCard.tsx
index ea6ec7fc9..a0cf3b67f 100644
--- a/src/components/ManagerCard.tsx
+++ b/src/components/ManagerCard.tsx
@@ -144,7 +144,7 @@ function ManagerCard() {
grade,
teamname: team.name,
coordinator: team?.cohort?.coordinator?.profile
- ? team.cohort?.coordinator.profile.name
+ ? team.cohort?.coordinator?.profile?.name
: team?.cohort?.coordinator?.email,
ttl: team?.ttl?.profile ? team.ttl.profile.name : team?.ttl?.email,
phase: team?.cohort?.phase?.name,
diff --git a/src/components/teamDetails.tsx b/src/components/teamDetails.tsx
index 47893c6d6..1f178458a 100644
--- a/src/components/teamDetails.tsx
+++ b/src/components/teamDetails.tsx
@@ -78,9 +78,9 @@ function TeamDetails() {
cohort: team?.cohort?.name,
teamname: team.name,
coordinator: team?.cohort?.coordinator?.profile
- ? team.cohort?.coordinator.profile.name
+ ? team?.cohort?.coordinator?.profile?.name
: team?.cohort?.coordinator?.email,
- ttl: team?.ttl?.profile ? team.ttl.profile.name : team?.ttl?.email,
+ ttl: team?.ttl?.profile ? team?.ttl?.profile?.name : team?.ttl?.email,
Qty,
Qnty,
skills,
@@ -228,12 +228,12 @@ function TeamDetails() {
{teamname}
- {selectedTeam.cohort}
+ {selectedTeam?.cohort}
Coordinator: {selectedTeam?.coordinator}
-
TTL: {selectedTeam.ttl}
+
TTL: {selectedTeam?.ttl}
@@ -285,12 +285,12 @@ function TeamDetails() {
Quality
-
- {selectedTeam.Qty >= 1.5 && selectedTeam.Qty <= 2
+
+ {selectedTeam?.Qty >= 1.5 && selectedTeam?.Qty <= 2
? 'Good'
- : selectedTeam.Qty >= 1 && selectedTeam.Qty < 1.5
+ : selectedTeam?.Qty >= 1 &&
+ selectedTeam?.Qty < 1.5
? 'Improve'
: 'Poor'}
@@ -322,11 +323,11 @@ function TeamDetails() {
Quantity
-
- {selectedTeam.Qnty >= 1.5 && selectedTeam.Qnty <= 2
+
+ {selectedTeam?.Qnty >= 1.5 &&
+ selectedTeam?.Qnty <= 2
? 'Good'
- : selectedTeam.Qnty >= 1 &&
- selectedTeam.Qnty < 1.5
+ : selectedTeam?.Qnty >= 1 &&
+ selectedTeam?.Qnty < 1.5
? 'Improve'
: 'Poor'}
@@ -360,11 +362,11 @@ function TeamDetails() {
Professionalism
-
- {selectedTeam.skills >= 1.5 &&
- selectedTeam.skills <= 2
+
+ {selectedTeam?.skills >= 1.5 &&
+ selectedTeam?.skills <= 2
? 'Good'
- : selectedTeam.skills >= 1 &&
- selectedTeam.skills < 1.5
+ : selectedTeam?.skills >= 1 &&
+ selectedTeam?.skills < 1.5
? 'Improve'
: 'Poor'}
diff --git a/src/index.tsx b/src/index.tsx
index 248cca3d7..c5f9017f7 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -23,9 +23,26 @@ import UserProvider from './hook/useAuth';
import App from './App';
import ThemeProvider from './hook/ThemeProvider';
+const specificMessagesToLogout = [
+ 'User not authenticated',
+ 'User account does not exist or has been deleted',
+ 'User with this token no longer exist!!',
+];
const errorLink = onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors) {
graphQLErrors.forEach(({ message, locations, path, extensions }) => {
+ if (
+ specificMessagesToLogout.some((errorMessage) =>
+ message.includes(errorMessage),
+ )
+ ) {
+ const encodedMessage = encodeURIComponent(message); // Encode the message
+ window.location.href = `/users/login?redirect_message=${encodedMessage}`;
+ localStorage.removeItem('auth');
+ localStorage.removeItem('auth_token');
+ toast.error(message);
+ }
+
if (extensions?.code === 'JWT_EXPIRED') {
window.location.pathname = '/users/login';
localStorage.removeItem('auth');
diff --git a/src/pages/Organization/AdminLogin.tsx b/src/pages/Organization/AdminLogin.tsx
index 411c9d794..2303954c7 100644
--- a/src/pages/Organization/AdminLogin.tsx
+++ b/src/pages/Organization/AdminLogin.tsx
@@ -1,6 +1,7 @@
/* eslint-disable */
+'use client';
import { useApolloClient, useMutation } from '@apollo/client';
-import React, { useContext, useState } from 'react';
+import React, { useContext, useEffect, useState } from 'react';
import { useForm } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { FaRegEnvelope, FaRegEye } from 'react-icons/fa';
@@ -45,6 +46,19 @@ function AdminLogin() {
const [LoginUser] = useMutation(LOGIN_MUTATION);
const client = useApolloClient();
const [searchParams] = useSearchParams();
+ // Function to get the redirect_message from the URL and toast it
+ const showRedirectMessage = () => {
+ const redirectMessage = searchParams.get('redirect_message');
+ console.log(redirectMessage);
+ if (redirectMessage) {
+ toast.error(redirectMessage);
+ }
+ };
+
+ // Call showRedirectMessage when the component mounts
+ useEffect(() => {
+ showRedirectMessage();
+ }, [searchParams]);
const onSubmit = async (userInput: any) => {
userInput.orgToken = orgToken;