Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 4620 | Rev 4641 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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 (
4628 stevensc 25
        <div className="group__actions">
4522 stevensc 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>
4528 stevensc 33
                <div className="row" style={{ gap: '.5rem' }}>
4522 stevensc 34
                    {linkInmail &&
4527 stevensc 35
                        <a href={linkInmail} className="button btn btn-primary">
4522 stevensc 36
                            Contactar con el Administrador
37
                        </a>
38
                    }
39
                    {actionLinks.link_accept &&
40
                        <button
41
                            onClick={() => handleActionLink(actionLinks.link_accept)}
4527 stevensc 42
                            className="button btn btn-primary"
4522 stevensc 43
                        >
44
                            Aceptar invitacion
45
                        </button>
46
                    }
47
                    {
48
                        actionLinks.link_cancel &&
49
                        <button
50
                            onClick={() => handleActionLink(actionLinks.link_cancel)}
4527 stevensc 51
                            className="button btn btn-secondary"
4522 stevensc 52
                        >
53
                            Cancelar invitacion
54
                        </button>
55
                    }
56
                    {actionLinks.link_leave &&
57
                        <button
58
                            onClick={() => handleActionLink(actionLinks.link_leave)}
4527 stevensc 59
                            className="button btn btn-secondary"
4522 stevensc 60
                        >
61
                            Abandonar grupo
62
                        </button>
63
                    }
64
                    {actionLinks.link_request &&
65
                        <button
66
                            onClick={() => handleActionLink(actionLinks.link_request)}
4527 stevensc 67
                            className="button btn btn-primary"
4522 stevensc 68
                        >
69
                            {accessibility === 'Auto unirse' ? 'Unirse' : 'Solicitar membresia'}
70
                        </button>
71
                    }
72
                </div>
73
            </div>
74
        </div>
75
    )
76
}
77
 
78
export default GroupActions