Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
4250 stevensc 1
/* eslint-disable react/prop-types */
2
import React from 'react'
3
import { useDispatch } from 'react-redux'
4263 stevensc 4
import { addNotification } from '../../../../redux/notification/notification.actions'
5
import { axios } from '../../../../utils'
4250 stevensc 6
 
7
const GroupInfo = ({
8
    group_uuid = '',
9
    image = '',
10
    name = '',
11
    accessibility = '',
12
    total_members = '',
13
    link_inmail = '',
14
    link_accept = '',
15
    link_cancel = '',
16
    link_request = '',
17
    link_leave = '',
18
    onComplete = function () { }
19
}) => {
20
 
21
    const dispatch = useDispatch()
22
 
23
    const handleGroupActions = (url) => {
24
        axios.post(url)
25
            .then(({ data }) => {
26
                if (!data.success) {
27
                    dispatch(addNotification({ style: 'danger', msg: data.data }))
28
                    return
29
                }
30
                dispatch(addNotification({ style: 'success', msg: data.data }))
31
                onComplete()
32
            })
33
            .catch(err => console.log('>>: err > ', err))
34
    }
35
 
36
    return (
37
        <div className="user_profile border-gray overflow-hidden m-0 p-1 mb-2">
38
            <div className="user-pro-img">
39
                <img
40
                    src={`/storage/type/group/code/${group_uuid}/${image ? `filename/${image}` : ""}`}
41
                    alt="profile-image"
42
                />
43
            </div>
44
            <div className="user_pro_status">
45
                <h1 className="font-weight-bold" style={{ fontSize: '1.5rem' }} >{name}</h1>
46
                <ul className="flw-status">
47
                    <div className="container horizontal-list">
48
                        <div className="row ">
49
                            {link_inmail &&
50
                                <a
51
                                    href={link_inmail}
52
                                    className="btn btn-primary"
53
                                >
54
                                    Contactar con el Administrador
55
                                </a>
56
                            }
57
                            <div className="members_count">
58
                                <b style={{ fontSize: '1rem' }} >{total_members}</b>
59
                                <p>Miembros</p>
60
                            </div>
61
                            {link_accept &&
62
                                <button
63
                                    onClick={() => handleGroupActions(link_accept)}
64
                                    className="btn btn-primary"
65
                                >
66
                                    Aceptar invitacion
67
                                </button>
68
                            }
69
                            {link_cancel &&
70
                                <button
71
                                    onClick={() => handleGroupActions(link_cancel)}
72
                                    className="btn btn-primary"
73
                                >
74
                                    Cancelar invitacion
75
                                </button>
76
                            }
77
                            {(!link_request && link_leave) &&
78
                                <button
79
                                    onClick={() => handleGroupActions(link_leave)}
80
                                    className="btn btn-primary"
81
                                >
82
                                    Abandonar grupo
83
                                </button>
84
                            }
85
                            {link_request &&
86
                                <button
87
                                    onClick={() => handleGroupActions(link_request)}
88
                                    className="btn btn-primary"
89
                                >
90
                                    {accessibility === 'Auto unirse' ? 'Unirse' : 'Solicitar membresia'}
91
                                </button>
92
                            }
93
                        </div>
94
                    </div>
95
                </ul>
96
            </div>
97
        </div>
98
    )
99
}
100
 
101
export default GroupInfo