Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 4540 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
4540 stevensc 1
/* eslint-disable react/prop-types */
2
import React from 'react'
3
import parse from 'html-react-parser'
4
import { axios } from '../../../../../utils';
5
import { useDispatch } from 'react-redux'
6
import { addNotification } from '../../../../../redux/notification/notification.actions';
7
import Avatar from '../../../../../shared/Avatar/Avatar';
8
 
9
const CompanyActions = ({ cover, companyId, name, image, actionLinks, overview, refetch }) => {
10
 
11
    const dispatch = useDispatch();
12
 
13
    const handleButtonAction = async (link) => {
14
        const { data: response } = await axios.post(link);
15
        if (response.success) {
16
            dispatch(addNotification({ style: "success", msg: response.data }))
17
            refetch();
18
        } else {
19
            dispatch(addNotification({ style: "danger", msg: "ha ocurrido un error" }))
20
        }
21
    };
22
 
23
    return (
24
        <div className="group__actions">
25
            <div className="group__actions-cover">
26
                <img src={`/storage/type/company-cover/code/${companyId}/${cover ? `filename/${cover}` : ""}`} alt='Profile cover' className='sidebar__cover' />
27
            </div>
28
            <div className="group__actions-body">
29
                <Avatar imageUrl={`/storage/type/company/code/${companyId}/${image ? `filename/${image}` : ""}`} size='xl' name={name} />
30
                <h1>{name}</h1>
31
                {parse(overview)}
4541 stevensc 32
                <div className="row" style={{ gap: '.5rem' }}>
33
                    {actionLinks?.link_contact &&
34
                        <a
35
                            href={actionLinks?.link_contact}
36
                            className="button btn btn-primary"
37
                        >
38
                            Mensaje
39
                        </a>
40
                    }
4540 stevensc 41
                    {actionLinks?.link_unfollow &&
42
                        <button
4541 stevensc 43
                            className="button btn btn-secondary"
4540 stevensc 44
                            onClick={() => handleButtonAction(actionLinks?.link_unfollow)}
45
                        >
46
                            Dejar de seguir
47
                        </button>
48
                    }
49
                    {actionLinks?.link_follow &&
50
                        <button
51
                            className="btn btn-primary"
52
                            onClick={() => handleButtonAction(actionLinks?.link_follow)}
53
                        >
54
                            Seguir
55
                        </button>
56
                    }
57
                    {
58
                        (actionLinks?.link_request && actionLinks?.link_unfollow)
59
                        &&
60
                        <button
61
                            className="button btn btn-secondary"
62
                            onClick={() => handleButtonAction(actionLinks?.link_request)}
63
                        >
64
                            ¿Trabaja en esta empresa?
65
                        </button>
66
                    }
67
                    {actionLinks?.link_accept &&
68
                        <button
69
                            className="button btn btn-primary"
70
                            onClick={() => handleButtonAction(actionLinks?.link_accept)}
71
                        >
72
                            Aceptar
73
                        </button>
74
                    }
75
                    {actionLinks?.link_cancel &&
76
                        <button
77
                            title=""
78
                            className="button btn btn-secondary"
79
                            onClick={() => handleButtonAction(actionLinks?.link_cancel)}
80
                        >
81
                            Cancelar
82
                        </button>
83
                    }
84
                    {actionLinks?.link_reject &&
85
                        <button
86
                            title=""
87
                            className="button btn btn-secondary"
88
                            onClick={() => handleButtonAction(actionLinks?.link_reject)}
89
                        >
90
                            Rechazar
91
                        </button>
92
                    }
93
                    {actionLinks?.link_leave &&
94
                        <button
95
                            data-link="{{>link_leave}}"
96
                            title=""
97
                            className="button btn btn-secondary"
98
                            onClick={() => handleButtonAction(actionLinks?.link_leave)}
99
                        >
100
                            Abandonar esta empresa
101
                        </button>
102
                    }
103
                </div>
104
            </div>
105
        </div>
106
    )
107
}
108
 
109
export default CompanyActions