File size: 2,736 Bytes
c750639
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import React from "react";
import {
  Box,
  Typography,
  CircularProgress,
  IconButton,
  Tooltip,
} from "@mui/material";
import { alpha } from "@mui/material/styles";
import VisibilityIcon from "@mui/icons-material/Visibility";

/**
 * Composant pour afficher une carte de document par défaut
 * @param {Object} props - Propriétés du composant
 * @returns {JSX.Element} - Carte de document par défaut
 */
const DefaultDocumentCard = ({
  doc,
  theme,
  selectedDocument,
  isDefaultDocument,
  urlSelected,
  isLoadingContent,
  handleDefaultDocClick,
  handleViewDocument,
  resetSelection,
}) => {
  // Vérifier si cette carte est actuellement sélectionnée
  const isSelected = selectedDocument?.id === doc.id;

  // Vérifier si une autre méthode est active (URL ou fichier)
  const otherMethodActive =
    (selectedDocument && !isDefaultDocument) || (urlSelected && !isSelected);

  return (
    <Box
      elevation={2}
      sx={{
        p: 2,
        display: "flex",
        flexDirection: "column",
        borderRadius: 1.5,
        alignItems: "center",
        cursor: "pointer",
        transition: "all 0.2s ease",
        height: "100%",
        position: "relative",
        border: isSelected
          ? `2px solid ${theme.palette.primary.main}`
          : `2px solid ${theme.palette.divider}`,
        "&:hover": {
          transform: "translateY(-2px)",
          boxShadow: 3,
        },
      }}
      onClick={() => handleDefaultDocClick(doc)}
    >
      <Tooltip title="View content">
        <IconButton
          onClick={(e) => {
            e.stopPropagation();
            handleViewDocument(doc);
          }}
          sx={{
            position: "absolute",
            top: 4,
            right: 4,
            color: "text.secondary",
            opacity: 0.4,
            "&:hover": {
              opacity: 0.8,
              backgroundColor: alpha(theme.palette.primary.main, 0.05),
            },
            padding: 0.3,
            "& .MuiSvgIcon-root": {
              fontSize: 16,
            },
          }}
          disabled={isLoadingContent}
        >
          {isLoadingContent && selectedDocument?.id === doc.id ? (
            <CircularProgress size={14} />
          ) : (
            <VisibilityIcon />
          )}
        </IconButton>
      </Tooltip>
      <Box sx={{ color: "primary.main", mb: 1 }}>{doc.icon}</Box>
      <Typography variant="subtitle1" component="div" gutterBottom>
        {doc.name}
      </Typography>
      <Typography
        variant="body2"
        color="text.secondary"
        align="center"
        sx={{ flexGrow: 1 }}
      >
        {doc.description}
      </Typography>
    </Box>
  );
};

export default DefaultDocumentCard;