From 269a415938140f05fd5e2a5769d64cbbc54776e2 Mon Sep 17 00:00:00 2001 From: Rukundo Kevin Date: Wed, 27 Sep 2023 15:38:02 +0200 Subject: [PATCH] Change attendance table --- src/Mutations/Attendance.tsx | 12 +- src/components/TraineeAttendance.tsx | 28 ++- src/components/TraineeAttendanceDetails.tsx | 223 ++++++++++---------- 3 files changed, 153 insertions(+), 110 deletions(-) diff --git a/src/Mutations/Attendance.tsx b/src/Mutations/Attendance.tsx index 6c76848ac..1f4806d98 100644 --- a/src/Mutations/Attendance.tsx +++ b/src/Mutations/Attendance.tsx @@ -1,8 +1,8 @@ import { gql } from '@apollo/client'; export const GET_ATTENDANCE = gql` - query ExampleQuery { - getTraineeAttendance { + query ExampleQuery($orgToken: String!) { + getTraineeAttendance(orgToken: $orgToken) { id trainees { traineeId @@ -17,6 +17,14 @@ export const GET_ATTENDANCE = gql` } `; +export const GET_TRAINEE_ATTENDANCE = gql` + query getTraineeAttendance($orgToken: String!) { + getAllTeams(orgToken: $orgToken) { + id + } + } +`; + export const UPDATE_ATTENDANCE = gql` mutation RecordAttendance( $week: String! diff --git a/src/components/TraineeAttendance.tsx b/src/components/TraineeAttendance.tsx index 81e5ecc23..e39ceec4a 100644 --- a/src/components/TraineeAttendance.tsx +++ b/src/components/TraineeAttendance.tsx @@ -1,15 +1,29 @@ /* eslint-disable */ -import React from 'react'; +import React, { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { Link } from 'react-router-dom'; import Pagination from '../components/Pagination'; import AttendanceData from '../dummyData/attendance.json'; import useDocumentTitle from '../hook/useDocumentTitle'; import Button from './Buttons'; +import { useLazyQuery, useQuery } from '@apollo/client'; +import { GET_ATTENDANCE, GET_TRAINEE_ATTENDANCE } from '../Mutations/Attendance'; +import { toast } from 'react-toastify'; const TraineeAttendance = () => { useDocumentTitle('Attendance'); const { t } = useTranslation(); + const { loading, data } = useQuery(GET_ATTENDANCE, { + variables: { + orgToken: localStorage.getItem('orgToken'), + }, + }); + + const [getAttend] = useLazyQuery(GET_ATTENDANCE, { + variables: { + orgToken: localStorage.getItem('orgToken'), + }, + }); const { firstContentIndex, @@ -25,6 +39,18 @@ const TraineeAttendance = () => { count: AttendanceData.length, }); + useEffect(() => { + getAttend({ + fetchPolicy: 'network-only', + onCompleted: (data) => { + console.log(data) + }, + onError: (error) => { + toast.error(error.message); + }, + }); + }, [ loading]); + return ( <>
diff --git a/src/components/TraineeAttendanceDetails.tsx b/src/components/TraineeAttendanceDetails.tsx index 0f24046ea..c99712fa1 100644 --- a/src/components/TraineeAttendanceDetails.tsx +++ b/src/components/TraineeAttendanceDetails.tsx @@ -4,128 +4,137 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import Button from './Buttons'; +interface Details { + session: string; + record: string; + comment: string; + id: number; +} + +const attendanceDetailsData = [ + { + id: 1, + session: 'Demo', + record: '1', + comment: + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam ', + }, + { + id: 1, + session: 'Stand Up', + record: '1', + comment: + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam ', + }, +]; + const TraineeAttendanceDetails = () => { const { t } = useTranslation(); - return ( -
-
- - - - - - - - - - - - - - + const [replyModal, setReplyModal] = React.useState(false); + const handleReplyModal = () => setReplyModal(!replyModal); - - - - - - - - - -
- {t('Session')} - - {t('Record')} - - {t('Comment')} -
- {t('Demo')} - 1 - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut - enim ad minim veniam - - -
{t('Standup')}1 - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut - enim ad minim veniam - - -
-
-
-
-

{t('Sprint 1')}

-

- June 20, 2022 - June 24, 2022 -

+ return ( + <> + {/* ATTENDANCE REPLY MODAL START */} +
+
+
+

+ {t('Reply to attendance')} +

+
+
+
+ {/* istanbul ignore next */} +
+
+ +