Skip to content

Commit

Permalink
completed session timeout for Admin: component to change timeout and …
Browse files Browse the repository at this point in the history
…session management hook
  • Loading branch information
JordanCampbell1 committed Aug 16, 2024
1 parent a3c3555 commit ac48132
Show file tree
Hide file tree
Showing 12 changed files with 1,071 additions and 202 deletions.
79 changes: 72 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@mui/x-data-grid": "^7.11.0",
"@mui/x-date-pickers": "^7.11.1",
"@pdfme/generator": "^1.2.6",
"@testing-library/react-hooks": "^8.0.1",
"bootstrap": "^5.3.3",
"customize-cra": "^1.0.0",
"dayjs": "^1.11.11",
Expand Down Expand Up @@ -50,7 +51,7 @@
"react-router-dom": "^6.26.0",
"react-scripts": "5.0.1",
"react-toastify": "^9.0.3",
"react-tooltip": "^5.27.1",
"react-tooltip": "^5.28.0",
"redux": "^4.1.1",
"redux-thunk": "^2.3.0",
"sanitize-html": "^2.13.0",
Expand Down
6 changes: 6 additions & 0 deletions src/GraphQl/Mutations/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,12 @@ export const UPDATE_COMMUNITY = gql`
}
`;

export const UPDATE_SESSION_TIMEOUT = gql`
mutation updateSessionTimeout($timeout: Int!) {
updateSessionTimeout(timeout: $timeout)
}
`;

export const RESET_COMMUNITY = gql`
mutation resetCommunity {
resetCommunity
Expand Down
8 changes: 8 additions & 0 deletions src/GraphQl/Queries/Queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,14 @@ export const GET_COMMUNITY_DATA = gql`
}
`;

export const GET_COMMUNITY_SESSION_TIMEOUT_DATA = gql`
query getCommunityData {
getCommunityData {
timeout
}
}
`;

// get the list of Action Item Categories
export { ACTION_ITEM_CATEGORY_LIST } from './ActionItemCategoryQueries';

Expand Down
3 changes: 3 additions & 0 deletions src/components/ProfileDropdown/ProfileDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import styles from './ProfileDropdown.module.css';
import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
import { useMutation } from '@apollo/client';
import { useTranslation } from 'react-i18next';
import useSession from 'utils/useSession';

/**
* Renders a profile dropdown menu for the user.
Expand All @@ -24,6 +25,7 @@ const profileDropdown = (): JSX.Element => {
const { t: tCommon } = useTranslation('common');
const [revokeRefreshToken] = useMutation(REVOKE_REFRESH_TOKEN);
const { getItem } = useLocalStorage();
const { endSession } = useSession();
const superAdmin = getItem('SuperAdmin');
const adminFor = getItem('AdminFor');
const userRole = superAdmin
Expand All @@ -45,6 +47,7 @@ const profileDropdown = (): JSX.Element => {
console.error('Error revoking refresh token:', error);
}
localStorage.clear();
endSession();
navigate('/');
};
const MAX_NAME_LENGTH = 20;
Expand Down
96 changes: 96 additions & 0 deletions src/components/UpdateSession/UpdateSession.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* Card styles */
.update-timeout-card {
width: 700px;
background: #ffffff;
border: none;
border-radius: 16px;
filter: drop-shadow(0px 4px 15.3px rgba(0, 0, 0, 0.08));
padding: 20px;
}

.update-timeout-card-header {
background: none;
padding: 16px;
border-bottom: none;
}

.update-timeout-card-title {
font-family: 'Lato', sans-serif;
font-weight: 600;
font-size: 24px;
color: #000000;
}

.update-timeout-card-body {
padding: 20px;
}

.update-timeout-current {
font-family: 'Lato', sans-serif;
font-weight: 400;
font-size: 16px;
color: #000000;
margin-bottom: 20px; /* Increased margin to create more space */
}

.update-timeout-label {
font-family: 'Lato', sans-serif;
font-weight: 400;
font-size: 16px;
color: #000000;
margin-bottom: 10px; /* Keep the same margin to maintain spacing with the slider */
}

.update-timeout-labels-container {
display: flex;
flex-direction: column;
align-items: start;
}

.update-timeout-value {
color: #14ae5c;
font-weight: bold;
}

.update-timeout-slider-labels {
display: flex;
justify-content: space-between;
font-size: 0.9rem;
color: #757575;
}

.update-timeout-button-container {
display: flex;
justify-content: right;
margin-top: 20px;
}

.update-timeout-button {
width: 112px;
height: 36px;
background: #31bb6b;
border-radius: 6px;
font-family: 'Lato', sans-serif;
font-weight: 500;
font-size: 16px;
color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
border: none;
box-shadow: none;
}

.update-timeout-button:hover {
background-color: #28a745;
border-color: #28a745;
box-shadow: none;
}

.update-timeout-button:active {
transform: scale(0.98);
}

.update-timeout-slider-container {
position: relative;
}
Loading

0 comments on commit ac48132

Please sign in to comment.