Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2875 Rev 2936
Línea 1... Línea 1...
1
import React, { useEffect, useState } from 'react'
1
import React from 'react'
2
import { useDispatch, useSelector } from 'react-redux'
2
import { useSelector } from 'react-redux'
3
import { Search } from '@mui/icons-material'
3
import { Search } from '@mui/icons-material'
Línea 4... Línea 4...
4
 
4
 
5
import { debounce } from '../../utils'
5
import { debounce } from '@utils'
6
import { searchEntities } from '../../services/items'
-
 
7
import { addNotification } from '../../redux/notification/notification.actions'
6
import { useFetch, useSearchQuery } from '@hooks'
8
 
-
 
9
import Spinner from '../../components/UI/Spinner'
7
 
10
import Input from '../../components/UI/inputs/Input'
8
import Input from '@components/UI/inputs/Input'
11
import TitleSection from '../../components/UI/TitleSection'
9
import TitleSection from '@components/UI/TitleSection'
12
import EmptySection from '../../components/UI/EmptySection'
-
 
Línea 13... Línea 10...
13
import ProfileItem from '../../components/profile/ProfileItem'
10
import AppliedJobsList from '@components/job/AppliedJobsList'
14
 
-
 
15
const AppliedJobsPage = () => {
-
 
16
  const [appliedJobs, setMyProfiles] = useState([])
-
 
17
  const [loading, setLoading] = useState(false)
11
 
Línea -... Línea 12...
-
 
12
const AppliedJobsPage = () => {
18
  const [search, setSearch] = useState('')
13
  const labels = useSelector(({ intl }) => intl.labels)
-
 
14
 
-
 
15
  const { getStringParams, setParam } = useSearchQuery()
Línea 19... Línea -...
19
  const labels = useSelector(({ intl }) => intl.labels)
-
 
20
 
-
 
21
  const dispatch = useDispatch()
-
 
22
 
-
 
23
  const getAppliedJobs = async (search = '') => {
-
 
24
    setLoading(true)
-
 
25
    try {
-
 
26
      const { success, data } = await searchEntities('job/applied-jobs', search)
-
 
27
 
-
 
28
      if (!success) {
-
 
29
        dispatch(addNotification({ style: 'danger', msg: data }))
-
 
30
        setLoading(false)
-
 
31
        return
-
 
32
      }
-
 
33
 
-
 
34
      setMyProfiles(data)
-
 
35
    } catch (error) {
-
 
36
      dispatch(addNotification({ style: 'danger', msg: error.message }))
-
 
37
    } finally {
-
 
38
      setLoading(false)
16
  const { data, isLoading, refetch } = useFetch(
39
    }
-
 
40
  }
-
 
41
 
-
 
42
  const handleSearch = debounce((value) => setSearch(value), 500)
-
 
Línea 43... Línea 17...
43
 
17
    '/job/applied-jobs' + getStringParams()
44
  useEffect(() => {
18
  )
45
    getAppliedJobs(search)
19
 
46
  }, [search])
20
  const handleSearch = debounce((e) => setParam('search', e.target.value))
47
 
-
 
48
  return (
-
 
49
    <main className='companies-info container'>
-
 
50
      <TitleSection title={labels.jobs_applied} />
-
 
51
      <Input icon={<Search />} onChange={handleSearch} variant='search' />
-
 
52
      {loading ? (
21
 
53
        <Spinner />
-
 
54
      ) : (
-
 
55
        <ul className='companies-list'>
-
 
56
          {appliedJobs.length ? (
-
 
57
            appliedJobs.map(({ id, title, employment_type, ...rest }) => (
-
 
58
              <ProfileItem
-
 
59
                key={id}
-
 
60
                name={title}
-
 
61
                status={employment_type}
-
 
62
                {...rest}
-
 
63
                fetchCallback={getAppliedJobs}
-
 
64
                btnAcceptTitle={labels.view_job}
-
 
65
                btnLeaveTitle={labels.job_request_cancel}
-
 
66
              />
-
 
67
            ))
-
 
68
          ) : (
-
 
69
            <EmptySection
-
 
70
              align='left'
-
 
71
              message={labels.datatable_szerorecords}
22
  return (
72
            />
23
    <>
73
          )}
24
      <TitleSection title={labels.jobs_applied} />
Línea 74... Línea 25...
74
        </ul>
25
      <Input icon={<Search />} onChange={handleSearch} variant='search' />