Skip to content

Commit 188d2de

Browse files
IsmaelmurekeziMugisha146Mugishahbapteceelogre
committed
#40 Fix single trainee detail page (#125)
* 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 5088aa5 commit 188d2de

File tree

20 files changed

+4253
-3503
lines changed

20 files changed

+4253
-3503
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ coverage
55
dist
66
buildcoverage
77
package-lock.json
8-
.DS_Store
8+
.DS_Store
9+
build/

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"start": "echo \"Error: no test specified\" && exit 1",
7+
"start": "webpack server",
88
"dev": "webpack server",
99
"test": "jest --watchAll=false",
1010
"build": "webpack build",
@@ -74,9 +74,11 @@
7474
"@emotion/styled": "^11.10.4",
7575
"@fortawesome/fontawesome-svg-core": "^6.4.2",
7676
"@fortawesome/free-regular-svg-icons": "^6.4.2",
77+
"@fortawesome/free-solid-svg-icons": "^6.2.0",
7778
"@fortawesome/react-fontawesome": "^0.2.0",
7879
"@heroicons/react": "^1.0.6",
7980
"@hookform/resolvers": "^3.3.0",
81+
"@mui/icons-material": "^6.1.1",
8082
"@mui/material": "^5.10.11",
8183
"@mui/x-date-pickers": "^5.0.6",
8284
"@testing-library/jest-dom": "^5.16.5",
@@ -89,6 +91,7 @@
8991
"bootstrap": "^5.2.2",
9092
"browser": "^0.2.6",
9193
"date-fns": "^2.29.3",
94+
"dayjs": "^1.11.6",
9295
"dotenv": "^16.0.3",
9396
"express": "^4.21.0",
9497
"flowbite": "^1.5.3",
@@ -97,11 +100,13 @@
97100
"googleapis": "^126.0.1",
98101
"graphql": "^16.6.0",
99102
"graphql-request": "^5.1.0",
103+
"html2canvas": "^1.4.1",
100104
"icons": "^1.0.0",
101105
"jest": "^29.1.2",
102106
"jest-environment-jsdom": "^29.1.2",
103107
"joi": "^17.10.2",
104108
"jquery": "^3.6.1",
109+
"jspdf": "^2.5.2",
105110
"jwt-decode": "^3.1.2",
106111
"mini-css-extract-plugin": "^2.6.1",
107112
"moment": "^2.29.4",
@@ -123,7 +128,8 @@
123128
"react-scripts": "^5.0.1",
124129
"react-select": "^5.7.4",
125130
"react-table": "^7.8.0",
126-
"react-toastify": "^9.1.3",
131+
"react-toastify": "^9.0.8",
132+
"redux": "^4.2.0",
127133
"redux-devtools-extension": "^2.13.9",
128134
"redux-state-sync": "^3.1.4",
129135
"redux-thunk": "^2.4.1",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from "react";
2+
3+
interface DetailItemProps {
4+
title: string;
5+
value: string | number | boolean;
6+
}
7+
8+
const DetailItem: React.FC<DetailItemProps> = ({ title, value }) => {
9+
return (
10+
<div className="w-72 bg-slate-300 pl-2 py-2 mb-3 rounded-md dark:bg-gray-800 dark:text-white">
11+
<h3 className="pb-1">{title}</h3>
12+
<p className="text-gray-500 text-sm dark:text-gray-400">
13+
{String(value)}
14+
</p>
15+
</div>
16+
);
17+
};
18+
19+
export default DetailItem;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from "react";
2+
3+
import { IconType } from "react-icons";
4+
5+
interface ProgramItemProps {
6+
title: string;
7+
value: string | number | boolean;
8+
Icon: IconType;
9+
}
10+
11+
const ProgramItem: React.FC<ProgramItemProps> = ({ title, value,Icon }) => {
12+
return (
13+
<div className="ml-5 flex items-center gap-4">
14+
<Icon size={50} />
15+
<div>
16+
<h3 className="pb-2">{title}</h3>
17+
<p className="text-gray-500 text-sm">{value}</p>
18+
</div>
19+
</div>
20+
);
21+
};
22+
23+
export default ProgramItem;
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import React from "react";
2+
import { DownloadPdf } from "../../utils/DownloadPdf";
3+
4+
interface TraineeDetails {
5+
interview_decision: string;
6+
trainee_id: {
7+
email: string;
8+
lastName: string;
9+
firstName: string;
10+
};
11+
}
12+
13+
interface DecisionButtonProps {
14+
decision: string;
15+
}
16+
17+
const getDecisionDetails = (decision: string) => {
18+
switch (decision) {
19+
case "Passed":
20+
case "Approved":
21+
return {
22+
text: "Passed",
23+
style: "bg-[#56C870] hover:bg-[#67dc82] dark:hover:bg-[#1f544cef] dark:bg-[#56C870]",
24+
};
25+
case "Failed":
26+
case "Rejected":
27+
return {
28+
text: "Failed",
29+
style: "bg-red-800 hover:bg-red-500",
30+
};
31+
default:
32+
return {
33+
text: "No Decision",
34+
style: "bg-gray-400",
35+
};
36+
}
37+
};
38+
39+
const DecisionButton: React.FC<DecisionButtonProps> = ({ decision }) => {
40+
const { text, style } = getDecisionDetails(decision);
41+
42+
return (
43+
<span className={`btn-Aprov h-11 ${style} text-white font-bold py-3 px-5 rounded`}>
44+
{text}
45+
</span>
46+
);
47+
};
48+
49+
const DecisionSection: React.FC<{ traineeDetails: TraineeDetails }> = ({ traineeDetails }) => {
50+
const { interview_decision, trainee_id } = traineeDetails;
51+
52+
return (
53+
<div className="w-full py-7 flex flex-col mx-16 bg-slate-200 rounded-xl shadow-md overflow-hidden md:max-w-2xl lg:flex lg:max-w-3xl dark:bg-[#192432] dark:text-white">
54+
<h2 className="font-bold text-lg text-[#56C870] top-5 ml-5 mt-[-10px] pb-2 uppercase">
55+
Status
56+
</h2>
57+
<div className="h-16 flex pl-6 items-center gap-5">
58+
<DecisionButton decision={interview_decision} />
59+
<button
60+
onClick={() => DownloadPdf()}
61+
className="btn-Aprov h-11 bg-blue-700 hover:bg-blue-600 dark:hover:bg-blue-600 text-white font-bold py-2 px-2 rounded dark:bg-blue-700"
62+
>
63+
Download PDF
64+
</button>
65+
<button className="btn-Aprov h-11 bg-blue-500 hover:bg-blue-600 dark:hover:bg-blue-600 text-white font-bold py-2 px-8 rounded dark:bg-blue-500">
66+
<a
67+
href={`https://mail.google.com/mail/?view=cm&fs=1&to=${trainee_id?.email}&su=Your%20ATLP%20Application%20Email&body=Dear%20${trainee_id?.lastName} ${trainee_id?.firstName},`}
68+
target="_blank"
69+
rel="noopener noreferrer"
70+
>
71+
Email
72+
</a>
73+
</button>
74+
</div>
75+
</div>
76+
);
77+
};
78+
79+
export default DecisionSection;

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") {
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export const sidebarItems1 = [
3434
icon: <Icon icon="akar-icons:globe"></Icon>,
3535
title: "Applications",
3636
},
37+
{
38+
path: "Trainee-applicants",
39+
icon: <Icon icon="ic:round-people"></Icon>,
40+
title: "Trainees-Applicants",
41+
},
3742
{
3843
path: "cohort",
3944
icon: <Icon icon="fa6-solid:graduation-cap"></Icon>,
@@ -91,6 +96,7 @@ export const applicantSidebarItems = [
9196
title: "Job Post ",
9297
},
9398
];
99+
94100
export const sidebarItems2 = [
95101
{
96102
path: "/documents",

src/pages/TraineApplicant/Trainee.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ const AddTrainee = (props: any) => {
354354
</li>
355355
<li>
356356
<Link
357-
to={`/trainee-applicant-details/${item._id}`}
357+
to={`/admin/trainee-applicant-details/${item._id}`}
358358
className="text-sm hover:bg-gray-100 text-gray-700 dark:text-white dark:hover:bg-gray-500 block px-4 py-2"
359359
>
360360
View

0 commit comments

Comments
 (0)