fix field + role user
This commit is contained in:
@@ -1,84 +0,0 @@
|
||||
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 CardDevice = ({ data, showPreviewModal, showEditModal, showDeleteDialog }) => {
|
||||
const getCardStyle = () => {
|
||||
const color = '#FF8C42'; // Orange color
|
||||
return {
|
||||
border: `2px solid ${color}`,
|
||||
borderRadius: '8px',
|
||||
textAlign: 'center' // Center text
|
||||
};
|
||||
};
|
||||
|
||||
const getTitleStyle = () => {
|
||||
const backgroundColor = '#FF8C42'; // Orange color
|
||||
return {
|
||||
backgroundColor,
|
||||
color: '#fff',
|
||||
padding: '2px 8px',
|
||||
borderRadius: '4px',
|
||||
display: 'inline-block',
|
||||
};
|
||||
};
|
||||
|
||||
return (
|
||||
<Row gutter={[16, 16]} style={{ marginTop: '16px', justifyContent: 'center' }}>
|
||||
{data.map((item) => (
|
||||
<Col xs={24} sm={12} md={8} lg={6} key={item.device_id}>
|
||||
<Card
|
||||
title={
|
||||
<span style={getTitleStyle()}>
|
||||
{item.device_name}
|
||||
</span>
|
||||
}
|
||||
style={getCardStyle()}
|
||||
actions={[
|
||||
<Space size="middle" style={{ display: 'flex', justifyContent: 'center' }}>
|
||||
<Button
|
||||
type="text"
|
||||
style={{ color: '#1890ff' }}
|
||||
icon={<EyeOutlined />}
|
||||
onClick={() => showPreviewModal(item)}
|
||||
/>
|
||||
<Button
|
||||
type="text"
|
||||
style={{ color: '#faad14' }}
|
||||
icon={<EditOutlined />}
|
||||
onClick={() => showEditModal(item)}
|
||||
/>
|
||||
<Button
|
||||
type="text"
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
onClick={() => showDeleteDialog(item)}
|
||||
/>
|
||||
</Space>,
|
||||
]}
|
||||
>
|
||||
<p>
|
||||
<Text strong>Code:</Text> {item.device_code}
|
||||
</p>
|
||||
<p>
|
||||
<Text strong>Location:</Text> {item.device_location}
|
||||
</p>
|
||||
<p>
|
||||
<Text strong>IP Address:</Text> {item.ip_address}
|
||||
</p>
|
||||
<p>
|
||||
<Text strong>Status:</Text>{' '}
|
||||
<Tag color={item.device_status ? 'green' : 'red'}>
|
||||
{item.device_status ? 'Running' : 'Offline'}
|
||||
</Tag>
|
||||
</p>
|
||||
</Card>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
);
|
||||
};
|
||||
|
||||
export default CardDevice;
|
||||
@@ -3,6 +3,7 @@ import { Modal, Input, Typography, Switch, Button, ConfigProvider, Divider } fro
|
||||
import { NotifAlert, NotifOk } from '../../../../components/Global/ToastNotif';
|
||||
import { createPlantSection, updatePlantSection } from '../../../../api/master-plant-section';
|
||||
import { validateRun } from '../../../../Utils/validate';
|
||||
import TextArea from 'antd/es/input/TextArea';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
@@ -40,7 +41,7 @@ const DetailPlantSection = (props) => {
|
||||
console.log(`📝 Input change: ${name} = ${value}`);
|
||||
|
||||
if (name) {
|
||||
setFormData(prev => ({
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
[name]: value,
|
||||
}));
|
||||
@@ -73,7 +74,7 @@ const DetailPlantSection = (props) => {
|
||||
return;
|
||||
|
||||
try {
|
||||
console.log("💾 Current formData before save:", formData);
|
||||
console.log('💾 Current formData before save:', formData);
|
||||
|
||||
const payload = {
|
||||
plant_sub_section_name: formData.plant_sub_section_name,
|
||||
@@ -82,7 +83,7 @@ const DetailPlantSection = (props) => {
|
||||
is_active: formData.is_active,
|
||||
};
|
||||
|
||||
console.log("📤 Payload to be sent:", payload);
|
||||
console.log('📤 Payload to be sent:', payload);
|
||||
|
||||
const response =
|
||||
props.actionMode === 'edit'
|
||||
@@ -125,17 +126,17 @@ const DetailPlantSection = (props) => {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
console.log("🔄 Modal state changed:", {
|
||||
console.log('🔄 Modal state changed:', {
|
||||
showModal: props.showModal,
|
||||
actionMode: props.actionMode,
|
||||
selectedData: props.selectedData
|
||||
selectedData: props.selectedData,
|
||||
});
|
||||
|
||||
if (props.selectedData) {
|
||||
console.log("📋 Setting form data from selectedData:", props.selectedData);
|
||||
console.log('📋 Setting form data from selectedData:', props.selectedData);
|
||||
setFormData(props.selectedData);
|
||||
} else {
|
||||
console.log("📋 Resetting to default data");
|
||||
console.log('📋 Resetting to default data');
|
||||
setFormData(defaultData);
|
||||
}
|
||||
}, [props.showModal, props.selectedData, props.actionMode]);
|
||||
@@ -212,7 +213,7 @@ const DetailPlantSection = (props) => {
|
||||
|
||||
{/* Plant Section Code - Auto Increment & Read Only */}
|
||||
<div style={{ marginBottom: 12 }}>
|
||||
<Text strong>Plant Section Code</Text>
|
||||
<Text strong>Plant Sub Section Code</Text>
|
||||
<Input
|
||||
name="sub_section_code"
|
||||
value={formData.sub_section_code || ''}
|
||||
@@ -249,12 +250,13 @@ const DetailPlantSection = (props) => {
|
||||
</div>
|
||||
<div style={{ marginBottom: 12 }}>
|
||||
<Text strong>Description</Text>
|
||||
<Input
|
||||
<TextArea
|
||||
name="plant_sub_section_description"
|
||||
value={formData.plant_sub_section_description}
|
||||
onChange={handleInputChange}
|
||||
placeholder="Enter Description (Optional)"
|
||||
readOnly={props.readOnly}
|
||||
rows={4}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user