source: frontend/web3-eDnevnik_Frontend/src/pages/RoditelPages/Roditel_MyPayments/Roditel_MyPayments.jsx

Last change on this file was 81cdf2d, checked in by Nikola Janev <nikolajanev57@…>, 10 days ago

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1import { useEffect, useState } from "react";
2import axios from "axios";
3
4import NavbarRoditel from "../../../components/NavbarRoditel/NavbarRoditel";
5const Roditel_MyPayments = () => {
6 const [payments, setPayments] = useState([]);
7 const [loading, setLoading] = useState(false);
8 const [roditelId, setRoditelId] = useState(null);
9 const [paymentSoopstenieId, setPaymentSoopstenieId] = useState(null);
10
11 useEffect(() => {
12 const fetchData = async () => {
13 try {
14 setLoading(true);
15 const resMe = await axios.get("http://localhost:8080/api/auth/me", {
16 withCredentials: true,
17 });
18
19 let roditelId = resMe.data.id;
20
21 const response = await axios.get(
22 `http://localhost:8080/api/payments/parent/${roditelId}`,
23 { withCredentials: true }
24 );
25 setPayments(response.data);
26 } catch (err) {
27 console.error("Error fetching roditel ID:", err);
28 } finally {
29 setLoading(false);
30 }
31 };
32 fetchData();
33 }, []);
34
35 return (
36 <>
37 <NavbarRoditel />
38
39 <table className="table stripped">
40 <thead>
41 <tr>
42 <th scope="col">Статус</th>
43 <th scope="col">Tx hash</th>
44 <th scope="col">Износ</th>
45 <th scope="col">Платено на</th>
46
47 <th scope="col">Креирано на</th>
48 <th scope="col">Соопштенеие ид</th>
49 </tr>
50 </thead>
51 <tbody>
52 {payments && payments.length > 0 ? (
53 payments.map((p) => (
54 <tr key={p.id}>
55 <td>{p.status}</td>
56 <td>{p.txHash}</td>
57 <td>
58 {Number(p.iznos).toFixed(18)} - {p.valuta}
59 </td>
60 <td>{p.platenoNa}</td>
61
62 <td>{p.createdAt}</td>
63 <td>{p.soopstenieId}</td>
64 </tr>
65 ))
66 ) : (
67 <tr>
68 <td className="col-1">Нема</td>
69 </tr>
70 )}
71 </tbody>
72 </table>
73 </>
74 );
75};
76
77export default Roditel_MyPayments;
Note: See TracBrowser for help on using the repository browser.