Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4112 Rev 5104
Línea -... Línea 1...
-
 
1
/* eslint-disable camelcase */
1
import React, { useEffect, useState } from "react";
2
import React, { useEffect, useState } from 'react'
2
import { useDispatch } from "react-redux";
3
import { useDispatch } from 'react-redux'
3
import { addNotification } from "../../../redux/notification/notification.actions";
4
import { addNotification } from '../../../redux/notification/notification.actions'
4
import { axios } from "../../../utils";
5
import { axios } from '../../../utils'
-
 
6
import EmptySection from '../../empty-section/EmptySection'
Línea 5... Línea 7...
5
 
7
 
6
const PeopleYouMayKnow = () => {
-
 
7
 
8
const PeopleYouMayKnow = () => {
8
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([]);
9
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([])
9
  const [lookMore, setLookMore] = useState(false);
10
  const [lookMore, setLookMore] = useState(false)
Línea 10... Línea 11...
10
  const dispatch = useDispatch()
11
  const dispatch = useDispatch()
11
 
12
 
12
  const handleConnect = (url) => {
13
  const handleConnect = (url) => {
Línea 27... Línea 28...
27
        }))
28
        }))
28
        return getSuggestion()
29
        return getSuggestion()
29
      })
30
      })
30
  }
31
  }
Línea 31... Línea 32...
31
 
32
 
32
  const getSuggestion = async (url = `/helpers/people-you-may-know`) => {
33
  const getSuggestion = async (url = '/helpers/people-you-may-know') => {
33
    try {
34
    try {
34
      const { data: response } = await axios.get(url)
35
      const { data: response } = await axios.get(url)
35
      if (response.success) setPeopleYouMayKnow(response.data);
36
      if (response.success) setPeopleYouMayKnow(response.data)
36
    } catch (error) {
37
    } catch (error) {
37
      console.log(error);
38
      console.log(error)
38
    }
39
    }
Línea 39... Línea 40...
39
  }
40
  }
40
 
41
 
41
  useEffect(() => {
42
  useEffect(() => {
Línea 42... Línea 43...
42
    getSuggestion()
43
    getSuggestion()
43
  }, []);
44
  }, [])
44
 
45
 
45
  const dataSlice = () => {
46
  const dataSlice = () => {
Línea 51... Línea 52...
51
  }
52
  }
Línea 52... Línea 53...
52
 
53
 
53
  return (
54
  return (
54
    <div className='peopleYouMayKnow'>
55
    <div className='peopleYouMayKnow'>
55
      <div className="sd-title d-flex align-items-center justify-content-between">
56
      <div className="sd-title d-flex align-items-center justify-content-between">
56
        <h3>Conecta con:</h3>
-
 
57
        {
57
        <h3>{`${LABELS.CONNECT_WITH}:`}</h3>
58
          peopleYouMayKnow.length >= 4 &&
58
        {peopleYouMayKnow.length >= 4 &&
59
          <label onClick={() => setLookMore(!lookMore)}>
59
          <label onClick={() => setLookMore(!lookMore)}>
60
            {lookMore ? 'Ver menos' : 'Ver mas'}
60
            {lookMore ? LABELS.VIEW_LESS : LABELS.VIEW_MORE}
61
          </label>
-
 
62
        }
61
          </label>}
63
      </div>
62
      </div>
64
      <div className='suggest-list'>
63
      <div className='suggest-list'>
65
        {peopleYouMayKnow.length
64
        {peopleYouMayKnow.length
66
          ? dataSlice().map(({ id, image, link_cancel, link_request, name, profile }) =>
65
          ? dataSlice().map(({ id, image, link_cancel, link_request, name, profile }) =>
Línea 74... Línea 73...
74
              {link_request &&
73
              {link_request &&
75
                <button
74
                <button
76
                  className="btn btn-primary"
75
                  className="btn btn-primary"
77
                  onClick={() => handleConnect(link_request)}
76
                  onClick={() => handleConnect(link_request)}
78
                >
77
                >
79
                  Conectar
78
                  {LABELS.CONNECT}
80
                </button>
79
                </button>
81
              }
80
              }
82
              {link_cancel &&
81
              {link_cancel &&
83
                <button
82
                <button
84
                  className="btn btn-secondary"
83
                  className="btn btn-secondary"
85
                  onClick={() => handleConnect(link_cancel)}
84
                  onClick={() => handleConnect(link_cancel)}
86
                >
85
                >
87
                  Cancelar
86
                  {LABELS.CANCEL}
88
                </button>
87
                </button>
89
              }
88
              }
90
            </div>
89
            </div>
91
          )
90
          )
92
          : <div className="view-more">Sin sugerencias</div>
91
          : <EmptySection align='left' message={LABELS.DATATABLE_EMPTY} />
93
        }
92
        }
94
      </div>
93
      </div>
95
    </div >
94
    </div>
96
  );
95
  )
97
};
96
}
Línea 98... Línea 97...
98
 
97