Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3719 Rev 3736
Línea 1... Línea 1...
1
import React, { useState } from 'react';
1
import React from 'react';
2
import { IconButton, Typography } from '@mui/material';
2
import { IconButton, Typography } from '@mui/material';
3
import { Edit } from '@mui/icons-material';
3
import Edit from '@mui/icons-material/Edit';
Línea 4... Línea -...
4
 
-
 
5
import Widget from '@components/UI/Widget';
4
 
Línea 6... Línea -...
6
import PrivacyModal from './privacy-modal';
-
 
7
 
-
 
8
const Privacy = ({
-
 
9
  privacy = '',
-
 
10
  privacies = [],
5
import { useModal } from '@shared/hooks';
11
  groupId = '',
-
 
12
  onEdit = () => {},
-
 
13
  edit = false
6
 
Línea -... Línea 7...
-
 
7
import { Card, CardContent, CardHeader } from '@shared/components';
14
}) => {
8
import { PrivacyForm } from './PrivacyForm';
Línea 15... Línea -...
15
  const [isModalOpen, setIsModalOpen] = useState(false);
-
 
16
 
-
 
17
  const toggleModal = () => setIsModalOpen(!isModalOpen);
-
 
18
 
-
 
19
  return (
-
 
20
    <>
9
 
21
      <Widget>
-
 
22
        <Widget.Header
-
 
23
          title='Privacidad'
-
 
24
          renderAction={() => {
-
 
25
            if (!edit) return;
-
 
26
            return (
10
export function Privacy({ uuid, privacy, privacies, updateGroup, edit }) {
27
              <IconButton onClick={toggleModal}>
-
 
28
                <Edit />
-
 
29
              </IconButton>
-
 
30
            );
-
 
31
          }}
-
 
32
        />
-
 
33
 
11
  const { showModal, closeModal } = useModal();
34
        <Widget.Body>
-
 
35
          <Typography>{privacy}</Typography>
12
 
36
        </Widget.Body>
-
 
37
      </Widget>
-
 
38
 
-
 
39
      <PrivacyModal
13
  const handleEdit = () => {
40
        show={isModalOpen}
14
    showModal(
41
        privacy={privacy}
15
      'Privacidad',
-
 
16
      <PrivacyForm
-
 
17
        privacies={privacies}
-
 
18
        privacy={privacy}
-
 
19
        uuid={uuid}
42
        groupId={groupId}
20
        onSubmit={(newPrivacy) => {
-
 
21
          updateGroup((prev) => ({ ...prev, privacy: newPrivacy }));
-
 
22
          closeModal();
-
 
23
        }}
-
 
24
      />
-
 
25
    );
-
 
26
  };
-
 
27
 
-
 
28
  return (
-
 
29
    <Card>
-
 
30
      <CardHeader
-
 
31
        title='Privacidad'
-
 
32
        renderAction={() => {
-
 
33
          if (!edit) return;
-
 
34
          return (
-
 
35
            <IconButton onClick={handleEdit}>
43
        privacies={privacies}
36
              <Edit />
-
 
37
            </IconButton>
-
 
38
          );
-
 
39
        }}
-
 
40
      />
-
 
41
 
44
        onClose={toggleModal}
42
      <CardContent>
45
        onConfirm={onEdit}
43
        <Typography>{privacy}</Typography>
Línea 46... Línea 44...
46
      />
44
      </CardContent>