Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3041 Rev 3694
Línea 1... Línea 1...
1
import React from 'react'
1
import React from 'react';
2
import { useSelector } from 'react-redux'
2
import { useSelector } from 'react-redux';
3
import { IconButton } from '@mui/material'
3
import Add from '@mui/icons-material/Add';
4
import { Add } from '@mui/icons-material'
4
import { IconButton } from '@mui/material';
5
 
5
 
6
import {
-
 
7
  addEducation,
-
 
8
  deleteEducation,
-
 
9
  editEducation
-
 
10
} from '@services/profile/education'
6
import { addEducation, deleteEducation, editEducation } from '@services/profile/education';
11
import { useResource } from '@hooks'
7
import { useResource } from '@hooks';
12
 
8
 
13
import Widget from '@components/UI/Widget'
9
import Widget from '@components/UI/Widget';
14
import EducationItem from './education-item'
10
import EducationItem from './education-item';
15
import EducationModal from './education-modal'
11
import EducationModal from './education-modal';
16
import EmptySection from '@components/UI/EmptySection'
12
import EmptySection from '@components/UI/EmptySection';
17
import ConfirmModal from '@components/modals/ConfirmModal'
13
import ConfirmModal from '@components/modals/ConfirmModal';
Línea 18... Línea 14...
18
 
14
 
19
const EducationsCard = ({ uuid = '', educations = [], edit = false }) => {
15
const EducationsCard = ({ uuid = '', educations = [], edit = false }) => {
Línea 20... Línea -...
20
  const labels = useSelector(({ intl }) => intl.labels)
-
 
21
 
-
 
22
  const {
-
 
23
    showModal,
-
 
24
    modalState,
-
 
25
    onAdd,
-
 
26
    onEdit,
-
 
27
    onDelete,
-
 
28
    resources,
16
  const labels = useSelector(({ intl }) => intl.labels);
29
    clearModal,
17
 
30
    currentResource
18
  const { showModal, modalState, onAdd, onEdit, onDelete, resources, clearModal, currentResource } =
31
  } = useResource({
19
    useResource({
32
    defaultResources: educations,
20
      defaultResources: educations,
33
    addResource: addEducation,
21
      addResource: addEducation,
34
    editResource: editEducation,
22
      editResource: editEducation,
Línea 35... Línea 23...
35
    deleteResource: deleteEducation
23
      deleteResource: deleteEducation
36
  })
24
    });
37
 
25
 
38
  return (
26
  return (
39
    <>
27
    <>
40
      <Widget>
28
      <Widget>
41
        <Widget.Header
29
        <Widget.Header
42
          title={labels.education}
30
          title={labels.education}
43
          renderAction={() => {
31
          renderAction={() => {
44
            if (!edit) return null
32
            if (!edit) return null;
45
            return (
33
            return (
46
              <IconButton onClick={() => showModal('add')}>
34
              <IconButton onClick={() => showModal('add')}>
47
                <Add />
35
                <Add />
48
              </IconButton>
36
              </IconButton>
Línea 49... Línea 37...
49
            )
37
            );
50
          }}
38
          }}
Línea 70... Línea 58...
70
      <EducationModal
58
      <EducationModal
71
        show={modalState === 'add' || modalState === 'edit'}
59
        show={modalState === 'add' || modalState === 'edit'}
72
        currentEducation={currentResource}
60
        currentEducation={currentResource}
73
        onClose={clearModal}
61
        onClose={clearModal}
74
        onConfirm={(education) => {
62
        onConfirm={(education) => {
75
          console.log(modalState)
63
          console.log(modalState);
76
          if (modalState === 'add') onAdd(uuid, education)
64
          if (modalState === 'add') onAdd(uuid, education);
77
          if (modalState === 'edit') onEdit(education)
65
          if (modalState === 'edit') onEdit(education);
78
        }}
66
        }}
79
      />
67
      />
Línea 80... Línea 68...
80
 
68
 
81
      <ConfirmModal
69
      <ConfirmModal
Línea 84... Línea 72...
84
        message='¿Esta seguro de eliminar esta educación?'
72
        message='¿Esta seguro de eliminar esta educación?'
85
        onAccept={onDelete}
73
        onAccept={onDelete}
86
        onClose={clearModal}
74
        onClose={clearModal}
87
      />
75
      />
88
    </>
76
    </>
89
  )
77
  );
90
}
78
};
Línea 91... Línea 79...
91
 
79