Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 7015 Rev 7019
Línea 1... Línea 1...
1
import React, { useEffect, useState } from 'react'
1
import React, { useEffect, useState } from 'react'
2
import { axios } from '../../utils'
2
import { axios } from '../../utils'
3
import { useDispatch, useSelector } from 'react-redux'
3
import { useDispatch, useSelector } from 'react-redux'
4
import { addNotification } from '../../redux/notification/notification.actions'
4
import { addNotification } from '../../redux/notification/notification.actions'
-
 
5
import EmptySection from '../../components/UI/EmptySection'
-
 
6
 
-
 
7
const mock = {
-
 
8
  items: [
-
 
9
    {
-
 
10
      image:
-
 
11
        '/storage/type/knowledge-area/code/facd46a7-70dd-4a8f-9827-605b8f32aaeb/filename/646e347a5124e-area1.png/',
-
 
12
      title: 'Programa #1',
-
 
13
      description:
-
 
14
        'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliq...',
-
 
15
      category: 'Programas de Desarrollo',
-
 
16
      link_view: '/knowledge-area/view/facd46a7-70dd-4a8f-9827-605b8f32aaeb',
-
 
17
      link_edit: '/knowledge-area/edit/facd46a7-70dd-4a8f-9827-605b8f32aaeb',
-
 
18
      link_delete:
-
 
19
        '/knowledge-area/delete/facd46a7-70dd-4a8f-9827-605b8f32aaeb',
-
 
20
    },
-
 
21
    {
-
 
22
      image:
-
 
23
        '/storage/type/knowledge-area/code/174ae74a-3e97-4820-a35e-8315d3a698ff/filename/646e39ca08a08-profile_1.png/',
-
 
24
      title: 'Desarrollo web',
-
 
25
      description: 'Prueba de desarrollo',
-
 
26
      category: 'Programas de Desarrollo',
-
 
27
      link_view: '/knowledge-area/view/174ae74a-3e97-4820-a35e-8315d3a698ff',
-
 
28
      link_edit: '/knowledge-area/edit/174ae74a-3e97-4820-a35e-8315d3a698ff',
-
 
29
      link_delete:
-
 
30
        '/knowledge-area/delete/174ae74a-3e97-4820-a35e-8315d3a698ff',
-
 
31
    },
-
 
32
  ],
-
 
33
  total: 2,
-
 
34
  page: 1,
-
 
35
  total_pages: 10,
-
 
36
}
Línea 5... Línea 37...
5
 
37
 
6
const KnowledgeAreaPage = ({ allowAdd = true, content_edit = true }) => {
38
const KnowledgeAreaPage = ({ allowAdd = true, content_edit = true }) => {
7
  const [knowledges, setKnowledges] = useState([])
39
  const [knowledges, setKnowledges] = useState([])
8
  const [knowledgesCategories, setKnowledgesCategories] = useState([])
40
  const [knowledgesCategories, setKnowledgesCategories] = useState([])
Línea 15... Línea 47...
15
        headers: {
47
        headers: {
16
          'Content-Type': 'application/json',
48
          'Content-Type': 'application/json',
17
        },
49
        },
18
      })
50
      })
19
      .then((response) => {
51
      .then((response) => {
20
        console.log(response.data)
52
        const { data, success } = response.data
-
 
53
 
-
 
54
        if (!success) {
-
 
55
          const errorMessage =
-
 
56
            typeof data === 'string'
-
 
57
              ? data
-
 
58
              : 'Ha ocurrido un error, por favor intente más tarde.'
-
 
59
 
-
 
60
          dispatch(addNotification({ style: 'danger', msg: errorMessage }))
-
 
61
          return
-
 
62
        }
-
 
63
 
-
 
64
        setKnowledges(data.items)
21
      })
65
      })
22
      .catch((error) => {
66
      .catch((error) => {
23
        dispatch(
67
        dispatch(
24
          addNotification({
68
          addNotification({
25
            style: 'danger',
69
            style: 'danger',
Línea 70... Línea 114...
70
              />
114
              />
71
              <button className="btn btn-search">{labels.search}</button>
115
              <button className="btn btn-search">{labels.search}</button>
72
            </form>
116
            </form>
73
          </div>
117
          </div>
Línea -... Línea 118...
-
 
118
 
-
 
119
          <div className="knowledge-record-list mt-3">
-
 
120
            {knowledges.length ? (
-
 
121
              knowledges.map((knowledge, index) => (
74
 
122
                <Item key={index} {...knowledge} />
-
 
123
              ))
75
          <div
124
            ) : (
76
            id="knowledge-record-list"
125
              <EmptySection
-
 
126
                message={labels.error_no_record_matched_your_query}
-
 
127
              />
77
            className="knowledge-record-list mt-3"
128
            )}
Línea 78... Línea 129...
78
          ></div>
129
          </div>
79
 
130
 
80
          <div id="knowledge-record-pagination"></div>
131
          {/* <div id="knowledge-record-pagination"></div> */}
81
        </div>
132
        </div>
82
      </div>
133
      </div>
83
    </section>
134
    </section>
Línea -... Línea 135...
-
 
135
  )
-
 
136
}
-
 
137
 
-
 
138
const Item = ({
-
 
139
  link_delete,
-
 
140
  link_view,
-
 
141
  link_edit,
-
 
142
  category,
-
 
143
  description,
-
 
144
  image,
-
 
145
  title,
-
 
146
}) => {
-
 
147
  return (
-
 
148
    <div className="knowledge-record-card">
-
 
149
      <a
-
 
150
        href={link_view}
-
 
151
        target="_blank"
-
 
152
        className="knowledge-record-card-actions-view"
-
 
153
        rel="noreferrer"
-
 
154
      >
-
 
155
        <img src={image} alt={`${title} image`} />
-
 
156
      </a>
-
 
157
      <div className="d-flex align-items-center justify-content-between">
-
 
158
        {link_edit && (
-
 
159
          <button data-link="{{>link_edit}}" className="btn-knowledge-edit">
-
 
160
            <i className="fa fa-pencil" aria-hidden="true" />
-
 
161
          </button>
-
 
162
        )}
-
 
163
 
-
 
164
        {link_delete && (
-
 
165
          <button data-link="{{>link_delete}}" className="btn-knowledge-delete">
-
 
166
            <i className="fa fa-trash" aria-hidden="true" />
-
 
167
          </button>
-
 
168
        )}
-
 
169
      </div>
-
 
170
      <h3>{category}</h3>
-
 
171
      <a href={link_view} target="_blank" rel="noreferrer">
-
 
172
        <h2>{title}</h2>
-
 
173
      </a>
-
 
174
      <p>{description}</p>
-
 
175
    </div>
84
  )
176
  )