Skip to content

Commit dca1783

Browse files
IsmaelmurekeziMugisha146Mugishahbapteceelogre
committed
* feature: improve trainee details page
* handling missing application info, also adding download functionality * fixing error related to download and refactoring * Update TrainneeDetails.tsx * handling issues related to deployment * Fix number can't be shared (#130) Co-authored-by: Mugisha <[email protected]> * #102 sidebar links review (#128) * fix: remove placeholder property * fix duplicate links --------- Co-authored-by: ceelogre <[email protected]> * Ft minimize dashboard menu #110 (#140) * fix: remove placeholder property * ft minimize dashboard menu * fix minimize dashboard by icon and categorize into section * fix minimize dashboard by icon and categorize into section * fix minimize dashboard by icon and categorize into section * fix minimize dashboard by icon and categorize into section * fix minimize dashboard by icon and categorize into section * fix minimize dashboard by icon and categorize into section * fix minimize dashboard scrollbar * fix minimize dashboard scrollbar * fix minimize dashboard scrollbar * Fix layout spacing between sidebar and main content in AdminLayout * new * Fix layout spacing between sidebar and main content in AdminLayout * fix layout --------- Co-authored-by: ceelogre <[email protected]> Co-authored-by: Prince-Kid <[email protected]> Co-authored-by: Mucyo Prince <[email protected]> Co-authored-by: Aime-Patrick <[email protected]> * #118 fx: builtinSuperAdminCreateProgram (#126) * fix: remove placeholder property * The built-in superadmin account cannot create a program --------- Co-authored-by: ceelogre <[email protected]> * feature: improve trainee details page * handling missing application info, also adding download functionality * Update TrainneeDetails.tsx * adding way to send email and other adjustments * refining and fixing some issues * Update webpack.config.js * customizing way of sending email * refactoring code to fix issue related to code climate * fixing issue for deployment * fixing issues related to refactoring --------- Co-authored-by: MUGISHA Emmanuel <[email protected]> Co-authored-by: Mugisha <[email protected]> Co-authored-by: ISHIMWE Jean Baptiste <[email protected]> Co-authored-by: ceelogre <[email protected]> Co-authored-by: ManziPatrick <[email protected]> Co-authored-by: Prince-Kid <[email protected]> Co-authored-by: Mucyo Prince <[email protected]> Co-authored-by: Aime-Patrick <[email protected]> Co-authored-by: Niyonshuti Jean De Dieu <[email protected]>
1 parent bd88713 commit dca1783

File tree

12 files changed

+3951
-3179
lines changed

12 files changed

+3951
-3179
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"@fortawesome/react-fontawesome": "^0.2.0",
7979
"@heroicons/react": "^1.0.6",
8080
"@hookform/resolvers": "^3.3.0",
81+
"@mui/icons-material": "^6.1.1",
8182
"@mui/material": "^5.10.11",
8283
"@mui/x-date-pickers": "^5.0.6",
8384
"@testing-library/jest-dom": "^5.16.5",

src/components/form/SignInForm.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,18 @@ const LoginForm = () => {
5151
});
5252

5353
const redirectAfterLogin = async () => {
54-
const lastAttemptedRoute = localStorage.getItem('lastAttemptedRoute');
55-
if (lastAttemptedRoute) {
56-
localStorage.removeItem('lastAttemptedRoute');
57-
navigate(lastAttemptedRoute);
58-
} else {
5954
await Token();
6055
const role = localStorage.getItem("roleName") as string;
56+
6157
if (role === "applicant") {
6258
navigate("/applicant");
63-
} else if (role === "superAdmin" || role === "admin") {
59+
} else if (role === "superAdmin" || "Admin") {
6460
navigate("/admin");
6561
} else {
6662
const searchParams = new URLSearchParams(location.search);
6763
const returnUrl = searchParams.get('returnUrl') || '/';
6864
navigate(returnUrl);
6965
}
70-
}
7166
}
7267

