@@ -12,7 +12,7 @@ import * as D from '../../components/common/Dropdown/styles';
1212import Modal from '../../components/common/Modal' ;
1313import * as ModalS from '../../components/common/Modal/styles' ;
1414import { Loading } from '../../components/common/Loading'
15-
15+ import { getAvatarUrl } from '../../utils/getAvatarurl'
1616
1717export default function CommunityPage ( ) {
1818 const { communityID } = useParams < { communityID : string } > ( ) ;
@@ -67,11 +67,10 @@ export default function CommunityPage() {
6767 try {
6868 await JoinCommunity ( community . communityID ) ;
6969
70- // Atualiza a interface após entrar na comunidade
7170 setCommunity ( ( prev : CommunityProps | null ) => prev ? ( {
7271 ...prev ,
73- isMember : true , // Esconde o botão
74- memberCount : ( prev . memberCount || 0 ) + 1 // Atualiza o contador visualmente
72+ isMember : true ,
73+ memberCount : ( prev . memberCount || 0 ) + 1
7574 } ) : null ) ;
7675
7776 setNotification ( { message : 'Você entrou na comunidade!' , type : 'success' } ) ;
@@ -94,7 +93,6 @@ export default function CommunityPage() {
9493 setNotification ( { message : 'Comunidade excluída com sucesso.' , type : 'success' } ) ;
9594 setIsDeleteModalOpen ( false ) ;
9695
97- // Redireciona para home após excluir
9896 setTimeout ( ( ) => {
9997 navigate ( '/feed' ) ;
10098 } , 1500 ) ;
@@ -113,15 +111,14 @@ export default function CommunityPage() {
113111 try {
114112 await LeaveCommunity ( community . communityID ) ;
115113
116- // Atualiza a interface
117114 setCommunity ( ( prev : CommunityProps | null ) => prev ? ( {
118115 ...prev ,
119- isMember : false , // O usuário não é mais membro
120- memberCount : Math . max ( ( prev . memberCount || 0 ) - 1 , 0 ) // Decrementa contador
116+ isMember : false ,
117+ memberCount : Math . max ( ( prev . memberCount || 0 ) - 1 , 0 )
121118 } ) : null ) ;
122119
123120 setNotification ( { message : 'Você saiu da comunidade.' , type : 'success' } ) ;
124- setIsLeaveModalOpen ( false ) ; // Fecha o modal
121+ setIsLeaveModalOpen ( false ) ;
125122
126123 } catch ( error ) {
127124 if ( error instanceof Error ) {
@@ -172,7 +169,10 @@ export default function CommunityPage() {
172169 < S . Banner />
173170
174171 < S . HeaderContainer >
175- < S . Avatar />
172+ < S . Avatar
173+ src = { getAvatarUrl ( community . name || 'comunidade' , 'identicon' ) }
174+ alt = { `Avatar da comunidade ${ community . name } ` }
175+ />
176176 < S . HeaderInfo >
177177 < h1 > { community . name } </ h1 >
178178 < span > { community . memberCount } membros</ span >
0 commit comments