Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3741 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3741 Rev 3746
Línea 1... Línea 1...
1
import React from 'react';
1
import React from 'react';
-
 
2
import { useNavigate } from 'react-router-dom';
Línea 2... Línea 3...
2
 
3
 
3
import { useAlertModal, useModal } from '@shared/hooks';
4
import { useAlertModal, useModal } from '@shared/hooks';
4
import { useCategories, useQuestions } from '@my-coach/hooks';
5
import { useCategories, useQuestions } from '@my-coach/hooks';
Línea 14... Línea 15...
14
  Grid
15
  Grid
15
} from '@shared/components';
16
} from '@shared/components';
16
import { QuestionCard, QuestionForm } from '@my-coach/components';
17
import { QuestionCard, QuestionForm } from '@my-coach/components';
Línea 17... Línea 18...
17
 
18
 
-
 
19
export function MyCoachPage() {
-
 
20
  const navigate = useNavigate();
-
 
21
 
-
 
22
  const { showModal, closeModal } = useModal();
-
 
23
  const { showAlert, closeAlert } = useAlertModal();
-
 
24
 
-
 
25
  const { categories, loading: categoriesLoading } = useCategories();
18
export function MyCoachPage() {
26
 
19
  const {
27
  const {
20
    questions,
28
    questions,
21
    loading,
29
    loading,
22
    hasMore,
30
    hasMore,
Línea 29... Línea 37...
29
    editQuestion,
37
    editQuestion,
30
    deleteQuestion,
38
    deleteQuestion,
31
    addQuestion
39
    addQuestion
32
  } = useQuestions();
40
  } = useQuestions();
Línea 33... Línea -...
33
 
-
 
34
  const { categories, loading: categoriesLoading } = useCategories();
-
 
35
 
-
 
36
  const { showModal, closeModal } = useModal();
-
 
37
  const { showAlert, closeAlert } = useAlertModal();
-
 
38
 
41
 
39
  const handleAddQuestion = () => {
42
  const handleAddQuestion = () => {
40
    showModal(
43
    showModal(
41
      'Agregar pregunta',
44
      'Agregar pregunta',
42
      <QuestionForm
45
      <QuestionForm
Línea 54... Línea 57...
54
      'Editar pregunta',
57
      'Editar pregunta',
55
      <QuestionForm
58
      <QuestionForm
56
        question={question}
59
        question={question}
57
        categories={categories}
60
        categories={categories}
58
        onSubmit={(data) => {
61
        onSubmit={(data) => {
59
          editQuestion(question.uuid, data);
62
          editQuestion(question.link_edit, data);
60
          closeModal();
63
          closeModal();
61
        }}
64
        }}
62
      />
65
      />
63
    );
66
    );
64
  };
67
  };
Línea 98... Línea 101...
98
        emptyMessage='No hay preguntas para mostrar'
101
        emptyMessage='No hay preguntas para mostrar'
99
        keyExtractor={(question) => question.uuid}
102
        keyExtractor={(question) => question.uuid}
100
        renderItem={(question) => (
103
        renderItem={(question) => (
101
          <QuestionCard
104
          <QuestionCard
102
            question={question}
105
            question={question}
103
            onEdit={handleEditQuestion}
106
            onEdit={question.link_edit ? () => handleEditQuestion(question) : null}
104
            onDelete={handleDeleteQuestion}
107
            onDelete={question.link_delete ? () => handleDeleteQuestion(question) : null}
-
 
108
            onView={question.link_view ? () => navigate(question.link_view) : null}
105
          />
109
          />
106
        )}
110
        )}
107
        renderFooter={() => (hasMore ? <Button onClick={loadMore}>Cargar más</Button> : null)}
111
        renderFooter={() => (hasMore ? <Button onClick={loadMore}>Cargar más</Button> : null)}
108
      />
112
      />
109
    </>
113
    </>