Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 7157 Rev 7158
Línea 44... Línea 44...
44
  const [questionsCategories, setQuestionsCategories] = useState([])
44
  const [questionsCategories, setQuestionsCategories] = useState([])
45
  const [search, setSearch] = useState('')
45
  const [search, setSearch] = useState('')
46
  const [category, setCategory] = useState('')
46
  const [category, setCategory] = useState('')
47
  const [currentPage, setCurrentPage] = useState(1)
47
  const [currentPage, setCurrentPage] = useState(1)
48
  const [totalPages, setTotalPages] = useState(1)
48
  const [totalPages, setTotalPages] = useState(1)
49
  const [allowAdd, setAllowAdd] = useState(false)
-
 
50
  const [modalShow, setModalShow] = useState(null)
49
  const [modalShow, setModalShow] = useState(null)
51
  const addUrl = useRef('')
50
  const addUrl = useRef('/my-coach/questions/add')
52
  const actionUrl = useRef('')
51
  const actionUrl = useRef('')
53
  const labels = useSelector(({ intl }) => intl.labels)
52
  const labels = useSelector(({ intl }) => intl.labels)
54
  const dispatch = useDispatch()
53
  const dispatch = useDispatch()
Línea 55... Línea 54...
55
 
54
 
Línea 69... Línea 68...
69
 
68
 
70
          dispatch(addNotification({ style: 'danger', msg: errorMessage }))
69
          dispatch(addNotification({ style: 'danger', msg: errorMessage }))
71
          return
70
          return
Línea -... Línea 71...
-
 
71
        }
-
 
72
 
-
 
73
        const categories = Object.entries(data.categories).map((values) => ({
-
 
74
          name: values[1],
-
 
75
          uuid: values[0],
72
        }
76
        }))
73
 
77
 
74
        setQuestionsCategories(data.categories)
78
        setQuestionsCategories(categories)
75
      })
79
      })
76
      .catch((error) => {
80
      .catch((error) => {
77
        dispatch(
81
        dispatch(
Línea 85... Línea 89...
85
  }
89
  }
Línea 86... Línea 90...
86
 
90
 
87
  const getQuestions = (search = '', page = 1, category_id = '') => {
91
  const getQuestions = (search = '', page = 1, category_id = '') => {
88
    const urlParams = { search, page, category_id }
92
    const urlParams = { search, page, category_id }
89
    axios
93
    axios
90
      .get(`my-coach/questions?${jsonToParams(urlParams)}`, {
94
      .get(`/my-coach/questions?${jsonToParams(urlParams)}`, {
91
        headers: {
95
        headers: {
92
          'Content-Type': 'application/json',
96
          'Content-Type': 'application/json',
93
        },
97
        },
94
      })
98
      })
Línea 101... Línea 105...
101
 
105
 
102
          dispatch(addNotification({ style: 'danger', msg: errorMessage }))
106
          dispatch(addNotification({ style: 'danger', msg: errorMessage }))
103
          return
107
          return
Línea -... Línea 108...
-
 
108
        }
104
        }
109
 
-
 
110
        setQuestions(data.items)
-
 
111
        setCurrentPage(data.page)
105
 
112
        setTotalPages(data.total_pages)
106
        console.log(data)
113
        addUrl.current = data.link_add
107
      })
114
      })
108
      .catch((error) => {
115
      .catch((error) => {
109
        dispatch(
116
        dispatch(
Línea 180... Línea 187...
180
  return (
187
  return (
181
    <>
188
    <>
182
      <Container as="section" className="companies-info">
189
      <Container as="section" className="companies-info">
183
        <div className="company-title">
190
        <div className="company-title">
184
          <h1 className="title mx-auto">{labels.knowledge_area_title}</h1>
191
          <h1 className="title mx-auto">{labels.knowledge_area_title}</h1>
185
          {allowAdd && (
-
 
186
            <h2
192
          <h2
187
              className="title cursor-pointer"
193
            className="title cursor-pointer"
188
              onClick={() => addQuestion(addUrl.current)}
194
            onClick={() => addQuestion(addUrl.current)}
189
            >
195
          >
190
              {labels.knowledge_area_add}
196
            {labels.knowledge_area_add}
191
            </h2>
197
          </h2>
192
          )}
-
 
193
        </div>
198
        </div>
Línea 194... Línea 199...
194
 
199
 
195
        <Row className="gap-3">
200
        <Row className="gap-3">
196
          <Col md="3">
201
          <Col md="3">