Skip to content

Commit

Permalink
implement attendance
Browse files Browse the repository at this point in the history
  • Loading branch information
“kebean” authored and aimedivin committed Sep 30, 2024
1 parent 1b58a2a commit f24da27
Show file tree
Hide file tree
Showing 20 changed files with 1,395 additions and 924 deletions.
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
href="https://fonts.googleapis.com/css2?family=Inria+Serif:ital@1&family=Lexend+Deca:wght@600&family=Open+Sans:wght@300;400;600;700;800&display=swap"
rel="stylesheet"
/> -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css"
integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg=="
crossorigin="anonymous" referrerpolicy="no-referrer" />

<link
href="https://fonts.googleapis.com/css2?family=PT+Serif:wght@400;700&display=swap"
Expand Down
221 changes: 9 additions & 212 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"istanbul": "^0.4.5",
"jsonwebtoken": "^9.0.1",
"jwt-decode": "^3.1.2",
"lucide-react": "^0.445.0",
"moment": "^2.29.4",
"pnpm": "^8.6.11",
"react-apexcharts": "^1.4.1",
Expand Down
142 changes: 120 additions & 22 deletions src/Mutations/Attendance.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
import { gql } from '@apollo/client';

export const GET_ATTENDANCE = gql`
query ExampleQuery {
getTraineeAttendance {
export const GET_TEAM_ATTENDANCE = gql`
query GetTeamAttendance($team: String!, $orgToken: String) {
getTeamAttendance(team: $team, orgToken: $orgToken) {
id
trainees {
traineeId
traineeEmail
status {
days
value
week
phase {
id
name
}
cohort {
id
name
}
teams {
team {
id
name
}
trainees {
trainee {
id
email
profile {
id
name
}
}
status {
day
date
score
}
}
}
week
}
}
`;

export const GET_ATTENDANCE_BY_ID = gql`
query GetAttendance($id: ID!) {
getTraineeAttendanceByID(id: $id) {
Expand All @@ -33,7 +53,6 @@ export const GET_ATTENDANCE_BY_ID = gql`
}
}
`;

export const GET_WEEKLY_ATTENDANCE = gql`
query GetTraineeAttendanceByID($traineeEmail: String!) {
getTraineeAttendanceByID(traineeEmail: $traineeEmail) {
Expand All @@ -46,27 +65,106 @@ export const GET_WEEKLY_ATTENDANCE = gql`
}
`;

export const UPDATE_ATTENDANCE = gql`
export const RECORD_ATTENDANCE = gql`
mutation RecordAttendance(
$week: String!
$days: String!
$week: Int!
$team: String!
$trainees: [TraineeInput!]!
$recordAttendanceOrgToken2: String!
$orgToken: String!
) {
recordAttendance(
week: $week
days: $days
team: $team
trainees: $trainees
orgToken: $recordAttendanceOrgToken2
orgToken: $orgToken
) {
team {
id
name
cohort {
name
}
}
trainees {
trainee {
profile {
name
}
}
status {
day
score
}
}
}
}
`;

export const UPDATE_ATTENDANCE = gql`
mutation UpdateAttendance(
$week: Int!
$team: String!
$trainees: [TraineeInput!]!
$orgToken: String!
) {
updateAttendance(
week: $week
team: $team
trainees: $trainees
orgToken: $orgToken
) {
id
week
phase {
id
name
}
cohort {
id
name
}
teams {
team {
id
name
}
trainees {
trainee {
id
email
profile {
id
name
}
}
status {
day
date
score
}
}
}
}
}
`;


export const DELETE_ATTENDANCE = gql`
mutation DeleteAttendance($week: String!, $team: String!, $day: String!) {
deleteAttendance(week: $week, team: $team, day: $day) {
team {
name
}
trainees {
traineeId
traineeEmail
trainee {
email
profile {
name
}
}
status {
days
value
day
score
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Mutations/manageStudentMutations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const GET_TRAINEES_QUERY = gql`
}
team {
name
id
cohort {
id
startDate
Expand Down Expand Up @@ -373,6 +374,7 @@ export const ADD_MEMBER_TO_TEAM = gql`
export const GET_TEAM_TRAINEE_QUERY = gql`
query GetTeamTrainees($orgToken: String, $team: String) {
getTeamTrainees(orgToken: $orgToken, team: $team) {
id
profile {
firstName
lastName
Expand Down
19 changes: 19 additions & 0 deletions src/Mutations/teamMutation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ export const GET_TEAMS = gql`
`;
export default GET_TEAMS;

export const GET_ALL_TEAMS = gql`
query Query($orgToken: String) {
getAllTeams(orgToken: $orgToken) {
id
name
cohort {
name
phase {
id
name
}
coordinator {
id
}
}
}
}
`;

export const ADD_TEAMS = gql`
mutation Mutation(
$name: String!
Expand Down
4 changes: 4 additions & 0 deletions src/assets/cancel_mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/assets/check-mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/assets/check_mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/tilde.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions src/components/Attendance/AttendanceSymbols.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React, { ReactElement } from 'react';
import { BsCheckLg } from 'react-icons/bs';
import { FaXmark } from 'react-icons/fa6';
import { FaCheck } from 'react-icons/fa';
import tilde from '../../assets/tilde.svg';


interface Props {
status: number | string;
}

interface Property {
color: string;
icon: ReactElement;
}
function AttendanceSymbols({ status }: Props) {
const score = String(status);
const property: Property = {
color: 'bg-[#0E8E0B]',
// icon: <i className="fa-solid fa-check font-semibold" />,
icon: <FaCheck className="text-[.8rem]" />,
};

if (score === '1') {
property.color = 'bg-[#FE8903]';
property.icon = <img src={tilde} alt="" />;
}
if (score === '0') {
property.color = 'bg-[#C30909]';
property.icon = <FaXmark className="text-base" />;
}
return (
<div
className={`${property.color} flex items-center justify-center w-[1.5rem] h-[1.5rem] rounded-full text-white`}
>
{property.icon}
</div>
);
}

export default AttendanceSymbols;
3 changes: 3 additions & 0 deletions src/components/CoordinatorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ export const GET_TEAMS_CARDS = gql`
professional_Skills
}
members {
id
profile {
name
lastName
firstName
}
}
active
Expand Down
Loading

0 comments on commit f24da27

Please sign in to comment.