Proyectos de Subversion LeadersLinked - SPA

Rev

Autoría | Ultima modificación | Ver Log |

import React from 'react';
import Edit from '@mui/icons-material/Edit';
import { IconButton, Typography } from '@mui/material';

import { useModal } from '@shared/hooks';
import { parse } from '@shared/utils';

import { Card, CardContent, CardHeader } from '@shared/components';
import { OverviewForm } from './OverviewForm';

export function Overview({ uuid, description, updateGroup, edit }) {
  const { showModal, closeModal } = useModal();

  const handleEdit = () => {
    showModal(
      'Visión general',
      <OverviewForm
        uuid={uuid}
        description={description}
        onSubmit={(data) => {
          updateGroup((prev) => ({ ...prev, overview: data }));
          closeModal();
        }}
      />
    );
  };

  return (
    <Card>
      <CardHeader
        title='Visión general'
        renderAction={() => {
          if (!edit) return;
          return (
            <IconButton onClick={handleEdit}>
              <Edit />
            </IconButton>
          );
        }}
      />

      <CardContent>
        <Typography>{parse(description ?? 'No hay descripción')}</Typography>
      </CardContent>
    </Card>
  );
}