7368
const onSubmit = async (data: loginFormData) => {
@@ -188,7 +183,7 @@ const LoginForm = () => {
188183
</div>
189184
<p className="text-sm mt-3 mb-2 text-[#616161] dark:text-gray-300">
190185
Don't have an account?{" "}
191-
<Link to="/register" className="text-[#56C870]">
186+
<Link to={'/signup'} className="text-[#56C870]">
192187
Sign up
193188
</Link>
194189
</p>

src/components/sidebar/navHeader.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const logo: string = require("../../assets/logo.svg").default;
1212
const profile: string = require("../../assets/avatar.png").default;
1313
const LogoWhite: string = require("../../assets/logoWhite.svg").default;
1414
import jwtDecode from "jwt-decode";
15+
import {destination} from '../../utils/utils'
1516

1617
const placeholderImage = profile;
1718

@@ -20,6 +21,7 @@ const onImageError = (e) => {
2021
}
2122

2223
function NavBar() {
24+
const userDestination = destination();
2325
const access_token = localStorage.getItem("access_token");
2426
//@ts-ignore
2527
const user = access_token ? jwtDecode(access_token).picture : profile;
@@ -35,7 +37,10 @@ function NavBar() {
3537
const handleShowProfileDropdown = () =>
3638
setShowprofileDropdown(!showProfileDropdown);
3739

40+
41+
3842
return (
43+
3944
<div className="flex items-center dark:bg-zinc-800 ">
4045
{showProfileDropdown && (
4146
<ProfileDropdown
@@ -59,8 +64,9 @@ function NavBar() {
5964
<IoClose className="w-7 text-9xl dark:text-dark-text-fill" />
6065
)}
6166
</span>
67+
6268
<span>
63-
<Link to="/" className="flex items-center">
69+
<Link to={userDestination} className="flex items-center">
6470
{theme ? (
6571
<img
6672
className="cursor-pointer mx-2 fill-[blue]"
@@ -79,6 +85,7 @@ function NavBar() {
7985
</h1>
8086
</Link>
8187
</span>
88+
8289
</div>
8390
<div className="flex items-center mr-4">
8491
<span className="flex items-center">

src/components/sidebar/sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const Sidebar = ({ expanded, setExpanded }) => {
6969
</ul>
7070
<button
7171
onClick={handleLogout}
72-
className="flex items-center p-1 font-semibold hover:font-bold text-white focus:outline-none hover:text-[#56c770] mt-4 ml-4 mt-3"
72+
className="flex items-center p-1 font-semibold hover:font-bold text-white focus:outline-none hover:text-[#56c770] mt-4 ml-4"
7373
>
7474
<Icon icon="hugeicons:logout-circle-02" className="mr-3" />
7575
{expanded && <span>Logout</span>}

src/components/sidebar/sidebarItems.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export const applicantSidebarItems = [
9696
title: "Job Post ",
9797
},
9898
];
99+
99100
export const sidebarItems2 = [
100101
{
101102
path: "/documents",

src/pages/PageNotFound.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const PageNotFound = () => {
1313
<Link to="/applicant">
1414
<button>Go to Applicant Dashboard</button>
1515
</Link>
16-
) : (role === "superAdmin" || role === "admin") ? (
16+
) : role === "superAdmin" || role === "Admin" ? (
1717
<Link to="/admin">
1818
<button>Go back to Homepage</button>
1919
</Link>

src/pages/PrivateRoute.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
import { Navigate, useLocation } from "react-router-dom";
1+
import { Navigate, Outlet, useLocation } from "react-router-dom";
22
import { Token } from "../utils/utils";
3-
import { useEffect } from "react";
3+
import { useEffect, useState } from "react";
44

5-
const PrivateRoute = ({ children }) => {
5+
6+
const PrivateRoute = ({ children, allowedRoles }) => {
67
const access_token = Token();
8+
const roleName = localStorage.getItem('roleName');
79
const location = useLocation();
8-
const user =
9-
//@ts-ignore
10-
access_token !== null && access_token !== undefined && access_token !== '';
10+
11+
const user = access_token && roleName && allowedRoles.includes(roleName);
12+
if (!access_token) {
13+
return <Navigate to="/login" />;
14+
}
15+
16+
if (!user) {
17+
return <Navigate to="/pageNotFound" />;
18+
}
1119

12-
useEffect(() => {
13-
if(!user){
14-
localStorage.setItem('lastAttemptedRoute', location.pathname);
15-
}
16-
}, [user, location])
17-
return user ? children : <Navigate to="/login" />;
20+
return children;
1821
};
1922

2023

2124
export default PrivateRoute;
25+

src/pages/programs/Programs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,15 +488,15 @@ const Programs = (props: any) => {
488488
>
489489
<li>
490490
<Link
491-
to={`/program/${item._id}/edit`}
491+
to={`/admin/program/${item._id}/edit`}
492492
className="text-sm hover:bg-gray-100 text-gray-700 dark:hover:bg-gray-500 dark:text-white block px-4 py-2"
493493
>
494494
Edit
495495
</Link>
496496
</li>
497497
<li>
498498
<Link
499-
to={`/program/${item._id}`}
499+
to={`/admin/program/${item._id}`}
500500
className="text-sm hover:bg-gray-100 text-gray-700 dark:text-white dark:hover:bg-gray-500 block px-4 py-2"
501501
>
502502
View

src/pages/programs/UpdateProgram.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const UpdateProgram = (props: any) => {
9595
<>
9696

9797
<div className="flex flex-col overflow-x-hidden bg-white dark:bg-dark-tertiary relative mt-10 w-[100%] py-3 min-h-[100vh]">
98-
<div className="block text-center text-sm font-bold text-gray-600 relative lg:left-[8rem] dark:text-white text-base lg:max-w-3xl sm:w-[100%] p-4 lg:px-4 m-4 mx-auto text-[24px]">
98+
<div className="block text-center font-bold text-gray-600 relative lg:left-[8rem] dark:text-white text-base lg:max-w-3xl sm:w-[100%] p-4 lg:px-4 m-4 mx-auto text-[24px]">
9999
<h1 className="p-2">Update Program</h1>
100100
</div>
101101
<form
@@ -264,7 +264,7 @@ const UpdateProgram = (props: any) => {
264264
{updateProgramStates.loading ? "Updating..." : "Update"}
265265
</button>
266266
<Link
267-
to="/programs"
267+
to="/admin/programs"
268268
className="dark:bg-[#56C870] flex bg-gray-600 rounded-md py-2 px-4 text-white font-medium cursor-pointer"
269269
>
270270
Cancel

0 commit comments

Comments
 (0)