Finished speed print setup + addition to print center modal. BOD-229

This commit is contained in:
Patrick Fic
2020-07-31 09:46:03 -07:00
parent 4130bd0bdb
commit 23f8243002
13 changed files with 498 additions and 106 deletions

View File

@@ -0,0 +1,105 @@
import { DeleteFilled } from "@ant-design/icons";
import { Button, Col, Form, Input, InputNumber, Row, Select } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
import { TemplateList } from "../../utils/TemplateConstants";
import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component";
//TODO Fix up styles.
export default function ShopInfoSpeedPrint({ bodyshop, form }) {
const { t } = useTranslation();
return (
<div>
<Form.List name={["speedprint"]}>
{(fields, { add, remove, move }) => {
return (
<div>
{fields.map((field, index) => (
<Form.Item key={field.key} style={{ padding: 0, margin: 2 }}>
<div className="imex-flex-row">
<Form.Item
className="imex-flex-row__margin"
label={t("bodyshop.fields.speedprint.id")}
key={`${index}id`}
name={[field.name, "id"]}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<Input />
</Form.Item>
<Form.Item
className="imex-flex-row__margin"
label={t("bodyshop.fields.speedprint.label")}
key={`${index}label`}
name={[field.name, "label"]}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<Input />
</Form.Item>
<Form.Item
className="imex-flex-row__margin"
name={[field.name, "templates"]}
label={t("bodyshop.fields.speedprint.templates")}
rules={[
{
required: true,
message: t("general.validation.required"),
type: "array",
},
]}
>
<Select mode="multiple">
{Object.keys(TemplateList)
.map((key) => TemplateList[key])
.filter((template) => template.drivingId === "job")
.map((template, idx) => (
<Select.Option key={idx} value={template.key}>
{template.title}
</Select.Option>
))}
</Select>
</Form.Item>
<DeleteFilled
className="imex-flex-row__margin"
onClick={() => {
remove(field.name);
}}
/>
<FormListMoveArrows
move={move}
index={index}
total={fields.length}
/>
</div>
</Form.Item>
))}
<Form.Item>
<Button
type="dashed"
onClick={() => {
add();
}}
style={{ width: "100%" }}
>
{t("bodyshop.actions.addspeedprint")}
</Button>
</Form.Item>
</div>
);
}}
</Form.List>
</div>
);
}