update ui brand device

This commit is contained in:
2025-12-04 01:17:25 +07:00
parent 1bc98de564
commit f22e120204
15 changed files with 3132 additions and 1349 deletions

View File

@@ -1,21 +1,14 @@
import React, { useState } from 'react';
import { Form, Input, Row, Col, Typography, Switch, Button, Card, Divider } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import SingleSparepartSelect from './SingleSparepartSelect';
import React from 'react';
import { Form, Input, Row, Col, Typography, Switch } from 'antd';
const { Text } = Typography;
const BrandForm = ({
form,
formData,
onValuesChange,
isEdit = false,
selectedSparepartIds = [],
onSparepartChange,
showSparepartSection = false
}) => {
const isActive = Form.useWatch('is_active', form) ?? formData.is_active ?? true;
const [showSparepart, setShowSparepart] = useState(showSparepartSection);
const isActive = Form.useWatch('is_active', form) ?? true;
return (
<div>
@@ -23,7 +16,13 @@ const BrandForm = ({
layout="vertical"
form={form}
onValuesChange={onValuesChange}
initialValues={formData}
initialValues={{
brand_name: '',
brand_type: '',
brand_model: '',
brand_manufacture: '',
is_active: true,
}}
>
<Form.Item label="Status">
<div style={{ display: 'flex', alignItems: 'center' }}>
@@ -83,39 +82,6 @@ const BrandForm = ({
</Col>
</Row>
</Form>
<Divider />
{/* Add Sparepart Button */}
<div style={{ marginTop: 16 }}>
<Button
type="dashed"
icon={<PlusOutlined />}
onClick={() => setShowSparepart(!showSparepart)}
style={{
width: '100%',
borderStyle: 'dashed',
marginBottom: showSparepart ? 16 : 0
}}
>
{showSparepart ? 'Hide Sparepart' : 'Add Sparepart'}
</Button>
</div>
{/* Sparepart Selection Section */}
{showSparepart && (
<Card
title="Brand Spareparts"
size="small"
style={{ marginTop: 16 }}
>
<SingleSparepartSelect
selectedSparepartIds={selectedSparepartIds}
onSparepartChange={onSparepartChange}
isReadOnly={false}
/>
</Card>
)}
</div>
);
};