Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3445 Rev 3446
Línea 29... Línea 29...
29
  linkInmail,
29
  linkInmail,
30
  following,
30
  following,
31
  totalConnections,
31
  totalConnections,
32
  facebook,
32
  facebook,
33
  twitter,
33
  twitter,
34
  instagram
34
  instagram,
-
 
35
  edit
35
}) => {
36
}) => {
36
  const [isConnecting, setIsConnecting] = useState(false);
37
  const [isConnecting, setIsConnecting] = useState(false);
37
  const [isAdded, setIsAdded] = useState(!requestConnection);
38
  const [isAdded, setIsAdded] = useState(!requestConnection);
38
  const [connectionUrl, setConnectionUrl] = useState(linkRequest || linkCancel || '');
39
  const [connectionUrl, setConnectionUrl] = useState(linkRequest || linkCancel || '');
39
  const [isModalOpen, setIsModalOpen] = useState(false);
40
  const [showConfirmationModal, setShowConfirmationModal] = useState(false);
40
  const labels = useSelector(({ intl }) => intl.labels);
41
  const labels = useSelector(({ intl }) => intl.labels);
41
  const { pathname } = useLocation();
42
  const { pathname } = useLocation();
42
  const dispatch = useDispatch();
43
  const dispatch = useDispatch();
Línea -... Línea 44...
-
 
44
 
-
 
45
  const toggleConfirmationModal = () => setShowConfirmationModal(!showConfirmationModal);
43
 
46
 
44
  const fetchConnectionUrls = useCallback(async () => {
47
  const fetchConnectionUrls = useCallback(async () => {
45
    try {
48
    try {
46
      const response = await axios.get(pathname);
49
      const response = await axios.get(pathname);
47
      const { link_request, link_cancel } = response.data;
50
      const { link_request, link_cancel } = response.data;
Línea 66... Línea 69...
66
      if (!success) {
69
      if (!success) {
67
        dispatch(addNotification({ style: 'danger', msg: data }));
70
        dispatch(addNotification({ style: 'danger', msg: data }));
68
      } else {
71
      } else {
69
        dispatch(addNotification({ style: 'success', msg: data }));
72
        dispatch(addNotification({ style: 'success', msg: data }));
70
        setIsAdded(!isAdded);
73
        setIsAdded(!isAdded);
71
        if (isModalOpen) {
74
        if (showConfirmationModal) {
72
          setIsModalOpen(false);
75
          toggleConfirmationModal();
73
        }
76
        }
74
        fetchConnectionUrls();
77
        fetchConnectionUrls();
75
      }
78
      }
76
    } catch (error) {
79
    } catch (error) {
77
      dispatch(addNotification({ style: 'danger', msg: `Error: ${error.message}` }));
80
      dispatch(addNotification({ style: 'danger', msg: `Error: ${error.message}` }));
78
    } finally {
81
    } finally {
79
      setIsConnecting(false);
82
      setIsConnecting(false);
80
    }
83
    }
81
  }, [connectionUrl, isAdded, dispatch, isModalOpen, fetchConnectionUrls]);
84
  }, [connectionUrl, isAdded, dispatch, showConfirmationModal, fetchConnectionUrls]);
Línea 82... Línea 85...
82
 
85
 
83
  return (
86
  return (
84
    <Widget>
87
    <Widget>
Línea 85... Línea 88...
85
      <Cover cover={cover} size={coverSize} url={coverUrl} />
88
      <Cover cover={cover} size={coverSize} url={coverUrl} edit={edit} />
86
 
89
 
87
      <Widget.Body>
90
      <Widget.Body>
88
        <Box sx={{ alignItems: 'center', mt: -40 }}>
91
        <Box sx={{ alignItems: 'center', mt: '-40px' }}>
89
          <Avatar
92
          <Avatar
90
            src={avatar}
93
            src={avatar}
91
            alt={name}
94
            alt={name}
92
            size={avatarSize}
95
            size={avatarSize}
93
            uploadUrl={avatarUrl}
96
            uploadUrl={avatarUrl}
-
 
97
            badgeStyles={{ mt: -75 }}
94
            badgeStyles={{ mt: -75 }}
98
            styles={{ width: 150, height: 150 }}
95
            styles={{ width: 150, height: 150 }}
99
            edit={edit}
96
          />
100
          />
97
        </Box>
101
        </Box>
98
        <Typography variant='h2'>{name}</Typography>
102
        <Typography variant='h2'>{name}</Typography>
Línea 111... Línea 115...
111
            </Link>
115
            </Link>
112
          )}
116
          )}
113
        </Row>
117
        </Row>
114
        <Row>
118
        <Row>
115
          {connectionUrl && isAdded && (
119
          {connectionUrl && isAdded && (
116
            <Button color='primary' onClick={() => setIsModalOpen(true)} disabled={isConnecting}>
120
            <Button color='primary' onClick={toggleConfirmationModal} disabled={isConnecting}>
117
              {labels.cancel}
121
              {labels.cancel}
118
            </Button>
122
            </Button>
119
          )}
123
          )}
120
          {connectionUrl && !isAdded && (
124
          {connectionUrl && !isAdded && (
121
            <Button color='primary' onClick={handleConnect} disabled={isConnecting}>
125
            <Button color='primary' onClick={handleConnect} disabled={isConnecting}>
Línea 129... Línea 133...
129
          )}
133
          )}
130
        </Row>
134
        </Row>
131
      </Widget.Body>
135
      </Widget.Body>
Línea 132... Línea 136...
132
 
136
 
133
      <ProfileModal
-
 
134
        closeModal={() => setIsModalOpen(false)}
137
      <ProfileModal
135
        fullName={name}
138
        fullName={name}
136
        facebook={facebook}
139
        facebook={facebook}
137
        twitter={twitter}
140
        twitter={twitter}
138
        instagram={instagram}
141
        instagram={instagram}
139
        following={following}
142
        following={following}
140
        formatted_address={address}
143
        formatted_address={address}
141
        overview={description}
144
        overview={description}
142
        total_connections={totalConnections}
145
        total_connections={totalConnections}
143
      />
146
      />
144
      <ConfirmModal
147
      <ConfirmModal
145
        show={isModalOpen}
148
        show={showConfirmationModal}
146
        onClose={() => setIsModalOpen(false)}
149
        onClose={toggleConfirmationModal}
147
        onAccept={handleConnect}
150
        onAccept={handleConnect}
148
        isLoading={isConnecting}
151
        isLoading={isConnecting}
149
      />
152
      />
150
    </Widget>
153
    </Widget>