| 4522 |
stevensc |
1 |
/* eslint-disable react/prop-types */
|
|
|
2 |
import React from 'react'
|
|
|
3 |
import { axios } from '../../../../../utils'
|
|
|
4 |
import { addNotification } from '../../../../../redux/notification/notification.actions'
|
|
|
5 |
import Avatar from '../../../../../shared/Avatar/Avatar'
|
|
|
6 |
import { useDispatch } from 'react-redux'
|
|
|
7 |
|
|
|
8 |
const GroupActions = ({ cover, groupId, name, image, groupType, linkInmail, actionLinks, accessibility }) => {
|
|
|
9 |
|
|
|
10 |
const dispatch = useDispatch();
|
|
|
11 |
|
|
|
12 |
const handleActionLink = (url) => {
|
|
|
13 |
axios.post(url)
|
|
|
14 |
.then(({ data }) => {
|
|
|
15 |
if (!data.success) {
|
|
|
16 |
return dispatch(addNotification({ style: 'error', msg: data.data }))
|
|
|
17 |
}
|
|
|
18 |
addNotification({ style: 'success', msg: data.data })
|
|
|
19 |
window.location.reload()
|
|
|
20 |
})
|
|
|
21 |
.catch(err => console.log('>>: err > ', err))
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
return (
|
|
|
25 |
<div className="group__actions">
|
|
|
26 |
<div className="group__actions-cover">
|
|
|
27 |
<img src={`/storage/type/group-cover/code/${groupId}/${cover ? `filename/${cover}` : ""}`} alt='Profile cover' className='sidebar__cover' />
|
|
|
28 |
</div>
|
|
|
29 |
<div className="group__actions-body">
|
|
|
30 |
<Avatar imageUrl={`/storage/type/group/code/${groupId}/${image ? `filename/${image}` : ""}`} size='xl' name={name} />
|
|
|
31 |
<h1>{name}</h1>
|
|
|
32 |
<span>{groupType}</span>
|
|
|
33 |
<div className="row ">
|
|
|
34 |
{linkInmail &&
|
|
|
35 |
<a href={linkInmail} className="btn btn-primary">
|
|
|
36 |
Contactar con el Administrador
|
|
|
37 |
</a>
|
|
|
38 |
}
|
|
|
39 |
{actionLinks.link_accept &&
|
|
|
40 |
<button
|
|
|
41 |
onClick={() => handleActionLink(actionLinks.link_accept)}
|
|
|
42 |
className="btn btn-primary"
|
|
|
43 |
>
|
|
|
44 |
Aceptar invitacion
|
|
|
45 |
</button>
|
|
|
46 |
}
|
|
|
47 |
{
|
|
|
48 |
actionLinks.link_cancel &&
|
|
|
49 |
<button
|
|
|
50 |
onClick={() => handleActionLink(actionLinks.link_cancel)}
|
|
|
51 |
className="btn btn-primary"
|
|
|
52 |
>
|
|
|
53 |
Cancelar invitacion
|
|
|
54 |
</button>
|
|
|
55 |
}
|
|
|
56 |
{actionLinks.link_leave &&
|
|
|
57 |
<button
|
|
|
58 |
onClick={() => handleActionLink(actionLinks.link_leave)}
|
|
|
59 |
className="btn btn-primary"
|
|
|
60 |
>
|
|
|
61 |
Abandonar grupo
|
|
|
62 |
</button>
|
|
|
63 |
}
|
|
|
64 |
{actionLinks.link_request &&
|
|
|
65 |
<button
|
|
|
66 |
onClick={() => handleActionLink(actionLinks.link_request)}
|
|
|
67 |
className="btn btn-primary"
|
|
|
68 |
>
|
|
|
69 |
{accessibility === 'Auto unirse' ? 'Unirse' : 'Solicitar membresia'}
|
|
|
70 |
</button>
|
|
|
71 |
}
|
|
|
72 |
</div>
|
|
|
73 |
</div>
|
|
|
74 |
</div>
|
|
|
75 |
)
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
export default GroupActions
|