@@ -5,7 +5,7 @@ import axios from 'axios';
5
5
import '../index.css' ;
6
6
7
7
const AdminDashboard : React . FC = ( ) => {
8
- const [ ads , setAds ] = useState < any [ ] > ( [ ] ) ;
8
+ const [ notifications , setNotifications ] = useState < any [ ] > ( [ ] ) ;
9
9
const [ loading , setLoading ] = useState < boolean > ( true ) ; // State for loading spinner
10
10
const [ error , setError ] = useState < string | null > ( null ) ; // State for error handling
11
11
@@ -20,7 +20,7 @@ const AdminDashboard: React.FC = () => {
20
20
} ,
21
21
} ) ;
22
22
if ( Array . isArray ( response . data ) ) {
23
- setAds ( response . data ) ;
23
+ setNotifications ( response . data ) ;
24
24
} else {
25
25
console . error ( 'Unexpected data format:' , response . data ) ;
26
26
setError ( 'Unexpected data format received from the server.' ) ;
@@ -41,7 +41,7 @@ const AdminDashboard: React.FC = () => {
41
41
return ;
42
42
}
43
43
44
- const adToDelete = ads [ index ] ;
44
+ const adToDelete = notifications [ index ] ;
45
45
const response = await fetch ( `https://api.contigosanmarcos.com/panel/notifications/${ adToDelete . id } ` , {
46
46
method : 'DELETE' ,
47
47
headers : {
@@ -50,7 +50,7 @@ const AdminDashboard: React.FC = () => {
50
50
} ) ;
51
51
52
52
if ( response . ok ) {
53
- setAds ( ( prevAds ) => prevAds . filter ( ( _ , i ) => i !== index ) ) ;
53
+ setNotifications ( ( prevNotifications ) => prevNotifications . filter ( ( _ , i ) => i !== index ) ) ;
54
54
alert ( `Se borró con éxito el banner` ) ;
55
55
} else {
56
56
alert ( `Necesitas iniciar sesión primero` ) ;
@@ -64,25 +64,25 @@ const AdminDashboard: React.FC = () => {
64
64
) : error ? (
65
65
< p className = "error-message" > { error } </ p > // Display error message if any
66
66
) : (
67
- < div className = "ad -list" >
68
- { ads . length > 0 ? (
69
- ads . map ( ( ad , index ) => (
70
- < div key = { ad . id } className = { `ad ad -item ${ ad . ad_type } ` } >
71
- { ad . ad_type === 'banner' ? (
72
- < div className = "ad -banner" >
73
- { ad . image_url && < img src = { ad . image_url } alt = { ad . ad_title } /> }
67
+ < div className = "notification -list" >
68
+ { notifications . length > 0 ? (
69
+ notifications . map ( ( notification , index ) => (
70
+ < div key = { notification . id } className = { `notification notification -item ${ notification . ad_type } ` } >
71
+ { notification . ad_type === 'banner' ? (
72
+ < div className = "notification -banner" >
73
+ { notification . image_url && < img src = { notification . image_url } alt = { notification . ad_title } /> }
74
74
</ div >
75
75
) : (
76
- < div className = "ad -post" >
77
- { ad . image_url && (
76
+ < div className = "notification -post" >
77
+ { notification . image_url && (
78
78
< div className = "ad-post-image" >
79
- < img src = { ad . image_url } alt = { ad . ad_title } />
79
+ < img src = { notification . image_url } alt = { notification . ad_title } />
80
80
</ div >
81
81
) }
82
- { ad . ad_title && < h3 > { ad . ad_title } </ h3 > }
83
- { ad . ad_content && < p > { ad . ad_content } </ p > }
84
- { ad . target_url && (
85
- < a href = { ad . target_url } target = "_blank" rel = "noopener noreferrer" >
82
+ { notification . ad_title && < h3 > { notification . ad_title } </ h3 > }
83
+ { notification . ad_content && < p > { notification . ad_content } </ p > }
84
+ { notification . target_url && (
85
+ < a href = { notification . target_url } target = "_blank" rel = "noopener noreferrer" >
86
86
More Info
87
87
</ a >
88
88
) }
@@ -100,7 +100,7 @@ const AdminDashboard: React.FC = () => {
100
100
</ div >
101
101
) )
102
102
) : (
103
- < p > No ads available.</ p >
103
+ < p > No notifications available.</ p >
104
104
) }
105
105
</ div >
106
106
) }
0 commit comments