@@ -18,17 +18,15 @@ export const Header = () => {
1818 } ;
1919
2020 const getNotificationText = ( notif ) => {
21+ if ( notif . type === 1 ) return null ;
2122 const types = {
22- 1 : `${ notif . senderName } te ha enviado un mensaje` ,
23- 2 : `${ notif . senderName } ha dado like a tu publicación` ,
23+ 2 : `${ notif . senderName } ha dado like a tu Proyecto` ,
2424 3 : `${ notif . senderName } ha comentado en tu foto` ,
2525 // añade más tipos según necesites
2626 } ;
27-
2827 return types [ notif . type ] || "Tienes una nueva notificación" ;
2928 } ;
3029
31-
3230 return (
3331 < header className = 'bg-neutral-80 py-2 pl-2 drawer border-b-1 border-neutral-70' >
3432 < input
@@ -45,19 +43,23 @@ export const Header = () => {
4543 { /* Bell icon y menú de notificaciones */ }
4644 < div className = "mx-4 flex items-center" >
4745 < div className = "relative" >
48- < button
49- type = "button"
50- className = "relative flex items-center justify-center text-white hover:text-gray-200"
51- aria-label = "Notificaciones"
52- onClick = { ( ) => setNotificationsOpen ( ( prev ) => ! prev ) }
53- >
54- < CiBellOn className = "h-6 w-6" />
55- { notifications . length > 0 && (
56- < span className = "absolute -top-1 -right-1 h-4 w-4 bg-red-500 text-white text-xs rounded-full flex items-center justify-center" >
57- { notifications . length }
58- </ span >
59- ) }
60- </ button >
46+ {
47+ profile && (
48+ < button
49+ type = "button"
50+ className = "relative flex items-center justify-center text-white hover:text-gray-200"
51+ aria-label = "Notificaciones"
52+ onClick = { ( ) => setNotificationsOpen ( ( prev ) => ! prev ) }
53+ >
54+ < CiBellOn className = "h-6 w-6" />
55+ { notifications . filter ( notif => notif . type !== 1 ) . length > 0 && (
56+ < span className = "absolute -top-1 -right-1 h-4 w-4 bg-red-500 text-white text-xs rounded-full flex items-center justify-center" >
57+ { notifications . filter ( notif => notif . type !== 1 ) . length }
58+ </ span >
59+ ) }
60+ </ button >
61+ )
62+ }
6163
6264 { /* Panel de notificaciones */ }
6365 { notificationsOpen && (
@@ -74,20 +76,22 @@ export const Header = () => {
7476 </ div >
7577
7678 < div className = "max-h-72 overflow-y-auto p-2 space-y-2" >
77- { notifications . length > 0 ? (
78- notifications . map ( ( notif , index ) => (
79- < div
80- key = { notif . _id || `${ notif . senderName } -${ notif . type } -${ index } ` }
81- className = "w-full bg-neutral-60 text-base-content shadow-md rounded-md p-3"
82- >
83- < div className = "text-sm font-medium" >
84- { getNotificationText ( notif ) }
79+ { notifications . filter ( notif => notif . type !== 1 ) . length > 0 ? (
80+ notifications
81+ . filter ( notif => notif . type !== 1 )
82+ . map ( ( notif , index ) => (
83+ < div
84+ key = { notif . _id || `${ notif . senderName } -${ notif . type } -${ index } ` }
85+ className = "w-full bg-neutral-60 text-base-content shadow-md rounded-md p-3"
86+ >
87+ < div className = "text-sm font-medium" >
88+ { getNotificationText ( notif ) }
89+ </ div >
90+ < span className = "text-xs opacity-60 block mt-1" >
91+ { formatMessageTime ( notif . createdAt ) }
92+ </ span >
8593 </ div >
86- < span className = "text-xs opacity-60 block mt-1" >
87- { formatMessageTime ( notif . createdAt ) }
88- </ span >
89- </ div >
90- ) )
94+ ) )
9195 ) : (
9296 < div className = "p-3 text-sm text-gray-400 text-center" >
9397 No hay notificaciones
@@ -96,7 +100,6 @@ export const Header = () => {
96100 </ div >
97101 </ div >
98102 ) }
99-
100103 </ div >
101104 </ div >
102105
0 commit comments