Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/layouts/app/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import {
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
faFilePen,
faBuildingUser,
faMedal,
faRankingStar,
faClockRotateLeft,
faChartColumn,
faChalkboardUser,
faGraduationCap,
Expand Down Expand Up @@ -78,11 +76,11 @@ const candidateItems: MenuProps['items'] = [
null
),
]),
getItem(
<Link to={PATH_CANDIDATE.organizations}>Organizations </Link>,
'organizations',
<FontAwesomeIcon icon={faBuildingUser} />
),
// getItem(
// <Link to={PATH_CANDIDATE.organizations}>Organizations </Link>,
// 'organizations',
// <FontAwesomeIcon icon={faBuildingUser} />
// ),
getItem(
<Link to={PATH_CANDIDATE.badges}>Badges </Link>,
'badges',
Expand All @@ -93,11 +91,11 @@ const candidateItems: MenuProps['items'] = [
'grading',
<FontAwesomeIcon icon={faRankingStar} />
),
getItem(
<Link to={PATH_CANDIDATE.activity_history}>Activity History </Link>,
'activity_history',
<FontAwesomeIcon icon={faClockRotateLeft} />
),
// getItem(
// <Link to={PATH_CANDIDATE.activity_history}>Activity History </Link>,
// 'activity_history',
// <FontAwesomeIcon icon={faClockRotateLeft} />
// ),
];

// org admin items
Expand Down
142 changes: 79 additions & 63 deletions src/pages/candidate/CandidateGrading.tsx
Original file line number Diff line number Diff line change
@@ -1,79 +1,95 @@
import { Button, Flex, Table, Typography } from "antd";

import{ useEffect, useState } from "react";
import {Table, Typography, notification } from "antd";
import axios from "axios";

export const CandidateGrading = () => {

const grades = [
{
key: 1,
org_name: 'Java Institute',
exam_name: 'Java programming for beginners - 2024',
grade: 'A',
score: 90,
date: '2024-07-01',
exam_id: 1
},
{
key: 2,
org_name: 'UCSC',
exam_name: 'Advanced Java programming - 2024',
grade: 'B',
score: 80,
date: '2024-07-01',
exam_id: 2
},
{
key: 3,
org_name: 'SLIIT',
exam_name: 'Python programming - 2024',
grade: 'C',
score: 70,
date: '2024-07-01',
exam_id: 3
},
]
const [grades, setGrades] = useState([]);
const [loading, setLoading] = useState(false);

// Fetch data from API
const fetchGrades = async () => {
const accessToken = sessionStorage.getItem("accessToken");
const userString = sessionStorage.getItem('user');
if (!userString || !accessToken) {
console.error("User information or token not found in session storage.");
return;
}

const user = JSON.parse(userString);
const candidateId = user?.id;

if (!accessToken || !candidateId) {
notification.error({
message: "Error",
description: "Missing authorization token or candidate ID.",
});
return;
}

try {
setLoading(true);
const response = await axios.get(
`http://localhost:8080/api/v1/candidate/${candidateId}/exam-details`,
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
);

// Map API response to table data
const formattedData = response.data.map((item:any, index:any) => ({
key: index + 1,
org_name: item.organizationName,
exam_name: item.examName,
grade: item.grade,
score: item.score,
exam_id: index + 1,
}));

setGrades(formattedData);
} catch (error) {
console.error("Failed to fetch grades:", error);
notification.error({
message: "Error",
description: "Failed to fetch grading data.",
});
} finally {
setLoading(false);
}
};

useEffect(() => {
fetchGrades();
}, []);

const columns = [
{
title: 'Organization Name',
dataIndex: 'org_name',
key: 'org_name',
title: "Organization Name",
dataIndex: "org_name",
key: "org_name",
},
{
title: 'Exam Name',
dataIndex: 'exam_name',
key: 'exam_name',
title: "Exam Name",
dataIndex: "exam_name",
key: "exam_name",
},
{
title: 'Grade',
dataIndex: 'grade',
key: 'grade',
title: "Grade",
dataIndex: "grade",
key: "grade",
},
{
title: 'Score',
dataIndex: 'score',
key: 'score',
title: "Score",
dataIndex: "score",
key: "score",
},
{
title: 'Date',
dataIndex: 'date',
key: 'date',
},
{
title: 'Action',
key: 'action',
render: () => (
<Flex>
<Button type="primary"><a href="#">View Exam</a></Button>
</Flex>
),
},
]

];

return (
<div>
<Typography.Title level={1}>Grading</Typography.Title>
<Table columns={columns} dataSource={grades} />
<Typography.Title level={1}>Exam Grades</Typography.Title>
<Table columns={columns} dataSource={grades} loading={loading} />
</div>
);
};
};
Loading