Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Ir a la última revisión | | 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)}
32
                <div className="row ">
33
                    {actionLinks?.link_unfollow &&
34
                        <button
35
                            className="btn btn-primary"
36
                            onClick={() => handleButtonAction(actionLinks?.link_unfollow)}
37
                        >
38
                            Dejar de seguir
39
                        </button>
40
                    }
41
                    {actionLinks?.link_follow &&
42
                        <button
43
                            className="btn btn-primary"
44
                            onClick={() => handleButtonAction(actionLinks?.link_follow)}
45
                        >
46
                            Seguir
47
                        </button>
48
                    }
49
                    {
50
                        (actionLinks?.link_request && actionLinks?.link_unfollow)
51
                        &&
52
                        <button
53
                            className="button btn btn-secondary"
54
                            onClick={() => handleButtonAction(actionLinks?.link_request)}
55
                        >
56
                            ¿Trabaja en esta empresa?
57
                        </button>
58
                    }
59
                    {actionLinks?.link_accept &&
60
                        <button
61
                            className="button btn btn-primary"
62
                            onClick={() => handleButtonAction(actionLinks?.link_accept)}
63
                        >
64
                            Aceptar
65
                        </button>
66
                    }
67
                    {actionLinks?.link_cancel &&
68
                        <button
69
                            title=""
70
                            className="button btn btn-secondary"
71
                            onClick={() => handleButtonAction(actionLinks?.link_cancel)}
72
                        >
73
                            Cancelar
74
                        </button>
75
                    }
76
                    {actionLinks?.link_reject &&
77
                        <button
78
                            title=""
79
                            className="button btn btn-secondary"
80
                            onClick={() => handleButtonAction(actionLinks?.link_reject)}
81
                        >
82
                            Rechazar
83
                        </button>
84
                    }
85
                    {actionLinks?.link_leave &&
86
                        <button
87
                            data-link="{{>link_leave}}"
88
                            title=""
89
                            className="button btn btn-secondary"
90
                            onClick={() => handleButtonAction(actionLinks?.link_leave)}
91
                        >
92
                            Abandonar esta empresa
93
                        </button>
94
                    }
95
                    {actionLinks?.link_contact &&
96
                        <a
97
                            href={actionLinks?.link_contact}
98
                            className="button btn btn-primary"
99
                        >
100
                            Mensaje
101
                        </a>
102
                    }
103
                </div>
104
            </div>
105
        </div>
106
    )
107
}
108
 
109
export default CompanyActions