Files
bodyshop/client/src/components/parts-shop-info/parts-shop-info-locations.component.jsx
2025-08-19 16:23:29 -04:00

49 lines
2.0 KiB
JavaScript

import { Button, Card, Divider, Form, Input, Space } from "antd";
import { DeleteOutlined, PlusOutlined } from "@ant-design/icons";
import { useTranslation } from "react-i18next";
export default function PartsShopInfoLocations() {
const { t } = useTranslation();
return (
<Card title={t("bodyshop.labels.parts_locations")}>
<Form.List name="parts_locations">
{(fields, { add, remove }) => (
<>
{fields.map(({ key, name, ...restField }) => (
<Space key={key} style={{ display: "flex", marginBottom: 8 }} align="baseline">
<Form.Item
{...restField}
name={[name, "location_name"]}
label={t("bodyshop.labels.location_name")}
rules={[{ required: true, message: t("bodyshop.errors.location_name_required") }]}
>
<Input placeholder={t("bodyshop.placeholders.location_name")} />
</Form.Item>
<Form.Item
{...restField}
name={[name, "location_code"]}
label={t("bodyshop.labels.location_code")}
rules={[{ required: true, message: t("bodyshop.errors.location_code_required") }]}
>
<Input placeholder={t("bodyshop.placeholders.location_code")} />
</Form.Item>
<Form.Item {...restField} name={[name, "description"]} label={t("bodyshop.labels.description")}>
<Input placeholder={t("bodyshop.placeholders.location_description")} />
</Form.Item>
<Button type="text" danger icon={<DeleteOutlined />} onClick={() => remove(name)} />
</Space>
))}
<Divider />
<Form.Item>
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined />}>
{t("bodyshop.actions.add_location")}
</Button>
</Form.Item>
</>
)}
</Form.List>
</Card>
);
}