Formatted some client files
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useState } from "react";
|
||||
import { IResourceComponentsProps, useTranslate } from "@refinedev/core";
|
||||
import { Create, useForm, useSelect } from "@refinedev/antd";
|
||||
import { Form, Input, DatePicker, Select, InputNumber, Radio, Divider, Button } from "antd";
|
||||
@@ -9,7 +9,7 @@ import { ISpool } from "./model";
|
||||
import { numberFormatter, numberParser } from "../../utils/parsing";
|
||||
import { useSpoolmanLocations } from "../../components/otherModels";
|
||||
import { MinusOutlined, PlusOutlined } from "@ant-design/icons";
|
||||
import '../../utils/overrides.css'
|
||||
import "../../utils/overrides.css";
|
||||
|
||||
interface CreateOrCloneProps {
|
||||
mode: "create" | "clone";
|
||||
@@ -20,7 +20,7 @@ export const SpoolCreate: React.FC<IResourceComponentsProps & CreateOrCloneProps
|
||||
|
||||
const { form, formProps, formLoading, onFinish, redirect } = useForm<ISpool>({
|
||||
redirect: false,
|
||||
warnWhenUnsavedChanges: false
|
||||
warnWhenUnsavedChanges: false,
|
||||
});
|
||||
|
||||
if (props.mode === "clone" && formProps.initialValues) {
|
||||
@@ -34,16 +34,16 @@ export const SpoolCreate: React.FC<IResourceComponentsProps & CreateOrCloneProps
|
||||
}
|
||||
|
||||
const handleSubmit = async (redirectTo: "list" | "edit" | "create") => {
|
||||
let values = await form.validateFields();
|
||||
const values = await form.validateFields();
|
||||
if (quantity > 1) {
|
||||
let submit = Array(quantity).fill(values);
|
||||
const submit = Array(quantity).fill(values);
|
||||
// queue multiple creates this way for now Refine doesn't seem to map Arrays to createMany or multiple creates like it says it does
|
||||
submit.forEach(async r => await onFinish(r));
|
||||
submit.forEach(async (r) => await onFinish(r));
|
||||
} else {
|
||||
await onFinish(values);
|
||||
}
|
||||
redirect(redirectTo, (values as ISpool).id);
|
||||
}
|
||||
};
|
||||
|
||||
const { queryResult } = useSelect<IFilament>({
|
||||
resource: "filament",
|
||||
@@ -120,11 +120,11 @@ export const SpoolCreate: React.FC<IResourceComponentsProps & CreateOrCloneProps
|
||||
const [quantity, setQuantity] = useState(1);
|
||||
const incrementQty = () => {
|
||||
setQuantity(quantity + 1);
|
||||
}
|
||||
};
|
||||
|
||||
const decrementQty = () => {
|
||||
setQuantity(quantity - 1);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Create
|
||||
@@ -132,27 +132,25 @@ export const SpoolCreate: React.FC<IResourceComponentsProps & CreateOrCloneProps
|
||||
isLoading={formLoading}
|
||||
footerButtons={() => (
|
||||
<>
|
||||
<div style={{ display: 'flex', backgroundColor: '#141414', border: '1px solid #424242', borderRadius: '6px' }}>
|
||||
<div
|
||||
style={{ display: "flex", backgroundColor: "#141414", border: "1px solid #424242", borderRadius: "6px" }}
|
||||
>
|
||||
<Button type="text" style={{ padding: 0, width: 32, height: 32 }} onClick={decrementQty}>
|
||||
<MinusOutlined />
|
||||
</Button>
|
||||
<InputNumber
|
||||
name="Quantity"
|
||||
min={1}
|
||||
id="qty-input"
|
||||
controls={false}
|
||||
value={quantity}
|
||||
>
|
||||
</InputNumber>
|
||||
<InputNumber name="Quantity" min={1} id="qty-input" controls={false} value={quantity}></InputNumber>
|
||||
<Button type="text" style={{ padding: 0, width: 32, height: 32 }} onClick={incrementQty}>
|
||||
<PlusOutlined />
|
||||
</Button>
|
||||
</div>
|
||||
<Button type="primary" onClick={() => handleSubmit("list")}>{t("buttons.save")}</Button>
|
||||
<Button type="primary" onClick={() => handleSubmit("create")}>{t("buttons.saveAndAdd")}</Button>
|
||||
<Button type="primary" onClick={() => handleSubmit("list")}>
|
||||
{t("buttons.save")}
|
||||
</Button>
|
||||
<Button type="primary" onClick={() => handleSubmit("create")}>
|
||||
{t("buttons.saveAndAdd")}
|
||||
</Button>
|
||||
</>
|
||||
)
|
||||
}
|
||||
)}
|
||||
>
|
||||
<Form {...formProps} layout="vertical">
|
||||
<Form.Item
|
||||
@@ -326,7 +324,7 @@ export const SpoolCreate: React.FC<IResourceComponentsProps & CreateOrCloneProps
|
||||
<TextArea maxLength={1024} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Create >
|
||||
</Create>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user