import React from 'react'; import { Card, Button, Row, Col, Typography, Space, Tag } from 'antd'; import { EditOutlined, DeleteOutlined, EyeOutlined } from '@ant-design/icons'; const { Text } = Typography; const CardList = ({ data, column, header, showPreviewModal, showEditModal, showDeleteDialog, cardColor, fieldColor, }) => { const getCardStyle = (color) => { const colorStyle = color ?? '#F3EDEA'; // Orange color return { border: `2px solid ${colorStyle}`, borderRadius: '8px', textAlign: 'center', // Center text }; }; const getTitleStyle = (color) => { const backgroundColor = color ?? '#FCF2ED'; return { backgroundColor, color: '#fff', padding: '2px 8px', borderRadius: '4px', display: 'inline-block', // ganti inline-block → block width: 'fit-content', // biar lebarnya tetap menyesuaikan teks }; }; return ( {data.map((item) => ( {item[header]} } style={getCardStyle(fieldColor ? item[fieldColor] : cardColor)} actions={[ showPreviewModal && ( showPreviewModal(item)} /> ), showEditModal && ( showEditModal(item)} /> ), showDeleteDialog && ( showDeleteDialog(item)} /> ), ].filter(Boolean)} // <== Hapus elemen yang undefined >
{column.map((itemCard, index) => ( {!itemCard.hidden && itemCard.title !== 'No' && itemCard.title !== 'Action' && (

{itemCard.title}:{' '} {itemCard.render ? itemCard.render( item[itemCard.dataIndex], item, index ) : item[itemCard.dataIndex] || item[itemCard.key] || '-'}

)}
))}
))}
); }; export default CardList;