diff --git a/src/pages/master/brandDevice/AddBrandDevice.jsx b/src/pages/master/brandDevice/AddBrandDevice.jsx index 99670e2..a070744 100644 --- a/src/pages/master/brandDevice/AddBrandDevice.jsx +++ b/src/pages/master/brandDevice/AddBrandDevice.jsx @@ -1,6 +1,19 @@ import { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; -import { Divider, Typography, Button, Steps, Form, Row, Col, Card, ConfigProvider } from 'antd'; +import { + Divider, + Typography, + Button, + Steps, + Form, + Row, + Col, + Card, + ConfigProvider, + Table, + Tag, + Space, +} from 'antd'; import { NotifAlert, NotifOk } from '../../../components/Global/ToastNotif'; import { useBreadcrumb } from '../../../layout/LayoutBreadcrumb'; import { createBrand } from '../../../api/master-brand'; @@ -11,6 +24,7 @@ import FormActions from './component/FormActions'; import SolutionForm from './component/SolutionForm'; import { useSolutionLogic } from './hooks/solution'; import { uploadFile, getFolderFromFileType } from '../../../api/file-uploads'; +import { EditOutlined, DeleteOutlined, EyeOutlined } from '@ant-design/icons'; const { Title } = Typography; const { Step } = Steps; @@ -39,7 +53,6 @@ const AddBrandDevice = () => { const [formData, setFormData] = useState(defaultData); const [errorCodes, setErrorCodes] = useState([]); const [errorCodeIcon, setErrorCodeIcon] = useState(null); - const [showErrorCodeModal, setShowErrorCodeModal] = useState(false); const { solutionFields, @@ -57,7 +70,6 @@ const AddBrandDevice = () => { setSolutionsForExistingRecord, } = useSolutionLogic(solutionForm); - useEffect(() => { setBreadcrumbItems([ { title: • Master }, @@ -427,7 +439,7 @@ const AddBrandDevice = () => { <> {/* Error Code Form Column */} - + { {/* Solution Form Column */} - + { - - {/* Error Codes List Button */} - - - + + - setShowErrorCodeModal(true)} - style={{ minWidth: '200px' }} - > - View All Error Codes ({errorCodes.length}) - - + { + title: 'Sol', + key: 'Sol', + width: '10%', + align: 'center', + render: (_, record) => { + const solutionCount = record.solution + ? record.solution.length + : 0; + return ( + 0 ? 'green' : 'red'} + > + {solutionCount} Sol + + ); + }, + }, + { + title: 'Status', + dataIndex: 'status', + key: 'status', + width: '20%', + align: 'center', + render: (_, { status }) => ( + + {status ? 'Active' : 'Inactive'} + + ), + }, + { + title: 'Action', + key: 'action', + align: 'center', + width: '15%', + render: (_, record) => ( + + + } + onClick={() => + handlePreviewErrorCode(record) + } + /> + + } + onClick={() => handleEditErrorCode(record)} + /> + } + onClick={() => + handleDeleteErrorCode(record.key) + } + /> + + ), + }, + ]} + rowKey="key" + pagination={{ + pageSize: 10, + showSizeChanger: false, + hideOnSinglePage: true, + }} + size="small" + scroll={{ y: 300 }} + /> + - - {/* Error Codes List Modal */} - setShowErrorCodeModal(false)} - errorCodes={errorCodes} - loading={loading} - onPreview={handlePreviewErrorCode} - onEdit={handleEditErrorCode} - onDelete={handleDeleteErrorCode} - onAddNew={handleCreateNewErrorCode} - /> > ); } diff --git a/src/pages/master/brandDevice/EditBrandDevice.jsx b/src/pages/master/brandDevice/EditBrandDevice.jsx index 4899a12..2196627 100644 --- a/src/pages/master/brandDevice/EditBrandDevice.jsx +++ b/src/pages/master/brandDevice/EditBrandDevice.jsx @@ -12,6 +12,9 @@ import { Spin, Modal, ConfigProvider, + Table, + Tag, + Space, } from 'antd'; import { NotifAlert, NotifOk } from '../../../components/Global/ToastNotif'; import { useBreadcrumb } from '../../../layout/LayoutBreadcrumb'; @@ -24,6 +27,7 @@ import ErrorCodeListModal from './component/ErrorCodeListModal'; import FormActions from './component/FormActions'; import { useErrorCodeLogic } from './hooks/errorCode'; import { useSolutionLogic } from './hooks/solution'; +import { EditOutlined, DeleteOutlined, EyeOutlined } from '@ant-design/icons'; const { Title } = Typography; const { Step } = Steps; @@ -53,7 +57,6 @@ const EditBrandDevice = () => { const [formData, setFormData] = useState(defaultData); const [errorCodes, setErrorCodes] = useState([]); const [errorCodeIcon, setErrorCodeIcon] = useState(null); - const [showErrorCodeModal, setShowErrorCodeModal] = useState(false); const [solutionForm] = Form.useForm(); const { errorCodeFields, addErrorCode, removeErrorCode, editErrorCode } = useErrorCodeLogic( @@ -493,7 +496,7 @@ const EditBrandDevice = () => { return ( <> - + @@ -503,7 +506,7 @@ const EditBrandDevice = () => { : 'Error Code Form' : editingErrorCodeKey ? 'Edit Error Code' - : 'Tambah Error Code'} + : 'Error Code'} } size="small" @@ -526,7 +529,7 @@ const EditBrandDevice = () => { - + @@ -559,49 +562,104 @@ const EditBrandDevice = () => { - - - {/* Error Codes List Button */} - - - + + - setShowErrorCodeModal(true)} - style={{ minWidth: '200px' }} - > - View All Error Codes ({errorCodes.length}) - - + { + title: 'Sol', + key: 'Sol', + width: '10%', + align: 'center', + render: (_, record) => { + const solutionCount = record.solution + ? record.solution.length + : 0; + return ( + 0 ? 'green' : 'red'} + > + {solutionCount} Sol + + ); + }, + }, + { + title: 'Status', + dataIndex: 'status', + key: 'status', + width: '20%', + align: 'center', + render: (_, { status }) => ( + + {status ? 'Active' : 'Inactive'} + + ), + }, + { + title: 'Action', + key: 'action', + align: 'center', + width: '15%', + render: (_, record) => ( + + + } + onClick={() => + handlePreviewErrorCode(record) + } + /> + + } + onClick={() => handleEditErrorCode(record)} + /> + } + onClick={() => + handleDeleteErrorCode(record.key) + } + /> + + ), + }, + ]} + rowKey="key" + pagination={{ + pageSize: 10, + showSizeChanger: false, + hideOnSinglePage: true, + }} + size="small" + scroll={{ y: 300 }} + /> + - - {/* Error Codes List Modal */} - setShowErrorCodeModal(false)} - errorCodes={errorCodes} - loading={loading} - onPreview={handlePreviewErrorCode} - onEdit={handleEditErrorCode} - onDelete={handleDeleteErrorCode} - onAddNew={handleCreateNewErrorCode} - /> > ); } diff --git a/src/pages/master/brandDevice/component/ErrorCodeSimpleForm.jsx b/src/pages/master/brandDevice/component/ErrorCodeSimpleForm.jsx index 791c59b..9781c75 100644 --- a/src/pages/master/brandDevice/component/ErrorCodeSimpleForm.jsx +++ b/src/pages/master/brandDevice/component/ErrorCodeSimpleForm.jsx @@ -1,13 +1,4 @@ -import { - Form, - Input, - Switch, - Upload, - Button, - Typography, - message, - ConfigProvider, -} from 'antd'; +import { Form, Input, Switch, Upload, Button, Typography, message, ConfigProvider } from 'antd'; import { UploadOutlined } from '@ant-design/icons'; import { uploadFile } from '../../../../api/file-uploads'; @@ -47,7 +38,8 @@ const ErrorCodeSimpleForm = ({ const folder = 'images'; const uploadResponse = await uploadFile(file, folder); - const iconPath = uploadResponse.data?.path_icon || uploadResponse.data?.path_solution || ''; + const iconPath = + uploadResponse.data?.path_icon || uploadResponse.data?.path_solution || ''; if (iconPath) { onErrorCodeIconUpload({ @@ -82,9 +74,7 @@ const ErrorCodeSimpleForm = ({ style={{ backgroundColor: statusValue ? '#23A55A' : '#bfbfbf' }} /> - - {statusValue ? 'Active' : 'Inactive'} - + {statusValue ? 'Active' : 'Inactive'} @@ -94,10 +84,7 @@ const ErrorCodeSimpleForm = ({ name="error_code" rules={[{ required: true, message: 'Error code wajib diisi!' }]} > - + {/* Error Name */} @@ -106,17 +93,11 @@ const ErrorCodeSimpleForm = ({ name="error_code_name" rules={[{ required: true, message: 'Error name wajib diisi!' }]} > - + {/* Error Description */} - + - + @@ -152,7 +135,13 @@ const ErrorCodeSimpleForm = ({ ) : ( - + No upload allowed )} @@ -181,12 +170,7 @@ const ErrorCodeSimpleForm = ({ {!isErrorCodeFormReadOnly && ( - + Remove )} @@ -221,7 +205,7 @@ const ErrorCodeSimpleForm = ({ }} style={{ width: '100%' }} > - + Add Error Code + Simpan Error Code @@ -230,4 +214,4 @@ const ErrorCodeSimpleForm = ({ ); }; -export default ErrorCodeSimpleForm; \ No newline at end of file +export default ErrorCodeSimpleForm;