Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 4628 | Rev 4645 | 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
                    }
4641 stevensc 39
                    {actionLinks?.link_accept &&
4522 stevensc 40
                        <button
4641 stevensc 41
                            onClick={() => handleActionLink(actionLinks?.link_accept)}
4527 stevensc 42
                            className="button btn btn-primary"
4522 stevensc 43
                        >
44
                            Aceptar invitacion
45
                        </button>
46
                    }
4641 stevensc 47
                    {actionLinks?.link_cancel &&
4522 stevensc 48
                        <button
4641 stevensc 49
                            onClick={() => handleActionLink(actionLinks?.link_cancel)}
4527 stevensc 50
                            className="button btn btn-secondary"
4522 stevensc 51
                        >
52
                            Cancelar invitacion
53
                        </button>
54
                    }
4641 stevensc 55
                    {actionLinks?.link_leave &&
4522 stevensc 56
                        <button
4641 stevensc 57
                            onClick={() => handleActionLink(actionLinks?.link_leave)}
4527 stevensc 58
                            className="button btn btn-secondary"
4522 stevensc 59
                        >
60
                            Abandonar grupo
61
                        </button>
62
                    }
4641 stevensc 63
                    {actionLinks?.link_request &&
4522 stevensc 64
                        <button
4641 stevensc 65
                            onClick={() => handleActionLink(actionLinks?.link_request)}
4527 stevensc 66
                            className="button btn btn-primary"
4522 stevensc 67
                        >
68
                            {accessibility === 'Auto unirse' ? 'Unirse' : 'Solicitar membresia'}
69
                        </button>
70
                    }
71
                </div>
72
            </div>
73
        </div>
74
    )
75
}
76
 
77
export default GroupActions