1- import React , { useState , memo , useEffect } from 'react' ;
1+ import React , { useState , memo , useEffect , useContext } from 'react' ;
22import Modal from 'react-modal' ;
33import { AiFillCloseCircle } from "react-icons/ai" ;
44import '../style/style.css'
55import Header from '../header'
6+ import { auth } from '../auth' ;
67Modal . setAppElement ( '#root' ) ; // Thiết lập phần tử gốc của ứng dụng
78
89function List_Project ( ) {
910 const [ data , set_data ] = useState ( [ ] )
1011 const [ employee , set_employee ] = useState ( [ ] )
12+ const [ tke , set_tke ] = useState ( { } )
13+ console . log ( 'in' )
14+ useEffect ( ( ) => {
15+ // fetch('http://127.0.0.1:5000/list-project', {
16+ fetch ( 'http://127.0.0.1:5000/api/thong-ke' , {
17+ method : 'GET' ,
18+ headers : {
19+ Accept : 'application/json' ,
20+ 'Content-Type' : 'application/json' ,
21+ Authorization : 'Bearer ' + 'token'
22+ } ,
23+ timeout : 2000 ,
24+ // body: JSON.stringify([]),
25+ } ) . then ( ( response ) => response . json ( ) )
26+ . then ( ( actualData ) => {
27+ // console.log(actualData)
28+ if ( actualData . result == 1 ) {
29+ set_tke ( actualData )
30+
31+ }
32+ else {
33+ alert ( actualData . message )
34+ }
35+ } ) ;
36+ } , [ ] )
1137 useEffect ( ( ) => {
1238 // fetch('http://127.0.0.1:5000/list-project', {
1339 fetch ( 'http://127.0.0.1:5000/employees' , {
@@ -54,7 +80,6 @@ function List_Project() {
5480 }
5581 } ) ;
5682 } , [ ] )
57-
5883 const type_name = {
5984 "Type 1" : "Phân loại văn bản" ,
6085 "Type 2" : "Hỏi đáp" ,
@@ -70,54 +95,61 @@ function List_Project() {
7095 "-1" : "#FF0000"
7196 }
7297 return (
73- < div style = { { marginLeft : 10 } } >
98+ < div >
7499 < Header />
75- < div className = 'tk-gradient' >
76- < div className = 'tk-gradient-each' >
77- < p style = { { fontSize : 20 , fontWeight : 600 } } > 879</ p >
78- < p style = { { fontSize : 18 , fontWeight : 400 } } > Mẫu API dữ liệu</ p >
79- </ div >
80- < div className = 'tk-gradient-each' >
81- < p style = { { fontSize : 20 , fontWeight : 600 } } > { data . length } </ p >
82- < p style = { { fontSize : 18 , fontWeight : 400 } } > Dự án</ p >
83- </ div >
84- < div className = 'tk-gradient-each' >
85- < p style = { { fontSize : 20 , fontWeight : 600 } } > 2</ p >
86- < p style = { { fontSize : 18 , fontWeight : 400 } } > Dự án hoàn thành</ p >
100+
101+ < div style = { { marginLeft : 10 } } >
102+ < div className = 'tk-gradient' >
103+ < div className = 'tk-gradient-each' >
104+ < p style = { { fontSize : 20 , fontWeight : 600 } } > { tke . dataListCount ? tke . dataListCount : 0 } </ p >
105+ < p style = { { fontSize : 18 , fontWeight : 400 } } > Số mẫu dữ liệu</ p >
106+ </ div >
107+ < div className = 'tk-gradient-each' >
108+ < p style = { { fontSize : 20 , fontWeight : 600 } } > { tke . projectCount ? tke . projectCount : 0 } </ p >
109+ < p style = { { fontSize : 18 , fontWeight : 400 } } > Dự án</ p >
110+ </ div >
111+ < div className = 'tk-gradient-each' >
112+ < p style = { { fontSize : 20 , fontWeight : 600 } } > { tke . projectFinished ? tke . projectFinished : 0 } </ p >
113+ < p style = { { fontSize : 18 , fontWeight : 400 } } > Dự án hoàn thành</ p >
114+ </ div >
115+ < div className = 'tk-gradient-each' >
116+ < p style = { { fontSize : 20 , fontWeight : 600 } } > { tke . employeeCount ? tke . employeeCount : 0 } </ p >
117+ < p style = { { fontSize : 18 , fontWeight : 400 } } > Thành viên</ p >
118+ </ div >
87119 </ div >
88- < div className = 'tk-gradient-each' >
89- < p style = { { fontSize : 20 , fontWeight : 600 } } > { employee . length } </ p >
90- < p style = { { fontSize : 18 , fontWeight : 400 } } > Thành viên</ p >
120+
121+ < h1 style = { { textAlign : 'center' } } > Danh sách dự án</ h1 >
122+ < div style = { { display : 'flex' , flexDirection : 'row' , marginTop : 40 , border : '0.5px solid black' , borderColor : 'black' , borderTop : 0 , borderLeft : 0 , borderRight : 0 } } >
123+ < div style = { { width : '3%' , fontWeight : 600 , marginRight : 10 } } > < p > STT</ p > </ div >
124+ < div style = { { width : '18%' , fontWeight : 600 , marginRight : 10 } } > < p > Tên dự án</ p > </ div >
125+ < div style = { { width : '18%' , fontWeight : 600 , marginRight : 10 } } > < p > Loại</ p > </ div >
126+ < div style = { { width : '14%' , fontWeight : 600 , marginRight : 10 } } > < p > Số người tham gia</ p > </ div >
127+ < div style = { { width : '12%' , fontWeight : 600 } } > < p > Số người tối đa</ p > </ div >
128+ < div style = { { width : '12%' , fontWeight : 600 } } > < p > Thời gian tạo</ p > </ div >
129+ < div style = { { width : '12%' , fontWeight : 600 , display : 'flex' , alignItems : 'center' , } } > < p > Status</ p > </ div >
130+ < div style = { { width : '10%' , fontWeight : 600 } } > < p > Action</ p > </ div >
91131 </ div >
132+ { data . map ( ( item , index ) => (
133+ < div style = { { display : 'flex' , flexDirection : 'row' , marginTop : 20 , marginBottom : 20 } } >
134+ < div style = { { width : '3%' , fontWeight : 400 , marginRight : 10 } } > < p > { index } </ p > </ div >
135+ < div style = { { width : '20%' , fontWeight : 400 , marginRight : 10 } } > < p > { item . nameProject } </ p > </ div >
136+ < div style = { { width : '20%' , fontWeight : 400 , marginRight : 10 } } > < p > { type_name [ item . type . type ] } </ p > </ div >
137+ < div style = { { width : '15%' , fontWeight : 400 , marginRight : 10 } } > < p > { item . listEmployee . length } </ p > </ div >
138+ < div style = { { width : '12%' , fontWeight : 400 } } > < p > { item . maxEmployees } </ p > </ div >
139+ < div style = { { width : '12%' , fontWeight : 400 } } > < p > { item . time } </ p > </ div >
140+ < div style = { { width : '12%' , fontWeight : 400 , display : 'flex' , alignItems : 'center' , } } > < p style = { { border : '1px solid rgba(0,0,0,0.5)' , width : '80%' , textAlign : 'center' , borderRadius : 10 , justifyContent : 'center' , display : 'flex' , alignItems : 'center' , backgroundColor : backgroundColor [ item . status ] , color : 'black' } } > { item . status == 0 ? 'Processing' : item . status == 1 ? 'Finished' : 'Lated' } </ p > </ div >
141+ < div style = { { marginLeft : 0 , width : '10%' , flexDirection : 'column' , display : 'flex' , justifyContent : 'center' , alignItems : 'center' } } >
142+ < a href = { '/bieu-do/' + item . id } style = { { marginLeft : 0 , color : '#43BFC7' } } > Thống kê</ a >
143+ < a href = { '/about/' + item . id } style = { { marginLeft : 0 } } > Xem chi tiết</ a >
144+ < a href = { '/edit-project/' + item . id } style = { { marginLeft : 0 , color : 'red' } } > Điều chỉnh</ a >
145+ { /* <a href={'/edit-project/' + item.id} style={{ marginLeft: 0, color: 'red' }}>Điều chỉnh</a> */ }
146+ </ div >
147+ </ div >
148+ ) ) }
92149 </ div >
93150
94- < h1 style = { { textAlign : 'center' } } > Danh sách dự án</ h1 >
95- < div style = { { display : 'flex' , flexDirection : 'row' , marginTop : 40 , border : '0.5px solid black' , borderColor : 'black' , borderTop : 0 , borderLeft : 0 , borderRight : 0 } } >
96- < div style = { { width : '19%' , fontWeight : 600 , marginRight : 10 } } > < p > Tên dự án</ p > </ div >
97- < div style = { { width : '19%' , fontWeight : 600 , marginRight : 10 } } > < p > Loại</ p > </ div >
98- < div style = { { width : '15%' , fontWeight : 600 , marginRight : 10 } } > < p > Số người tham gia</ p > </ div >
99- < div style = { { width : '12%' , fontWeight : 600 } } > < p > Số người tối đa</ p > </ div >
100- < div style = { { width : '12%' , fontWeight : 600 } } > < p > Thời gian tạo</ p > </ div >
101- < div style = { { width : '12%' , fontWeight : 600 , display : 'flex' , alignItems : 'center' , } } > < p > Status</ p > </ div >
102- < div style = { { width : '10%' , fontWeight : 600 } } > < p > Action</ p > </ div >
103- </ div >
104- { data . map ( ( item , index ) => (
105- < div style = { { display : 'flex' , flexDirection : 'row' , marginTop : 20 , marginBottom : 20 } } >
106- < div style = { { width : '20%' , fontWeight : 400 , marginRight : 10 } } > < p > { item . nameProject } </ p > </ div >
107- < div style = { { width : '20%' , fontWeight : 400 , marginRight : 10 } } > < p > { type_name [ item . type . type ] } </ p > </ div >
108- < div style = { { width : '15%' , fontWeight : 400 , marginRight : 10 } } > < p > { item . listEmployee . length } </ p > </ div >
109- < div style = { { width : '12%' , fontWeight : 400 } } > < p > { item . maxEmployees } </ p > </ div >
110- < div style = { { width : '12%' , fontWeight : 400 } } > < p > { item . time } </ p > </ div >
111- < div style = { { width : '12%' , fontWeight : 400 , display : 'flex' , alignItems : 'center' , } } > < p style = { { border : '1px solid rgba(0,0,0,0.5)' , width : '80%' , textAlign : 'center' , borderRadius : 10 , justifyContent : 'center' , display : 'flex' , alignItems : 'center' , backgroundColor : backgroundColor [ item . status ] , color : 'black' } } > { item . status == 0 ? 'Processing' : item . status == 1 ? 'Finished' : 'Lated' } </ p > </ div >
112- < div style = { { marginLeft : 0 , width : '10%' , flexDirection : 'column' , display : 'flex' , justifyContent : 'center' , alignItems : 'center' } } >
113- < a href = { '/bieu-do/' + item . id } style = { { marginLeft : 0 , color : '#43BFC7' } } > Thống kê</ a >
114- < a href = { '/about/' + item . id } style = { { marginLeft : 0 } } > Xem chi tiết</ a >
115- < a href = { '/edit-project/' + item . id } style = { { marginLeft : 0 , color : 'red' } } > Điều chỉnh</ a >
116- { /* <a href={'/edit-project/' + item.id} style={{ marginLeft: 0, color: 'red' }}>Điều chỉnh</a> */ }
117- </ div >
118- </ div >
119- ) ) }
120151 </ div >
152+
121153 ) ;
122154}
123155
0 commit comments