Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3156 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3156 Rev 3432
Línea 1... Línea 1...
1
import React from 'react'
1
import React from "react";
2
import { useNavigate } from 'react-router-dom'
2
import { useNavigate } from "react-router-dom";
3
import { Avatar, Button, Typography } from '@mui/material'
3
import { Avatar, Button, Typography } from "@mui/material";
4
import { useDispatch } from 'react-redux'
4
import { useDispatch } from "react-redux";
5
import parse from 'html-react-parser'
5
import parse from "html-react-parser";
Línea 6... Línea 6...
6
 
6
 
7
import { axios } from '@app/utils'
7
import { axios } from "@app/utils";
Línea 8... Línea 8...
8
import { addNotification } from '@app/redux/notification/notification.actions'
8
import { addNotification } from "@app/redux/notification/notification.actions";
Línea 9... Línea 9...
9
 
9
 
10
import Widget from '@components/UI/Widget'
10
import Widget from "@components/UI/Widget";
11
 
11
 
12
export default function CompanyWidget({
12
export default function CompanyWidget({
Línea 20... Línea 20...
20
    link_follow,
20
    link_follow,
21
    link_request,
21
    link_request,
22
    link_accept,
22
    link_accept,
23
    link_cancel,
23
    link_cancel,
24
    link_reject,
24
    link_reject,
25
    link_leave
25
    link_leave,
26
  },
26
  },
27
  refetch = () => {}
27
  refetch = () => {},
28
}) {
28
}) {
29
  const dispatch = useDispatch()
29
  const dispatch = useDispatch();
30
  const navigate = useNavigate()
30
  const navigate = useNavigate();
Línea 31... Línea 31...
31
 
31
 
32
  const handleButtonAction = async (link) => {
32
  const handleButtonAction = async (link) => {
-
 
33
    const response = await axios.post(link);
33
    const { data: response } = await axios.post(link)
34
    const { success, data } = response.data;
34
    if (response.success) {
35
    if (success) {
35
      dispatch(addNotification({ style: 'success', msg: response.data }))
36
      dispatch(addNotification({ style: "success", msg: data }));
36
      refetch()
37
      refetch();
37
    } else {
38
    } else {
38
      dispatch(
39
      dispatch(
39
        addNotification({ style: 'danger', msg: 'ha ocurrido un error' })
40
        addNotification({ style: "danger", msg: "ha ocurrido un error" })
40
      )
41
      );
41
    }
42
    }
Línea 42... Línea 43...
42
  }
43
  };
43
 
44
 
44
  return (
45
  return (
Línea 45... Línea 46...
45
    <Widget>
46
    <Widget>
46
      <Widget.Media height={150} src={cover} />
47
      <Widget.Media height={150} src={cover} />
47
 
48
 
48
      <Widget.Body>
49
      <Widget.Body>
49
        <Avatar
50
        <Avatar
50
          src={image}
51
          src={image}
51
          alt={name}
52
          alt={name}
52
          sx={{ mt: '-40px', width: '80px', height: '80px' }}
53
          sx={{ mt: "-40px", width: "80px", height: "80px" }}
53
        />
54
        />
Línea 54... Línea 55...
54
        <Typography variant='h2'>{name}</Typography>
55
        <Typography variant="h2">{name}</Typography>
55
        <Typography variant='body1'>{parse(overview ?? '')}</Typography>
56
        <Typography variant="body1">{parse(overview ?? "")}</Typography>
56
      </Widget.Body>
57
      </Widget.Body>
57
 
58
 
58
      <Widget.Actions>
59
      <Widget.Actions>
59
        {link_contact && (
60
        {link_contact && (
60
          <Button color='primary' onClick={() => navigate(link_contact)}>
61
          <Button color="primary" onClick={() => navigate(link_contact)}>
61
            Mensaje
62
            Mensaje
62
          </Button>
63
          </Button>
63
        )}
64
        )}
64
        {link_unfollow && (
65
        {link_unfollow && (
65
          <Button
66
          <Button
66
            color='secondary'
67
            color="secondary"
67
            onClick={() => handleButtonAction(link_unfollow)}
68
            onClick={() => handleButtonAction(link_unfollow)}
68
          >
69
          >
69
            Dejar de seguir
70
            Dejar de seguir
70
          </Button>
71
          </Button>
71
        )}
72
        )}
72
        {link_follow && (
73
        {link_follow && (
73
          <Button
74
          <Button
74
            color='primary'
75
            color="primary"
75
            onClick={() => handleButtonAction(link_follow)}
76
            onClick={() => handleButtonAction(link_follow)}
76
          >
77
          >
77
            Seguir
78
            Seguir
78
          </Button>
79
          </Button>
79
        )}
80
        )}
80
        {link_request && link_unfollow && (
81
        {link_request && link_unfollow && (
81
          <Button
82
          <Button
82
            color='secondary'
83
            color="secondary"
83
            onClick={() => handleButtonAction(link_request)}
84
            onClick={() => handleButtonAction(link_request)}
84
          >
85
          >
85
            ¿Trabaja en esta empresa?
86
            ¿Trabaja en esta empresa?
86
          </Button>
87
          </Button>
87
        )}
88
        )}
88
        {link_accept && (
89
        {link_accept && (
89
          <Button
90
          <Button
90
            color='primary'
91
            color="primary"
91
            onClick={() => handleButtonAction(link_accept)}
92
            onClick={() => handleButtonAction(link_accept)}
92
          >
93
          >
93
            Aceptar
94
            Aceptar
94
          </Button>
95
          </Button>
95
        )}
96
        )}
96
        {link_cancel && (
97
        {link_cancel && (
97
          <Button color='info' onClick={() => handleButtonAction(link_cancel)}>
98
          <Button color="info" onClick={() => handleButtonAction(link_cancel)}>
98
            Cancelar
99
            Cancelar
99
          </Button>
100
          </Button>
100
        )}
101
        )}
101
        {link_reject && (
102
        {link_reject && (
102
          <Button color='info' onClick={() => handleButtonAction(link_reject)}>
103
          <Button color="info" onClick={() => handleButtonAction(link_reject)}>
103
            Rechazar
104
            Rechazar
104
          </Button>
105
          </Button>
105
        )}
106
        )}
106
        {link_leave && (
107
        {link_leave && (
107
          <Button
108
          <Button
108
            color='secondary'
109
            color="secondary"
109
            onClick={() => handleButtonAction(link_leave)}
110
            onClick={() => handleButtonAction(link_leave)}
110
          >
111
          >
111
            Abandonar esta empresa
112
            Abandonar esta empresa
112
          </Button>
113
          </Button>
113
        )}
114
        )}