Rev 4527 | Rev 4628 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
/* eslint-disable react/prop-types */
import React from 'react'
import { axios } from '../../../../../utils'
import { addNotification } from '../../../../../redux/notification/notification.actions'
import Avatar from '../../../../../shared/Avatar/Avatar'
import { useDispatch } from 'react-redux'
const GroupActions = ({ cover, groupId, name, image, groupType, linkInmail, actionLinks, accessibility }) => {
const dispatch = useDispatch();
const handleActionLink = (url) => {
axios.post(url)
.then(({ data }) => {
if (!data.success) {
return dispatch(addNotification({ style: 'error', msg: data.data }))
}
addNotification({ style: 'success', msg: data.data })
window.location.reload()
})
.catch(err => console.log('>>: err > ', err))
}
return (
<div className="group__actions">
<div className="group__actions-cover">
<img src={`/storage/type/group-cover/code/${groupId}/${cover ? `filename/${cover}` : ""}`} alt='Profile cover' className='sidebar__cover' />
</div>
<div className="group__actions-body">
<Avatar imageUrl={`/storage/type/group/code/${groupId}/${image ? `filename/${image}` : ""}`} size='xl' name={name} />
<h1>{name}</h1>
<span>{groupType}</span>
<div className="row" style={{ gap: '.5rem' }}>
{linkInmail &&
<a href={linkInmail} className="button btn btn-primary">
Contactar con el Administrador
</a>
}
{actionLinks.link_accept &&
<button
onClick={() => handleActionLink(actionLinks.link_accept)}
className="button btn btn-primary"
>
Aceptar invitacion
</button>
}
{
actionLinks.link_cancel &&
<button
onClick={() => handleActionLink(actionLinks.link_cancel)}
className="button btn btn-secondary"
>
Cancelar invitacion
</button>
}
{actionLinks.link_leave &&
<button
onClick={() => handleActionLink(actionLinks.link_leave)}
className="button btn btn-secondary"
>
Abandonar grupo
</button>
}
{actionLinks.link_request &&
<button
onClick={() => handleActionLink(actionLinks.link_request)}
className="button btn btn-primary"
>
{accessibility === 'Auto unirse' ? 'Unirse' : 'Solicitar membresia'}
</button>
}
</div>
</div>
</div>
)
}
export default GroupActions