modify color card by data

This commit is contained in:
2025-10-22 16:11:52 +07:00
parent f52d61da62
commit 98e5ed250c
5 changed files with 34 additions and 8 deletions

View File

@@ -12,11 +12,12 @@ const CardList = ({
showEditModal, showEditModal,
showDeleteDialog, showDeleteDialog,
cardColor, cardColor,
fieldColor,
}) => { }) => {
const getCardStyle = () => { const getCardStyle = (color) => {
const color = cardColor ?? '#F3EDEA'; // Orange color const colorStyle = color ?? '#F3EDEA'; // Orange color
return { return {
border: `2px solid ${color}`, border: `2px solid ${colorStyle}`,
borderRadius: '8px', borderRadius: '8px',
textAlign: 'center', // Center text textAlign: 'center', // Center text
}; };
@@ -47,12 +48,14 @@ const CardList = ({
alignItems: 'center', alignItems: 'center',
}} }}
> >
<span style={getTitleStyle(item.color ?? cardColor)}> <span
style={getTitleStyle(fieldColor ? item[fieldColor] : cardColor)}
>
{item[header]} {item[header]}
</span> </span>
</div> </div>
} }
style={getCardStyle()} style={getCardStyle(fieldColor ? item[fieldColor] : cardColor)}
actions={[ actions={[
<EyeOutlined <EyeOutlined
style={{ color: '#1890ff' }} style={{ color: '#1890ff' }}

View File

@@ -17,6 +17,7 @@ const TableList = memo(function TableList({
showEditModal, showEditModal,
showDeleteDialog, showDeleteDialog,
cardColor, cardColor,
fieldColor,
}) { }) {
const [gridLoading, setGridLoading] = useState(false); const [gridLoading, setGridLoading] = useState(false);
@@ -29,7 +30,7 @@ const TableList = memo(function TableList({
total_page: 1, total_page: 1,
}); });
const [viewMode, setViewMode] = useState('card'); const [viewMode, setViewMode] = useState('list');
const { useBreakpoint } = Grid; const { useBreakpoint } = Grid;
@@ -98,6 +99,7 @@ const TableList = memo(function TableList({
{(isMobile && mobile) || viewMode === 'card' ? ( {(isMobile && mobile) || viewMode === 'card' ? (
<CardList <CardList
cardColor={cardColor} cardColor={cardColor}
fieldColor={fieldColor}
data={data} data={data}
column={columns} column={columns}
header={header} header={header}

View File

@@ -186,6 +186,7 @@ const ListStatus = memo(function ListStatus(props) {
<TableList <TableList
mobile mobile
cardColor={'#42AAFF'} cardColor={'#42AAFF'}
fieldColor={'status_color'}
header={'status_name'} header={'status_name'}
showPreviewModal={showPreviewModal} showPreviewModal={showPreviewModal}
showEditModal={showEditModal} showEditModal={showEditModal}

View File

@@ -230,6 +230,12 @@ const ListRole = memo(function ListRole(props) {
</Col> </Col>
<Col xs={24} sm={24} md={24} lg={24} xl={24} style={{ marginTop: '16px' }}> <Col xs={24} sm={24} md={24} lg={24} xl={24} style={{ marginTop: '16px' }}>
<TableList <TableList
mobile
cardColor={'#42AAFF'}
header={'role_name'}
showPreviewModal={showPreviewModal}
showEditModal={showEditModal}
showDeleteDialog={showDeleteDialog}
getData={getAllRole} getData={getAllRole}
queryParams={formDataFilter} queryParams={formDataFilter}
columns={columns(showPreviewModal, showEditModal, showDeleteDialog)} columns={columns(showPreviewModal, showEditModal, showDeleteDialog)}

View File

@@ -150,7 +150,11 @@ const columns = (
Rejected Rejected
</Tag> </Tag>
); );
} else if (record.is_approve === 2 || record.is_approve === '2' || record.is_approve === true) { } else if (
record.is_approve === 2 ||
record.is_approve === '2' ||
record.is_approve === true
) {
// Approved // Approved
return ( return (
<Tag color={'green'} key={'status'}> <Tag color={'green'} key={'status'}>
@@ -174,7 +178,11 @@ const columns = (
align: 'center', align: 'center',
render: (_, record) => { render: (_, record) => {
// Only show active status if user is approved // Only show active status if user is approved
if (record.is_approve === 2 || record.is_approve === '2' || record.is_approve === true) { if (
record.is_approve === 2 ||
record.is_approve === '2' ||
record.is_approve === true
) {
if (record.is_active === true || record.is_active === 1) { if (record.is_active === true || record.is_active === 1) {
return ( return (
<Tag color={'green'} key={'active'}> <Tag color={'green'} key={'active'}>
@@ -450,6 +458,12 @@ const ListUser = memo(function ListUser(props) {
</Col> </Col>
<Col xs={24} sm={24} md={24} lg={24} xl={24} style={{ marginTop: '16px' }}> <Col xs={24} sm={24} md={24} lg={24} xl={24} style={{ marginTop: '16px' }}>
<TableList <TableList
mobile
cardColor={'#42AAFF'}
header={'user_name'}
showPreviewModal={showPreviewModal}
showEditModal={showEditModal}
showDeleteDialog={showDeleteDialog}
getData={getAllUser} getData={getAllUser}
queryParams={formDataFilter} queryParams={formDataFilter}
columns={columns( columns={columns(