repair: brandDevice add edit page

This commit is contained in:
2025-12-12 16:54:30 +07:00
parent 2ff50342e8
commit ea3adf40cc
5 changed files with 107 additions and 578 deletions

View File

@@ -10,22 +10,18 @@ import {
Col,
Card,
Spin,
Tag,
Space,
Input,
ConfigProvider,
} from 'antd';
import { EyeOutlined, EditOutlined, DeleteOutlined, SearchOutlined } from '@ant-design/icons';
import { EyeOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
import { NotifAlert, NotifOk, NotifConfirmDialog } from '../../../components/Global/ToastNotif';
import { useBreadcrumb } from '../../../layout/LayoutBreadcrumb';
import { getBrandById, createBrand, createErrorCode, getErrorCodesByBrandId, updateErrorCode, deleteErrorCode, deleteBrand } from '../../../api/master-brand';
import { getFileUrl } from '../../../api/file-uploads';
import { SendRequest } from '../../../components/Global/ApiRequest';
import BrandForm from './component/BrandForm';
import ErrorCodeForm from './component/ErrorCodeForm';
import SolutionForm from './component/SolutionForm';
import SparepartSelect from './component/SparepartSelect';
import ListErrorCode from './component/ListErrorCode';
import FormActions from './component/FormActions';
const { Title } = Typography;
const { Step } = Steps;
@@ -129,7 +125,7 @@ const AddBrandDevice = () => {
const isFileType = solution.type_solution && solution.type_solution !== 'text';
newSolutionTypes[fieldKey] = isFileType ? 'file' : 'text';
newSolutionStatuses[fieldKey] = solution.is_active !== false;
newSolutionStatuses[fieldKey] = solution.is_active;
let fileObject = null;
if (isFileType && (solution.path_solution || solution.path_document)) {
@@ -149,7 +145,7 @@ const AddBrandDevice = () => {
name: solution.solution_name || '',
type: isFileType ? 'file' : 'text',
text: solution.text_solution || '',
status: solution.is_active !== false,
status: solution.is_active,
file: fileObject,
fileUpload: fileObject,
path_solution: solution.path_solution || solution.path_document || null,
@@ -311,7 +307,7 @@ const AddBrandDevice = () => {
error_code_name: record.error_code_name || '',
error_code_description: record.error_code_description || '',
error_code_color: record.error_code_color || '#000000',
status: record.is_active !== false,
status: record.is_active,
});
if (record.path_icon) {
@@ -1129,13 +1125,23 @@ const AddBrandDevice = () => {
return (
<Card>
<Steps current={currentStep} style={{ marginBottom: 24 }}>
<Step title="Brand Device Details" />
<Step title="Error Codes & Solutions" />
</Steps>
<div style={{ position: 'relative' }}>
{loading && (
<ConfigProvider
theme={{
components: {
Switch: {
colorPrimary: '#23A55A',
colorPrimaryHover: '#23A55A',
},
},
}}
>
<Card>
<Steps current={currentStep} style={{ marginBottom: 24 }}>
<Step title="Brand Device Details" />
<Step title="Error Codes & Solutions" />
</Steps>
<div style={{ position: 'relative' }}>
{loading && (
<div
style={{
position: 'absolute',
@@ -1209,7 +1215,8 @@ const AddBrandDevice = () => {
)}
</div>
</div>
</Card>
</Card>
</ConfigProvider>
);
};