1 | import useGet from "../Hooks/useGet";
|
---|
2 | import {Container} from "react-bootstrap";
|
---|
3 | import { FaLock, FaLockOpen } from "react-icons/fa";
|
---|
4 | import React from "react";
|
---|
5 | import useApprove from "../Hooks/useApprove";
|
---|
6 |
|
---|
7 | const AllProfilesTable = () => {
|
---|
8 |
|
---|
9 | const { data, isLoading, setData, getData, setChanged } = useGet('/user')
|
---|
10 | const { getData: approveProfile} = useApprove()
|
---|
11 |
|
---|
12 | !isLoading && console.log(data)
|
---|
13 |
|
---|
14 | const dateFormatter = (str) => {
|
---|
15 | const inputDate = new Date(str);
|
---|
16 |
|
---|
17 | const options = {
|
---|
18 | year: '2-digit',
|
---|
19 | month: '2-digit',
|
---|
20 | day: '2-digit',
|
---|
21 | hour12: false,
|
---|
22 | };
|
---|
23 |
|
---|
24 | return inputDate.toLocaleString('mk-MK', options);
|
---|
25 |
|
---|
26 | }
|
---|
27 |
|
---|
28 | return (
|
---|
29 | <>
|
---|
30 | <Container fluid >
|
---|
31 | <table className="table table-hover">
|
---|
32 | <thead>
|
---|
33 | <tr>
|
---|
34 | <th scope="col"></th>
|
---|
35 | <th scope="col">Име и презиме</th>
|
---|
36 | <th scope="col">Адреса</th>
|
---|
37 | <th scope="col">Email</th>
|
---|
38 | <th scope="col">Датум на раѓање</th>
|
---|
39 | <th scope="col">Контакт телефон</th>
|
---|
40 | <th>Акции</th>
|
---|
41 | </tr>
|
---|
42 | </thead>
|
---|
43 | <tbody>
|
---|
44 | {!isLoading && data.map((f, i) => { return <tr key={f.userID}>
|
---|
45 | <th style={{verticalAlign: "middle"}} scope="row">{i + 1}</th>
|
---|
46 | <td style={{verticalAlign: "middle"}}>{f.name + ' ' + f.surname}</td>
|
---|
47 | <td style={{verticalAlign: "middle"}}>{f.address}</td>
|
---|
48 | <td style={{verticalAlign: "middle"}}>{f.email}</td>
|
---|
49 | <td style={{verticalAlign: "middle"}}>{dateFormatter(f.birthDate)}</td>
|
---|
50 | <td style={{verticalAlign: "middle"}}>{f.contact}</td>
|
---|
51 | <td style={{verticalAlign: "middle"}}>
|
---|
52 | {f.accountNonLocked &&
|
---|
53 | <FaLock size={'2.2em'} color={'#159895'} onClick={() => {
|
---|
54 | approveProfile('/users/lock/' + f.userID).then(() => {
|
---|
55 | setChanged((prev) => {
|
---|
56 | return Math.random();
|
---|
57 | })
|
---|
58 | })
|
---|
59 | }}/>}
|
---|
60 | {!f.accountNonLocked &&
|
---|
61 | <FaLockOpen size={'2.2em'} color={'#159895'} onClick={() => {
|
---|
62 | approveProfile('/users/unlock/' + f.userID).then(() => {
|
---|
63 | setChanged((prev) => {
|
---|
64 | return Math.random();
|
---|
65 | })
|
---|
66 | })
|
---|
67 | }}/>}
|
---|
68 | </td>
|
---|
69 | </tr>})}
|
---|
70 | </tbody>
|
---|
71 | </table>
|
---|
72 | </Container>
|
---|
73 | </>
|
---|
74 | )
|
---|
75 | }
|
---|
76 |
|
---|
77 | export default AllProfilesTable; |
---|