| 1 | import React, { useState, useEffect } from "react";
|
|---|
| 2 | import axios from "axios";
|
|---|
| 3 | import { useParams } from "react-router-dom";
|
|---|
| 4 | import { Link } from "react-router-dom";
|
|---|
| 5 | import styles from "./Roditel_ViewPrisustvaStyles.module.css";
|
|---|
| 6 | import NavbarRoditel from "../../../components/NavbarRoditel/NavbarRoditel.jsx";
|
|---|
| 7 |
|
|---|
| 8 | const Roditel_ViewPrisustva = () => {
|
|---|
| 9 | const [studentData, setStudentData] = useState(null);
|
|---|
| 10 | const { studentId } = useParams();
|
|---|
| 11 | const [loading, setLoading] = useState(true);
|
|---|
| 12 | const [error, setError] = useState(null);
|
|---|
| 13 |
|
|---|
| 14 | useEffect(() => {
|
|---|
| 15 | const fetchData = async () => {
|
|---|
| 16 | try {
|
|---|
| 17 | setLoading(true);
|
|---|
| 18 |
|
|---|
| 19 | const res = await axios.get(
|
|---|
| 20 | `http://localhost:8080/api/users/ucenici/${studentId}/prisustva`,
|
|---|
| 21 | { withCredentials: true }
|
|---|
| 22 | );
|
|---|
| 23 |
|
|---|
| 24 | setStudentData(res.data);
|
|---|
| 25 | } catch (err) {
|
|---|
| 26 | setError("Грешка при вчитување");
|
|---|
| 27 | console.error(err);
|
|---|
| 28 | } finally {
|
|---|
| 29 | setLoading(false);
|
|---|
| 30 | }
|
|---|
| 31 | };
|
|---|
| 32 |
|
|---|
| 33 | if (studentId) fetchData();
|
|---|
| 34 | }, [studentId]);
|
|---|
| 35 |
|
|---|
| 36 | if (loading) return <div className={styles.loadingState}>Вчитување...</div>;
|
|---|
| 37 |
|
|---|
| 38 | if (error) return <div>{error}</div>;
|
|---|
| 39 |
|
|---|
| 40 | return (
|
|---|
| 41 | <div className={styles.Klasen_ViewPrisustvaZaUcenik}>
|
|---|
| 42 | <NavbarRoditel />
|
|---|
| 43 | <div className="container m-3 mx-auto bg-success text-white d-flex flex-row justify-content-between">
|
|---|
| 44 | <span className="fs-4 text-white text-decoration-underline p-3">
|
|---|
| 45 | Соопштенија
|
|---|
| 46 | </span>
|
|---|
| 47 | <Link
|
|---|
| 48 | className="fs-4 text-white text-decoration-none p-3"
|
|---|
| 49 | to={`/roditelDashboard/${studentData.classId}/weeklyPlan`}
|
|---|
| 50 | >
|
|---|
| 51 | Неделен план
|
|---|
| 52 | </Link>
|
|---|
| 53 | <Link
|
|---|
| 54 | className="fs-4 text-white text-decoration-none p-3"
|
|---|
| 55 | to={`/roditelDashboard/${studentData.classId}/raspored`}
|
|---|
| 56 | >
|
|---|
| 57 | Распоред
|
|---|
| 58 | </Link>
|
|---|
| 59 |
|
|---|
| 60 | <Link
|
|---|
| 61 | className="fs-4 text-white text-decoration-none p-3"
|
|---|
| 62 | to={`/roditelDashboard/student/${studentData?.id}/grades`}
|
|---|
| 63 | >
|
|---|
| 64 | Оценки
|
|---|
| 65 | </Link>
|
|---|
| 66 | <Link
|
|---|
| 67 | className="fs-4 text-white text-decoration-none p-3"
|
|---|
| 68 | to={`/roditelDashboard/student/${studentData?.id}/prisustva`}
|
|---|
| 69 | >
|
|---|
| 70 | Присуства
|
|---|
| 71 | </Link>
|
|---|
| 72 | </div>
|
|---|
| 73 |
|
|---|
| 74 | <main className={styles.contentWrapper}>
|
|---|
| 75 | <header className={styles.pageHeader}>
|
|---|
| 76 | <h1>
|
|---|
| 77 | Преглед на присуства за {studentData.ime} {studentData.prezime}
|
|---|
| 78 | </h1>
|
|---|
| 79 | </header>
|
|---|
| 80 |
|
|---|
| 81 | <div className={styles.tableContainer}>
|
|---|
| 82 | <table className="table table-stripped">
|
|---|
| 83 | <thead>
|
|---|
| 84 | <tr>
|
|---|
| 85 | <th>Датум</th>
|
|---|
| 86 | <th>Статус</th>
|
|---|
| 87 | <th>Забелешка</th>
|
|---|
| 88 | <th>Евидентирано од</th>
|
|---|
| 89 | <th>За часот</th>
|
|---|
| 90 | </tr>
|
|---|
| 91 | </thead>
|
|---|
| 92 |
|
|---|
| 93 | <tbody>
|
|---|
| 94 | {studentData.prisustva?.length > 0 ? (
|
|---|
| 95 | studentData.prisustva.map((p) => (
|
|---|
| 96 | <tr key={p.id}>
|
|---|
| 97 | <td>{new Date(p.datum).toLocaleDateString("mk-MK")}</td>
|
|---|
| 98 |
|
|---|
| 99 | <td>
|
|---|
| 100 | <span className={styles.statusPill}>{p.status}</span>
|
|---|
| 101 | </td>
|
|---|
| 102 |
|
|---|
| 103 | <td className={styles.noteCell}>{p.zabeleska || "—"}</td>
|
|---|
| 104 |
|
|---|
| 105 | <td>
|
|---|
| 106 | {p.nastavnik.ime} {p.nastavnik.prezime}
|
|---|
| 107 | </td>
|
|---|
| 108 |
|
|---|
| 109 | <td>
|
|---|
| 110 | {p.cas.ime} во {p.cas.denVo_Nedelata} со реден час{" "}
|
|---|
| 111 | {p.cas.reden_cas}
|
|---|
| 112 | </td>
|
|---|
| 113 | </tr>
|
|---|
| 114 | ))
|
|---|
| 115 | ) : (
|
|---|
| 116 | <tr>
|
|---|
| 117 | <td colSpan="5" className={styles.emptyMessage}>
|
|---|
| 118 | Нема евидентирано присуства.
|
|---|
| 119 | </td>
|
|---|
| 120 | </tr>
|
|---|
| 121 | )}
|
|---|
| 122 | </tbody>
|
|---|
| 123 | </table>
|
|---|
| 124 | </div>
|
|---|
| 125 | </main>
|
|---|
| 126 | </div>
|
|---|
| 127 | );
|
|---|
| 128 | };
|
|---|
| 129 |
|
|---|
| 130 | export default Roditel_ViewPrisustva;
|
|---|