Skip to content

Commit cd3e07c

Browse files
author
“kebean”
committed
implement attendance
1 parent ea1e1e3 commit cd3e07c

File tree

6 files changed

+95
-28
lines changed

6 files changed

+95
-28
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/AttendanceCard.tsx

Whitespace-only changes.

src/components/ModalAttendance.tsx

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import React from "react";
2+
3+
interface ModalProps {
4+
isVisible: boolean;
5+
onClose: () => void;
6+
}
7+
8+
const ModalAttendance: React.FC<ModalProps> = ({ isVisible, onClose }) => {
9+
const dummyTrainees = [
10+
{ name: "Ngoma Chris", attendance: 1 },
11+
{ name: "Ngoma Chris", attendance: 0 },
12+
{ name: "Ngoma Chris", attendance: 2 },
13+
];
14+
15+
if (!isVisible) return null;
16+
17+
return (
18+
<div className="fixed inset-0 bg-gray-900 bg-opacity-75 flex justify-center items-center z-50">
19+
<div className="bg-gray-800 text-white rounded-lg w-96 p-6 shadow-lg">
20+
<h2 className="text-xl font-bold text-center text-purple-400 mb-4">
21+
Take Attendance
22+
</h2>
23+
<div className="text-center">
24+
<h3 className="font-semibold text-lg">Week 4</h3>
25+
<p className="text-sm">Monday, 27th November 2023</p>
26+
</div>
27+
28+
{/* Trainees List */}
29+
<div className="mt-4 grid grid-cols-2 gap-2">
30+
{dummyTrainees.map((trainee, index) => (
31+
<div
32+
key={index}
33+
className="flex justify-between items-center bg-gray-700 rounded-lg p-2"
34+
>
35+
<span>{trainee.name}</span>
36+
<div className="flex items-center space-x-2">
37+
<span>[{trainee.attendance}]</span>
38+
<button className="text-red-500"></button>
39+
</div>
40+
</div>
41+
))}
42+
</div>
43+
44+
{/* Trainee Search Input */}
45+
<div className="mt-4">
46+
<label htmlFor="trainee" className="block text-sm font-medium">
47+
Trainee Name
48+
</label>
49+
<div className="flex mt-1">
50+
<input
51+
id="trainee"
52+
type="text"
53+
className="bg-gray-700 text-white w-full py-2 px-3 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500"
54+
placeholder="Ngoma Chris"
55+
/>
56+
<button className="ml-2 bg-purple-500 text-white px-4 py-2 rounded-md hover:bg-purple-600">
57+
Search
58+
</button>
59+
</div>
60+
</div>
61+
62+
{/* Attendance Status Icons */}
63+
<div className="mt-4 flex items-center justify-center space-x-4">
64+
<button className="text-green-500">✔️</button>
65+
<button className="text-yellow-500">~</button>
66+
<button className="text-red-500"></button>
67+
</div>
68+
69+
{/* Buttons */}
70+
<div className="mt-6 flex justify-between">
71+
<button
72+
onClick={onClose}
73+
className="bg-gray-500 text-white py-2 px-4 rounded-md hover:bg-gray-600"
74+
>
75+
Cancel
76+
</button>
77+
<button className="bg-purple-500 text-white py-2 px-4 rounded-md hover:bg-purple-600">
78+
Submit
79+
</button>
80+
</div>
81+
</div>
82+
</div>
83+
);
84+
};
85+
86+
export default ModalAttendance;

src/components/Sidebar.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ function Sidebar({ style, toggle }: { style: string; toggle: () => void }) {
8181
<UserGroupIcon className="w-5" />
8282
</SideNavLink>
8383
</CheckRole>
84+
<CheckRole roles={['admin', 'coordinator']}>
85+
<SideNavLink onClick={toggle} to="/Attendance" name="Attendance">
86+
<UserGroupIcon className="w-5" />
87+
</SideNavLink>
88+
</CheckRole>
8489
{/* INVITATION */}
8590
<CheckRole roles={['admin', 'coordinator']}>
8691
<SideNavLink onClick={toggle} to="/invitation" name="Invitation">

src/containers/DashRoutes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function DashRoutes() {
126126
<Route path="/settings" element={<Settings />} />
127127
<Route path="/performance" element={<TraineePerfomance />} />
128128
{/* <Route path="/attendance" element={<TraineeAttendance />} /> */}
129-
<Route path="/attendance" element={<Attendance />} />
129+
<Route path="/attendance" element={<Attendance/>} />
130130
<Route path="/attendance-details" element={<AttendanceDetails />} />
131131
<Route path="/teams" element={<AdminTeams />} />
132132
<Route path="/cohorts" element={<AdminCohorts />} />

src/pages/Attendance.tsx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +0,0 @@
1-
import React from 'react';
2-
import CheckRole from '../utils/CheckRoles';
3-
4-
const TraineeAttendanceTracker = React.lazy(
5-
() => import('../pages/TraineeAttendance'),
6-
);
7-
const TraineeAttendance = React.lazy(
8-
() => import('../components/TraineeAttendance'),
9-
);
10-
11-
function Attendance() {
12-
return (
13-
<>
14-
<CheckRole roles={['coordinator']}>
15-
<TraineeAttendanceTracker />
16-
</CheckRole>
17-
<CheckRole roles={['trainee']}>
18-
<TraineeAttendance />
19-
</CheckRole>
20-
</>
21-
);
22-
}
23-
24-
export default Attendance;

0 commit comments

Comments
 (0)