Skip to content

Commit 138a8bb

Browse files
“kebean”Calebgisa72
authored andcommitted
implement attendance
1 parent ea1e1e3 commit 138a8bb

File tree

12 files changed

+839
-702
lines changed

12 files changed

+839
-702
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"istanbul": "^0.4.5",
7575
"jsonwebtoken": "^9.0.1",
7676
"jwt-decode": "^3.1.2",
77+
"lucide-react": "^0.445.0",
7778
"moment": "^2.29.4",
7879
"pnpm": "^8.6.11",
7980
"react-apexcharts": "^1.4.1",

src/Mutations/Attendance.tsx

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
import { gql } from '@apollo/client';
22

3-
export const GET_ATTENDANCE = gql`
4-
query ExampleQuery {
5-
getTraineeAttendance {
3+
export const GET_TEAM_ATTENDANCE = gql`
4+
query GetTeamAttendance($team: String!, $orgToken: String) {
5+
getTeamAttendance(team: $team, orgToken: $orgToken) {
66
id
7-
trainees {
8-
traineeId
9-
traineeEmail
10-
status {
11-
days
12-
value
7+
week
8+
phase {
9+
_id
10+
name
11+
}
12+
cohort {
13+
name
14+
}
15+
teams {
16+
team {
17+
id
18+
name
19+
}
20+
trainees {
21+
trainee {
22+
id
23+
email
24+
profile {
25+
name
26+
}
27+
}
28+
status {
29+
day
30+
score
31+
}
1332
}
1433
}
15-
week
1634
}
1735
}
1836
`;
19-
2037
export const GET_ATTENDANCE_BY_ID = gql`
2138
query GetAttendance($id: ID!) {
2239
getTraineeAttendanceByID(id: $id) {
@@ -33,7 +50,6 @@ export const GET_ATTENDANCE_BY_ID = gql`
3350
}
3451
}
3552
`;
36-
3753
export const GET_WEEKLY_ATTENDANCE = gql`
3854
query GetTraineeAttendanceByID($traineeEmail: String!) {
3955
getTraineeAttendanceByID(traineeEmail: $traineeEmail) {
@@ -46,6 +62,41 @@ export const GET_WEEKLY_ATTENDANCE = gql`
4662
}
4763
`;
4864

65+
export const RECORD_ATTENDANCE = gql`
66+
mutation RecordAttendance(
67+
$week: Int!
68+
$team: String!
69+
$trainees: [TraineeInput!]!
70+
$orgToken: String!
71+
) {
72+
recordAttendance(
73+
week: $week
74+
team: $team
75+
trainees: $trainees
76+
orgToken: $orgToken
77+
) {
78+
team {
79+
id
80+
name
81+
cohort {
82+
name
83+
}
84+
}
85+
trainees {
86+
trainee {
87+
profile {
88+
name
89+
}
90+
}
91+
status {
92+
day
93+
score
94+
}
95+
}
96+
}
97+
}
98+
`;
99+
49100
export const UPDATE_ATTENDANCE = gql`
50101
mutation RecordAttendance(
51102
$week: String!

src/Mutations/manageStudentMutations.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const GET_TRAINEES_QUERY = gql`
5858
}
5959
team {
6060
name
61+
id
6162
cohort {
6263
id
6364
startDate
@@ -369,6 +370,7 @@ export const ADD_MEMBER_TO_TEAM = gql`
369370
export const GET_TEAM_TRAINEE_QUERY = gql`
370371
query GetTeamTrainees($orgToken: String, $team: String) {
371372
getTeamTrainees(orgToken: $orgToken, team: $team) {
373+
id
372374
profile {
373375
firstName
374376
lastName

src/Mutations/teamMutation.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ export const GET_TEAMS = gql`
1010
`;
1111
export default GET_TEAMS;
1212

13+
export const GET_ALL_TEAMS = gql`
14+
query Query($orgToken: String) {
15+
getAllTeams(orgToken: $orgToken) {
16+
id
17+
name
18+
cohort {
19+
name
20+
coordinator {
21+
id
22+
}
23+
}
24+
}
25+
}
26+
`;
27+
1328
export const ADD_TEAMS = gql`
1429
mutation Mutation(
1530
$name: String!

src/components/AttendanceCard.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
3+
type AttendanceCardProps = {
4+
name: string;
5+
email: string;
6+
score: 'present' | 'late' | 'absent';
7+
};
8+
9+
const scoreColors = {
10+
present: 'text-green-500',
11+
late: 'text-yellow-500',
12+
absent: 'text-red-500',
13+
};
14+
15+
const scoreIcons = {
16+
present: '✅',
17+
late: '⚠️',
18+
absent: '❌',
19+
};
20+
21+
function AttendanceCard({ name, email, score }: AttendanceCardProps) {
22+
return (
23+
<tr className="bg-white dark:bg-gray-800">
24+
<td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-gray-100">
25+
{name}
26+
</td>
27+
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-300">
28+
{email}
29+
</td>
30+
<td className="px-6 py-4 whitespace-nowrap text-sm font-medium">
31+
<span className={scoreColors[score]}>{scoreIcons[score]}</span>
32+
</td>
33+
</tr>
34+
);
35+
}
36+
37+
export default AttendanceCard;

src/components/CoordinatorCard.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ export const GET_TEAMS_CARDS = gql`
2626
professional_Skills
2727
}
2828
members {
29+
id
2930
profile {
3031
name
32+
lastName
33+
firstName
3134
}
3235
}
3336
active
@@ -164,23 +167,21 @@ function ManagerCard() {
164167
});
165168

166169
return (
167-
<div
168-
className="px-4 md:px-0 pb-20 w-full dark:bg-dark-frame-bg dark:text-black h-full flex overflow-x-auto "
169-
>
170-
{loading ? (
171-
<div className="flex items-center justify-center w-full h-full">
172-
<div className="spinner" />
173-
</div>
174-
) : (
175-
<div className="pl-10 flex">
176-
{teamData &&
170+
<div className="px-4 md:px-0 pb-20 w-full dark:bg-dark-frame-bg dark:text-black h-full flex overflow-x-auto ">
171+
{loading ? (
172+
<div className="flex items-center justify-center w-full h-full">
173+
<div className="spinner" />
174+
</div>
175+
) : (
176+
<div className="pl-10 flex">
177+
{teamData &&
177178
teamData.map((teamProps: any, index: number) => (
178-
<Link key={index} to={`/team/${(teamProps.teamname)}`}>
179+
<Link key={index} to={`/team/${teamProps.teamname}`}>
179180
<Card {...teamProps} />
180181
</Link>
181182
))}
182-
</div>
183-
)}
183+
</div>
184+
)}
184185
</div>
185186
);
186187
}

0 commit comments

Comments
 (0)