refactor: streamline IndexPlantSection and DetailPlantSection components, enhance ListPlantSection with improved search and action handling

This commit is contained in:
2025-10-16 23:05:26 +07:00
parent 7538c18624
commit 956730135e
3 changed files with 345 additions and 359 deletions

View File

@@ -1,75 +1,7 @@
import React from 'react';
import { Modal, Form, Input, ConfigProvider, Button, Typography } from 'antd';
import React, { memo } from 'react';
const { Text } = Typography;
const DetailPlantSection = memo(function DetailPlantSection(props) {
return null;
});
const DetailPlantSection = ({ visible, onCancel, onOk, form, editingKey, readOnly }) => {
const modalTitle = readOnly
? 'Preview Sub Section'
: editingKey
? 'Edit Sub Section'
: 'Tambah Sub Section';
return (
<Modal
title={modalTitle}
visible={visible}
onCancel={onCancel}
footer={[
<React.Fragment key="modal-footer">
<ConfigProvider
theme={{
token: { colorBgContainer: '#E9F6EF' },
components: {
Button: {
defaultBg: 'white',
defaultColor: '#23A55A',
defaultBorderColor: '#23A55A',
defaultHoverColor: '#23A55A',
defaultHoverBorderColor: '#23A55A',
},
},
}}
>
<Button onClick={onCancel}>Batal</Button>
</ConfigProvider>
<ConfigProvider
theme={{
token: {
colorBgContainer: '#209652',
},
components: {
Button: {
defaultBg: '#23a55a',
defaultColor: '#FFFFFF',
defaultBorderColor: '#23a55a',
defaultHoverColor: '#FFFFFF',
defaultHoverBorderColor: '#23a55a',
},
},
}}
>
{!readOnly && <Button onClick={onOk}>Simpan</Button>}
</ConfigProvider>
</React.Fragment>,
]}
destroyOnClose
>
<Form form={form} layout="vertical" name="form_in_modal">
<div style={{ marginBottom: 12 }}>
<Text strong>Nama Sub Section</Text>
<Text style={{ color: 'red' }}> *</Text>
<Form.Item
name="sub_section_name"
rules={[{ required: true, message: 'Silakan masukkan nama sub section!' }]}
style={{ marginBottom: 0 }}
>
<Input readOnly={readOnly} placeholder="Masukkan Nama Sub Section" />
</Form.Item>
</div>
</Form>
</Modal>
);
};
export default DetailPlantSection;
export default DetailPlantSection;