Client: Better spool filament select
This commit is contained in:
@@ -9,9 +9,22 @@ import { IFilament } from "../filaments/model";
|
|||||||
export const SpoolCreate: React.FC<IResourceComponentsProps> = () => {
|
export const SpoolCreate: React.FC<IResourceComponentsProps> = () => {
|
||||||
const { formProps, saveButtonProps } = useForm();
|
const { formProps, saveButtonProps } = useForm();
|
||||||
|
|
||||||
const { selectProps } = useSelect<IFilament>({
|
const { queryResult } = useSelect<IFilament>({
|
||||||
resource: "filament",
|
resource: "filament",
|
||||||
optionLabel: "name",
|
});
|
||||||
|
|
||||||
|
const filamentOptions = queryResult.data?.data.map((item) => {
|
||||||
|
let label;
|
||||||
|
if (item.vendor) {
|
||||||
|
label = `${item.vendor.name} - ${item.name}`;
|
||||||
|
} else {
|
||||||
|
label = item.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
label: label,
|
||||||
|
value: item.id,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -54,7 +67,7 @@ export const SpoolCreate: React.FC<IResourceComponentsProps> = () => {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Select {...selectProps} />
|
<Select options={filamentOptions} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label="Used Weight"
|
label="Used Weight"
|
||||||
|
|||||||
@@ -9,9 +9,22 @@ import { IFilament } from "../filaments/model";
|
|||||||
export const SpoolEdit: React.FC<IResourceComponentsProps> = () => {
|
export const SpoolEdit: React.FC<IResourceComponentsProps> = () => {
|
||||||
const { formProps, saveButtonProps } = useForm();
|
const { formProps, saveButtonProps } = useForm();
|
||||||
|
|
||||||
const { selectProps } = useSelect<IFilament>({
|
const { queryResult } = useSelect<IFilament>({
|
||||||
resource: "filament",
|
resource: "filament",
|
||||||
optionLabel: "name",
|
});
|
||||||
|
|
||||||
|
const filamentOptions = queryResult.data?.data.map((item) => {
|
||||||
|
let label;
|
||||||
|
if (item.vendor) {
|
||||||
|
label = `${item.vendor.name} - ${item.name}`;
|
||||||
|
} else {
|
||||||
|
label = item.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
label: label,
|
||||||
|
value: item.id,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
if (formProps.initialValues) {
|
if (formProps.initialValues) {
|
||||||
@@ -84,7 +97,7 @@ export const SpoolEdit: React.FC<IResourceComponentsProps> = () => {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Select {...selectProps} />
|
<Select options={filamentOptions} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label="Used Weight"
|
label="Used Weight"
|
||||||
|
|||||||
Reference in New Issue
Block a user