@@ -3,65 +3,72 @@ import React, { useEffect, useState } from "react";
33export default function Dashboard ( ) {
44 const [ tasks , setTasks ] = useState ( [ ] ) ;
55 const [ loading , setLoading ] = useState ( true ) ;
6- const API_URL = import . meta. env . VITE_API_URL || "https://fat-eibl-backend.onrender.com" ;
6+
7+ // Backend URL (Render)
8+ const API_URL = import . meta. env . VITE_API_URL || "https://fat-eibl-backend-x1sp.onrender.com" ;
79
810 useEffect ( ( ) => {
9- const fetchTasks = async ( ) => {
11+ async function fetchTasks ( ) {
1012 try {
11- const response = await fetch ( `${ API_URL } /tasks` ) ;
12- if ( ! response . ok ) throw new Error ( "Failed to load tasks" ) ;
13- const data = await response . json ( ) ;
13+ const res = await fetch ( `${ API_URL } /tasks` ) ;
14+ if ( ! res . ok ) throw new Error ( "Failed to fetch tasks" ) ;
15+ const data = await res . json ( ) ;
1416 setTasks ( data ) ;
1517 } catch ( err ) {
16- console . error ( "Error loading tasks :" , err ) ;
18+ console . error ( "Error fetching data :" , err ) ;
1719 } finally {
1820 setLoading ( false ) ;
1921 }
20- } ;
21-
22+ }
2223 fetchTasks ( ) ;
2324 } , [ API_URL ] ) ;
2425
2526 return (
26- < div style = { { textAlign : "center" , marginTop : "60px" , fontFamily : "Arial" } } >
27- < h1 style = { { color : "#0047AB" } } > Finance Audit Dashboard</ h1 >
28- < h3 style = { { color : "#666" } } > Edme Insurance Brokers Limited</ h3 >
27+ < div style = { { fontFamily : "Arial, sans-serif" , backgroundColor : "#f8f9fc" , minHeight : "100vh" , padding : "20px" } } >
28+ < h1 style = { { color : "#0047AB" , textAlign : "center" } } > Finance Audit Dashboard</ h1 >
29+ < h3 style = { { textAlign : "center" , color : "#555" } } >
30+ Edme Insurance Brokers Limited
31+ </ h3 >
32+
2933 { loading ? (
30- < p > Loading reports ...</ p >
34+ < p style = { { textAlign : "center" } } > Loading tasks ...</ p >
3135 ) : (
32- < table
33- border = "1"
34- cellPadding = "10"
35- style = { {
36- margin : "30px auto" ,
37- borderCollapse : "collapse" ,
38- width : "80%" ,
39- background : "#f9f9f9" ,
40- } }
41- >
42- < thead >
43- < tr style = { { background : "#0047AB" , color : "white" } } >
44- < th > ID</ th >
45- < th > Task</ th >
46- < th > Status</ th >
47- </ tr >
48- </ thead >
49- < tbody >
50- { tasks . length > 0 ? (
51- tasks . map ( ( task ) => (
52- < tr key = { task . id } >
53- < td > { task . id } </ td >
54- < td > { task . title } </ td >
55- < td > { task . status } </ td >
56- </ tr >
57- ) )
58- ) : (
59- < tr >
60- < td colSpan = "3" > No data available</ td >
36+ < div style = { { marginTop : "30px" } } >
37+ < table
38+ style = { {
39+ borderCollapse : "collapse" ,
40+ margin : "0 auto" ,
41+ width : "90%" ,
42+ boxShadow : "0 2px 8px rgba(0, 0, 0, 0.1)" ,
43+ backgroundColor : "white" ,
44+ } }
45+ >
46+ < thead >
47+ < tr style = { { backgroundColor : "#0047AB" , color : "white" } } >
48+ < th style = { { padding : "12px" } } > ID</ th >
49+ < th style = { { padding : "12px" } } > Task Title</ th >
50+ < th style = { { padding : "12px" } } > Status</ th >
6151 </ tr >
62- ) }
63- </ tbody >
64- </ table >
52+ </ thead >
53+ < tbody >
54+ { tasks . length > 0 ? (
55+ tasks . map ( ( task ) => (
56+ < tr key = { task . id } >
57+ < td style = { { padding : "10px" , textAlign : "center" } } > { task . id } </ td >
58+ < td style = { { padding : "10px" } } > { task . title } </ td >
59+ < td style = { { padding : "10px" , textAlign : "center" } } > { task . status } </ td >
60+ </ tr >
61+ ) )
62+ ) : (
63+ < tr >
64+ < td colSpan = "3" style = { { textAlign : "center" , padding : "20px" } } >
65+ No data available
66+ </ td >
67+ </ tr >
68+ ) }
69+ </ tbody >
70+ </ table >
71+ </ div >
6572 ) }
6673 </ div >
6774 ) ;
0 commit comments